Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12150


Ignore:
Timestamp:
03/06/15 13:24:42 (10 years ago)
Author:
pfleck
Message:

#2350 Fixed Bugs in Steady-State ALPS OperatorGraph and Mover.

Location:
branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3
Files:
3 edited

Legend:

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

    r12142 r12150  
    7272      var variableCreator = new VariableCreator() { Name = "Initialize" };
    7373      var randomScopeProcessor = new RandomLayerProcessor() { Name = "Select a layer" };
     74      var layerPopulationSizeCounter = new SubScopesCounter() { Name = "Count LayerPopulationSize" };
    7475      var isLayerZeroComperator = new Comparator() { Name = "IsLayerZero = Layer == 0" };
    7576      var isLayerZeroBranch = new ConditionalBranch() { Name = "IsLayerZero?" };
     
    9798      var tryMoveUp = new AlpsSsMover() { Name = "Try Move Up" };
    9899      var removeWorkingScope = new LeftReducer() { Name = "Remove Working Scope" };
     100      var incrementEvaluations = new IntCounter() { Name = "incr. EvaluatedSolutions" };
    99101      var incrIterations = new IntCounter() { Name = "Incr. Iterations" };
    100102      var layerAnalyzerProcessor = new UniformSubScopesProcessor();
     
    116118      variableCreator.Successor = randomScopeProcessor;
    117119
    118       randomScopeProcessor.Operator = isLayerZeroComperator;
     120      randomScopeProcessor.Operator = layerPopulationSizeCounter;
     121      randomScopeProcessor.Successor = incrIterations;
     122
     123      layerPopulationSizeCounter.ValueParameter.ActualName = "LayerPopulationSize";
     124      layerPopulationSizeCounter.AccumulateParameter.Value =  new BoolValue(false);
     125      layerPopulationSizeCounter.Successor = isLayerZeroComperator;
    119126
    120127      isLayerZeroComperator.LeftSideParameter.ActualName = "Layer";
     
    164171      selectRandomTargetIndex.LeftSideParameter.ActualName = "TargetIndex";
    165172      selectRandomTargetIndex.MinimumParameter.Value = new IntValue(0);
    166       selectRandomTargetIndex.MaximumParameter.ActualName = "PopulationSize";
     173      selectRandomTargetIndex.MaximumParameter.ActualName = "LayerPopulationSize";
    167174      selectRandomTargetIndex.MaximumParameter.Value = null;
    168175      selectRandomTargetIndex.Successor = copyLayer;
     
    178185
    179186      matingPoolSize.ValueParameter.ActualName = "MatingPoolSize";
     187      matingPoolSize.AccumulateParameter.Value = new BoolValue(false);
    180188      matingPoolSize.Successor = matingPoolSizeMin2;
    181189
     
    206214      tryMoveUp.Successor = removeWorkingScope;
    207215
    208       removeWorkingScope.Successor = incrIterations;
     216      removeWorkingScope.Successor = incrementEvaluations;
     217
     218      incrementEvaluations.Increment = new IntValue(1);
     219      incrementEvaluations.ValueParameter.ActualName = "EvaluatedSolutions";
    209220
    210221      incrIterations.ValueParameter.ActualName = "Iterations";
  • branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/AlpsSsGeneticAlgorithmMainOperator.cs

    r12138 r12150  
    5050      var subScopesRemover = new SubScopesRemover();
    5151      var evaluator = new Placeholder() { Name = "Evaluator (Placeholder)" };
    52       var incrementEvaluations = new IntCounter() { Name = "incr. EvaluatedSolutions" };
     52     
    5353
    5454      OperatorGraph.InitialOperator = selector;
     
    8080
    8181      evaluator.OperatorParameter.ActualName = "Evaluator";
    82       evaluator.Successor = incrementEvaluations;
    83 
    84       incrementEvaluations.Increment = new IntValue(1);
    85       incrementEvaluations.ValueParameter.ActualName = "EvaluatedSolutions";
    8682    }
    8783  }
  • branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/AlpsSsMover.cs

    r12142 r12150  
    7777
    7878      if (i < n) {
    79         TryMoveUp(gs, newIndividual, i, j, n, m, random);
     79        TryMoveUp(gs, newIndividual, layer, i, j, n, m, random);
    8080        layer.SubScopes[j] = newIndividual;
    8181        newIndividual.Name = j.ToString();
     
    8585    }
    8686
    87     private void TryMoveUp(IScope gs, IScope individual, int i, int j, int n, int m, IRandom random) {
     87    private void TryMoveUp(IScope gs, IScope individual, IScope layer, int i, int j, int n, int m, IRandom random) {
    8888      if (i < n) {
    8989        if (gs.SubScopes.Count <= i + 1) {
    9090          var newLayer = new Scope((i + 1).ToString());
    9191          newLayer.Variables.Add(new Variable("Layer", new IntValue(i + 1)));
     92          newLayer.Variables.Add(new Variable("LayerPopulationSize", new IntValue(1)));
    9293          gs.SubScopes.Add(newLayer);
    9394        }
     
    9697        var replaceIndex = FindReplaceable(higherLayer, individual, random, m);
    9798        if (replaceIndex.HasValue) {
    98           TryMoveUp(gs, higherLayer.SubScopes[j], i + 1, replaceIndex.Value, n, m, random); // TODO higherlayer[j] does not exist
    99           if (replaceIndex.Value >= higherLayer.SubScopes.Count)
    100             higherLayer.SubScopes.Add(individual);
    101           else
    102             higherLayer.SubScopes[replaceIndex.Value] = individual;
     99          var replacedIndividual = layer.SubScopes[j];
     100          if (replaceIndex.Value >= higherLayer.SubScopes.Count) {
     101            higherLayer.SubScopes.Add(replacedIndividual);
     102          } else {
     103            TryMoveUp(gs, higherLayer.SubScopes[j], higherLayer, i + 1, replaceIndex.Value, n, m, random);
     104            // TODO higherlayer[j] does not exist
     105            higherLayer.SubScopes[replaceIndex.Value] = replacedIndividual;
     106          }
    103107        }
    104108      }
Note: See TracChangeset for help on using the changeset viewer.