Changeset 12192


Ignore:
Timestamp:
03/11/15 15:45:29 (7 years ago)
Author:
pfleck
Message:

#2350 Improved performance of steady state ALPS.

  • Introduced a batch cycle in the main loop to avoid too frequent updates of some variables and analyzers.
  • No cloning of individuals when creating the mating pool.
Location:
branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/AlpsSsGeneticAlgorithm.cs

    r12159 r12192  
    6464      get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateElites"]; }
    6565    }
     66    private IValueParameter<IntValue> BatchSizeParameter {
     67      get { return (IValueParameter<IntValue>)Parameters["BatchSize"]; }
     68    }
    6669    #endregion
    6770
     
    127130      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
    128131      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
     132      Parameters.Add(new ValueParameter<IntValue>("BatchSize", "Number of inner iterations before updates and analyzers are fired.", new IntValue(100)) { Hidden = true });
    129133      AgeInheritance = new ReductionOperation(ReductionOperations.Min);
    130134
     
    140144      var initializeAge = new VariableCreator() { Name = "Initialize Age" };
    141145      var initializeEvaluatedSolutions = new ExpressionCalculator() { Name = "Initialize EvaluatedSolutions" };
     146      var initializeResultEvaluatedSolutions = new Assigner() { Name = "Initialize ResultEvaluatedSolutions" };
    142147      var initializePopulationSize = new Assigner() { Name = "Initialize PopulationSize" };
    143148      var resultsCollector = new ResultsCollector();
     
    182187      initializeEvaluatedSolutions.CollectedValues.Add(new LookupParameter<IntValue>("LayerSize"));
    183188      initializeEvaluatedSolutions.CollectedValues.Add(new LookupParameter<IntValue>("NumberOfLayers"));
    184       initializeEvaluatedSolutions.Successor = initializePopulationSize;
     189      initializeEvaluatedSolutions.Successor = initializeResultEvaluatedSolutions;
     190
     191      initializeResultEvaluatedSolutions.LeftSideParameter.ActualName = "ResultEvaluatedSolutions";
     192      initializeResultEvaluatedSolutions.RightSideParameter.ActualName = "EvaluatedSolutions";
     193      initializeResultEvaluatedSolutions.Successor = initializePopulationSize;
    185194
    186195      initializePopulationSize.LeftSideParameter.ActualName = "PopulationSize";
     
    188197      initializePopulationSize.Successor = resultsCollector;
    189198
    190       resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
     199      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "ResultEvaluatedSolutions"));
    191200      resultsCollector.Successor = mainLoop;
    192201
  • branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/AlpsSsGeneticAlgorithmMainLoop.cs

    r12171 r12192  
    7171
    7272      var variableCreator = new VariableCreator() { Name = "Initialize" };
     73      var resultsColletor = new ResultsCollector();
    7374      var layersProcessor = new NamedSubScopeProcessor() { Name = "Process Layers" };
    74       var randomScopeProcessor = new RandomLayerProcessor() { Name = "Select a layer" };
     75      var initializeBatchIteration = new Assigner() { Name = "Initialize BatchIterations" };
     76      var randomLayerProcessor = new RandomLayerProcessor() { Name = "Select a layer" };
    7577      var isLayerZeroComperator = new Comparator() { Name = "IsLayerZero = Layer == 0" };
    7678      var isLayerZeroBranch = new ConditionalBranch() { Name = "IsLayerZero?" };
     
    9597      var resetTargetIndex = new Assigner() { Name = "TargetIndex = 0" };
    9698      var tryMoveUp = new AlpsSsMover() { Name = "Try Move Up" };
    97       var incrementEvaluations = new IntCounter() { Name = "incr. EvaluatedSolutions" };
     99      var incrementEvaluations = new IntCounter() { Name = "Incr. EvaluatedSolutions" };
     100      var incrementBatchIterations = new IntCounter() { Name = "Incr. BatchIterations" };
     101      var batchFinishedComperator = new Comparator() { Name = "BatchFinished = BatchIterations >= BatchSize" };
     102      var batchFinishedBranch = new ConditionalBranch() { Name = "BatchFinished?" };
    98103      var incrIterations = new IntCounter() { Name = "Incr. Iterations" };
     104      var updateResultEvaluatedSolutions = new IntCounter() { Name = "Update ResultEvaluatedSolutions" };
    99105      var layerAnalyzerProcessor = new UniformSubScopesProcessor();
    100106      var layerAnalyzer = new Placeholder() { Name = "LayerAnalyzer (Placeholder)" };
     
    114120      variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("ValidParents", new BoolValue(false)));
    115121      variableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("IsLayerZero", new BoolValue(false)));
    116       variableCreator.Successor = layersProcessor;
    117 
    118       layersProcessor.Operator = randomScopeProcessor;
     122      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("BatchIterations", new IntValue(0)));
     123      variableCreator.Successor = resultsColletor;
     124
     125      resultsColletor.CollectedValues.Add(new LookupParameter<IntValue>("Iterations"));
     126      resultsColletor.Successor = layersProcessor;
     127
    119128      layersProcessor.TargetScopeParameter.ActualName = "Layers";
    120 
    121       randomScopeProcessor.Operator = isLayerZeroComperator;
    122       // TODO move to old individuals
    123       randomScopeProcessor.Successor = incrIterations;
     129      layersProcessor.Operator = initializeBatchIteration;
     130
     131      initializeBatchIteration.LeftSideParameter.ActualName = "BatchIterations";
     132      initializeBatchIteration.RightSideParameter.Value = new IntValue(0);
     133      initializeBatchIteration.Successor = randomLayerProcessor;
     134
     135      randomLayerProcessor.Operator = isLayerZeroComperator;
     136      randomLayerProcessor.Successor = incrementBatchIterations;
    124137
    125138      isLayerZeroComperator.LeftSideParameter.ActualName = "Layer";
     
    203216      tryMoveUp.Successor = incrementEvaluations;
    204217
     218      incrementEvaluations.ValueParameter.ActualName = "EvaluatedSolutions";
    205219      incrementEvaluations.Increment = new IntValue(1);
    206       incrementEvaluations.ValueParameter.ActualName = "EvaluatedSolutions";
     220
     221      incrementBatchIterations.ValueParameter.ActualName = "BatchIterations";
     222      incrementBatchIterations.Increment = new IntValue(1);
     223      incrementBatchIterations.Successor = batchFinishedComperator;
     224
     225      batchFinishedComperator.LeftSideParameter.ActualName = "BatchIterations";
     226      batchFinishedComperator.RightSideParameter.ActualName = "BatchSize";
     227      batchFinishedComperator.ResultParameter.ActualName = "BatchFinished";
     228      batchFinishedComperator.Successor = batchFinishedBranch;
     229
     230      batchFinishedBranch.ConditionParameter.ActualName = "BatchFinished";
     231      batchFinishedBranch.TrueBranch = incrIterations;
     232      batchFinishedBranch.FalseBranch = randomLayerProcessor;
    207233
    208234      incrIterations.ValueParameter.ActualName = "Iterations";
    209235      incrIterations.Increment = new IntValue(1);
    210       incrIterations.Successor = layerAnalyzerProcessor;
     236      incrIterations.Successor = updateResultEvaluatedSolutions;
     237
     238      updateResultEvaluatedSolutions.ValueParameter.ActualName = "ResultEvaluatedSolutions";
     239      updateResultEvaluatedSolutions.IncrementParameter.ActualName = "BatchSize";
     240      updateResultEvaluatedSolutions.IncrementParameter.Value = null;
     241      updateResultEvaluatedSolutions.Successor = layerAnalyzerProcessor;
    211242
    212243      layerAnalyzerProcessor.Operator = layerAnalyzer;
     
    225256
    226257      terminateBranch.ConditionParameter.ActualName = "Terminate";
    227       terminateBranch.FalseBranch = randomScopeProcessor;
     258      terminateBranch.FalseBranch = initializeBatchIteration;
    228259    }
    229260  }
  • branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/HeuristicLab.Algorithms.ALPS.SteadyState-3.3.csproj

    r12159 r12192  
    7676  </PropertyGroup>
    7777  <ItemGroup>
     78    <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     79      <SpecificVersion>False</SpecificVersion>
     80      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
     81    </Reference>
    7882    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    7983      <SpecificVersion>False</SpecificVersion>
  • branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/SteadyStateMatingPoolCreator.cs

    r12171 r12192  
    9393        let age = (evaluations - evalsCreated) / popSize
    9494        where age < ageLimit
    95         select (IScope)individual.Clone();
     95        select (IScope)individual/*.Clone()*/;
    9696
    9797      foreach (var individual in matingPool) {
Note: See TracChangeset for help on using the changeset viewer.