Changeset 5356 for trunk/sources/HeuristicLab.Algorithms.NSGA2
- Timestamp:
- 01/22/11 15:18:20 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs
r5143 r5356 26 26 using HeuristicLab.Core; 27 27 using HeuristicLab.Data; 28 using HeuristicLab.Operators; 28 29 using HeuristicLab.Optimization; 29 30 using HeuristicLab.Optimization.Operators; … … 139 140 } 140 141 private RankAndCrowdingSorter RankAndCrowdingSorter { 141 get { return (RankAndCrowdingSorter) SolutionsCreator.Successor; }142 get { return (RankAndCrowdingSorter)((SubScopesCounter)SolutionsCreator.Successor).Successor; } 142 143 } 143 144 private NSGA2MainLoop MainLoop { 144 get { return (NSGA2MainLoop)RankAndCrowdingSorter.Successor; } 145 get { 146 return (NSGA2MainLoop)( 147 (ResultsCollector)RankAndCrowdingSorter.Successor 148 ).Successor; 149 } 145 150 } 146 151 #endregion … … 151 156 [StorableConstructor] 152 157 protected NSGA2(bool deserializing) : base(deserializing) { } 153 protected NSGA2(NSGA2 original, Cloner cloner) : base (original, cloner) { 158 protected NSGA2(NSGA2 original, Cloner cloner) 159 : base(original, cloner) { 154 160 paretoFrontAnalyzer = (RankBasedParetoFrontAnalyzer)cloner.Clone(original.paretoFrontAnalyzer); 155 161 AttachEventHandlers(); … … 170 176 RandomCreator randomCreator = new RandomCreator(); 171 177 SolutionsCreator solutionsCreator = new SolutionsCreator(); 178 SubScopesCounter subScopesCounter = new SubScopesCounter(); 172 179 RankAndCrowdingSorter rankAndCrowdingSorter = new RankAndCrowdingSorter(); 180 ResultsCollector resultsCollector = new ResultsCollector(); 173 181 NSGA2MainLoop mainLoop = new NSGA2MainLoop(); 174 182 175 183 OperatorGraph.InitialOperator = randomCreator; 176 184 … … 183 191 184 192 solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name; 185 solutionsCreator.Successor = rankAndCrowdingSorter; 193 solutionsCreator.Successor = subScopesCounter; 194 195 subScopesCounter.Name = "Initialize EvaluatedSolutions"; 196 subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions"; 197 subScopesCounter.Successor = rankAndCrowdingSorter; 186 198 187 199 rankAndCrowdingSorter.CrowdingDistanceParameter.ActualName = "CrowdingDistance"; 188 200 rankAndCrowdingSorter.RankParameter.ActualName = "Rank"; 189 rankAndCrowdingSorter.Successor = mainLoop; 201 rankAndCrowdingSorter.Successor = resultsCollector; 202 203 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions")); 204 resultsCollector.ResultsParameter.ActualName = "Results"; 205 resultsCollector.Successor = mainLoop; 190 206 191 207 mainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name; … … 199 215 mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; 200 216 mainLoop.ResultsParameter.ActualName = "Results"; 217 mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions"; 201 218 202 219 foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is ISingleObjectiveSelector)).OrderBy(x => x.Name)) … … 218 235 219 236 public override IDeepCloneable Clone(Cloner cloner) { 220 return new NSGA2(this, cloner); 237 return new NSGA2(this, cloner); 221 238 } 222 239 -
trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2MainLoop.cs
r5208 r5356 75 75 public ValueLookupParameter<IOperator> AnalyzerParameter { 76 76 get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; } 77 } 78 public LookupParameter<IntValue> EvaluatedSolutionsParameter { 79 get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; } 77 80 } 78 81 #endregion … … 101 104 Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored.")); 102 105 Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation.")); 106 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated.")); 103 107 #endregion 104 108 … … 119 123 UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor(); 120 124 Placeholder evaluator = new Placeholder(); 125 SubScopesCounter subScopesCounter = new SubScopesCounter(); 121 126 MergingReducer mergingReducer = new MergingReducer(); 122 127 RankAndCrowdingSorter rankAndCrowdingSorter = new RankAndCrowdingSorter(); … … 125 130 IntCounter intCounter = new IntCounter(); 126 131 Comparator comparator = new Comparator(); 127 ResultsCollector resultsCollector2 = new ResultsCollector();128 132 Placeholder analyzer2 = new Placeholder(); 129 133 ConditionalBranch conditionalBranch = new ConditionalBranch(); … … 163 167 evaluator.Name = "Evaluator"; 164 168 evaluator.OperatorParameter.ActualName = EvaluatorParameter.Name; 169 170 subScopesCounter.Name = "Increment EvaluatedSolutions"; 171 subScopesCounter.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name; 165 172 166 173 rankAndCrowdingSorter.CrowdingDistanceParameter.ActualName = "CrowdingDistance"; … … 177 184 comparator.ResultParameter.ActualName = "Terminate"; 178 185 comparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name; 179 180 resultsCollector2.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));181 resultsCollector2.ResultsParameter.ActualName = ResultsParameter.Name;182 186 183 187 analyzer2.Name = "Analyzer"; … … 210 214 subScopesRemover.Successor = null; 211 215 uniformSubScopesProcessor2.Operator = evaluator; 212 uniformSubScopesProcessor2.Successor = null;216 uniformSubScopesProcessor2.Successor = subScopesCounter; 213 217 evaluator.Successor = null; 218 subScopesCounter.Successor = null; 214 219 mergingReducer.Successor = rankAndCrowdingSorter; 215 220 rankAndCrowdingSorter.Successor = leftSelector; … … 217 222 rightReducer.Successor = intCounter; 218 223 intCounter.Successor = comparator; 219 comparator.Successor = resultsCollector2; 220 resultsCollector2.Successor = analyzer2; 224 comparator.Successor = analyzer2; 221 225 analyzer2.Successor = conditionalBranch; 222 226 conditionalBranch.FalseBranch = selector;
Note: See TracChangeset
for help on using the changeset viewer.