Changeset 11484 for branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/MultiObjectiveEvaluator.cs
- Timestamp:
- 10/21/14 18:49:05 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ProgrammableProblem/HeuristicLab.Problems.Programmable/3.3/Operators/MultiObjectiveEvaluator.cs
r11400 r11484 30 30 31 31 namespace HeuristicLab.Problems.Programmable { 32 [Item("Multi-objective Evaluator", "Calls the script's Evaluate method to get the quality values of the parameter vector.")]32 [Item("Multi-objective Evaluator", "Calls the Evaluate method of the problem definition and writes the return value into the scope.")] 33 33 [StorableClass] 34 34 public class MultiObjectiveEvaluator : SingleSuccessorOperator, IMultiObjectiveProgrammableProblemEvaluator, IStochasticOperator { … … 38 38 } 39 39 40 public ILookupParameter<IMultiObjectiveProblemDefinition Host> ProblemDefinitionParameter {41 get { return (ILookupParameter<IMultiObjectiveProblemDefinition Host>)Parameters["ProblemDefinition"]; }40 public ILookupParameter<IMultiObjectiveProblemDefinition> ProblemDefinitionParameter { 41 get { return (ILookupParameter<IMultiObjectiveProblemDefinition>)Parameters["ProblemDefinition"]; } 42 42 } 43 43 44 public ILookupParameter< Configuration> ConfigurationParameter {45 get { return (ILookupParameter< Configuration>)Parameters["Configuration"]; }44 public ILookupParameter<Encoding> EncodingParameter { 45 get { return (ILookupParameter<Encoding>)Parameters["Encoding"]; } 46 46 } 47 47 … … 55 55 public MultiObjectiveEvaluator() { 56 56 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use.")); 57 Parameters.Add(new LookupParameter<IMultiObjectiveProblemDefinition Host>("ProblemDefinition", "The host that holds the problem definition."));58 Parameters.Add(new LookupParameter< Configuration>("Configuration", "An item that holds the problem's configuration."));57 Parameters.Add(new LookupParameter<IMultiObjectiveProblemDefinition>("ProblemDefinition", "The host that holds the problem definition.")); 58 Parameters.Add(new LookupParameter<Encoding>("Encoding", "An item that holds the problem's encoding.")); 59 59 Parameters.Add(new LookupParameter<DoubleArray>("Qualities", "The qualities of the parameter vector.")); 60 60 } … … 66 66 public override IOperation Apply() { 67 67 var random = RandomParameter.ActualValue; 68 var host= ProblemDefinitionParameter.ActualValue;69 if ( host.Instance == null) throw new InvalidOperationException("Script instance is null, maybe the code doesn't compile.");70 var config = ConfigurationParameter.ActualValue;68 var definition = ProblemDefinitionParameter.ActualValue; 69 if (definition == null) throw new InvalidOperationException("Problem definition is null."); 70 var config = EncodingParameter.ActualValue; 71 71 var vector = Helper.Extract(ExecutionContext.Scope, config); 72 QualitiesParameter.ActualValue = new DoubleArray( host.Instance.Evaluate(random, vector));72 QualitiesParameter.ActualValue = new DoubleArray(definition.Evaluate(random, vector)); 73 73 return base.Apply(); 74 74 }
Note: See TracChangeset
for help on using the changeset viewer.