Changeset 5528
- Timestamp:
- 02/21/11 17:40:38 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/ArtificialAntProblem.cs
r5521 r5528 83 83 84 84 #region Parameter Properties 85 public ValueParameter<BoolValue> MaximizationParameter {86 get { return ( ValueParameter<BoolValue>)Parameters["Maximization"]; }85 public IValueParameter<BoolValue> MaximizationParameter { 86 get { return (IValueParameter<BoolValue>)Parameters["Maximization"]; } 87 87 } 88 88 IParameter ISingleObjectiveProblem.MaximizationParameter { 89 89 get { return MaximizationParameter; } 90 90 } 91 public ValueParameter<SymbolicExpressionTreeCreator> SolutionCreatorParameter {92 get { return ( ValueParameter<SymbolicExpressionTreeCreator>)Parameters["SolutionCreator"]; }91 public IValueParameter<ISymbolicExpressionTreeCreator> SolutionCreatorParameter { 92 get { return (IValueParameter<ISymbolicExpressionTreeCreator>)Parameters["SolutionCreator"]; } 93 93 } 94 94 IParameter IProblem.SolutionCreatorParameter { 95 95 get { return SolutionCreatorParameter; } 96 96 } 97 public ValueParameter<Evaluator> EvaluatorParameter {98 get { return ( ValueParameter<Evaluator>)Parameters["Evaluator"]; }97 public IValueParameter<Evaluator> EvaluatorParameter { 98 get { return (IValueParameter<Evaluator>)Parameters["Evaluator"]; } 99 99 } 100 100 IParameter IProblem.EvaluatorParameter { 101 101 get { return EvaluatorParameter; } 102 102 } 103 public ValueParameter<ISymbolicExpressionTreeGrammar> ArtificialAntExpressionGrammarParameter {104 get { return ( ValueParameter<ISymbolicExpressionTreeGrammar>)Parameters["ArtificialAntExpressionGrammar"]; }105 } 106 public ValueParameter<IntValue> MaxExpressionLengthParameter {107 get { return ( ValueParameter<IntValue>)Parameters["MaxExpressionLength"]; }108 } 109 public ValueParameter<IntValue> MaxExpressionDepthParameter {110 get { return ( ValueParameter<IntValue>)Parameters["MaxExpressionDepth"]; }111 } 112 public ValueParameter<IntValue> MaxFunctionDefinitionsParameter {113 get { return ( ValueParameter<IntValue>)Parameters["MaxFunctionDefinitions"]; }114 } 115 public ValueParameter<IntValue> MaxFunctionArgumentsParameter {103 public IValueParameter<ISymbolicExpressionTreeGrammar> ArtificialAntExpressionGrammarParameter { 104 get { return (IValueParameter<ISymbolicExpressionTreeGrammar>)Parameters["ArtificialAntExpressionGrammar"]; } 105 } 106 public IValueParameter<IntValue> MaxExpressionLengthParameter { 107 get { return (IValueParameter<IntValue>)Parameters["MaxExpressionLength"]; } 108 } 109 public IValueParameter<IntValue> MaxExpressionDepthParameter { 110 get { return (IValueParameter<IntValue>)Parameters["MaxExpressionDepth"]; } 111 } 112 public IValueParameter<IntValue> MaxFunctionDefinitionsParameter { 113 get { return (IValueParameter<IntValue>)Parameters["MaxFunctionDefinitions"]; } 114 } 115 public IValueParameter<IntValue> MaxFunctionArgumentsParameter { 116 116 get { return (ValueParameter<IntValue>)Parameters["MaxFunctionArguments"]; } 117 117 } 118 public ValueParameter<BoolMatrix> WorldParameter {119 get { return ( ValueParameter<BoolMatrix>)Parameters["World"]; }120 } 121 public ValueParameter<IntValue> MaxTimeStepsParameter {122 get { return ( ValueParameter<IntValue>)Parameters["MaxTimeSteps"]; }123 } 124 125 public ValueParameter<DoubleValue> BestKnownQualityParameter {126 get { return ( ValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; }118 public IValueParameter<BoolMatrix> WorldParameter { 119 get { return (IValueParameter<BoolMatrix>)Parameters["World"]; } 120 } 121 public IValueParameter<IntValue> MaxTimeStepsParameter { 122 get { return (IValueParameter<IntValue>)Parameters["MaxTimeSteps"]; } 123 } 124 125 public IValueParameter<DoubleValue> BestKnownQualityParameter { 126 get { return (IValueParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 127 127 } 128 128 IParameter ISingleObjectiveProblem.BestKnownQualityParameter { … … 156 156 set { MaxFunctionArgumentsParameter.Value = value; } 157 157 } 158 public SymbolicExpressionTreeCreator SolutionCreator {158 public ISymbolicExpressionTreeCreator SolutionCreator { 159 159 get { return SolutionCreatorParameter.Value; } 160 160 set { SolutionCreatorParameter.Value = value; } … … 195 195 [StorableHook(HookType.AfterDeserialization)] 196 196 private void AfterDeserialization() { 197 // BackwardsCompatibility3.3198 #region Backwards compatible code (remove with 3.4)199 if (operators == null) InitializeOperators();200 #endregion201 197 AttachEventHandlers(); 202 198 } … … 217 213 ISymbolicExpressionTreeGrammar grammar = new GlobalSymbolicExpressionGrammar(new ArtificialAntExpressionGrammar()); 218 214 Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to true as the Artificial Ant Problem is a maximization problem.", new BoolValue(true))); 219 Parameters.Add(new ValueParameter< SymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new artificial ant solutions.", creator));215 Parameters.Add(new ValueParameter<ISymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new artificial ant solutions.", creator)); 220 216 Parameters.Add(new ValueParameter<Evaluator>("Evaluator", "The operator which should be used to evaluate artificial ant solutions.", evaluator)); 221 217 Parameters.Add(new ValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this artificial ant instance.", new DoubleValue(89))); … … 258 254 259 255 private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) { 256 SolutionCreator.SymbolicExpressionTreeParameter.ActualName = "AntTrailSolution"; 257 var grammarBased = SolutionCreator as ISymbolicExpressionTreeGrammarBasedOperator; 258 if (grammarBased != null) 259 grammarBased.SymbolicExpressionTreeGrammarParameter.ActualName = "ArtificialAntExpressionGrammar"; 260 260 261 SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged); 261 262 ParameterizeAnalyzers(); … … 268 269 } 269 270 private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) { 271 Evaluator.QualityParameter.ActualName = "FoodEaten"; 270 272 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 271 273 ParameterizeAnalyzers(); … … 325 327 326 328 private void ParameterizeOperators() { 327 var operators = Parameters.OfType<IValueParameter>().Select(p => p. ActualValue).OfType<IOperator>().Union(Operators);329 var operators = Parameters.OfType<IValueParameter>().Select(p => p.Value).OfType<IOperator>().Union(Operators); 328 330 329 331 foreach (ISymbolicExpressionTreeGrammarBasedOperator op in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) {
Note: See TracChangeset
for help on using the changeset viewer.