Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/18/11 14:50:19 (13 years ago)
Author:
mkommend
Message:

#1418: Fixed compilation errors in Problems.ArtificalAnt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/ArtificialAntProblem.cs

    r5499 r5517  
    2828using HeuristicLab.Data;
    2929using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    30 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Analyzers;
    31 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Creators;
    32 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Interfaces;
    3330using HeuristicLab.Optimization;
    3431using HeuristicLab.Parameters;
     
    104101      get { return EvaluatorParameter; }
    105102    }
    106     public ValueParameter<ISymbolicExpressionGrammar> ArtificialAntExpressionGrammarParameter {
    107       get { return (ValueParameter<ISymbolicExpressionGrammar>)Parameters["ArtificialAntExpressionGrammar"]; }
     103    public ValueParameter<ISymbolicExpressionTreeGrammar> ArtificialAntExpressionGrammarParameter {
     104      get { return (ValueParameter<ISymbolicExpressionTreeGrammar>)Parameters["ArtificialAntExpressionGrammar"]; }
    108105    }
    109106    public ValueParameter<IntValue> MaxExpressionLengthParameter {
     
    218215      Evaluator evaluator = new Evaluator();
    219216      BoolMatrix world = new BoolMatrix(santaFeAntTrail);
    220       ISymbolicExpressionGrammar grammar = new GlobalSymbolicExpressionGrammar(new ArtificialAntExpressionGrammar());
     217      ISymbolicExpressionTreeGrammar grammar = new GlobalSymbolicExpressionGrammar(new ArtificialAntExpressionGrammar());
    221218      Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to true as the Artificial Ant Problem is a maximization problem.", new BoolValue(true)));
    222219      Parameters.Add(new ValueParameter<SymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new artificial ant solutions.", creator));
     
    227224      Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefinitions", "Maximal number of automatically defined functions in the expression to control the artificial ant.", new IntValue(3)));
    228225      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<ISymbolicExpressionGrammar>("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));
    230227      Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world));
    231228      Parameters.Add(new ValueParameter<IntValue>("MaxTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600)));
     
    233230      creator.SymbolicExpressionTreeParameter.ActualName = "AntTrailSolution";
    234231      evaluator.QualityParameter.ActualName = "FoodEaten";
    235       ParameterizeSolutionCreator();
    236       ParameterizeEvaluator();
    237232      InitializeOperators();
    238233      AttachEventHandlers();
     
    263258    private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
    264259      SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
    265       ParameterizeSolutionCreator();
    266       ParameterizeEvaluator();
    267260      ParameterizeAnalyzers();
    268261      ParameterizeOperators();
     
    270263    }
    271264    private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
    272       ParameterizeEvaluator();
    273265      ParameterizeAnalyzers();
    274266      ParameterizeOperators();
     
    276268    private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
    277269      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    278       ParameterizeEvaluator();
    279       ParameterizeAnalyzers();
     270      ParameterizeAnalyzers();
     271      ParameterizeOperators();
    280272      OnEvaluatorChanged();
    281273    }
     
    283275    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    284276      ParameterizeAnalyzers();
    285     }
    286 
     277      ParameterizeOperators();
     278    }
    287279    #endregion
    288280
     
    299291    }
    300292
    301     void MaxFunctionDefinitionsParameter_ValueChanged(object sender, EventArgs e) {
     293    private void MaxFunctionDefinitionsParameter_ValueChanged(object sender, EventArgs e) {
    302294      ArtificialAntExpressionGrammar.MaxFunctionDefinitions = MaxFunctionDefinitions.Value;
    303295    }
    304 
    305     void MaxFunctionArgumentsParameter_ValueChanged(object sender, EventArgs e) {
     296    private void MaxFunctionArgumentsParameter_ValueChanged(object sender, EventArgs e) {
    306297      ArtificialAntExpressionGrammar.MaxFunctionArguments = MaxFunctionArguments.Value;
    307298    }
     
    317308    }
    318309
    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     }
    329310    private void ParameterizeAnalyzers() {
    330311      foreach (IAntTrailAnalyzer analyzer in AntTrailAnalyzers) {
     
    340321
    341322    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
    346330      }
    347331      foreach (Evaluator op in Operators.OfType<Evaluator>()) {
     
    357341        op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    358342      }
    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    }
    370351    #endregion
    371352  }
Note: See TracChangeset for help on using the changeset viewer.