Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/15/11 13:34:38 (14 years ago)
Author:
mkommend
Message:

#1418: Finally added results from the grammar refactoring.

Location:
branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4
Files:
2 edited

Legend:

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

    r5517 r5686  
    2828namespace HeuristicLab.Problems.ArtificialAnt {
    2929  [StorableClass]
    30   public class ArtificialAntExpressionGrammar : DefaultSymbolicExpressionGrammar {
     30  public class ArtificialAntExpressionGrammar : SymbolicExpressionGrammar {
    3131
    3232    public ArtificialAntExpressionGrammar()
     
    5353
    5454      allSymbols.ForEach(s => AddSymbol(s));
    55       SetMinSubtreeCount(ifFoodAhead, 2);
    56       SetMaxSubtreeCount(ifFoodAhead, 2);
    57       SetMinSubtreeCount(prog2, 2);
    58       SetMaxSubtreeCount(prog2, 2);
    59       SetMinSubtreeCount(prog3, 3);
    60       SetMaxSubtreeCount(prog3, 3);
    61       SetMinSubtreeCount(move, 0);
    62       SetMaxSubtreeCount(move, 0);
    63       SetMinSubtreeCount(left, 0);
    64       SetMaxSubtreeCount(left, 0);
    65       SetMinSubtreeCount(right, 0);
    66       SetMaxSubtreeCount(right, 0);
     55      SetSubtreeCount(ifFoodAhead, 2, 3);
     56      SetSubtreeCount(prog2, 2, 2);
     57      SetSubtreeCount(prog3, 3, 3);
     58      SetSubtreeCount(move, 0, 0);
     59      SetSubtreeCount(left, 0, 0);
     60      SetSubtreeCount(right, 0, 0);
    6761
    6862      // each symbols is allowed as child of the start symbol
    69       allSymbols.ForEach(s => SetAllowedChild(StartSymbol, s, 0));
     63      allSymbols.ForEach(s => AddAllowedChildSymbol(StartSymbol, s));
     64      allSymbols.ForEach(s => AddAllowedChildSymbol(DefunSymbol, s));
    7065
    7166      // each symbol is allowed as child of all other symbols (except for terminals that have MaxSubtreeCount == 0
    72       foreach (var parent in allSymbols) {
    73         for (int argIndex = 0; argIndex < GetMaxSubtreeCount(parent); argIndex++) {
    74           foreach (var child in allSymbols) {
    75             SetAllowedChild(parent, child, argIndex);
    76           }
     67      foreach (var parent in nonTerminalSymbols) {
     68        foreach (var child in allSymbols) {
     69          AddAllowedChildSymbol(parent, child);
    7770        }
    7871      }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/ArtificialAntProblem.cs

    r5578 r5686  
    101101      get { return EvaluatorParameter; }
    102102    }
    103     public IValueParameter<ISymbolicExpressionTreeGrammar> ArtificialAntExpressionGrammarParameter {
    104       get { return (IValueParameter<ISymbolicExpressionTreeGrammar>)Parameters["ArtificialAntExpressionGrammar"]; }
     103    public IValueParameter<ISymbolicExpressionGrammar> ArtificialAntExpressionGrammarParameter {
     104      get { return (IValueParameter<ISymbolicExpressionGrammar>)Parameters["ArtificialAntExpressionGrammar"]; }
    105105    }
    106106    public IValueParameter<IntValue> MaxExpressionLengthParameter {
     
    173173      get { return EvaluatorParameter.Value; }
    174174    }
    175     public GlobalSymbolicExpressionGrammar ArtificialAntExpressionGrammar {
    176       get { return (GlobalSymbolicExpressionGrammar)ArtificialAntExpressionGrammarParameter.Value; }
     175    public ArtificialAntExpressionGrammar ArtificialAntExpressionGrammar {
     176      get { return (ArtificialAntExpressionGrammar)ArtificialAntExpressionGrammarParameter.Value; }
    177177    }
    178178    public DoubleValue BestKnownQuality {
     
    211211      Evaluator evaluator = new Evaluator();
    212212      BoolMatrix world = new BoolMatrix(santaFeAntTrail);
    213       ISymbolicExpressionTreeGrammar grammar = new GlobalSymbolicExpressionGrammar(new ArtificialAntExpressionGrammar());
    214213      Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to true as the Artificial Ant Problem is a maximization problem.", new BoolValue(true)));
    215214      Parameters.Add(new ValueParameter<ISymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new artificial ant solutions.", creator));
     
    220219      Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefinitions", "Maximal number of automatically defined functions in the expression to control the artificial ant.", new IntValue(3)));
    221220      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)));
    222       Parameters.Add(new ValueParameter<ISymbolicExpressionTreeGrammar>("ArtificialAntExpressionGrammar", "The grammar that should be used for artificial ant expressions.", grammar));
     221      Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("ArtificialAntExpressionGrammar", "The grammar that should be used for artificial ant expressions.", new ArtificialAntExpressionGrammar()));
    223222      Parameters.Add(new ValueParameter<BoolMatrix>("World", "The world for the artificial ant with scattered food items.", world));
    224223      Parameters.Add(new ValueParameter<IntValue>("MaxTimeSteps", "The number of time steps the artificial ant has available to collect all food items.", new IntValue(600)));
     
    294293
    295294    private void MaxFunctionDefinitionsParameter_ValueChanged(object sender, EventArgs e) {
    296       ArtificialAntExpressionGrammar.MaxFunctionDefinitions = MaxFunctionDefinitions.Value;
     295      ArtificialAntExpressionGrammar.MaximumFunctionDefinitions = MaxFunctionDefinitions.Value;
    297296      ParameterizeOperators();
    298297      ParameterizeAnalyzers();
    299298    }
    300299    private void MaxFunctionArgumentsParameter_ValueChanged(object sender, EventArgs e) {
    301       ArtificialAntExpressionGrammar.MaxFunctionArguments = MaxFunctionArguments.Value;
     300      ArtificialAntExpressionGrammar.MaximumFunctionArguments = MaxFunctionArguments.Value;
    302301      ParameterizeOperators();
    303302      ParameterizeAnalyzers();
Note: See TracChangeset for help on using the changeset viewer.