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.GeneticAlgorithm/3.3
Files:
2 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  }
Note: See TracChangeset for help on using the changeset viewer.