- Timestamp:
- 04/23/11 10:00:31 (14 years ago)
- Location:
- branches/histogram
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/histogram
- Property svn:ignore
-
old new 10 10 protoc.exe 11 11 HeuristicLab 3.3.5.1.ReSharper.user 12 *.psess 13 *.vsp
-
- Property svn:mergeinfo changed
/trunk/sources merged: 6026,6029-6031,6035-6037,6042-6045
- Property svn:ignore
-
branches/histogram/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingImprovementOperator.cs
r5809 r6046 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Linq; 25 using System.Text; 24 using HeuristicLab.Analysis; 25 using HeuristicLab.Common; 26 26 using HeuristicLab.Core; 27 using HeuristicLab.Data; 28 using HeuristicLab.Operators; 29 using HeuristicLab.Optimization; 30 using HeuristicLab.Parameters; 27 31 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 using HeuristicLab.Operators;29 using HeuristicLab.Common;30 using HeuristicLab.Parameters;31 using HeuristicLab.Algorithms.SimulatedAnnealing;32 using HeuristicLab.Data;33 using HeuristicLab.Optimization;34 using HeuristicLab.Optimization.Operators;35 using HeuristicLab.Analysis;36 32 using HeuristicLab.PluginInfrastructure; 37 33 … … 42 38 [Item("SimulatedAnnealingImprovementOperator", "A simulated annealing improvement operator.")] 43 39 [StorableClass] 44 public class SimulatedAnnealingImprovementOperator: SingleSuccessorOperator, ILocalImprovementOperator { 40 public sealed class SimulatedAnnealingImprovementOperator : SingleSuccessorOperator, ILocalImprovementOperator, IStochasticOperator { 41 #region IGenericLocalImprovementOperator Properties 42 public Type ProblemType { get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); } } 43 public IProblem Problem { 44 get { return problem; } 45 set { 46 if (problem != value) { 47 if (value != null && !(value is ISingleObjectiveHeuristicOptimizationProblem)) 48 throw new ArgumentException("Only problems of type " + ProblemType.ToString() + " can be assigned."); 49 if (problem != null) DeregisterProblemEventHandlers(); 50 problem = (ISingleObjectiveHeuristicOptimizationProblem)value; 51 if (problem != null) RegisterProblemEventHandlers(); 52 UpdateProblem(); 53 } 54 } 55 } 56 #endregion 57 58 [Storable] 59 private ISingleObjectiveHeuristicOptimizationProblem problem; 45 60 [Storable] 46 61 private SimulatedAnnealingMainLoop loop; 47 48 62 [Storable] 49 63 private BestAverageWorstQualityAnalyzer qualityAnalyzer; 50 64 65 #region Parameter Properties 66 public ILookupParameter<IRandom> RandomParameter { 67 get { return (ILookupParameter<IRandom>)Parameters["Random"]; } 68 } 51 69 private ConstrainedValueParameter<IMoveGenerator> MoveGeneratorParameter { 52 70 get { return (ConstrainedValueParameter<IMoveGenerator>)Parameters["MoveGenerator"]; } … … 58 76 get { return (ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>)Parameters["MoveEvaluator"]; } 59 77 } 60 private ValueParameter<IntValue> MaximumIterationsParameter { 61 get { return (ValueParameter<IntValue>)Parameters["MaximumIterations"]; } 62 } 63 private ValueParameter<IntValue> InnerIterationsParameter { 64 get { return (ValueParameter<IntValue>)Parameters["InnerIterations"]; } 65 } 66 public LookupParameter<IntValue> EvaluatedSolutionsParameter { 67 get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; } 78 private IValueLookupParameter<IntValue> InnerIterationsParameter { 79 get { return (IValueLookupParameter<IntValue>)Parameters["InnerIterations"]; } 68 80 } 69 81 public ValueParameter<MultiAnalyzer> AnalyzerParameter { … … 79 91 get { return (ConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["AnnealingOperator"]; } 80 92 } 81 93 public ScopeTreeLookupParameter<DoubleValue> QualityParameter { 94 get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; } 95 } 96 #region ILocalImprovementOperator Parameters 97 public IValueLookupParameter<IntValue> MaximumIterationsParameter { 98 get { return (IValueLookupParameter<IntValue>)Parameters["MaximumIterations"]; } 99 } 100 public ILookupParameter<IntValue> EvaluatedSolutionsParameter { 101 get { return (ILookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; } 102 } 103 public ILookupParameter<ResultCollection> ResultsParameter { 104 get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; } 105 } 106 #endregion 107 #endregion 108 109 #region Properties 82 110 public IMoveGenerator MoveGenerator { 83 111 get { return MoveGeneratorParameter.Value; } … … 96 124 set { AnalyzerParameter.Value = value; } 97 125 } 126 #endregion 98 127 99 128 [StorableConstructor] 100 protected SimulatedAnnealingImprovementOperator(bool deserializing) : base(deserializing) {} 129 private SimulatedAnnealingImprovementOperator(bool deserializing) : base(deserializing) { } 130 private SimulatedAnnealingImprovementOperator(SimulatedAnnealingImprovementOperator original, Cloner cloner) 131 : base(original, cloner) { 132 this.problem = cloner.Clone(original.problem); 133 this.loop = cloner.Clone(original.loop); 134 this.qualityAnalyzer = cloner.Clone(original.qualityAnalyzer); 135 RegisterEventHandlers(); 136 } 137 public SimulatedAnnealingImprovementOperator() 138 : base() { 139 loop = new SimulatedAnnealingMainLoop(); 140 141 qualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 142 143 Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use.")); 144 Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution.")); 145 Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move.")); 146 Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move.")); 147 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(150))); 148 Parameters.Add(new ValueLookupParameter<IntValue>("InnerIterations", "Number of moves that MultiMoveGenerators should create. This is ignored for Exhaustive- and SingleMoveGenerators.", new IntValue(1500))); 149 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated moves.")); 150 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution.", new MultiAnalyzer())); 151 Parameters.Add(new ValueParameter<DoubleValue>("StartTemperature", "The initial temperature.", new DoubleValue(100))); 152 Parameters.Add(new ValueParameter<DoubleValue>("EndTemperature", "The final temperature which should be reached when iterations reaches maximum iterations.", new DoubleValue(1e-6))); 153 Parameters.Add(new ConstrainedValueParameter<IDiscreteDoubleValueModifier>("AnnealingOperator", "The operator used to modify the temperature.")); 154 Parameters.Add(new LookupParameter<ResultCollection>("Results", "The variable where the results are stored.")); 155 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The quality/fitness value of a solution.")); 156 157 foreach (IDiscreteDoubleValueModifier op in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name)) 158 AnnealingOperatorParameter.ValidValues.Add(op); 159 160 ParameterizeAnnealingOperators(); 161 ParameterizeSAMainLoop(); 162 163 RegisterEventHandlers(); 164 } 165 166 public override IDeepCloneable Clone(Cloner cloner) { 167 return new SimulatedAnnealingImprovementOperator(this, cloner); 168 } 169 101 170 [StorableHook(HookType.AfterDeserialization)] 102 171 private void AfterDeserialization() { 103 Initialize(); 104 } 105 protected SimulatedAnnealingImprovementOperator(SimulatedAnnealingImprovementOperator original, Cloner cloner) 106 : base(original, cloner) { 107 this.loop = cloner.Clone(original.loop); 108 this.qualityAnalyzer = cloner.Clone(original.qualityAnalyzer); 109 Initialize(); 110 } 111 public override IDeepCloneable Clone(Cloner cloner) { 112 return new SimulatedAnnealingImprovementOperator(this, cloner); 113 } 114 public SimulatedAnnealingImprovementOperator() 115 : base() { 116 loop = new SimulatedAnnealingMainLoop(); 117 118 qualityAnalyzer = new BestAverageWorstQualityAnalyzer(); 119 120 Parameters.Add(new ConstrainedValueParameter<IMoveGenerator>("MoveGenerator", "The operator used to generate moves to the neighborhood of the current solution.")); 121 Parameters.Add(new ConstrainedValueParameter<IMoveMaker>("MoveMaker", "The operator used to perform a move.")); 122 Parameters.Add(new ConstrainedValueParameter<ISingleObjectiveMoveEvaluator>("MoveEvaluator", "The operator used to evaluate a move.")); 123 Parameters.Add(new ValueParameter<IntValue>("MaximumIterations", "The maximum number of generations which should be processed.", new IntValue(150))); 124 Parameters.Add(new ValueParameter<IntValue>("InnerIterations", "Number of moves that MultiMoveGenerators should create. This is ignored for Exhaustive- and SingleMoveGenerators.", new IntValue(1500))); 125 Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of evaluated moves.")); 126 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the solution.", new MultiAnalyzer())); 127 Parameters.Add(new ValueParameter<DoubleValue>("StartTemperature", "The initial temperature.", new DoubleValue(100))); 128 Parameters.Add(new ValueParameter<DoubleValue>("EndTemperature", "The final temperature which should be reached when iterations reaches maximum iterations.", new DoubleValue(1e-6))); 129 Parameters.Add(new ConstrainedValueParameter<IDiscreteDoubleValueModifier>("AnnealingOperator", "The operator used to modify the temperature.")); 130 131 foreach (IDiscreteDoubleValueModifier op in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name)) 132 AnnealingOperatorParameter.ValidValues.Add(op); 133 134 ParameterizeAnnealingOperators(); 135 136 Initialize(); 137 } 138 139 private void Initialize() { 172 RegisterEventHandlers(); 173 } 174 175 #region Event Handler Registration 176 private void RegisterEventHandlers() { 140 177 MoveGeneratorParameter.ValueChanged += new EventHandler(MoveGeneratorParameter_ValueChanged); 141 } 178 if (problem != null) 179 RegisterProblemEventHandlers(); 180 } 181 182 private void RegisterProblemEventHandlers() { 183 problem.Reset += new EventHandler(problem_Reset); 184 problem.OperatorsChanged += new EventHandler(problem_OperatorsChanged); 185 } 186 187 private void DeregisterProblemEventHandlers() { 188 problem.Reset -= new EventHandler(problem_Reset); 189 problem.OperatorsChanged -= new EventHandler(problem_OperatorsChanged); 190 } 191 #endregion 192 193 #region Event Handlers 194 private void MoveGeneratorParameter_ValueChanged(object sender, EventArgs e) { 195 ChooseMoveOperators(); 196 ParameterizeSAMainLoop(); 197 } 198 199 private void problem_Reset(object sender, EventArgs e) { 200 UpdateProblem(); 201 } 202 203 private void problem_OperatorsChanged(object sender, EventArgs e) { 204 UpdateProblem(); 205 } 206 #endregion 142 207 143 208 private void ParameterizeAnnealingOperators() { … … 152 217 } 153 218 154 public void OnProblemChanged(IProblem problem) {155 UpdateMoveOperators( problem);219 public void UpdateProblem() { 220 UpdateMoveOperators(); 156 221 ChooseMoveOperators(); 157 222 158 ParameterizeMoveGenerators(problem as ISingleObjectiveHeuristicOptimizationProblem); 159 ParameterizeMoveEvaluators(problem as ISingleObjectiveHeuristicOptimizationProblem); 160 ParameterizeMoveMakers(problem as ISingleObjectiveHeuristicOptimizationProblem); 161 162 ParameterizeAnalyzers(problem as ISingleObjectiveHeuristicOptimizationProblem); 163 UpdateAnalyzers(problem as ISingleObjectiveHeuristicOptimizationProblem); 164 } 165 166 void ParameterizeAnalyzers(ISingleObjectiveHeuristicOptimizationProblem problem) { 223 ParameterizeMoveGenerators(); 224 225 ParameterizeSAMainLoop(); 226 ParameterizeAnalyzers(); 227 UpdateAnalyzers(); 228 } 229 230 private void ParameterizeAnalyzers() { 167 231 qualityAnalyzer.ResultsParameter.ActualName = "Results"; 168 232 if (problem != null) { … … 174 238 } 175 239 176 void UpdateAnalyzers(ISingleObjectiveHeuristicOptimizationProblem problem) { 240 private void ParameterizeSAMainLoop() { 241 loop.AnalyzerParameter.ActualName = AnalyzerParameter.Name; 242 loop.EvaluatedMovesParameter.ActualName = EvaluatedSolutionsParameter.Name; 243 loop.IterationsParameter.ActualName = "LocalIterations"; 244 loop.MaximumIterationsParameter.ActualName = MaximumIterationsParameter.Name; 245 loop.MoveEvaluatorParameter.ActualName = MoveEvaluatorParameter.Name; 246 loop.MoveGeneratorParameter.ActualName = MoveGeneratorParameter.Name; 247 loop.MoveMakerParameter.ActualName = MoveMakerParameter.Name; 248 loop.QualityParameter.ActualName = QualityParameter.Name; 249 loop.RandomParameter.ActualName = RandomParameter.Name; 250 loop.ResultsParameter.ActualName = ResultsParameter.Name; 251 252 if (problem != null) { 253 loop.BestKnownQualityParameter.ActualName = problem.BestKnownQualityParameter.Name; 254 loop.MaximizationParameter.ActualName = problem.MaximizationParameter.Name; 255 } 256 if (MoveEvaluator != null) { 257 loop.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName; 258 } 259 } 260 261 private void UpdateAnalyzers() { 177 262 Analyzer.Operators.Clear(); 178 263 if (problem != null) { … … 187 272 } 188 273 189 void MoveGeneratorParameter_ValueChanged(object sender, EventArgs e) { 190 ChooseMoveOperators(); 191 } 192 193 private void UpdateMoveOperators(IProblem problem) { 274 private void UpdateMoveOperators() { 194 275 IMoveGenerator oldMoveGenerator = MoveGenerator; 195 276 IMoveMaker oldMoveMaker = MoveMaker; … … 199 280 200 281 if (problem != null) { 201 foreach (IM oveGenerator generator in problem.Operators.OfType<IMoveGenerator>().OrderBy(x => x.Name))282 foreach (IMultiMoveGenerator generator in problem.Operators.OfType<IMultiMoveGenerator>().OrderBy(x => x.Name)) 202 283 MoveGeneratorParameter.ValidValues.Add(generator); 203 204 foreach (IMoveMaker maker in problem.Operators.OfType<IMoveMaker>().OrderBy(x => x.Name)) 205 MoveMakerParameter.ValidValues.Add(maker); 206 207 foreach (ISingleObjectiveMoveEvaluator evaluator in problem.Operators.OfType<ISingleObjectiveMoveEvaluator>().OrderBy(x => x.Name)) 208 MoveEvaluatorParameter.ValidValues.Add(evaluator); 209 } 210 211 if (oldMoveGenerator != null) { 212 IMoveGenerator newMoveGenerator = MoveGeneratorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveGenerator.GetType()); 213 if (newMoveGenerator != null) MoveGenerator = newMoveGenerator; 214 } 215 if (MoveGenerator == null) { 216 ClearMoveParameters(); 217 } 218 219 if (oldMoveMaker != null) { 220 IMoveMaker mm = MoveMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveMaker.GetType()); 221 if (mm != null) MoveMaker = mm; 222 } 223 224 if (oldMoveEvaluator != null) { 225 ISingleObjectiveMoveEvaluator me = MoveEvaluatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveEvaluator.GetType()); 226 if (me != null) MoveEvaluator = me; 227 } 228 } 229 230 private void ChooseMoveOperators() { 231 IMoveMaker oldMoveMaker = MoveMaker; 232 ISingleObjectiveMoveEvaluator oldMoveEvaluator = MoveEvaluator; 284 foreach (IExhaustiveMoveGenerator generator in problem.Operators.OfType<IExhaustiveMoveGenerator>().OrderBy(x => x.Name)) 285 MoveGeneratorParameter.ValidValues.Add(generator); 286 287 if (oldMoveGenerator != null) { 288 IMoveGenerator newMoveGenerator = MoveGeneratorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveGenerator.GetType()); 289 if (newMoveGenerator != null) MoveGenerator = newMoveGenerator; 290 } 291 292 ChooseMoveOperators(oldMoveMaker, oldMoveEvaluator); 293 } 294 } 295 296 private void ChooseMoveOperators(IMoveMaker oldMoveMaker = null, ISingleObjectiveMoveEvaluator oldMoveEvaluator = null) { 297 if (oldMoveMaker == null) oldMoveMaker = MoveMaker; 298 if (oldMoveEvaluator == null) oldMoveEvaluator = MoveEvaluator; 299 MoveMakerParameter.ValidValues.Clear(); 300 MoveEvaluatorParameter.ValidValues.Clear(); 233 301 234 302 if (MoveGenerator != null) { 235 List<Type> moveTypes = MoveGenerator.GetType().GetInterfaces().Where(x => typeof(IMoveOperator).IsAssignableFrom(x)).ToList(); 236 foreach (Type type in moveTypes.ToList()) { 237 if (moveTypes.Any(t => t != type && type.IsAssignableFrom(t))) 238 moveTypes.Remove(type); 239 } 240 List<IMoveMaker> validMoveMakers = new List<IMoveMaker>(); 241 List<ISingleObjectiveMoveEvaluator> validMoveEvaluators = new List<ISingleObjectiveMoveEvaluator>(); 242 243 foreach (Type type in moveTypes) { 244 var moveMakers = MoveMakerParameter.ValidValues.Where(x => type.IsAssignableFrom(x.GetType())).OrderBy(x => x.Name); 245 foreach (IMoveMaker moveMaker in moveMakers) 246 validMoveMakers.Add(moveMaker); 247 248 var moveEvaluators = MoveEvaluatorParameter.ValidValues.Where(x => type.IsAssignableFrom(x.GetType())).OrderBy(x => x.Name); 249 foreach (ISingleObjectiveMoveEvaluator moveEvaluator in moveEvaluators) 250 validMoveEvaluators.Add(moveEvaluator); 251 } 303 IMoveGenerator generator = MoveGeneratorParameter.Value; 304 foreach (IMoveMaker moveMaker in MoveHelper.GetCompatibleMoveMakers(generator, Problem.Operators).OrderBy(x => x.Name)) 305 MoveMakerParameter.ValidValues.Add(moveMaker); 306 foreach (ISingleObjectiveMoveEvaluator moveEvaluator in MoveHelper.GetCompatibleSingleObjectiveMoveEvaluators(generator, Problem.Operators).OrderBy(x => x.Name)) 307 MoveEvaluatorParameter.ValidValues.Add(moveEvaluator); 308 252 309 if (oldMoveMaker != null) { 253 IMoveMaker mm = validMoveMakers.FirstOrDefault(x => x.GetType() == oldMoveMaker.GetType());310 IMoveMaker mm = MoveMakerParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveMaker.GetType()); 254 311 if (mm != null) MoveMaker = mm; 255 else MoveMaker = validMoveMakers.FirstOrDefault(); 256 } 257 312 } 258 313 if (oldMoveEvaluator != null) { 259 ISingleObjectiveMoveEvaluator me = validMoveEvaluators.FirstOrDefault(x => x.GetType() == oldMoveEvaluator.GetType());314 ISingleObjectiveMoveEvaluator me = MoveEvaluatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMoveEvaluator.GetType()); 260 315 if (me != null) MoveEvaluator = me; 261 else MoveEvaluator = validMoveEvaluators.FirstOrDefault(); 262 } 316 } 263 317 } 264 318 } … … 270 324 } 271 325 272 private void ParameterizeMoveGenerators( ISingleObjectiveHeuristicOptimizationProblem problem) {326 private void ParameterizeMoveGenerators() { 273 327 if (problem != null) { 274 328 foreach (IMultiMoveGenerator generator in problem.Operators.OfType<IMultiMoveGenerator>()) … … 276 330 } 277 331 } 278 private void ParameterizeMoveEvaluators(ISingleObjectiveHeuristicOptimizationProblem problem) {279 foreach (ISingleObjectiveMoveEvaluator op in problem.Operators.OfType<ISingleObjectiveMoveEvaluator>()) {280 op.QualityParameter.ActualName = problem.Evaluator.QualityParameter.ActualName;281 }282 }283 private void ParameterizeMoveMakers(ISingleObjectiveHeuristicOptimizationProblem problem) {284 foreach (IMoveMaker op in problem.Operators.OfType<IMoveMaker>()) {285 op.QualityParameter.ActualName = problem.Evaluator.QualityParameter.ActualName;286 if (MoveEvaluator != null)287 op.MoveQualityParameter.ActualName = MoveEvaluator.MoveQualityParameter.ActualName;288 }289 }290 332 291 333 public override IOperation Apply() { 292 Scope subScope = new Scope(); 334 IScope currentScope = ExecutionContext.Scope; 335 336 Scope localScope = new Scope(); 293 337 Scope individual = new Scope(); 294 338 295 foreach (Variable var in ExecutionContext.Scope.Variables) { 296 individual.Variables.Add(var); 297 } 298 subScope.SubScopes.Add(individual); 299 300 ExecutionContext.Scope.SubScopes.Add(subScope); 301 int index = subScope.Parent.SubScopes.IndexOf(subScope); 339 foreach (IVariable var in currentScope.Variables) 340 individual.Variables.Add(var); // add reference to variable otherwise the analyzer fails (it's looking down the tree) 341 342 localScope.SubScopes.Add(individual); 343 currentScope.SubScopes.Add(localScope); 344 int index = currentScope.SubScopes.Count - 1; 302 345 303 346 SubScopesProcessor processor = new SubScopesProcessor(); … … 307 350 remover.SubScopeIndexParameter.Value = new IntValue(index); 308 351 309 for (int i = 0; i < index; i++) { 310 processor.Operators.Add(new EmptyOperator()); 352 if (index > 0) { 353 EmptyOperator eo = new EmptyOperator(); 354 for (int i = 0; i < index - 1; i++) { 355 processor.Operators.Add(eo); 356 } 311 357 } 312 358 313 359 VariableCreator variableCreator = new VariableCreator(); 314 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>( "LocalIterations", new IntValue(0)));360 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>(loop.IterationsParameter.ActualName, new IntValue(0))); 315 361 316 362 variableCreator.Successor = loop; 317 318 loop.EvaluatedMovesParameter.ActualName = EvaluatedSolutionsParameter.ActualName;319 363 320 364 processor.Operators.Add(variableCreator); 321 365 processor.Successor = remover; 322 366 323 IOperation next = base.Apply(); 324 if (next as ExecutionContext != null) { 325 remover.Successor = (next as ExecutionContext).Operator; 326 } 327 328 return ExecutionContext.CreateChildOperation(processor); 367 OperationCollection next = new OperationCollection(base.Apply()); 368 next.Insert(0, ExecutionContext.CreateChildOperation(processor)); 369 370 return next; 329 371 } 330 372 } -
branches/histogram/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingMainLoop.cs
r5753 r6046 61 61 } 62 62 public LookupParameter<IntValue> IterationsParameter { 63 get { return (LookupParameter<IntValue>)Parameters[" LocalIterations"]; }63 get { return (LookupParameter<IntValue>)Parameters["Iterations"]; } 64 64 } 65 65 public ValueLookupParameter<IntValue> MaximumIterationsParameter { … … 112 112 Parameters.Add(new ValueLookupParameter<DoubleValue>("EndTemperature", "The end temperature.")); 113 113 Parameters.Add(new ValueLookupParameter<IntValue>("InnerIterations", "The amount of inner iterations (number of moves before temperature is adjusted again).")); 114 Parameters.Add(new LookupParameter<IntValue>(" LocalIterations", "The number of generations."));114 Parameters.Add(new LookupParameter<IntValue>("Iterations", "The number of iterations.")); 115 115 Parameters.Add(new ValueLookupParameter<IntValue>("MaximumIterations", "The maximum number of iterations which should be processed.")); 116 116 … … 231 231 } 232 232 233 [StorableHook(HookType.AfterDeserialization)] 234 private void AfterDeserialization() { 235 // BackwardsCompatibility3.3 236 #region Backwards compatible code (remove with 3.4) 237 if (!Parameters.ContainsKey("Iterations")) 238 Parameters.Add(new LookupParameter<IntValue>("Iterations", "The number of iterations.")); 239 #endregion 240 } 241 233 242 public override IOperation Apply() { 234 243 if (MoveGeneratorParameter.ActualValue == null || MoveEvaluatorParameter.ActualValue == null || MoveMakerParameter.ActualValue == null)
Note: See TracChangeset
for help on using the changeset viewer.