Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/24/11 17:38:42 (14 years ago)
Author:
abeham
Message:

#1344

  • Fixed discovery of the main loop operator in the MainLoop property
Location:
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3
Files:
3 edited

Legend:

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

    r5356 r5366  
    239239    }
    240240    private IslandOffspringSelectionGeneticAlgorithmMainLoop MainLoop {
    241       get {
    242         return (IslandOffspringSelectionGeneticAlgorithmMainLoop)(
    243           (ResultsCollector)(
    244             (UniformSubScopesProcessor)(
    245               (VariableCreator)IslandProcessor.Successor
    246             ).Successor
    247           ).Successor
    248         ).Successor;
    249       }
     241      get { return FindMainLoop(IslandProcessor.Successor); }
    250242    }
    251243    [Storable]
     
    625617      Analyzer.Operators.Add(selectionPressureAnalyzer);
    626618    }
     619    private IslandOffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) {
     620      IOperator mainLoop = start;
     621      while (mainLoop != null && !(mainLoop is IslandOffspringSelectionGeneticAlgorithmMainLoop))
     622        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
     623      if (mainLoop == null) return null;
     624      else return (IslandOffspringSelectionGeneticAlgorithmMainLoop)mainLoop;
     625    }
    627626    #endregion
    628627  }
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.cs

    r5356 r5366  
    191191    }
    192192    private OffspringSelectionGeneticAlgorithmMainLoop MainLoop {
    193       get {
    194         return (OffspringSelectionGeneticAlgorithmMainLoop)(
    195           (ResultsCollector)(
    196             (SubScopesCounter)SolutionsCreator.Successor
    197           ).Successor
    198         ).Successor;
    199       }
     193      get { return FindMainLoop(SolutionsCreator.Successor); }
    200194    }
    201195    [Storable]
     
    469463      Analyzer.Operators.Add(selectionPressureAnalyzer);
    470464    }
     465    private OffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) {
     466      IOperator mainLoop = start;
     467      while (mainLoop != null && !(mainLoop is OffspringSelectionGeneticAlgorithmMainLoop))
     468        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
     469      if (mainLoop == null) return null;
     470      else return (OffspringSelectionGeneticAlgorithmMainLoop)mainLoop;
     471    }
    471472    #endregion
    472473  }
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASA.cs

    r5356 r5366  
    215215    }
    216216    private SASEGASAMainLoop MainLoop {
    217       get {
    218         return (SASEGASAMainLoop)(
    219           (ResultsCollector)(
    220             (UniformSubScopesProcessor)(
    221               (VariableCreator)VillageProcessor.Successor
    222             ).Successor
    223           ).Successor
    224         ).Successor;
    225       }
     217      get { return FindMainLoop(VillageProcessor.Successor); }
    226218    }
    227219    [Storable]
     
    563555      Analyzer.Operators.Add(selectionPressureAnalyzer);
    564556    }
     557    private SASEGASAMainLoop FindMainLoop(IOperator start) {
     558      IOperator mainLoop = start;
     559      while (mainLoop != null && !(mainLoop is SASEGASAMainLoop))
     560        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
     561      if (mainLoop == null) return null;
     562      else return (SASEGASAMainLoop)mainLoop;
     563    }
    565564    #endregion
    566565  }
Note: See TracChangeset for help on using the changeset viewer.