Changeset 3446


Ignore:
Timestamp:
04/20/10 17:01:31 (11 years ago)
Author:
abeham
Message:

updated OSIslandGA #976

Location:
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3
Files:
2 edited

Legend:

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

    r3429 r3446  
    3737  public sealed class OffspringSelectionGeneticAlgorithmMainLoop : AlgorithmOperator {
    3838    #region Parameter properties
    39     public OptionalValueParameter<VariableCreator> VariableInitializerParameter {
    40       get { return (OptionalValueParameter<VariableCreator>)Parameters["VariableInitializer"]; }
    41     }
    4239    public ValueLookupParameter<IRandom> RandomParameter {
    4340      get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
     
    104101    }
    105102    #endregion
    106 
    107     public VariableCreator VariableInitializer {
    108       get { return VariableInitializerParameter.Value; }
    109       set { VariableInitializerParameter.Value = value; }
    110     }
    111103
    112104    [StorableConstructor]
     
    119111    private void Initialize() {
    120112      #region Create parameters
    121       Parameters.Add(new OptionalValueParameter<VariableCreator>("VariableInitializer", "Operator to initialize some variables.", new VariableCreator()));
    122113      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
    123114      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
     
    144135
    145136      #region Create operators
    146       Placeholder variableInitializer = new Placeholder();
     137      ConditionalBranch initializationBranch = new ConditionalBranch();
    147138      VariableCreator variableCreator = new VariableCreator();
    148139      Assigner variableAssigner = new Assigner();
     
    196187      ConditionalBranch conditionalBranch2 = new ConditionalBranch();
    197188
    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 
     189      initializationBranch.ConditionParameter.ActualName = "IsInitialized";
     190
     191      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
     192      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
    208193      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
    209194      variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0)));
    210195      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutionsResult", new IntValue(0)));
     196      variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("IsInitialized", new BoolValue(true)));
     197
     198      variableAssigner.LeftSideParameter.ActualName = "ComparisonFactor";
     199      variableAssigner.RightSideParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
    211200
    212201      bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
     
    397386
    398387      #region Create operator graph
    399       OperatorGraph.InitialOperator = variableInitializer;
    400       variableInitializer.Successor = variableCreator;
    401       variableCreator.Successor = bestQualityMemorizer1;
     388      OperatorGraph.InitialOperator = initializationBranch;
     389      initializationBranch.FalseBranch = variableCreator;
     390      initializationBranch.Successor = selector;
     391      variableCreator.Successor = variableAssigner;
     392      variableAssigner.Successor = bestQualityMemorizer1;
    402393      bestQualityMemorizer1.Successor = bestQualityMemorizer2;
    403394      bestQualityMemorizer2.Successor = bestAverageWorstQualityCalculator1;
     
    407398      qualityDifferenceCalculator1.Successor = visualizer1;
    408399      visualizer1.Successor = resultsCollector;
    409       resultsCollector.Successor = selector;
     400      resultsCollector.Successor = null;
    410401      selector.Successor = subScopesProcessor1;
    411402      subScopesProcessor1.Operators.Add(new EmptyOperator());
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionIslandGeneticAlgorithmMainLoop.cs

    r3429 r3446  
    192192     
    193193      islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("IslandResults", new ResultCollection()));
    194       islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0)));
    195       islandVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue(0)));
    196 
    197       islandVariableAssigner.LeftSideParameter.ActualName = "ComparisonFactor";
    198       islandVariableAssigner.RightSideParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
     194
     195      islandVariableAssigner.LeftSideParameter.ActualName = "MaximumGenerations";
     196      islandVariableAssigner.RightSideParameter.ActualName = "MigrationInterval";
    199197
    200198      bestQualityMemorizer1.BestQualityParameter.ActualName = "BestQuality";
     
    242240      resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name;
    243241
    244       mainLoop.VariableInitializer = null; // we do the variable initialization here
    245242      mainLoop.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
    246243      mainLoop.MaximizationParameter.ActualName = MaximizationParameter.Name;
Note: See TracChangeset for help on using the changeset viewer.