Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5517


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

#1418: Fixed compilation errors in Problems.ArtificalAnt.

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

Legend:

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

    r5473 r5517  
    2525using HeuristicLab.Data;
    2626using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2827using HeuristicLab.Problems.ArtificialAnt.Symbols;
    2928
     
    6564    private int currentAntLocationColumn;
    6665    private int nFoodItems;
    67     private Stack<SymbolicExpressionTreeNode> nodeStack = new Stack<SymbolicExpressionTreeNode>();
     66    private Stack<ISymbolicExpressionTreeNode> nodeStack = new Stack<ISymbolicExpressionTreeNode>();
    6867
    6968    private void CountFoodItems() {
     
    9493      // expression evaluated completly => start at root again
    9594      if (nodeStack.Count == 0) {
    96         nodeStack.Push(Expression.Root.SubTrees[0].SubTrees[0]);
     95        nodeStack.Push(Expression.Root.GetSubTree(0).GetSubTree(0));
    9796      }
    9897
     
    115114        NextField(out nextAntLocationRow, out nextAntLocationColumn);
    116115        if (World[nextAntLocationRow, nextAntLocationColumn]) {
    117           nodeStack.Push(currentNode.SubTrees[0]);
     116          nodeStack.Push(currentNode.GetSubTree(0));
    118117        } else {
    119           nodeStack.Push(currentNode.SubTrees[1]);
     118          nodeStack.Push(currentNode.GetSubTree(1));
    120119        }
    121120      } else if (currentNode.Symbol is Prog2) {
    122         nodeStack.Push(currentNode.SubTrees[1]);
    123         nodeStack.Push(currentNode.SubTrees[0]);
     121        nodeStack.Push(currentNode.GetSubTree(1));
     122        nodeStack.Push(currentNode.GetSubTree(0));
    124123        return;
    125124      } else if (currentNode.Symbol is Prog3) {
    126         nodeStack.Push(currentNode.SubTrees[2]);
    127         nodeStack.Push(currentNode.SubTrees[1]);
    128         nodeStack.Push(currentNode.SubTrees[0]);
     125        nodeStack.Push(currentNode.GetSubTree(2));
     126        nodeStack.Push(currentNode.GetSubTree(1));
     127        nodeStack.Push(currentNode.GetSubTree(0));
    129128        return;
    130129      } else if (currentNode.Symbol is InvokeFunction) {
     
    132131        var functionDefinition = (SymbolicExpressionTreeNode)FindMatchingFunction(invokeNode.Symbol.FunctionName).Clone();
    133132        var argumentCutPoints = (from node in functionDefinition.IterateNodesPrefix()
    134                                  where node.SubTrees.Count > 0
     133                                 where node.SubTrees.Count() > 0
    135134                                 from subtree in node.SubTrees
    136135                                 where subtree is ArgumentTreeNode
    137                                  select new { Parent = node, Argument = subtree.Symbol as Argument, ChildIndex = node.SubTrees.IndexOf(subtree) }).ToList();
     136                                 select new { Parent = node, Argument = subtree.Symbol as Argument, ChildIndex = node.IndexOfSubTree(subtree) }).ToList();
    138137        foreach (var cutPoint in argumentCutPoints) {
    139138          cutPoint.Parent.RemoveSubTree(cutPoint.ChildIndex);
    140           cutPoint.Parent.InsertSubTree(cutPoint.ChildIndex, (SymbolicExpressionTreeNode)invokeNode.SubTrees[cutPoint.Argument.ArgumentIndex].Clone());
     139          cutPoint.Parent.InsertSubTree(cutPoint.ChildIndex, (SymbolicExpressionTreeNode)invokeNode.GetSubTree(cutPoint.Argument.ArgumentIndex).Clone());
    141140        }
    142         nodeStack.Push(functionDefinition.SubTrees[0]);
     141        nodeStack.Push(functionDefinition.GetSubTree(0));
    143142      } else {
    144143        throw new InvalidOperationException(currentNode.Symbol.ToString());
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/ArtificialAntExpressionGrammar.cs

    r5473 r5517  
    2424using HeuristicLab.Common;
    2525using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    26 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
    2726using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2827using HeuristicLab.Problems.ArtificialAnt.Symbols;
  • 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  }
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/IfFoodAhead.cs

    r5445 r5517  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626namespace HeuristicLab.Problems.ArtificialAnt.Symbols {
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Left.cs

    r5445 r5517  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626namespace HeuristicLab.Problems.ArtificialAnt.Symbols {
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Move.cs

    r5445 r5517  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626namespace HeuristicLab.Problems.ArtificialAnt.Symbols {
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Prog2.cs

    r5445 r5517  
    2323using HeuristicLab.Common;
    2424using HeuristicLab.Core;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     25using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727namespace HeuristicLab.Problems.ArtificialAnt.Symbols {
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Prog3.cs

    r5445 r5517  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626namespace HeuristicLab.Problems.ArtificialAnt.Symbols {
  • branches/DataAnalysis Refactoring/HeuristicLab.Problems.ArtificialAnt/3.4/Symbols/Right.cs

    r5445 r5517  
    2222using HeuristicLab.Common;
    2323using HeuristicLab.Core;
    24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Symbols;
     24using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2626namespace HeuristicLab.Problems.ArtificialAnt.Symbols {
Note: See TracChangeset for help on using the changeset viewer.