Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14555 for branches/jschiess


Ignore:
Timestamp:
01/10/17 18:03:16 (8 years ago)
Author:
jschiess
Message:

#1836 SA reheating strategies: Refactoring, Added Connolly Reheater Operator

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  
    114114  </ItemGroup>
    115115  <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" />
    117121    <Compile Include="Plugin.cs" />
    118     <Compile Include="FixedReheater.cs" />
    119     <Compile Include="ContinuousReheater.cs" />
    120122    <Compile Include="SimulatedAnnealingImprovementOperator.cs" />
    121123    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/jschiess/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealing.cs

    r14452 r14555  
    4848        private const string MoveMakerName = "MoveMaker";
    4949        private const string AnnealingOperatorName = "AnnealingOperator";
    50         private const string HeatingStrategyOperatorName = "HeatingStrategyOperator";
     50        private const string ReheatingOperatorName = "ReheatingOperator";
    5151        private const string MaximumIterationsName = "MaximumIterations";
    5252        private const string InitialTemperatureName = "InitialTemperature";
     
    105105            get { return (IConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters[AnnealingOperatorName]; }
    106106        }
    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]; }
    110111        }
    111112
     
    159160            set { AnnealingOperatorParameter.Value = value; }
    160161        }
    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; }
    165167        }
    166168
     
    215217            Parameters.Add(new ConstrainedValueParameter<IMoveMaker>(MoveMakerName, "The operator used to perform a move."));
    216218            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."));
    218220            Parameters.Add(new ValueParameter<IntValue>(MaximumIterationsName, "The maximum number of generations which should be processed.", new IntValue(10000)));
    219221            Parameters.Add(new ValueParameter<DoubleValue>(InitialTemperatureName, "The initial temperature.", new DoubleValue(100)));
     
    274276            mainLoop.EndTemperatureParameter.ActualName = EndTemperatureName;
    275277            mainLoop.EvaluatedMovesParameter.ActualName = EvaluatedMovesName;
    276             mainLoop.HeatingStrategyOperatorParameter.ActualName = HeatingStrategyOperatorParameter.Name;
    277278
    278279            mainLoop.IterationsParameter.ActualName = IterationsName;
     
    287288            mainLoop.TemperatureParameter.ActualName = TemperatureName;
    288289
     290            foreach (var op in ApplicationManager.Manager.GetInstances<IReheatingOperator>().OrderBy(x => x.Name))
     291            {
     292               
     293                ReheatingOperatorParameter.ValidValues.Add(op);
     294            }
     295
    289296            foreach (var op in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name))
    290297            {
    291298                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);
    297299            }
    298300
     
    568570                op.EndValueParameter.Hidden = true;
    569571            }
    570            
    571             foreach(var op in HeatingStrategyOperatorParameter.ValidValues)
     572            foreach (var op in ReheatingOperatorParameter.ValidValues)
    572573            {
    573574                op.Parameterize();
    574575            }
    575 
    576576            #endregion
    577577
  • branches/jschiess/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingImprovementOperator.cs

    r14406 r14555  
    377377      VariableCreator variableCreator = new VariableCreator();
    378378      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>(loop.IterationsParameter.ActualName, new IntValue(0)));
    379 
     379       
    380380      variableCreator.Successor = loop;
    381381
  • branches/jschiess/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/SimulatedAnnealingMainLoop.cs

    r14452 r14555  
    3939        private const string MoveMakerName = "MoveMaker";
    4040        private const string AnnealingOperatorName = "AnnealingOperator";
    41         private const string HeatingStrategyOperatorName = "HeatingStrategyOperator";
     41        private const string ReheatingOperatorName = "ReheatingOperator";
    4242        private const string MaximumIterationsName = "MaximumIterations";
    4343        private const string LowerTemperatureName = "LowerTemperature";
     
    114114            get { return (IValueLookupParameter<IOperator>)Parameters[AnnealingOperatorName]; }
    115115        }
    116         public IValueLookupParameter<IOperator> HeatingStrategyOperatorParameter
    117         {
    118             get { return (IValueLookupParameter<IOperator>)Parameters[HeatingStrategyOperatorName]; }
     116        public IValueLookupParameter<IOperator> ReheatingOperatorParameter
     117        {
     118            get { return (IValueLookupParameter<IOperator>)Parameters[ReheatingOperatorName]; }
    119119        }
    120120        public IValueLookupParameter<IOperator> AnalyzerParameter
     
    181181            Parameters.Add(new ValueLookupParameter<IOperator>(MoveMakerName, "The operator that performs a move and updates the quality."));
    182182            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."));
    184184
    185185            Parameters.Add(new ValueLookupParameter<IOperator>(AnalyzerName, "The operator used to analyze each generation."));
     
    245245            temperatureController.CoolingParameter.ActualName = CoolingParameter.Name;
    246246            temperatureController.EndTemperatureParameter.ActualName = EndTemperatureParameter.Name;
    247             temperatureController.HeatingStrategyOperatorParameter.ActualName = HeatingStrategyOperatorParameter.Name;
     247            temperatureController.ReheatingOperatorParameter.ActualName = ReheatingOperatorParameter.Name;
    248248            temperatureController.IsAcceptedParameter.ActualName = IsAcceptedName;
    249249            temperatureController.IterationsParameter.ActualName = IterationsParameter.Name;
  • branches/jschiess/HeuristicLab.Algorithms.SimulatedAnnealing/3.3/TemperatureController.cs

    r14452 r14555  
    3838    {
    3939        #region Strings
     40        private const string ReheatingOperatorName = "ReheatingOperator";
    4041        private const string AnnealingOperatorName = "AnnealingOperator";
    41         private const string HeatingStrategyOperatorName = "HeatingStrategyOperator";
    4242        private const string MaximumIterationsName = "MaximumIterations";
    4343        private const string LowerTemperatureName = "LowerTemperature";
     
    8989            get { return (IValueLookupParameter<IOperator>)Parameters[AnnealingOperatorName]; }
    9090        }
    91         public IValueLookupParameter<ISimulatedAnnealingHeatingStrategy> HeatingStrategyOperatorParameter
     91        public IValueLookupParameter<IReheatingOperator> ReheatingOperatorParameter
    9292        {
    93             get { return (IValueLookupParameter<ISimulatedAnnealingHeatingStrategy>)Parameters[HeatingStrategyOperatorName]; }
     93            get { return (IValueLookupParameter<IReheatingOperator>)Parameters[ReheatingOperatorName]; }
    9494        }
    9595        public ILookupParameter<BoolValue> IsAcceptedParameter
     
    114114            Parameters.Add(new ValueLookupParameter<IntValue>(MaximumIterationsName, "The maximum number of iterations which should be processed."));
    115115            Parameters.Add(new ValueLookupParameter<IOperator>(AnnealingOperatorName, "The operator that cools the temperature."));
    116             Parameters.Add(new ValueLookupParameter<ISimulatedAnnealingHeatingStrategy>(HeatingStrategyOperatorName, "The operator that heats the temperature."));
     116            Parameters.Add(new ValueLookupParameter<IReheatingOperator>(ReheatingOperatorName, "The operator that reheats the temperature if necessary."));
    117117            Parameters.Add(new LookupParameter<IntValue>(TemperatureStartIndexName, "The index where the annealing or heating was last changed."));
    118118            Parameters.Add(new LookupParameter<BoolValue>(CoolingName, "True when the temperature should be cooled, false otherwise."));
     
    130130        public override IOperation Apply()
    131131        {
    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),
    157134                    base.Apply()
    158135                };
    159             }else
    160             {
    161                 // else just use the heating parameter
    162                 return new OperationCollection {
    163                     ExecutionContext.CreateOperation(HeatingStrategyOperatorParameter.ActualValue),
    164                     base.Apply()
    165                 };
    166             }
    167136        }
    168137    }
Note: See TracChangeset for help on using the changeset viewer.