Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/24/09 00:58:23 (15 years ago)
Author:
abeham
Message:

Updated ES to uniformly distributed initialization of strategy vector #495
Fixed Plus/Comma display bug on load #491
Removed some unnecessary references
Added necessary reference to RealVector

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ES/ES.cs

    r1091 r1222  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Text;
    2524using System.Xml;
    2625using HeuristicLab.Core;
    2726using HeuristicLab.Data;
    28 using HeuristicLab.SequentialEngine;
    2927using HeuristicLab.Operators;
    3028using HeuristicLab.Random;
    3129using HeuristicLab.Logging;
    3230using HeuristicLab.Selection;
    33 using HeuristicLab.Selection.OffspringSelection;
    34 using HeuristicLab.Evolutionary;
     31using HeuristicLab.RealVector;
    3532
    3633namespace HeuristicLab.ES {
     
    132129      vi.AddVariable(new Variable("EvaluatedSolutions", new IntData()));
    133130      vi.AddVariable(new Variable("PlusNotation", new BoolData(true)));
     131      vi.AddVariable(new Variable("ProblemDimension", new IntData(1)));
     132      vi.AddVariable(new Variable("ShakingFactorsMin", new DoubleData(0.1)));
     133      vi.AddVariable(new Variable("ShakingFactorsMax", new DoubleData(5.0)));
    134134      vi.AddVariable(new Variable("Generations", new IntData()));
    135135      vi.AddVariable(new Variable("MaximumGenerations", new IntData(1000)));
    136       vi.AddVariable(new Variable("GeneralLearningRate", new DoubleData(0.1)));
    137       vi.AddVariable(new Variable("LearningRate", new DoubleData(0.1)));
     136      vi.AddVariable(new Variable("GeneralLearningRate", new DoubleData(1.0 / Math.Sqrt(2))));
     137      vi.AddVariable(new Variable("LearningRate", new DoubleData(1.0 / Math.Sqrt(2))));
    138138      op.OperatorGraph.AddOperator(vi);
    139139      sp.AddSubOperator(vi);
     
    177177      sp2.AddSubOperator(c);
    178178
    179       VariableInjector vi = new VariableInjector();
    180       vi.AddVariable(new Variable("ShakingFactors", new DoubleArrayData(new double[] { 5.0 })));
    181       op.OperatorGraph.AddOperator(vi);
    182       sp2.AddSubOperator(vi);
     179      UniformRandomRealVectorGenerator urrvg = new UniformRandomRealVectorGenerator();
     180      urrvg.GetVariableInfo("Length").ActualName = "ProblemDimension";
     181      urrvg.GetVariableInfo("Minimum").ActualName = "ShakingFactorsMin";
     182      urrvg.GetVariableInfo("Maximum").ActualName = "ShakingFactorsMax";
     183      urrvg.GetVariableInfo("RealVector").ActualName = "ShakingFactors";
     184      op.OperatorGraph.AddOperator(urrvg);
     185      sp2.AddSubOperator(urrvg);
    183186
    184187      Sorter s = new Sorter();
     
    456459      }
    457460    }
    458     private DoubleArrayData myShakingFactors;
    459     /// <summary>
    460     /// Gets or sets the initial strategy vector s(0).
     461    private IntData myProblemDimension;
     462    /// <summary>
     463    /// Gets or sets the problem dimension which determines the length of the strategy vector.
    461464    /// </summary>
    462465    /// <remarks>Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/>
    463466    /// in the setter.</remarks>
    464     public double[] ShakingFactors {
    465       get { return myShakingFactors.Data; }
    466       set { myShakingFactors.Data = value; }
     467    public int ProblemDimension {
     468      get { return myProblemDimension.Data; }
     469      set { myProblemDimension.Data = value; }
     470    }
     471    private DoubleData myShakingFactorsMin;
     472    /// <summary>
     473    /// Gets or sets the minimal value for each dimension of the strategy vector.
     474    /// </summary>
     475    /// <remarks>Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/>
     476    /// in the setter.</remarks>
     477    public double ShakingFactorsMin {
     478      get { return myShakingFactorsMin.Data; }
     479      set {
     480        myShakingFactorsMin.Data = value;
     481        OnChanged();
     482      }
     483    }
     484    private DoubleData myShakingFactorsMax;
     485    /// <summary>
     486    /// Gets or sets the maximal value for each dimension of the strategy vector.
     487    /// </summary>
     488    /// <remarks>Calls <see cref="ItemBase.OnChanged"/> of base class <see cref="ItemBase"/>
     489    /// in the setter.</remarks>
     490    public double ShakingFactorsMax {
     491      get { return myShakingFactorsMax.Data; }
     492      set {
     493        myShakingFactorsMax.Data = value;
     494        OnChanged();
     495      }
    467496    }
    468497    private DoubleData myGeneralLearningRate;
     
    633662      myMaximumGenerations = vi.GetVariable("MaximumGenerations").GetValue<IntData>();
    634663      myPlusNotation = vi.GetVariable("PlusNotation").GetValue<BoolData>();
     664      myProblemDimension = vi.GetVariable("ProblemDimension").GetValue<IntData>();
     665      myShakingFactorsMin = vi.GetVariable("ShakingFactorsMin").GetValue<DoubleData>();
     666      myShakingFactorsMax = vi.GetVariable("ShakingFactorsMax").GetValue<DoubleData>();
    635667      myGeneralLearningRate = vi.GetVariable("GeneralLearningRate").GetValue<DoubleData>();
    636668      myLearningRate = vi.GetVariable("LearningRate").GetValue<DoubleData>();
     
    638670      CombinedOperator co3 = (CombinedOperator)sp1.SubOperators[1];
    639671      myPopulationInitialization = co3;
    640       // Variable Injector
    641       VariableInjector vi2 = (VariableInjector)co3.OperatorGraph.InitialOperator.SubOperators[1].SubOperators[0].SubOperators[3];
    642       myShakingFactors = vi2.GetVariable("ShakingFactors").GetValue<DoubleArrayData>();
    643672      // ES Main
    644673      CombinedOperator co4 = (CombinedOperator)sp1.SubOperators[2];
Note: See TracChangeset for help on using the changeset viewer.