- Timestamp:
- 03/19/10 19:35:45 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearch.cs
r3131 r3134 155 155 } 156 156 ParameterizeSolutionsCreator(); 157 Parameterize LSMainLoop();157 ParameterizeMainLoop(); 158 158 ParameterizeMoveEvaluator(); 159 159 ParameterizeMoveMaker(); … … 170 170 ParameterizeStochasticOperator(Problem.Evaluator); 171 171 ParameterizeSolutionsCreator(); 172 Parameterize LSMainLoop();172 ParameterizeMainLoop(); 173 173 ParameterizeMoveEvaluator(); 174 174 ParameterizeMoveMaker(); 175 175 Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged); 176 176 base.Problem_EvaluatorChanged(sender, e); 177 } 178 protected override void Problem_VisualizerChanged(object sender, EventArgs e) { 179 ParameterizeStochasticOperator(Problem.Visualizer); 180 ParameterizeMainLoop(); 181 base.Problem_VisualizerChanged(sender, e); 177 182 } 178 183 protected override void Problem_OperatorsChanged(object sender, EventArgs e) { … … 188 193 if (oldMoveGenerator == MoveGenerator) // in this case MoveGeneratorParameter_ValueChanged did not fire 189 194 UpdateMoveParameters(); 190 Parameterize LSMainLoop();195 ParameterizeMainLoop(); 191 196 ParameterizeMoveEvaluator(); 192 197 ParameterizeMoveMaker(); … … 194 199 } 195 200 private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) { 196 Parameterize LSMainLoop();201 ParameterizeMainLoop(); 197 202 ParameterizeMoveEvaluator(); 198 203 ParameterizeMoveMaker(); … … 202 207 } 203 208 private void MoveEvaluatorParameter_ValueChanged(object sender, EventArgs e) { 204 Parameterize LSMainLoop();209 ParameterizeMainLoop(); 205 210 ParameterizeMoveEvaluator(); 206 211 ParameterizeMoveMaker(); 207 212 } 208 213 private void MoveEvaluator_MoveQualityParameter_ActualNameChanged(object sender, EventArgs e) { 209 Parameterize LSMainLoop();214 ParameterizeMainLoop(); 210 215 ParameterizeMoveEvaluator(); 211 216 ParameterizeMoveMaker(); … … 273 278 SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name; 274 279 } 275 private void Parameterize LSMainLoop() {280 private void ParameterizeMainLoop() { 276 281 MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name; 277 282 MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName; 278 283 if (MoveEvaluator != null) 279 284 MainLoop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName; 285 MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name; 286 MainLoop.VisualizerParameter.ActualName = Problem.VisualizerParameter.Name; 287 MainLoop.VisualizationParameter.ActualName = Problem.Visualizer.VisualizationParameter.ActualName; 280 288 } 281 289 private void ParameterizeStochasticOperator(IOperator op) { -
trunk/sources/HeuristicLab.Algorithms.LocalSearch/3.3/LocalSearchMainLoop.cs
r3103 r3134 46 46 get { return (LookupParameter<DoubleValue>)Parameters["Quality"]; } 47 47 } 48 public ValueLookupParameter<DoubleValue> BestKnownQualityParameter { 49 get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; } 50 } 48 51 public LookupParameter<DoubleValue> MoveQualityParameter { 49 52 get { return (LookupParameter<DoubleValue>)Parameters["MoveQuality"]; } … … 63 66 public ValueLookupParameter<IOperator> MoveMakerParameter { 64 67 get { return (ValueLookupParameter<IOperator>)Parameters["MoveMaker"]; } 68 } 69 public ValueLookupParameter<IOperator> VisualizerParameter { 70 get { return (ValueLookupParameter<IOperator>)Parameters["Visualizer"]; } 71 } 72 public LookupParameter<IItem> VisualizationParameter { 73 get { return (LookupParameter<IItem>)Parameters["Visualization"]; } 65 74 } 66 75 … … 79 88 Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false.")); 80 89 Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution.")); 90 Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far.")); 81 91 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The value which represents the quality of a move.")); 82 92 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.")); … … 86 96 Parameters.Add(new ValueLookupParameter<IOperator>("MoveMaker", "The operator that performs a move and updates the quality.")); 87 97 Parameters.Add(new ValueLookupParameter<IOperator>("MoveEvaluator", "The operator that evaluates a move.")); 88 98 99 Parameters.Add(new ValueLookupParameter<IOperator>("Visualizer", "The operator used to visualize solutions.")); 100 Parameters.Add(new LookupParameter<IItem>("Visualization", "The item which represents the visualization of solutions.")); 89 101 Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the TS should be applied.")); 90 102 #endregion … … 92 104 #region Create operators 93 105 VariableCreator variableCreator = new VariableCreator(); 106 BestQualityMemorizer bestQualityMemorizer1 = new BestQualityMemorizer(); 107 BestQualityMemorizer bestQualityMemorizer2 = new BestQualityMemorizer(); 108 DataTableValuesCollector dataTableValuesCollector1 = new DataTableValuesCollector(); 109 QualityDifferenceCalculator qualityDifferenceCalculator1 = new QualityDifferenceCalculator(); 110 Placeholder visualizer1 = new Placeholder(); 94 111 ResultsCollector resultsCollector = new ResultsCollector(); 95 112 UniformSequentialSubScopesProcessor mainProcessor = new UniformSequentialSubScopesProcessor(); … … 104 121 Placeholder moveMaker = new Placeholder(); 105 122 SubScopesRemover subScopesRemover = new SubScopesRemover(); 106 DataTableValuesCollector valuesCollector = new DataTableValuesCollector();107 123 IntCounter iterationsCounter = new IntCounter(); 108 124 Comparator iterationsComparator = new Comparator(); 125 BestQualityMemorizer bestQualityMemorizer3 = new BestQualityMemorizer(); 126 BestQualityMemorizer bestQualityMemorizer4 = new BestQualityMemorizer(); 127 DataTableValuesCollector dataTableValuesCollector2 = new DataTableValuesCollector(); 128 QualityDifferenceCalculator qualityDifferenceCalculator2 = new QualityDifferenceCalculator(); 129 Placeholder visualizer2 = new Placeholder(); 109 130 ConditionalBranch iterationsTermination = new ConditionalBranch(); 110 EmptyOperator finished = new EmptyOperator();111 131 112 132 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Iterations", new IntValue(0))); 113 variableCreator.CollectedValues.Add(new ValueParameter<DataTable>("Qualities", new DataTable("Qualities"))); 133 134 bestQualityMemorizer1.BestQualityParameter.ActualName = BestKnownQualityParameter.Name; 135 bestQualityMemorizer1.MaximizationParameter.ActualName = MaximizationParameter.Name; 136 bestQualityMemorizer1.QualityParameter.ActualName = QualityParameter.Name; 137 138 bestQualityMemorizer2.BestQualityParameter.ActualName = "BestQuality"; 139 bestQualityMemorizer2.MaximizationParameter.ActualName = MaximizationParameter.Name; 140 bestQualityMemorizer2.QualityParameter.ActualName = QualityParameter.Name; 141 142 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("BestQuality")); 143 dataTableValuesCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name)); 144 dataTableValuesCollector1.DataTableParameter.ActualName = "Qualities"; 145 146 qualityDifferenceCalculator1.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest"; 147 qualityDifferenceCalculator1.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name; 148 qualityDifferenceCalculator1.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest"; 149 qualityDifferenceCalculator1.SecondQualityParameter.ActualName = "BestQuality"; 150 151 visualizer1.Name = "Visualizer (placeholder)"; 152 visualizer1.OperatorParameter.ActualName = VisualizerParameter.Name; 153 154 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iterations")); 155 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Quality", null, "BestQuality")); 156 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name)); 157 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Absolute Difference of Best Known Quality to Best Quality", null, "AbsoluteDifferenceBestKnownToBest")); 158 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Relative Difference of Best Known Quality to Best Quality", null, "RelativeDifferenceBestKnownToBest")); 159 resultsCollector.CollectedValues.Add(new LookupParameter<IItem>("Solution Visualization", null, VisualizationParameter.Name)); 160 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities")); 161 resultsCollector.ResultsParameter.ActualName = ResultsParameter.Name; 114 162 115 163 mainProcessor.Name = "Solution processor (UniformSequentialSubScopesProcessor)"; 116 117 resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Iterations"));118 resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Quality"));119 resultsCollector.CollectedValues.Add(new LookupParameter<DataTable>("Qualities"));120 resultsCollector.ResultsParameter.ActualName = "Results";121 164 122 165 moveGenerator.Name = "MoveGenerator (placeholder)"; … … 143 186 144 187 subScopesRemover.RemoveAllSubScopes = true; 145 146 valuesCollector.CollectedValues.Add(new LookupParameter<DoubleValue>("Quality"));147 valuesCollector.DataTableParameter.ActualName = "Qualities";148 188 149 189 iterationsCounter.Name = "Iterations Counter"; … … 157 197 iterationsComparator.ResultParameter.ActualName = "IterationsCondition"; 158 198 199 bestQualityMemorizer3.BestQualityParameter.ActualName = BestKnownQualityParameter.Name; 200 bestQualityMemorizer3.MaximizationParameter.ActualName = MaximizationParameter.Name; 201 bestQualityMemorizer3.QualityParameter.ActualName = QualityParameter.Name; 202 203 bestQualityMemorizer4.BestQualityParameter.ActualName = "BestQuality"; 204 bestQualityMemorizer4.MaximizationParameter.ActualName = MaximizationParameter.Name; 205 bestQualityMemorizer4.QualityParameter.ActualName = QualityParameter.Name; 206 207 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("BestQuality")); 208 dataTableValuesCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Best Known Quality", null, BestKnownQualityParameter.Name)); 209 dataTableValuesCollector2.DataTableParameter.ActualName = "Qualities"; 210 211 qualityDifferenceCalculator2.AbsoluteDifferenceParameter.ActualName = "AbsoluteDifferenceBestKnownToBest"; 212 qualityDifferenceCalculator2.FirstQualityParameter.ActualName = BestKnownQualityParameter.Name; 213 qualityDifferenceCalculator2.RelativeDifferenceParameter.ActualName = "RelativeDifferenceBestKnownToBest"; 214 qualityDifferenceCalculator2.SecondQualityParameter.ActualName = "BestQuality"; 215 216 visualizer2.Name = "Visualizer (placeholder)"; 217 visualizer2.OperatorParameter.ActualName = VisualizerParameter.Name; 218 159 219 iterationsTermination.Name = "Iterations Termination Condition"; 160 220 iterationsTermination.ConditionParameter.ActualName = "IterationsCondition"; … … 163 223 #region Create operator graph 164 224 OperatorGraph.InitialOperator = variableCreator; 165 variableCreator.Successor = mainProcessor; 166 mainProcessor.Operator = resultsCollector; 225 variableCreator.Successor = bestQualityMemorizer1; 226 bestQualityMemorizer1.Successor = bestQualityMemorizer2; 227 bestQualityMemorizer2.Successor = dataTableValuesCollector1; 228 dataTableValuesCollector1.Successor = qualityDifferenceCalculator1; 229 qualityDifferenceCalculator1.Successor = visualizer1; 230 visualizer1.Successor = resultsCollector; 231 resultsCollector.Successor = mainProcessor; 232 mainProcessor.Operator = moveGenerator; 167 233 mainProcessor.Successor = iterationsCounter; 168 resultsCollector.Successor = moveGenerator;169 234 moveGenerator.Successor = moveEvaluationProcessor; 170 235 moveEvaluationProcessor.Operator = moveEvaluator; … … 174 239 moveMakingProcessor.Operator = qualityComparator; 175 240 moveMakingProcessor.Successor = subScopesRemover; 176 subScopesRemover.Successor = valuesCollector;241 subScopesRemover.Successor = null; 177 242 qualityComparator.Successor = improvesQualityBranch; 178 243 improvesQualityBranch.TrueBranch = moveMaker; 244 improvesQualityBranch.FalseBranch = null; 245 improvesQualityBranch.Successor = null; 246 moveMaker.Successor = null; 179 247 iterationsCounter.Successor = iterationsComparator; 180 iterationsComparator.Successor = iterationsTermination; 248 iterationsComparator.Successor = bestQualityMemorizer3; 249 bestQualityMemorizer3.Successor = bestQualityMemorizer4; 250 bestQualityMemorizer4.Successor = dataTableValuesCollector2; 251 dataTableValuesCollector2.Successor = qualityDifferenceCalculator2; 252 qualityDifferenceCalculator2.Successor = visualizer2; 253 visualizer2.Successor = iterationsTermination; 181 254 iterationsTermination.TrueBranch = mainProcessor; 182 iterationsTermination.FalseBranch = finished;255 iterationsTermination.FalseBranch = null; 183 256 #endregion 184 257 }
Note: See TracChangeset
for help on using the changeset viewer.