[15295] | 1 | using HeuristicLab.Operators;
|
---|
| 2 | using System;
|
---|
| 3 | using System.Collections.Generic;
|
---|
| 4 | using System.Linq;
|
---|
| 5 | using System.Text;
|
---|
| 6 | using System.Threading.Tasks;
|
---|
| 7 | using HeuristicLab.Common;
|
---|
| 8 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 9 | using HeuristicLab.Core;
|
---|
| 10 | using HeuristicLab.Data;
|
---|
| 11 | using HeuristicLab.Parameters;
|
---|
| 12 | using HeuristicLab.Optimization;
|
---|
| 13 | using HeuristicLab.PluginInfrastructure;
|
---|
| 14 | using HeuristicLab.Analysis;
|
---|
| 15 |
|
---|
| 16 | namespace HeuristicLab.Algorithms.SimulatedAnnealing
|
---|
| 17 | {
|
---|
| 18 | [Item("-", "No reheats are performed.")]
|
---|
| 19 | [StorableClass]
|
---|
| 20 | public class NoReheatingOperator : SingleSuccessorOperator, IReheatingOperator
|
---|
| 21 | {
|
---|
| 22 | #region Strings
|
---|
| 23 | private const string AnnealingOperatorName = "AnnealingOperator";
|
---|
| 24 | private const string LowerTemperatureName = "LowerTemperature";
|
---|
| 25 | private const string IterationsName = "Iterations";
|
---|
| 26 | private const string TemperatureStartIndexName = "TemperatureStartIndex";
|
---|
| 27 | private const string StartTemperatureName = "StartTemperature";
|
---|
| 28 | private const string EndTemperatureName = "EndTemperature";
|
---|
| 29 | private const string TemperatureName = "Temperature";
|
---|
| 30 | private const string MaximumIterationsName = "MaximumIterations";
|
---|
| 31 |
|
---|
| 32 |
|
---|
| 33 | #endregion
|
---|
| 34 | #region Parameters
|
---|
| 35 | public ILookupParameter<DoubleValue> TemperatureParameter
|
---|
| 36 | {
|
---|
| 37 | get { return (ILookupParameter<DoubleValue>)Parameters[TemperatureName]; }
|
---|
| 38 | }
|
---|
| 39 | public ILookupParameter<DoubleValue> LowerTemperatureParameter
|
---|
| 40 | {
|
---|
| 41 | get { return (ILookupParameter<DoubleValue>)Parameters[LowerTemperatureName]; }
|
---|
| 42 | }
|
---|
| 43 | public ILookupParameter<DoubleValue> StartTemperatureParameter
|
---|
| 44 | {
|
---|
| 45 | get { return (ILookupParameter<DoubleValue>)Parameters[StartTemperatureName]; }
|
---|
| 46 | }
|
---|
| 47 | public ILookupParameter<DoubleValue> EndTemperatureParameter
|
---|
| 48 | {
|
---|
| 49 | get { return (ILookupParameter<DoubleValue>)Parameters[EndTemperatureName]; }
|
---|
| 50 | }
|
---|
| 51 | public ILookupParameter<IntValue> TemperatureStartIndexParameter
|
---|
| 52 | {
|
---|
| 53 | get { return (ILookupParameter<IntValue>)Parameters[TemperatureStartIndexName]; }
|
---|
| 54 | }
|
---|
| 55 | public ILookupParameter<IntValue> IterationsParameter
|
---|
| 56 | {
|
---|
| 57 | get { return (ILookupParameter<IntValue>)Parameters[IterationsName]; }
|
---|
| 58 | }
|
---|
| 59 | public ILookupParameter<IOperator> AnnealingOperatorParameter
|
---|
| 60 | {
|
---|
| 61 | get { return (ILookupParameter<IOperator>)Parameters[AnnealingOperatorName]; }
|
---|
| 62 | }
|
---|
| 63 | public ILookupParameter<IntValue> MaximumIterationsParameter
|
---|
| 64 | {
|
---|
| 65 | get { return (ILookupParameter<IntValue>)Parameters[MaximumIterationsName]; }
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | #endregion
|
---|
| 69 |
|
---|
| 70 | public NoReheatingOperator() : base()
|
---|
| 71 | {
|
---|
| 72 | #region Create parameters
|
---|
| 73 | Parameters.Add(new LookupParameter<DoubleValue>(TemperatureName, "The current temperature."));
|
---|
| 74 | Parameters.Add(new LookupParameter<DoubleValue>(LowerTemperatureName, "The lower bound of the temperature."));
|
---|
| 75 | Parameters.Add(new LookupParameter<IntValue>(IterationsName, "The number of iterations."));
|
---|
| 76 | Parameters.Add(new LookupParameter<IntValue>(TemperatureStartIndexName, "The index where the annealing or heating was last changed."));
|
---|
| 77 | Parameters.Add(new LookupParameter<DoubleValue>(StartTemperatureName, "The temperature from which cooling or reheating should occur."));
|
---|
| 78 | Parameters.Add(new LookupParameter<DoubleValue>(EndTemperatureName, "The temperature to which should be cooled or heated."));
|
---|
| 79 | Parameters.Add(new LookupParameter<IntValue>(MaximumIterationsName, "The maximum number of iterations which should be processed."));
|
---|
| 80 | Parameters.Add(new LookupParameter<IOperator>(AnnealingOperatorName, "The operator that cools the temperature."));
|
---|
| 81 | #endregion
|
---|
| 82 |
|
---|
| 83 | Parameterize();
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | [StorableConstructor]
|
---|
| 87 | protected NoReheatingOperator(bool deserializing) : base(deserializing) { }
|
---|
| 88 | protected NoReheatingOperator(NoReheatingOperator original, Cloner cloner) : base(original, cloner) { }
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | public override IDeepCloneable Clone(Cloner cloner)
|
---|
| 92 | {
|
---|
| 93 | return new NoReheatingOperator(this, cloner);
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | public void Parameterize()
|
---|
| 97 | {
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | public override IOperation Apply()
|
---|
| 101 | {
|
---|
| 102 | TemperatureStartIndexParameter.ActualValue.Value = Math.Max(0, IterationsParameter.ActualValue.Value - 1);
|
---|
| 103 | StartTemperatureParameter.ActualValue.Value = TemperatureParameter.ActualValue.Value;
|
---|
| 104 | EndTemperatureParameter.ActualValue.Value = LowerTemperatureParameter.ActualValue.Value;
|
---|
| 105 | return new OperationCollection {
|
---|
| 106 | ExecutionContext.CreateOperation(AnnealingOperatorParameter.ActualValue),
|
---|
| 107 | base.Apply()
|
---|
| 108 | };
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 | }
|
---|