Free cookie consent management tool by TermsFeed Policy Generator

Changeset 5366


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
Files:
10 edited

Legend:

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

    r5356 r5366  
    135135    }
    136136    private GeneticAlgorithmMainLoop GeneticAlgorithmMainLoop {
    137       get {
    138         return (GeneticAlgorithmMainLoop)(
    139           (ResultsCollector)(
    140             (SubScopesCounter)SolutionsCreator.Successor
    141           ).Successor
    142         ).Successor;
    143       }
     137      get { return FindMainLoop(SolutionsCreator.Successor); }
    144138    }
    145139    [Storable]
     
    375369      Analyzer.Operators.Add(qualityAnalyzer);
    376370    }
     371    private GeneticAlgorithmMainLoop FindMainLoop(IOperator start) {
     372      IOperator mainLoop = start;
     373      while (mainLoop != null && !(mainLoop is GeneticAlgorithmMainLoop))
     374        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
     375      if (mainLoop == null) return null;
     376      else return (GeneticAlgorithmMainLoop)mainLoop;
     377    }
    377378    #endregion
    378379  }
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs

    r5356 r5366  
    187187    }
    188188    private IslandGeneticAlgorithmMainLoop MainLoop {
    189       get {
    190         return (IslandGeneticAlgorithmMainLoop)(
    191           (ResultsCollector)(
    192             (UniformSubScopesProcessor)(
    193               (VariableCreator)IslandProcessor.Successor
    194             ).Successor
    195           ).Successor
    196         ).Successor;
    197       }
     189      get { return FindMainLoop(IslandProcessor.Successor); }
    198190    }
    199191    [Storable]
     
    506498      Analyzer.Operators.Add(qualityAnalyzer);
    507499    }
     500    private IslandGeneticAlgorithmMainLoop FindMainLoop(IOperator start) {
     501      IOperator mainLoop = start;
     502      while (mainLoop != null && !(mainLoop is IslandGeneticAlgorithmMainLoop))
     503        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
     504      if (mainLoop == null) return null;
     505      else return (IslandGeneticAlgorithmMainLoop)mainLoop;
     506    }
    508507    #endregion
    509508  }
  • trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs

    r5356 r5366  
    118118    }
    119119    private LocalSearchMainLoop MainLoop {
    120       get {
    121         return (LocalSearchMainLoop)(
    122           (ResultsCollector)(
    123             (VariableCreator)SolutionsCreator.Successor
    124           ).Successor
    125         ).Successor;
    126       }
     120      get { return FindMainLoop(SolutionsCreator.Successor); }
    127121    }
    128122    [Storable]
     
    396390      }
    397391    }
     392    private LocalSearchMainLoop FindMainLoop(IOperator start) {
     393      IOperator mainLoop = start;
     394      while (mainLoop != null && !(mainLoop is LocalSearchMainLoop))
     395        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
     396      if (mainLoop == null) return null;
     397      else return (LocalSearchMainLoop)mainLoop;
     398    }
    398399    #endregion
    399400  }
  • trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs

    r5356 r5366  
    4242  [StorableClass]
    4343  public class NSGA2 : EngineAlgorithm, IStorableContent {
     44    public string Filename { get; set; }
     45
    4446    #region Problem Properties
    4547    public override Type ProblemType {
     
    143145    }
    144146    private NSGA2MainLoop MainLoop {
    145       get {
    146         return (NSGA2MainLoop)(
    147           (ResultsCollector)RankAndCrowdingSorter.Successor
    148         ).Successor;
    149       }
     147      get { return FindMainLoop(RankAndCrowdingSorter.Successor); }
    150148    }
    151149    #endregion
     
    392390      Analyzer.Operators.Add(paretoFrontAnalyzer);
    393391    }
     392    private NSGA2MainLoop FindMainLoop(IOperator start) {
     393      IOperator mainLoop = start;
     394      while (mainLoop != null && !(mainLoop is NSGA2MainLoop))
     395        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
     396      if (mainLoop == null) return null;
     397      else return (NSGA2MainLoop)mainLoop;
     398    }
    394399    #endregion
    395 
    396     public string Filename {
    397       get;
    398       set;
    399     }
    400400  }
    401401}
  • 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  }
  • trunk/sources/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealing.cs

    r5356 r5366  
    136136    }
    137137    private SimulatedAnnealingMainLoop MainLoop {
    138       get {
    139         return (SimulatedAnnealingMainLoop)(
    140           (ResultsCollector)(
    141             (VariableCreator)SolutionsCreator.Successor
    142           ).Successor
    143         ).Successor;
    144       }
     138      get { return FindMainLoop(SolutionsCreator.Successor); }
    145139    }
    146140    [Storable]
     
    432426      Analyzer.Operators.Add(qualityAnalyzer);
    433427    }
     428    private SimulatedAnnealingMainLoop FindMainLoop(IOperator start) {
     429      IOperator mainLoop = start;
     430      while (mainLoop != null && !(mainLoop is SimulatedAnnealingMainLoop))
     431        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
     432      if (mainLoop == null) return null;
     433      else return (SimulatedAnnealingMainLoop)mainLoop;
     434    }
    434435    #endregion
    435436  }
  • trunk/sources/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs

    r5356 r5366  
    135135    }
    136136    private TabuSearchMainLoop MainLoop {
    137       get {
    138         return (TabuSearchMainLoop)(
    139           (ResultsCollector)(
    140             (VariableCreator)SolutionsCreator.Successor
    141           ).Successor
    142         ).Successor;
    143       }
     137      get { return FindMainLoop(SolutionsCreator.Successor); }
    144138    }
    145139    [Storable]
     
    492486      }
    493487    }
     488    private TabuSearchMainLoop FindMainLoop(IOperator start) {
     489      IOperator mainLoop = start;
     490      while (mainLoop != null && !(mainLoop is TabuSearchMainLoop))
     491        mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
     492      if (mainLoop == null) return null;
     493      else return (TabuSearchMainLoop)mainLoop;
     494    }
    494495    #endregion
    495496  }
Note: See TracChangeset for help on using the changeset viewer.