#region License Information
/* HeuristicLab
* Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Linq;
using HeuristicLab.Common;
using HeuristicLab.Core;
using HeuristicLab.Data;
using HeuristicLab.Operators;
using HeuristicLab.Parameters;
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
namespace HeuristicLab.Algorithms.SimulatedAnnealing
{
[Item("TemperatureController", "Decides based on information from the heatingoperator, whether to use cooling or heating and calls the appropriate operator.")]
[StorableClass]
public class TemperatureController : SingleSuccessorOperator
{
#region Strings
private const string ReheatingOperatorName = "ReheatingOperator";
private const string AnnealingOperatorName = "AnnealingOperator";
private const string MaximumIterationsName = "MaximumIterations";
private const string LowerTemperatureName = "LowerTemperature";
private const string IterationsName = "Iterations";
private const string TemperatureStartIndexName = "TemperatureStartIndex";
private const string CoolingName = "Cooling";
private const string StartTemperatureName = "StartTemperature";
private const string EndTemperatureName = "EndTemperature";
private const string TemperatureName = "Temperature";
private const string IsAcceptedName = "IsAccepted";
private const string AcceptanceMemoryName = "AcceptanceMemory";
private const string ReheatCountName = "ReheatCount";
#endregion
#region Parameter Properties
public ILookupParameter TemperatureParameter
{
get { return (ILookupParameter)Parameters[TemperatureName]; }
}
public IValueLookupParameter LowerTemperatureParameter
{
get { return (IValueLookupParameter)Parameters[LowerTemperatureName]; }
}
public ILookupParameter StartTemperatureParameter
{
get { return (ILookupParameter)Parameters[StartTemperatureName]; }
}
public ILookupParameter EndTemperatureParameter
{
get { return (ILookupParameter)Parameters[EndTemperatureName]; }
}
public ILookupParameter TemperatureStartIndexParameter
{
get { return (ILookupParameter)Parameters[TemperatureStartIndexName]; }
}
public ILookupParameter CoolingParameter
{
get { return (ILookupParameter)Parameters[CoolingName]; }
}
public ILookupParameter IterationsParameter
{
get { return (ILookupParameter)Parameters[IterationsName]; }
}
public IValueLookupParameter MaximumIterationsParameter
{
get { return (IValueLookupParameter)Parameters[MaximumIterationsName]; }
}
public IValueLookupParameter AnnealingOperatorParameter
{
get { return (IValueLookupParameter)Parameters[AnnealingOperatorName]; }
}
public IValueLookupParameter ReheatingOperatorParameter
{
get { return (IValueLookupParameter)Parameters[ReheatingOperatorName]; }
}
public ILookupParameter IsAcceptedParameter
{
get { return (ILookupParameter)Parameters[IsAcceptedName]; }
}
public ILookupParameter> AcceptanceMemoryParameter
{
get { return (ILookupParameter>)Parameters[AcceptanceMemoryName]; }
}
public ILookupParameter ReheatCountParameter
{
get { return (ILookupParameter)Parameters[ReheatCountName]; }
}
#endregion
[StorableConstructor]
protected TemperatureController(bool deserializing) : base(deserializing) { }
protected TemperatureController(TemperatureController original, Cloner cloner) : base(original, cloner) { }
public TemperatureController()
: base()
{
Parameters.Add(new LookupParameter(TemperatureName, "The current temperature."));
Parameters.Add(new ValueLookupParameter(LowerTemperatureName, "The lower bound of the temperature."));
Parameters.Add(new LookupParameter(IterationsName, "The number of iterations."));
Parameters.Add(new ValueLookupParameter(MaximumIterationsName, "The maximum number of iterations which should be processed."));
Parameters.Add(new ValueLookupParameter(AnnealingOperatorName, "The operator that cools the temperature."));
Parameters.Add(new ValueLookupParameter(ReheatingOperatorName, "The operator that reheats the temperature if necessary."));
Parameters.Add(new LookupParameter(TemperatureStartIndexName, "The index where the annealing or heating was last changed."));
Parameters.Add(new LookupParameter(CoolingName, "True when the temperature should be cooled, false otherwise."));
Parameters.Add(new LookupParameter(StartTemperatureName, "The temperature from which cooling or reheating should occur."));
Parameters.Add(new LookupParameter(EndTemperatureName, "The temperature to which should be cooled or heated."));
Parameters.Add(new LookupParameter(IsAcceptedName, "Whether the move was accepted or not."));
Parameters.Add(new LookupParameter>(AcceptanceMemoryName, "Memorizes the last N acceptance decisions."));
Parameters.Add(new LookupParameter(ReheatCountName, "The number of reheats."));
}
public override IDeepCloneable Clone(Cloner cloner)
{
return new TemperatureController(this, cloner);
}
public override IOperation Apply()
{
return new OperationCollection {
ExecutionContext.CreateOperation(ReheatingOperatorParameter.ActualValue),
base.Apply()
};
}
}
}