Changeset 13372 for branches/ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/MultiObjectiveExternalEvaluationProblem.cs
- Timestamp:
- 11/24/15 17:22:41 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProblemRefactoring/HeuristicLab.Problems.ExternalEvaluation/3.4/MultiObjectiveExternalEvaluationProblem.cs
r13336 r13372 37 37 [Creatable(CreatableAttribute.Categories.ExternalEvaluationProblems, Priority = 200)] 38 38 [StorableClass] 39 public class MultiObjectiveExternalEvaluationProblem : MultiObjectiveProblem<IEncoding >, IExternalEvaluationProblem {39 public class MultiObjectiveExternalEvaluationProblem : MultiObjectiveProblem<IEncoding<ISolution>, ISolution>, IExternalEvaluationProblem { 40 40 41 41 public static new Image StaticItemImage { … … 99 99 } 100 100 101 public override double[] Evaluate(I ndividualindividual, IRandom random) {101 public override double[] Evaluate(ISolution individual, IRandom random) { 102 102 var qualityMessage = Evaluate(BuildSolutionMessage(individual)); 103 103 if (!qualityMessage.HasExtension(MultiObjectiveQualityMessage.QualityMessage_)) … … 111 111 } 112 112 113 public override void Analyze(I ndividual[] individuals, double[][] qualities, ResultCollection results, IRandom random) {113 public override void Analyze(ISolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) { 114 114 OptimizationSupport.Analyze(individuals, qualities, results, random); 115 115 } … … 140 140 try { 141 141 return client.Evaluate(message, GetQualityMessageExtensions()); 142 } finally { 142 } 143 finally { 143 144 lock (clientLock) { 144 145 activeClients.Remove(client); … … 148 149 } 149 150 150 private SolutionMessage BuildSolutionMessage(I ndividual individual, int solutionId = 0) {151 private SolutionMessage BuildSolutionMessage(ISolution solution, int solutionId = 0) { 151 152 lock (clientLock) { 152 153 SolutionMessage.Builder protobufBuilder = SolutionMessage.CreateBuilder(); 153 154 protobufBuilder.SolutionId = solutionId; 154 155 var scope = new Scope(); 155 individual.CopyToScope(scope);156 ScopeUtil.CopySolutionToScope(scope, Encoding, solution); 156 157 foreach (var variable in scope.Variables) { 157 158 try { 158 159 MessageBuilder.AddToMessage(variable.Value, variable.Name, protobufBuilder); 159 } catch (ArgumentException ex) { 160 } 161 catch (ArgumentException ex) { 160 162 throw new InvalidOperationException(string.Format("ERROR while building solution message: Parameter {0} cannot be added to the message", Name), ex); 161 163 }
Note: See TracChangeset
for help on using the changeset viewer.