Changeset 5517 for branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/ArtificialAntProblem.cs
- Timestamp:
- 02/18/11 14:50:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/ArtificialAntProblem.cs
r5499 r5517 28 28 using HeuristicLab.Data; 29 29 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Analyzers;31 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;32 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;33 30 using HeuristicLab.Optimization; 34 31 using HeuristicLab.Parameters; … … 104 101 get { return EvaluatorParameter; } 105 102 } 106 public ValueParameter<ISymbolicExpression Grammar> ArtificialAntExpressionGrammarParameter {107 get { return (ValueParameter<ISymbolicExpression Grammar>)Parameters["ArtificialAntExpressionGrammar"]; }103 public ValueParameter<ISymbolicExpressionTreeGrammar> ArtificialAntExpressionGrammarParameter { 104 get { return (ValueParameter<ISymbolicExpressionTreeGrammar>)Parameters["ArtificialAntExpressionGrammar"]; } 108 105 } 109 106 public ValueParameter<IntValue> MaxExpressionLengthParameter { … … 218 215 Evaluator evaluator = new Evaluator(); 219 216 BoolMatrix world = new BoolMatrix(santaFeAntTrail); 220 ISymbolicExpression Grammar grammar = new GlobalSymbolicExpressionGrammar(new ArtificialAntExpressionGrammar());217 ISymbolicExpressionTreeGrammar grammar = new GlobalSymbolicExpressionGrammar(new ArtificialAntExpressionGrammar()); 221 218 Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to true as the Artificial Ant Problem is a maximization problem.", new BoolValue(true))); 222 219 Parameters.Add(new ValueParameter<SymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new artificial ant solutions.", creator)); … … 227 224 Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefinitions", "Maximal number of automatically defined functions in the expression to control the artificial ant.", new IntValue(3))); 228 225 Parameters.Add(new ValueParameter<IntValue>("MaxFunctionArguments", "Maximal number of arguments of automatically defined functions in the expression to control the artificial ant.", new IntValue(3))); 229 Parameters.Add(new ValueParameter<ISymbolicExpression Grammar>("ArtificialAntExpressionGrammar", "The grammar that should be used for artificial ant expressions.", grammar));226 Parameters.Add(new ValueParameter<ISymbolicExpressionTreeGrammar>("ArtificialAntExpressionGrammar", "The grammar that should be used for artificial ant expressions.", grammar)); 230 227 Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world)); 231 228 Parameters.Add(new ValueParameter<IntValue>("MaxTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600))); … … 233 230 creator.SymbolicExpressionTreeParameter.ActualName = "AntTrailSolution"; 234 231 evaluator.QualityParameter.ActualName = "FoodEaten"; 235 ParameterizeSolutionCreator();236 ParameterizeEvaluator();237 232 InitializeOperators(); 238 233 AttachEventHandlers(); … … 263 258 private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) { 264 259 SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged); 265 ParameterizeSolutionCreator();266 ParameterizeEvaluator();267 260 ParameterizeAnalyzers(); 268 261 ParameterizeOperators(); … … 270 263 } 271 264 private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) { 272 ParameterizeEvaluator();273 265 ParameterizeAnalyzers(); 274 266 ParameterizeOperators(); … … 276 268 private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) { 277 269 Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 278 Parameterize Evaluator();279 Parameterize Analyzers();270 ParameterizeAnalyzers(); 271 ParameterizeOperators(); 280 272 OnEvaluatorChanged(); 281 273 } … … 283 275 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 284 276 ParameterizeAnalyzers(); 285 }286 277 ParameterizeOperators(); 278 } 287 279 #endregion 288 280 … … 299 291 } 300 292 301 void MaxFunctionDefinitionsParameter_ValueChanged(object sender, EventArgs e) {293 private void MaxFunctionDefinitionsParameter_ValueChanged(object sender, EventArgs e) { 302 294 ArtificialAntExpressionGrammar.MaxFunctionDefinitions = MaxFunctionDefinitions.Value; 303 295 } 304 305 void MaxFunctionArgumentsParameter_ValueChanged(object sender, EventArgs e) { 296 private void MaxFunctionArgumentsParameter_ValueChanged(object sender, EventArgs e) { 306 297 ArtificialAntExpressionGrammar.MaxFunctionArguments = MaxFunctionArguments.Value; 307 298 } … … 317 308 } 318 309 319 private void ParameterizeSolutionCreator() {320 SolutionCreator.SymbolicExpressionGrammarParameter.ActualName = ArtificialAntExpressionGrammarParameter.Name;321 SolutionCreator.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;322 SolutionCreator.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;323 }324 private void ParameterizeEvaluator() {325 Evaluator.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;326 Evaluator.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;327 Evaluator.WorldParameter.ActualName = WorldParameter.Name;328 }329 310 private void ParameterizeAnalyzers() { 330 311 foreach (IAntTrailAnalyzer analyzer in AntTrailAnalyzers) { … … 340 321 341 322 private void ParameterizeOperators() { 342 foreach (ISymbolicExpressionTreeOperator op in Operators.OfType<ISymbolicExpressionTreeOperator>()) { 343 op.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name; 344 op.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name; 345 op.SymbolicExpressionGrammarParameter.ActualName = ArtificialAntExpressionGrammarParameter.Name; 323 foreach (ISymbolicExpressionTreeGrammarBasedOperator op in Operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) { 324 op.SymbolicExpressionTreeGrammarParameter.ActualName = ArtificialAntExpressionGrammarParameter.Name; 325 } 326 foreach (ISymbolicExpressionTreeSizeConstraintOperator op in Operators.OfType<ISymbolicExpressionTreeSizeConstraintOperator>()) { 327 op.MaximumSymbolicExpressionTreeDepthParameter.ActualName = MaxExpressionDepthParameter.Name; 328 op.MaximumSymbolicExpressionTreeLengthParameter.ActualName = MaxExpressionLengthParameter.Name; 329 346 330 } 347 331 foreach (Evaluator op in Operators.OfType<Evaluator>()) { … … 357 341 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 358 342 } 359 foreach (ISymbolicExpressionTreeArchitectureManipulator op in Operators.OfType<ISymbolicExpressionTreeArchitectureManipulator>()) { 360 op.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefinitionsParameter.Name; 361 op.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name; 362 } 363 foreach (SymbolicExpressionTreeCreator op in Operators.OfType<SymbolicExpressionTreeCreator>()) { 364 op.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name; 365 op.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefinitionsParameter.Name; 366 } 367 } 368 369 343 foreach (ISymbolicExpressionTreeArchitectureAlteringOperator op in Operators.OfType<ISymbolicExpressionTreeArchitectureAlteringOperator>()) { 344 op.MaximumFunctionDefinitionsParameter.ActualName = MaxFunctionDefinitionsParameter.Name; 345 op.MaximumFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name; 346 } 347 foreach (ISymbolicExpressionTreeCreator op in Operators.OfType<ISymbolicExpressionTreeCreator>()) { 348 op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName; 349 } 350 } 370 351 #endregion 371 352 }
Note: See TracChangeset
for help on using the changeset viewer.