Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/21/11 17:40:38 (14 years ago)
Author:
mkommend
Message:

#1418: Updated ArtificialAntProblem.

File:
1 edited

Legend:

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

    r5521 r5528  
    8383
    8484    #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"]; }
    8787    }
    8888    IParameter ISingleObjectiveProblem.MaximizationParameter {
    8989      get { return MaximizationParameter; }
    9090    }
    91     public ValueParameter<SymbolicExpressionTreeCreator> SolutionCreatorParameter {
    92       get { return (ValueParameter<SymbolicExpressionTreeCreator>)Parameters["SolutionCreator"]; }
     91    public IValueParameter<ISymbolicExpressionTreeCreator> SolutionCreatorParameter {
     92      get { return (IValueParameter<ISymbolicExpressionTreeCreator>)Parameters["SolutionCreator"]; }
    9393    }
    9494    IParameter IProblem.SolutionCreatorParameter {
    9595      get { return SolutionCreatorParameter; }
    9696    }
    97     public ValueParameter<Evaluator> EvaluatorParameter {
    98       get { return (ValueParameter<Evaluator>)Parameters["Evaluator"]; }
     97    public IValueParameter<Evaluator> EvaluatorParameter {
     98      get { return (IValueParameter<Evaluator>)Parameters["Evaluator"]; }
    9999    }
    100100    IParameter IProblem.EvaluatorParameter {
    101101      get { return EvaluatorParameter; }
    102102    }
    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 {
    116116      get { return (ValueParameter<IntValue>)Parameters["MaxFunctionArguments"]; }
    117117    }
    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"]; }
    127127    }
    128128    IParameter ISingleObjectiveProblem.BestKnownQualityParameter {
     
    156156      set { MaxFunctionArgumentsParameter.Value = value; }
    157157    }
    158     public SymbolicExpressionTreeCreator SolutionCreator {
     158    public ISymbolicExpressionTreeCreator SolutionCreator {
    159159      get { return SolutionCreatorParameter.Value; }
    160160      set { SolutionCreatorParameter.Value = value; }
     
    195195    [StorableHook(HookType.AfterDeserialization)]
    196196    private void AfterDeserialization() {
    197       // BackwardsCompatibility3.3
    198       #region Backwards compatible code (remove with 3.4)
    199       if (operators == null) InitializeOperators();
    200       #endregion
    201197      AttachEventHandlers();
    202198    }
     
    217213      ISymbolicExpressionTreeGrammar grammar = new GlobalSymbolicExpressionGrammar(new ArtificialAntExpressionGrammar());
    218214      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));
    220216      Parameters.Add(new ValueParameter<Evaluator>("Evaluator", "The operator which should be used to evaluate artificial ant solutions.", evaluator));
    221217      Parameters.Add(new ValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this artificial ant instance.", new DoubleValue(89)));
     
    258254
    259255    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
    260261      SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
    261262      ParameterizeAnalyzers();
     
    268269    }
    269270    private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
     271      Evaluator.QualityParameter.ActualName = "FoodEaten";
    270272      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    271273      ParameterizeAnalyzers();
     
    325327
    326328    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);
    328330
    329331      foreach (ISymbolicExpressionTreeGrammarBasedOperator op in operators.OfType<ISymbolicExpressionTreeGrammarBasedOperator>()) {
Note: See TracChangeset for help on using the changeset viewer.