Changeset 14555
- Timestamp:
- 01/10/17 18:03:16 (8 years ago)
- Location:
- branches/jschiess/HeuristicLab.Algorithms.SimulatedAnnealing/3.3
- Files:
-
- 6 added
- 3 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/jschiess/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/HeuristicLab.Algorithms.SimulatedAnnealing-3.3.csproj
r14452 r14555 114 114 </ItemGroup> 115 115 <ItemGroup> 116 <Compile Include="ISimulatedAnnealingHeatingStrategy.cs" /> 116 <Compile Include="AcceptanceRatioReheatingOperator.cs" /> 117 <Compile Include="ConnollyReheatingOperator.cs" /> 118 <Compile Include="ConsecutiveRejectionReheatingOperator.cs" /> 119 <Compile Include="NoReheatingOperator.cs" /> 120 <Compile Include="IReheatingOperator.cs" /> 117 121 <Compile Include="Plugin.cs" /> 118 <Compile Include="FixedReheater.cs" />119 <Compile Include="ContinuousReheater.cs" />120 122 <Compile Include="SimulatedAnnealingImprovementOperator.cs" /> 121 123 <Compile Include="Properties\AssemblyInfo.cs" /> -
branches/jschiess/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealing.cs
r14452 r14555 48 48 private const string MoveMakerName = "MoveMaker"; 49 49 private const string AnnealingOperatorName = "AnnealingOperator"; 50 private const string HeatingStrategyOperatorName = "HeatingStrategyOperator";50 private const string ReheatingOperatorName = "ReheatingOperator"; 51 51 private const string MaximumIterationsName = "MaximumIterations"; 52 52 private const string InitialTemperatureName = "InitialTemperature"; … … 105 105 get { return (IConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters[AnnealingOperatorName]; } 106 106 } 107 public OptionalConstrainedValueParameter<ISimulatedAnnealingHeatingStrategy> HeatingStrategyOperatorParameter 108 { 109 get { return (OptionalConstrainedValueParameter<ISimulatedAnnealingHeatingStrategy>)Parameters[HeatingStrategyOperatorName]; } 107 108 public IConstrainedValueParameter<IReheatingOperator> ReheatingOperatorParameter 109 { 110 get { return (IConstrainedValueParameter<IReheatingOperator>)Parameters[ReheatingOperatorName]; } 110 111 } 111 112 … … 159 160 set { AnnealingOperatorParameter.Value = value; } 160 161 } 161 public ISimulatedAnnealingHeatingStrategy HeatingStrategyOperator 162 { 163 get { return HeatingStrategyOperatorParameter.Value; } 164 set { HeatingStrategyOperatorParameter.Value = value; } 162 163 public IReheatingOperator ReheatingOperator 164 { 165 get { return ReheatingOperatorParameter.Value; } 166 set { ReheatingOperatorParameter.Value = value; } 165 167 } 166 168 … … 215 217 Parameters.Add(new ConstrainedValueParameter<IMoveMaker>(MoveMakerName, "The operator used to perform a move.")); 216 218 Parameters.Add(new ConstrainedValueParameter<IDiscreteDoubleValueModifier>(AnnealingOperatorName, "The operator used to cool the temperature.")); 217 Parameters.Add(new OptionalConstrainedValueParameter<ISimulatedAnnealingHeatingStrategy>(HeatingStrategyOperatorName, "1The operator used to heat the temperature."));219 Parameters.Add(new ConstrainedValueParameter<IReheatingOperator>(ReheatingOperatorName, "The operator used to reheat the temperature, if necessary.")); 218 220 Parameters.Add(new ValueParameter<IntValue>(MaximumIterationsName, "The maximum number of generations which should be processed.", new IntValue(10000))); 219 221 Parameters.Add(new ValueParameter<DoubleValue>(InitialTemperatureName, "The initial temperature.", new DoubleValue(100))); … … 274 276 mainLoop.EndTemperatureParameter.ActualName = EndTemperatureName; 275 277 mainLoop.EvaluatedMovesParameter.ActualName = EvaluatedMovesName; 276 mainLoop.HeatingStrategyOperatorParameter.ActualName = HeatingStrategyOperatorParameter.Name;277 278 278 279 mainLoop.IterationsParameter.ActualName = IterationsName; … … 287 288 mainLoop.TemperatureParameter.ActualName = TemperatureName; 288 289 290 foreach (var op in ApplicationManager.Manager.GetInstances<IReheatingOperator>().OrderBy(x => x.Name)) 291 { 292 293 ReheatingOperatorParameter.ValidValues.Add(op); 294 } 295 289 296 foreach (var op in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name)) 290 297 { 291 298 AnnealingOperatorParameter.ValidValues.Add(op); 292 }293 294 foreach (var op in ApplicationManager.Manager.GetInstances<ISimulatedAnnealingHeatingStrategy>().OrderBy(x => x.Name))295 {296 HeatingStrategyOperatorParameter.ValidValues.Add(op);297 299 } 298 300 … … 568 570 op.EndValueParameter.Hidden = true; 569 571 } 570 571 foreach(var op in HeatingStrategyOperatorParameter.ValidValues) 572 foreach (var op in ReheatingOperatorParameter.ValidValues) 572 573 { 573 574 op.Parameterize(); 574 575 } 575 576 576 #endregion 577 577 -
branches/jschiess/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingImprovementOperator.cs
r14406 r14555 377 377 VariableCreator variableCreator = new VariableCreator(); 378 378 variableCreator.CollectedValues.Add(new ValueParameter<IntValue>(loop.IterationsParameter.ActualName, new IntValue(0))); 379 379 380 380 variableCreator.Successor = loop; 381 381 -
branches/jschiess/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingMainLoop.cs
r14452 r14555 39 39 private const string MoveMakerName = "MoveMaker"; 40 40 private const string AnnealingOperatorName = "AnnealingOperator"; 41 private const string HeatingStrategyOperatorName = "HeatingStrategyOperator";41 private const string ReheatingOperatorName = "ReheatingOperator"; 42 42 private const string MaximumIterationsName = "MaximumIterations"; 43 43 private const string LowerTemperatureName = "LowerTemperature"; … … 114 114 get { return (IValueLookupParameter<IOperator>)Parameters[AnnealingOperatorName]; } 115 115 } 116 public IValueLookupParameter<IOperator> HeatingStrategyOperatorParameter117 { 118 get { return (IValueLookupParameter<IOperator>)Parameters[ HeatingStrategyOperatorName]; }116 public IValueLookupParameter<IOperator> ReheatingOperatorParameter 117 { 118 get { return (IValueLookupParameter<IOperator>)Parameters[ReheatingOperatorName]; } 119 119 } 120 120 public IValueLookupParameter<IOperator> AnalyzerParameter … … 181 181 Parameters.Add(new ValueLookupParameter<IOperator>(MoveMakerName, "The operator that performs a move and updates the quality.")); 182 182 Parameters.Add(new ValueLookupParameter<IOperator>(AnnealingOperatorName, "The operator that cools the temperature.")); 183 Parameters.Add(new ValueLookupParameter<IOperator>( HeatingStrategyOperatorName, "The operator that heats the temperature."));183 Parameters.Add(new ValueLookupParameter<IOperator>(ReheatingOperatorName, "The operator that reheats the temperature if necessary.")); 184 184 185 185 Parameters.Add(new ValueLookupParameter<IOperator>(AnalyzerName, "The operator used to analyze each generation.")); … … 245 245 temperatureController.CoolingParameter.ActualName = CoolingParameter.Name; 246 246 temperatureController.EndTemperatureParameter.ActualName = EndTemperatureParameter.Name; 247 temperatureController. HeatingStrategyOperatorParameter.ActualName = HeatingStrategyOperatorParameter.Name;247 temperatureController.ReheatingOperatorParameter.ActualName = ReheatingOperatorParameter.Name; 248 248 temperatureController.IsAcceptedParameter.ActualName = IsAcceptedName; 249 249 temperatureController.IterationsParameter.ActualName = IterationsParameter.Name; -
branches/jschiess/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/TemperatureController.cs
r14452 r14555 38 38 { 39 39 #region Strings 40 private const string ReheatingOperatorName = "ReheatingOperator"; 40 41 private const string AnnealingOperatorName = "AnnealingOperator"; 41 private const string HeatingStrategyOperatorName = "HeatingStrategyOperator";42 42 private const string MaximumIterationsName = "MaximumIterations"; 43 43 private const string LowerTemperatureName = "LowerTemperature"; … … 89 89 get { return (IValueLookupParameter<IOperator>)Parameters[AnnealingOperatorName]; } 90 90 } 91 public IValueLookupParameter<I SimulatedAnnealingHeatingStrategy> HeatingStrategyOperatorParameter91 public IValueLookupParameter<IReheatingOperator> ReheatingOperatorParameter 92 92 { 93 get { return (IValueLookupParameter<I SimulatedAnnealingHeatingStrategy>)Parameters[HeatingStrategyOperatorName]; }93 get { return (IValueLookupParameter<IReheatingOperator>)Parameters[ReheatingOperatorName]; } 94 94 } 95 95 public ILookupParameter<BoolValue> IsAcceptedParameter … … 114 114 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumIterationsName, "The maximum number of iterations which should be processed.")); 115 115 Parameters.Add(new ValueLookupParameter<IOperator>(AnnealingOperatorName, "The operator that cools the temperature.")); 116 Parameters.Add(new ValueLookupParameter<I SimulatedAnnealingHeatingStrategy>(HeatingStrategyOperatorName, "The operator that heats the temperature."));116 Parameters.Add(new ValueLookupParameter<IReheatingOperator>(ReheatingOperatorName, "The operator that reheats the temperature if necessary.")); 117 117 Parameters.Add(new LookupParameter<IntValue>(TemperatureStartIndexName, "The index where the annealing or heating was last changed.")); 118 118 Parameters.Add(new LookupParameter<BoolValue>(CoolingName, "True when the temperature should be cooled, false otherwise.")); … … 130 130 public override IOperation Apply() 131 131 { 132 var iterations = IterationsParameter.ActualValue.Value; 133 var heatingStrategyOperator = HeatingStrategyOperatorParameter.ActualValue; 134 var accepted = IsAcceptedParameter.ActualValue; 135 136 // if there is no heatingstrategyoperator just do cooling 137 if (accepted == null || heatingStrategyOperator == null) 138 { 139 CoolingParameter.ActualValue.Value = true; 140 }else 141 { 142 // else, let the heatingstrategyoperator decide if it is time to reheat 143 var acceptances = AcceptanceMemoryParameter.ActualValue; 144 acceptances.Add(accepted); 145 CoolingParameter.ActualValue.Value = !heatingStrategyOperator. 146 ShouldReheat(CoolingParameter.ActualValue.Value, acceptances); 147 } 148 149 // if we want to cool, use the cooling parameter 150 if (CoolingParameter.ActualValue.Value == true) 151 { 152 TemperatureStartIndexParameter.ActualValue.Value = Math.Max(0, iterations - 1); 153 StartTemperatureParameter.ActualValue.Value = TemperatureParameter.ActualValue.Value; 154 EndTemperatureParameter.ActualValue.Value = LowerTemperatureParameter.ActualValue.Value; 155 return new OperationCollection { 156 ExecutionContext.CreateOperation(AnnealingOperatorParameter.ActualValue), 132 return new OperationCollection { 133 ExecutionContext.CreateOperation(ReheatingOperatorParameter.ActualValue), 157 134 base.Apply() 158 135 }; 159 }else160 {161 // else just use the heating parameter162 return new OperationCollection {163 ExecutionContext.CreateOperation(HeatingStrategyOperatorParameter.ActualValue),164 base.Apply()165 };166 }167 136 } 168 137 }
Note: See TracChangeset
for help on using the changeset viewer.