Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/21/11 10:54:30 (14 years ago)
Author:
abeham
Message:

#1344

  • Added EvaluatedSolutions result to GeneticAlgorithm
  • Updated the GA and SGP samples (GA samples with parallel engine, SGP with sequential engine)
Location:
trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs

    r5307 r5346  
    2626using HeuristicLab.Core;
    2727using HeuristicLab.Data;
     28using HeuristicLab.Operators;
    2829using HeuristicLab.Optimization;
    2930using HeuristicLab.Optimization.Operators;
     
    134135    }
    135136    private GeneticAlgorithmMainLoop GeneticAlgorithmMainLoop {
    136       get { return (GeneticAlgorithmMainLoop)SolutionsCreator.Successor; }
     137      get { return (GeneticAlgorithmMainLoop)((Assigner)SolutionsCreator.Successor).Successor; }
    137138    }
    138139    [Storable]
     
    155156      RandomCreator randomCreator = new RandomCreator();
    156157      SolutionsCreator solutionsCreator = new SolutionsCreator();
     158      Assigner assigner = new Assigner();
    157159      GeneticAlgorithmMainLoop geneticAlgorithmMainLoop = new GeneticAlgorithmMainLoop();
    158160      OperatorGraph.InitialOperator = randomCreator;
     
    166168
    167169      solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
    168       solutionsCreator.Successor = geneticAlgorithmMainLoop;
     170      solutionsCreator.Successor = assigner;
     171
     172      assigner.Name = "Initialize EvaluatedSolutions";
     173      assigner.LeftSideParameter.ActualName = "EvaluatedSolutions";
     174      assigner.RightSideParameter.ActualName = PopulationSizeParameter.Name;
     175      assigner.Successor = geneticAlgorithmMainLoop;
    169176
    170177      geneticAlgorithmMainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
     
    176183      geneticAlgorithmMainLoop.RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
    177184      geneticAlgorithmMainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
     185      geneticAlgorithmMainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
     186      geneticAlgorithmMainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
    178187      geneticAlgorithmMainLoop.ResultsParameter.ActualName = "Results";
    179188
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithmMainLoop.cs

    r5208 r5346  
    7272    public ValueLookupParameter<IOperator> AnalyzerParameter {
    7373      get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
     74    }
     75    public ValueLookupParameter<IntValue> EvaluatedSolutionsParameter {
     76      get { return (ValueLookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
     77    }
     78    public ValueLookupParameter<IntValue> PopulationSizeParameter {
     79      get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; }
    7480    }
    7581    private ScopeParameter CurrentScopeParameter {
     
    109115      Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
    110116      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
     117      Parameters.Add(new ValueLookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
     118      Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population."));
    111119      Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the genetic algorithm should be applied."));
    112120      #endregion
     
    126134      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
    127135      Placeholder evaluator = new Placeholder();
     136      IntCounter intCounter1 = new IntCounter();
    128137      SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
    129138      BestSelector bestSelector = new BestSelector();
    130139      RightReducer rightReducer = new RightReducer();
    131140      MergingReducer mergingReducer = new MergingReducer();
    132       IntCounter intCounter = new IntCounter();
     141      IntCounter intCounter2 = new IntCounter();
    133142      Comparator comparator = new Comparator();
    134143      ResultsCollector resultsCollector2 = new ResultsCollector();
     
    139148
    140149      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
     150      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>(EvaluatedSolutionsParameter.Name));
    141151      resultsCollector1.ResultsParameter.ActualName = "Results";
    142152
     
    164174      evaluator.Name = "Evaluator";
    165175      evaluator.OperatorParameter.ActualName = "Evaluator";
     176
     177      intCounter1.Name = "Increment EvaluatedSolutions";
     178      intCounter1.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
     179      intCounter1.Increment = null;
     180      intCounter1.IncrementParameter.ActualName = PopulationSizeParameter.Name;
    166181
    167182      bestSelector.CopySelected = new BoolValue(false);
     
    170185      bestSelector.QualityParameter.ActualName = "Quality";
    171186
    172       intCounter.Increment = new IntValue(1);
    173       intCounter.ValueParameter.ActualName = "Generations";
     187      intCounter2.Increment = new IntValue(1);
     188      intCounter2.ValueParameter.ActualName = "Generations";
    174189
    175190      comparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
     
    179194
    180195      resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
     196      resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>(EvaluatedSolutionsParameter.Name));
    181197      resultsCollector2.ResultsParameter.ActualName = "Results";
    182198
     
    206222      subScopesRemover.Successor = null;
    207223      uniformSubScopesProcessor2.Operator = evaluator;
    208       uniformSubScopesProcessor2.Successor = null;
     224      uniformSubScopesProcessor2.Successor = intCounter1;
    209225      evaluator.Successor = null;
     226      intCounter1.Successor = null;
    210227      subScopesProcessor2.Operators.Add(bestSelector);
    211228      subScopesProcessor2.Operators.Add(new EmptyOperator());
     
    213230      bestSelector.Successor = rightReducer;
    214231      rightReducer.Successor = null;
    215       mergingReducer.Successor = intCounter;
    216       intCounter.Successor = comparator;
     232      mergingReducer.Successor = intCounter2;
     233      intCounter2.Successor = comparator;
    217234      comparator.Successor = resultsCollector2;
    218235      resultsCollector2.Successor = analyzer2;
Note: See TracChangeset for help on using the changeset viewer.