- Timestamp:
- 04/03/19 15:37:38 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/ExternalEvaluationProblem.cs
r16723 r16751 40 40 // BackwardsCompatibility3.3 41 41 // Rename class to SingleObjectiveExternalEvaluationProblem 42 public class ExternalEvaluationProblem : SingleObjectiveProblem<IEncoding<I Solution>, ISolution>, IExternalEvaluationProblem {42 public class ExternalEvaluationProblem : SingleObjectiveProblem<IEncoding<IEncodedSolution>, IEncodedSolution>, IExternalEvaluationProblem { 43 43 44 44 public static new Image StaticItemImage { … … 66 66 67 67 #region Properties 68 public new IEncoding<I Solution> Encoding {68 public new IEncoding<IEncodedSolution> Encoding { 69 69 get { return base.Encoding; } 70 70 set { base.Encoding = value; } … … 114 114 } 115 115 116 public override double Evaluate(I Solution individual, IRandom random) {116 public override double Evaluate(IEncodedSolution individual, IRandom random) { 117 117 var qualityMessage = Evaluate(BuildSolutionMessage(individual)); 118 118 if (!qualityMessage.HasExtension(SingleObjectiveQualityMessage.QualityMessage_)) … … 126 126 } 127 127 128 public override void Analyze(I Solution[] individuals, double[] qualities, ResultCollection results, IRandom random) {128 public override void Analyze(IEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) { 129 129 OptimizationSupport.Analyze(individuals, qualities, results, random); 130 130 } 131 131 132 public override IEnumerable<I Solution> GetNeighbors(ISolution individual, IRandom random) {132 public override IEnumerable<IEncodedSolution> GetNeighbors(IEncodedSolution individual, IRandom random) { 133 133 return OptimizationSupport.GetNeighbors(individual, random); 134 134 } … … 167 167 } 168 168 169 private SolutionMessage BuildSolutionMessage(I Solution solution, int solutionId = 0) {169 private SolutionMessage BuildSolutionMessage(IEncodedSolution solution, int solutionId = 0) { 170 170 lock (clientLock) { 171 171 SolutionMessage.Builder protobufBuilder = SolutionMessage.CreateBuilder(); 172 172 protobufBuilder.SolutionId = solutionId; 173 173 var scope = new Scope(); 174 ScopeUtil.Copy SolutionToScope(scope, Encoding, solution);174 ScopeUtil.CopyEncodedSolutionToScope(scope, Encoding, solution); 175 175 foreach (var variable in scope.Variables) { 176 176 try { -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Interfaces/IMultiObjectiveOptimizationSupport.cs
r16723 r16751 27 27 [StorableType("f924ef9c-d824-40d2-89b2-6dd1220df98b")] 28 28 public interface IMultiObjectiveOptimizationSupport { 29 void Analyze(I Solution[] individuals, double[][] qualities, ResultCollection results, IRandom random);29 void Analyze(IEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random); 30 30 } 31 31 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Interfaces/ISingleObjectiveOptimizationSupport.cs
r16723 r16751 28 28 [StorableType("09d522e0-c10f-474c-b7c0-7d7f98e63f44")] 29 29 public interface ISingleObjectiveOptimizationSupport { 30 void Analyze(I Solution[] individuals, double[] qualities, ResultCollection results, IRandom random);31 IEnumerable<I Solution> GetNeighbors(ISolution individual, IRandom random);30 void Analyze(IEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random); 31 IEnumerable<IEncodedSolution> GetNeighbors(IEncodedSolution individual, IRandom random); 32 32 } 33 33 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/MultiObjectiveExternalEvaluationProblem.cs
r16723 r16751 37 37 [Creatable(CreatableAttribute.Categories.ExternalEvaluationProblems, Priority = 200)] 38 38 [StorableType("CCA50199-A6AB-4C84-B4FA-0262CAF416EC")] 39 public class MultiObjectiveExternalEvaluationProblem : MultiObjectiveProblem<IEncoding<I Solution>, ISolution>, IExternalEvaluationProblem {39 public class MultiObjectiveExternalEvaluationProblem : MultiObjectiveProblem<IEncoding<IEncodedSolution>, IEncodedSolution>, IExternalEvaluationProblem { 40 40 41 41 public static new Image StaticItemImage { … … 63 63 64 64 #region Properties 65 public new IEncoding<I Solution> Encoding {65 public new IEncoding<IEncodedSolution> Encoding { 66 66 get { return base.Encoding; } 67 67 set { base.Encoding = value; } … … 114 114 } 115 115 116 public override double[] Evaluate(I Solution individual, IRandom random) {116 public override double[] Evaluate(IEncodedSolution individual, IRandom random) { 117 117 var qualityMessage = Evaluate(BuildSolutionMessage(individual)); 118 118 if (!qualityMessage.HasExtension(MultiObjectiveQualityMessage.QualityMessage_)) … … 126 126 } 127 127 128 public override void Analyze(I Solution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {128 public override void Analyze(IEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) { 129 129 OptimizationSupport.Analyze(individuals, qualities, results, random); 130 130 } … … 164 164 } 165 165 166 private SolutionMessage BuildSolutionMessage(I Solution solution, int solutionId = 0) {166 private SolutionMessage BuildSolutionMessage(IEncodedSolution solution, int solutionId = 0) { 167 167 lock (clientLock) { 168 168 SolutionMessage.Builder protobufBuilder = SolutionMessage.CreateBuilder(); 169 169 protobufBuilder.SolutionId = solutionId; 170 170 var scope = new Scope(); 171 ScopeUtil.Copy SolutionToScope(scope, Encoding, solution);171 ScopeUtil.CopyEncodedSolutionToScope(scope, Encoding, solution); 172 172 foreach (var variable in scope.Variables) { 173 173 try { -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/CompiledMultiObjectiveOptimizationSupport.cs
r13372 r16751 5 5 public class CompiledMultiObjectiveOptimizationSupport : CompiledOptimizationSupport, IMultiObjectiveOptimizationSupport { 6 6 7 public void Analyze(I Solution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {7 public void Analyze(IEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) { 8 8 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 9 9 // Write or update results given the range of vectors and resulting qualities -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/CompiledSingleObjectiveOptimizationSupport.cs
r13372 r16751 6 6 public class CompiledSingleObjectiveOptimizationSupport : CompiledOptimizationSupport, ISingleObjectiveOptimizationSupport { 7 7 8 public void Analyze(I Solution[] individuals, double[] qualities, ResultCollection results, IRandom random) {8 public void Analyze(IEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) { 9 9 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 10 10 // Write or update results given the range of vectors and resulting qualities … … 17 17 } 18 18 19 public IEnumerable<I Solution> GetNeighbors(ISolution individual, IRandom random) {19 public IEnumerable<IEncodedSolution> GetNeighbors(IEncodedSolution individual, IRandom random) { 20 20 // Use vars.yourVariable to access variables in the variable store i.e. yourVariable 21 21 // Create new vectors, based on the given one that represent small changes … … 24 24 // Algorithm will draw only a finite amount of samples 25 25 // Change to a for-loop to return a concrete amount of neighbors 26 var neighbor = (I Solution)individual.Clone();26 var neighbor = (IEncodedSolution)individual.Clone(); 27 27 // For instance, perform a single bit-flip in a binary parameter 28 28 //var bIndex = random.Next(neighbor.BinaryVector("b").Length); -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/MultiObjectiveOptimizationSupportScript.cs
r16723 r16751 39 39 } 40 40 41 void IMultiObjectiveOptimizationSupport.Analyze(I Solution[] individuals, double[][] qualities, ResultCollection results, IRandom random) {41 void IMultiObjectiveOptimizationSupport.Analyze(IEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) { 42 42 CompiledInstance.Analyze(individuals, qualities, results, random); 43 43 } -
branches/2521_ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/Programmable/SingleObjectiveOptimizationSupportScript.cs
r16723 r16751 40 40 } 41 41 42 void ISingleObjectiveOptimizationSupport.Analyze(I Solution[] individuals, double[] qualities, ResultCollection results, IRandom random) {42 void ISingleObjectiveOptimizationSupport.Analyze(IEncodedSolution[] individuals, double[] qualities, ResultCollection results, IRandom random) { 43 43 CompiledInstance.Analyze(individuals, qualities, results, random); 44 44 } 45 45 46 IEnumerable<I Solution> ISingleObjectiveOptimizationSupport.GetNeighbors(ISolution individual, IRandom random) {46 IEnumerable<IEncodedSolution> ISingleObjectiveOptimizationSupport.GetNeighbors(IEncodedSolution individual, IRandom random) { 47 47 return CompiledInstance.GetNeighbors(individual, random); 48 48 }
Note: See TracChangeset
for help on using the changeset viewer.