Changeset 7478 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/GRASPWithPathRelinking.cs
- Timestamp:
- 02/16/12 16:00:07 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Algorithms/3.3/GRASPWithPathRelinking.cs
r7438 r7478 27 27 using HeuristicLab.Data; 28 28 using HeuristicLab.Optimization; 29 using HeuristicLab.Optimization.Operators; 29 30 using HeuristicLab.Parameters; 30 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 79 80 get { return (ConstrainedValueParameter<ICrossover>)Parameters["PathRelinking"]; } 80 81 } 81 public ConstrainedValueParameter<I Merger> EliteSetMergerParameter {82 get { return (ConstrainedValueParameter<I Merger>)Parameters["EliteSetMerger"]; }82 public ConstrainedValueParameter<IPopulationReducer> EliteSetReducerParameter { 83 get { return (ConstrainedValueParameter<IPopulationReducer>)Parameters["EliteSetReducer"]; } 83 84 } 84 85 #endregion … … 109 110 get { return (RandomCreator)OperatorGraph.InitialOperator; } 110 111 } 112 private SolutionsCreator SolutionsCreator { 113 get { return (SolutionsCreator)RandomCreator.Successor; } 114 } 111 115 private GRASPWithPathRelinkingMainLoop MainLoop { 112 get { return RandomCreator.Successor as GRASPWithPathRelinkingMainLoop; }116 get { return SolutionsCreator.Successor as GRASPWithPathRelinkingMainLoop; } 113 117 } 114 118 #endregion … … 135 139 Parameters.Add(new FixedValueParameter<IntValue>("MinimumEliteSetSize", "(ρ) The minimum amount of elites for performing path relinking.", new IntValue(2))); 136 140 Parameters.Add(new ConstrainedValueParameter<ICrossover>("PathRelinking", "The operator that performs the path relinking.")); 137 Parameters.Add(new ConstrainedValueParameter<I Merger>("EliteSetMerger", "The operator that merges new solutions into theelite set."));141 Parameters.Add(new ConstrainedValueParameter<IPopulationReducer>("EliteSetReducer", "The operator that reduces the old elite set and the new solution(s) to a new elite set.")); 138 142 139 143 analyzer = new BestAverageWorstQualityAnalyzer(); 140 144 Analyzer.Operators.Add(analyzer); 141 145 142 RandomCreator randomCreator = new RandomCreator();146 var randomCreator = new RandomCreator(); 143 147 OperatorGraph.InitialOperator = randomCreator; 144 148 … … 149 153 randomCreator.SetSeedRandomlyParameter.Value = null; 150 154 155 var solutionsCreator = new SolutionsCreator(); 156 solutionsCreator.NumberOfSolutionsParameter.ActualName = MinimumEliteSetSizeParameter.Name; 157 solutionsCreator.ParallelParameter.Value = new BoolValue(true); 158 randomCreator.Successor = solutionsCreator; 159 151 160 var mainLoop = new GRASPWithPathRelinkingMainLoop(); 152 161 mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; 153 mainLoop.EliteSet MergerParameter.ActualName = EliteSetMergerParameter.Name;162 mainLoop.EliteSetReducerParameter.ActualName = EliteSetReducerParameter.Name; 154 163 mainLoop.EliteSetSizeParameter.ActualName = EliteSetSizeParameter.Name; 155 164 mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions"; … … 158 167 mainLoop.PathRelinkingParameter.ActualName = PathRelinkingParameter.Name; 159 168 mainLoop.ResultsParameter.ActualName = "Results"; 160 randomCreator.Successor = mainLoop;169 solutionsCreator.Successor = mainLoop; 161 170 162 171 InitializeOperators(); … … 219 228 InitializeFromInstallation(LocalImprovementParameter, x => x.ProblemType.IsAssignableFrom(Problem.GetType())); 220 229 InitializeFromProblem(PathRelinkingParameter); 221 InitializeFromProblem(EliteSet MergerParameter);230 InitializeFromProblem(EliteSetReducerParameter); 222 231 } else { 223 232 LocalImprovementParameter.ValidValues.Clear(); 224 233 PathRelinkingParameter.ValidValues.Clear(); 225 EliteSet MergerParameter.ValidValues.Clear();234 EliteSetReducerParameter.ValidValues.Clear(); 226 235 } 227 236 Analyzer.Operators.Add(analyzer); … … 232 241 private void Parameterize() { 233 242 if (Problem != null) { 243 SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; 244 SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name; 245 234 246 MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name; 235 247 MainLoop.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name; … … 245 257 localImprovement.ResultsParameter.ActualName = "Results"; 246 258 } 247 foreach (var merger in EliteSetMergerParameter.ValidValues) { 248 merger.PopulationSizeParameter.ActualName = EliteSetSizeParameter.Name; 259 foreach (var reducer in EliteSetReducerParameter.ValidValues) { 260 reducer.MinimumPopulationSizeParameter.ActualName = MinimumEliteSetSizeParameter.Name; 261 reducer.MaximumPopulationSizeParameter.ActualName = EliteSetSizeParameter.Name; 249 262 } 250 263 }
Note: See TracChangeset
for help on using the changeset viewer.