Changeset 8086 for branches/ScatterSearch (trunk integration)/HeuristicLab.Algorithms.SimulatedAnnealing
- Timestamp:
- 06/22/12 11:11:38 (12 years ago)
- Location:
- branches/ScatterSearch (trunk integration)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ScatterSearch (trunk integration)
- Property svn:ignore
-
old new 20 20 bin 21 21 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/ScatterSearch (trunk integration)/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealing.cs
r7517 r8086 144 144 [Storable] 145 145 private QualityAnalyzer qualityAnalyzer; 146 [Storable] 147 private SingleValueAnalyzer temperatureAnalyzer; 146 148 #endregion 147 149 … … 150 152 [StorableHook(HookType.AfterDeserialization)] 151 153 private void AfterDeserialization() { 154 if (temperatureAnalyzer == null) { 155 temperatureAnalyzer = new SingleValueAnalyzer(); 156 temperatureAnalyzer.Name = "TemperatureAnalyzer"; 157 temperatureAnalyzer.ResultsParameter.ActualName = "Results"; 158 temperatureAnalyzer.ValueParameter.ActualName = "Temperature"; 159 temperatureAnalyzer.ValuesParameter.ActualName = "Temperature Chart"; 160 Analyzer.Operators.Add(temperatureAnalyzer); 161 } 152 162 Initialize(); 153 163 } … … 155 165 : base(original, cloner) { 156 166 qualityAnalyzer = cloner.Clone(original.qualityAnalyzer); 167 temperatureAnalyzer = cloner.Clone(original.temperatureAnalyzer); 157 168 Initialize(); 158 169 } … … 205 216 mainLoop.AnnealingOperatorParameter.ActualName = AnnealingOperatorParameter.Name; 206 217 mainLoop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name; 218 mainLoop.TemperatureParameter.ActualName = "Temperature"; 207 219 mainLoop.StartTemperatureParameter.ActualName = StartTemperatureParameter.Name; 208 220 mainLoop.EndTemperatureParameter.ActualName = EndTemperatureParameter.Name; … … 218 230 219 231 qualityAnalyzer = new QualityAnalyzer(); 232 temperatureAnalyzer = new SingleValueAnalyzer(); 233 temperatureAnalyzer.Name = "TemperatureAnalyzer"; 220 234 ParameterizeAnalyzers(); 221 235 UpdateAnalyzers(); … … 233 247 ParameterizeStochasticOperator(Problem.SolutionCreator); 234 248 ParameterizeStochasticOperator(Problem.Evaluator); 235 foreach (IOperator op in Problem.Operators ) ParameterizeStochasticOperator(op);249 foreach (IOperator op in Problem.Operators.OfType<IOperator>()) ParameterizeStochasticOperator(op); 236 250 foreach (ISingleObjectiveMoveEvaluator op in Problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) { 237 251 op.MoveQualityParameter.ActualNameChanged += new EventHandler(MoveEvaluator_MoveQualityParameter_ActualNameChanged); … … 266 280 } 267 281 protected override void Problem_OperatorsChanged(object sender, EventArgs e) { 268 foreach (IOperator op in Problem.Operators ) ParameterizeStochasticOperator(op);282 foreach (IOperator op in Problem.Operators.OfType<IOperator>()) ParameterizeStochasticOperator(op); 269 283 // This may seem pointless, but some operators already have the eventhandler registered, others don't 270 284 // FIXME: Is there another way to solve this problem? … … 348 362 qualityAnalyzer.QualityParameter.Hidden = false; 349 363 qualityAnalyzer.BestKnownQualityParameter.Hidden = false; 364 temperatureAnalyzer.ResultsParameter.ActualName = "Results"; 365 temperatureAnalyzer.ValueParameter.ActualName = "Temperature"; 366 temperatureAnalyzer.ValuesParameter.ActualName = "Temperature Chart"; 350 367 } 351 368 } … … 470 487 } 471 488 Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault); 489 Analyzer.Operators.Add(temperatureAnalyzer, temperatureAnalyzer.EnabledByDefault); 472 490 } 473 491 private SimulatedAnnealingMainLoop FindMainLoop(IOperator start) { -
branches/ScatterSearch (trunk integration)/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingImprovementOperator.cs
r7259 r8086 316 316 if (MoveGenerator != null) { 317 317 IMoveGenerator generator = MoveGeneratorParameter.Value; 318 foreach (IMoveMaker moveMaker in MoveHelper.GetCompatibleMoveMakers(generator, Problem.Operators ).OrderBy(x => x.Name))318 foreach (IMoveMaker moveMaker in MoveHelper.GetCompatibleMoveMakers(generator, Problem.Operators.OfType<IOperator>()).OrderBy(x => x.Name)) 319 319 MoveMakerParameter.ValidValues.Add(moveMaker); 320 foreach (ISingleObjectiveMoveEvaluator moveEvaluator in MoveHelper.GetCompatibleSingleObjectiveMoveEvaluators(generator, Problem.Operators ).OrderBy(x => x.Name))320 foreach (ISingleObjectiveMoveEvaluator moveEvaluator in MoveHelper.GetCompatibleSingleObjectiveMoveEvaluators(generator, Problem.Operators.OfType<IOperator>()).OrderBy(x => x.Name)) 321 321 MoveEvaluatorParameter.ValidValues.Add(moveEvaluator); 322 322 -
branches/ScatterSearch (trunk integration)/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingMainLoop.cs
r7259 r8086 51 51 get { return (LookupParameter<DoubleValue>)Parameters["MoveQuality"]; } 52 52 } 53 public ILookupParameter<DoubleValue> TemperatureParameter { 54 get { return (ILookupParameter<DoubleValue>)Parameters["Temperature"]; } 55 } 53 56 public ValueLookupParameter<DoubleValue> StartTemperatureParameter { 54 57 get { return (ValueLookupParameter<DoubleValue>)Parameters["StartTemperature"]; } … … 109 112 Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far.")); 110 113 Parameters.Add(new LookupParameter<DoubleValue>("MoveQuality", "The value which represents the quality of a move.")); 114 Parameters.Add(new LookupParameter<DoubleValue>("Temperature", "The current temperature.")); 111 115 Parameters.Add(new ValueLookupParameter<DoubleValue>("StartTemperature", "The initial temperature.")); 112 116 Parameters.Add(new ValueLookupParameter<DoubleValue>("EndTemperature", "The end temperature.")); … … 126 130 127 131 #region Create operators 128 VariableCreator variableCreator = new VariableCreator();132 Assigner temperatureInitializer = new Assigner(); 129 133 ResultsCollector resultsCollector1 = new ResultsCollector(); 130 134 SubScopesProcessor subScopesProcessor0 = new SubScopesProcessor(); … … 148 152 ConditionalBranch iterationsTermination = new ConditionalBranch(); 149 153 150 variableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("Temperature", new DoubleValue(double.MaxValue))); 154 temperatureInitializer.LeftSideParameter.ActualName = TemperatureParameter.ActualName; 155 temperatureInitializer.RightSideParameter.ActualName = StartTemperatureParameter.Name; 151 156 152 157 resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>(IterationsParameter.Name)); 153 resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Temperature"));154 158 resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name; 155 159 … … 199 203 200 204 #region Create operator graph 201 OperatorGraph.InitialOperator = variableCreator;202 variableCreator.Successor = resultsCollector1;205 OperatorGraph.InitialOperator = temperatureInitializer; 206 temperatureInitializer.Successor = resultsCollector1; 203 207 resultsCollector1.Successor = subScopesProcessor0; 204 208 subScopesProcessor0.Operators.Add(analyzer1); … … 237 241 if (!Parameters.ContainsKey("Iterations")) 238 242 Parameters.Add(new LookupParameter<IntValue>("Iterations", "The number of iterations.")); 243 if (!Parameters.ContainsKey("Temperature")) 244 Parameters.Add(new LookupParameter<DoubleValue>("Temperature", "The current temperature.")); 239 245 #endregion 240 246 }
Note: See TracChangeset
for help on using the changeset viewer.