Changeset 3427


Ignore:
Timestamp:
04/20/10 00:30:46 (11 years ago)
Author:
abeham
Message:

moved initialization of generations, comparison factor, and evaluated solutions to a value parameter in preparation of building an Offspring Selection Island GA #976

File:
1 edited

Legend:

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

    r3426 r3427  
    3737  public sealed class OffspringSelectionGeneticAlgorithmMainLoop : AlgorithmOperator {
    3838    #region Parameter properties
     39    public ValueParameter<VariableCreator> VariableInitializerParameter {
     40      get { return (ValueParameter<VariableCreator>)Parameters["VariableInitializer"]; }
     41    }
    3942    public ValueLookupParameter<IRandom> RandomParameter {
    4043      get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
     
    101104    }
    102105    #endregion
     106
     107    public VariableCreator VariableInitializer {
     108      get { return VariableInitializerParameter.Value; }
     109      set { VariableInitializerParameter.Value = value; }
     110    }
    103111
    104112    [StorableConstructor]
     
    111119    private void Initialize() {
    112120      #region Create parameters
     121      Parameters.Add(new ValueParameter<VariableCreator>("VariableInitializer", "Operator to initialize some variables.", new VariableCreator()));
    113122      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
    114123      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
     
    135144
    136145      #region Create operators
     146      Placeholder variableInitializer = new Placeholder();
    137147      VariableCreator variableCreator = new VariableCreator();
    138148      Assigner variableAssigner = new Assigner();
     
    186196      ConditionalBranch conditionalBranch2 = new ConditionalBranch();
    187197
    188       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
     198      VariableInitializer.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
     199      VariableInitializer.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
     200      VariableInitializer.Successor = variableAssigner;
     201
     202      variableAssigner.LeftSideParameter.ActualName = "ComparisonFactor";
     203      variableAssigner.RightSideParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
     204
     205      variableInitializer.Name = "VariableInitializer (placeholder)";
     206      variableInitializer.OperatorParameter.ActualName = VariableInitializerParameter.Name;
     207
    189208      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
    190209      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0)));
    191       variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
    192210      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutionsResult", new IntValue(0)));
    193 
    194       variableAssigner.LeftSideParameter.ActualName = "ComparisonFactor";
    195       variableAssigner.RightSideParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
    196211
    197212      bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
     
    229244
    230245      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
    231       resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutionsResult"));
    232246      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Best Quality", null, "CurrentBestQuality"));
    233247      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Average Quality", null, "CurrentAverageQuality"));
     
    237251      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest"));
    238252      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest"));
     253      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutionsResult"));
     254      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Curent Comparison Factor", null, "ComparisonFactor"));
    239255      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", null, "SelectionPressure"));
    240256      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", null, "CurrentSuccessRatio"));
     
    381397
    382398      #region Create operator graph
    383       OperatorGraph.InitialOperator = variableCreator;
    384       variableCreator.Successor = variableAssigner;
    385       variableAssigner.Successor = bestQualityMemorizer1;
     399      OperatorGraph.InitialOperator = variableInitializer;
     400      variableInitializer.Successor = variableCreator;
     401      variableCreator.Successor = bestQualityMemorizer1;
    386402      bestQualityMemorizer1.Successor = bestQualityMemorizer2;
    387403      bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1;
Note: See TracChangeset for help on using the changeset viewer.