Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/10/17 15:31:35 (7 years ago)
Author:
bwerth
Message:

#2592 formatting & removed unreferenced enum

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/MOCMAEvolutionStrategy/HeuristicLab.Algorithms.MOCMAEvolutionStrategy/3.3/MOCMAEvolutionStrategy.cs

    r15089 r15176  
    4242  [System.Runtime.InteropServices.Guid("5AC20A69-BBBF-4153-B57D-3EAF92DC505E")]
    4343  public class MOCMAEvolutionStrategy : BasicAlgorithm {
    44     public override Type ProblemType
    45     {
     44    public override Type ProblemType {
    4645      get { return typeof(MultiObjectiveBasicProblem<RealVectorEncoding>); }
    4746    }
    48     public new MultiObjectiveBasicProblem<RealVectorEncoding> Problem
    49     {
     47    public new MultiObjectiveBasicProblem<RealVectorEncoding> Problem {
    5048      get { return (MultiObjectiveBasicProblem<RealVectorEncoding>)base.Problem; }
    5149      set { base.Problem = value; }
    5250    }
    53     public override bool SupportsPause
    54     {
     51    public override bool SupportsPause {
    5552      get { return true; }
    5653    }
    5754
    58     #region storable fields
     55    #region Storable fields
    5956    [Storable]
    6057    private IRandom random = new MersenneTwister();
     
    106103
    107104    #region ParameterProperties
    108     public IFixedValueParameter<IntValue> MaximumRuntimeParameter
    109     {
     105    public IFixedValueParameter<IntValue> MaximumRuntimeParameter {
    110106      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumRuntimeName]; }
    111107    }
    112     public IFixedValueParameter<IntValue> SeedParameter
    113     {
     108    public IFixedValueParameter<IntValue> SeedParameter {
    114109      get { return (IFixedValueParameter<IntValue>)Parameters[SeedName]; }
    115110    }
    116     public FixedValueParameter<BoolValue> SetSeedRandomlyParameter
    117     {
     111    public FixedValueParameter<BoolValue> SetSeedRandomlyParameter {
    118112      get { return (FixedValueParameter<BoolValue>)Parameters[SetSeedRandomlyName]; }
    119113    }
    120     public IFixedValueParameter<IntValue> PopulationSizeParameter
    121     {
     114    public IFixedValueParameter<IntValue> PopulationSizeParameter {
    122115      get { return (IFixedValueParameter<IntValue>)Parameters[PopulationSizeName]; }
    123116    }
    124     public IFixedValueParameter<IntValue> MaximumGenerationsParameter
    125     {
     117    public IFixedValueParameter<IntValue> MaximumGenerationsParameter {
    126118      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumGenerationsName]; }
    127119    }
    128     public IFixedValueParameter<IntValue> MaximumEvaluatedSolutionsParameter
    129     {
     120    public IFixedValueParameter<IntValue> MaximumEvaluatedSolutionsParameter {
    130121      get { return (IFixedValueParameter<IntValue>)Parameters[MaximumEvaluatedSolutionsName]; }
    131122    }
    132     public IValueParameter<DoubleArray> InitialSigmaParameter
    133     {
     123    public IValueParameter<DoubleArray> InitialSigmaParameter {
    134124      get { return (IValueParameter<DoubleArray>)Parameters[InitialSigmaName]; }
    135125    }
    136     public IConstrainedValueParameter<IIndicator> IndicatorParameter
    137     {
     126    public IConstrainedValueParameter<IIndicator> IndicatorParameter {
    138127      get { return (IConstrainedValueParameter<IIndicator>)Parameters[IndicatorName]; }
    139128    }
     
    141130
    142131    #region Properties
    143     public int MaximumRuntime
    144     {
     132    public int MaximumRuntime {
    145133      get { return MaximumRuntimeParameter.Value.Value; }
    146134      set { MaximumRuntimeParameter.Value.Value = value; }
    147135    }
    148     public int Seed
    149     {
     136    public int Seed {
    150137      get { return SeedParameter.Value.Value; }
    151138      set { SeedParameter.Value.Value = value; }
    152139    }
    153     public bool SetSeedRandomly
    154     {
     140    public bool SetSeedRandomly {
    155141      get { return SetSeedRandomlyParameter.Value.Value; }
    156142      set { SetSeedRandomlyParameter.Value.Value = value; }
    157143    }
    158     public int PopulationSize
    159     {
     144    public int PopulationSize {
    160145      get { return PopulationSizeParameter.Value.Value; }
    161146      set { PopulationSizeParameter.Value.Value = value; }
    162147    }
    163     public int MaximumGenerations
    164     {
     148    public int MaximumGenerations {
    165149      get { return MaximumGenerationsParameter.Value.Value; }
    166150      set { MaximumGenerationsParameter.Value.Value = value; }
    167151    }
    168     public int MaximumEvaluatedSolutions
    169     {
     152    public int MaximumEvaluatedSolutions {
    170153      get { return MaximumEvaluatedSolutionsParameter.Value.Value; }
    171154      set { MaximumEvaluatedSolutionsParameter.Value.Value = value; }
    172155    }
    173     public DoubleArray InitialSigma
    174     {
     156    public DoubleArray InitialSigma {
    175157      get { return InitialSigmaParameter.Value; }
    176158      set { InitialSigmaParameter.Value = value; }
    177159    }
    178     public IIndicator Indicator
    179     {
     160    public IIndicator Indicator {
    180161      get { return IndicatorParameter.Value; }
    181162      set { IndicatorParameter.Value = value; }
     
    192173
    193174    #region ResultsProperties
    194     private int ResultsEvaluations
    195     {
     175    private int ResultsEvaluations {
    196176      get { return ((IntValue)Results[EvaluationsResultName].Value).Value; }
    197177      set { ((IntValue)Results[EvaluationsResultName].Value).Value = value; }
    198178    }
    199     private int ResultsIterations
    200     {
     179    private int ResultsIterations {
    201180      get { return ((IntValue)Results[IterationsResultName].Value).Value; }
    202181      set { ((IntValue)Results[IterationsResultName].Value).Value = value; }
    203182    }
    204183    #region Datatable
    205     private DataTable ResultsQualities
    206     {
     184    private DataTable ResultsQualities {
    207185      get { return (DataTable)Results[TimetableResultName].Value; }
    208186    }
    209     private DataRow ResultsBestHypervolumeDataLine
    210     {
     187    private DataRow ResultsBestHypervolumeDataLine {
    211188      get { return ResultsQualities.Rows[BestHypervolumeResultName]; }
    212189    }
    213     private DataRow ResultsHypervolumeDataLine
    214     {
     190    private DataRow ResultsHypervolumeDataLine {
    215191      get { return ResultsQualities.Rows[HypervolumeResultName]; }
    216192    }
    217     private DataRow ResultsGenerationalDistanceDataLine
    218     {
     193    private DataRow ResultsGenerationalDistanceDataLine {
    219194      get { return ResultsQualities.Rows[GenerationalDistanceResultName]; }
    220195    }
    221     private DataRow ResultsInvertedGenerationalDistanceDataLine
    222     {
     196    private DataRow ResultsInvertedGenerationalDistanceDataLine {
    223197      get { return ResultsQualities.Rows[InvertedGenerationalDistanceResultName]; }
    224198    }
    225     private DataRow ResultsCrowdingDataLine
    226     {
     199    private DataRow ResultsCrowdingDataLine {
    227200      get { return ResultsQualities.Rows[CrowdingResultName]; }
    228201    }
    229     private DataRow ResultsSpacingDataLine
    230     {
     202    private DataRow ResultsSpacingDataLine {
    231203      get { return ResultsQualities.Rows[SpacingResultName]; }
    232204    }
    233     private DataRow ResultsHypervolumeDifferenceDataLine
    234     {
     205    private DataRow ResultsHypervolumeDifferenceDataLine {
    235206      get { return ResultsQualities.Rows[DifferenceToBestKnownHypervolumeResultName]; }
    236207    }
    237208    #endregion
    238209    //QualityIndicators
    239     private double ResultsHypervolume
    240     {
     210    private double ResultsHypervolume {
    241211      get { return ((DoubleValue)Results[HypervolumeResultName].Value).Value; }
    242212      set { ((DoubleValue)Results[HypervolumeResultName].Value).Value = value; }
    243213    }
    244     private double ResultsGenerationalDistance
    245     {
     214    private double ResultsGenerationalDistance {
    246215      get { return ((DoubleValue)Results[GenerationalDistanceResultName].Value).Value; }
    247216      set { ((DoubleValue)Results[GenerationalDistanceResultName].Value).Value = value; }
    248217    }
    249     private double ResultsInvertedGenerationalDistance
    250     {
     218    private double ResultsInvertedGenerationalDistance {
    251219      get { return ((DoubleValue)Results[InvertedGenerationalDistanceResultName].Value).Value; }
    252220      set { ((DoubleValue)Results[InvertedGenerationalDistanceResultName].Value).Value = value; }
    253221    }
    254     private double ResultsCrowding
    255     {
     222    private double ResultsCrowding {
    256223      get { return ((DoubleValue)Results[CrowdingResultName].Value).Value; }
    257224      set { ((DoubleValue)Results[CrowdingResultName].Value).Value = value; }
    258225    }
    259     private double ResultsSpacing
    260     {
     226    private double ResultsSpacing {
    261227      get { return ((DoubleValue)Results[SpacingResultName].Value).Value; }
    262228      set { ((DoubleValue)Results[SpacingResultName].Value).Value = value; }
    263229    }
    264     private double ResultsBestHypervolume
    265     {
     230    private double ResultsBestHypervolume {
    266231      get { return ((DoubleValue)Results[BestHypervolumeResultName].Value).Value; }
    267232      set { ((DoubleValue)Results[BestHypervolumeResultName].Value).Value = value; }
    268233    }
    269     private double ResultsBestKnownHypervolume
    270     {
     234    private double ResultsBestKnownHypervolume {
    271235      get { return ((DoubleValue)Results[BestKnownHypervolumeResultName].Value).Value; }
    272236      set { ((DoubleValue)Results[BestKnownHypervolumeResultName].Value).Value = value; }
    273237    }
    274     private double ResultsDifferenceBestKnownHypervolume
    275     {
     238    private double ResultsDifferenceBestKnownHypervolume {
    276239      get { return ((DoubleValue)Results[DifferenceToBestKnownHypervolumeResultName].Value).Value; }
    277240      set { ((DoubleValue)Results[DifferenceToBestKnownHypervolumeResultName].Value).Value = value; }
     
    279242    }
    280243    //Solutions
    281     private DoubleMatrix ResultsSolutions
    282     {
     244    private DoubleMatrix ResultsSolutions {
    283245      get { return (DoubleMatrix)Results[CurrentFrontResultName].Value; }
    284246      set { Results[CurrentFrontResultName].Value = value; }
    285247    }
    286     private ScatterPlotContent ResultsScatterPlot
    287     {
     248    private ScatterPlotContent ResultsScatterPlot {
    288249      get { return (ScatterPlotContent)Results[ScatterPlotResultName].Value; }
    289250      set { Results[ScatterPlotResultName].Value = value; }
     
    401362        ResultsDifferenceBestKnownHypervolume = ResultsBestKnownHypervolume;
    402363      }
    403       //TODO? move FrontScatterPlotContent partially? to MultiobjectiveTestProblem?
    404364      ResultsScatterPlot = new ScatterPlotContent(new double[0][], new double[0][], problem.BestKnownFront.ToJaggedArray(), problem.Objectives);
    405365    }
     
    413373          ResultsIterations++;
    414374          cancellationToken.ThrowIfCancellationRequested();
    415         }
    416         finally {
     375        } finally {
    417376          Analyze();
    418377        }
    419378      }
    420 
    421 
    422379    }
    423380    private void Iterate() {
     
    483440      int[] ranks;
    484441      var fronts = DominationCalculator<Individual>.CalculateAllParetoFronts(parents.ToArray(), parents.Select(i => i.PenalizedFitness).ToArray(), Problem.Maximization, out ranks);
    485       // NonDominatedSort(parents, individual => individual.PenalizedFitness);
    486442
    487443      //deselect the highest rank fronts until we would end up with less or equal mu elements
     
    508464      foreach (var p in parents.Skip(solutions.Length).Where(i => i.Selected))
    509465        p.UpdateAsOffspring();
    510 
    511466      for (var i = 0; i < solutions.Length; i++)
    512467        if (parents[i].Selected)
    513468          parents[i].UpdateAsParent(parents[i + solutions.Length].Selected);
    514 
    515469      solutions = parents.Where(p => p.Selected).ToArray();
    516470    }
    517471
    518472    private void Analyze() {
    519       //TODO? move FrontScatterPlotContent partially to MultiobjectiveTestProblem
    520473      ResultsScatterPlot = new ScatterPlotContent(solutions.Select(x => x.Fitness).ToArray(), solutions.Select(x => x.Mean.ToArray()).ToArray(), ResultsScatterPlot.ParetoFront, ResultsScatterPlot.Objectives);
    521 
    522474      ResultsSolutions = solutions.Select(x => x.Mean.ToArray()).ToMatrix();
    523475
     
    550502        random);
    551503    }
    552 
    553504  }
    554505}
Note: See TracChangeset for help on using the changeset viewer.