Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/11/15 11:21:44 (8 years ago)
Author:
bwerth
Message:

#1087 implemented more Testfunctions; enabled setting of SolutionSize

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/MultiObjectiveTestFunctionProblem.cs

    r13421 r13448  
    2121      get {
    2222        return Parameters.ContainsKey("TestFunction") ? TestFunction.Maximization : new bool[2];
    23       } //TODO shady
     23      }
    2424    }
    2525
    2626    #region Parameter Properties
     27
     28
    2729    private IFixedValueParameter<IntValue> ProblemSizeParameter {
    2830      get { return (IFixedValueParameter<IntValue>)Parameters["ProblemSize"]; }
     
    7375      Parameters.Add(new FixedValueParameter<IntValue>("ProblemSize", "The dimensionality of the problem instance (number of variables in the function).", new IntValue(2)));
    7476      Parameters.Add(new FixedValueParameter<IntValue>("SolutionSize", "The dimensionality of the solution vector (number of objectives).", new IntValue(2)));
    75       Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The bounds of the solution given as either one line for all variables or a line for each variable. The first column specifies lower bound, the second upper bound.", new DoubleMatrix(new double[,] { { -100, 100 } })));
     77      Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The bounds of the solution given as either one line for all variables or a line for each variable. The first column specifies lower bound, the second upper bound.", new DoubleMatrix(new double[,] { { -4, 4 } })));
    7678      Parameters.Add(new ValueParameter<IMultiObjectiveTestFunction>("TestFunction", "The function that is to be optimized.", new Fonseca()));
    7779
     
    9799      TestFunctionParameter.ValueChanged += TestFunctionParameterOnValueChanged;
    98100      ProblemSizeParameter.Value.ValueChanged += ProblemSizeOnValueChanged;
     101      SolutionSizeParameter.Value.ValueChanged += SolutionSizeOnValueChanged;
    99102      BoundsParameter.ValueChanged += BoundsParameterOnValueChanged;
    100103    }
    101104
    102     public double[] Evaluate(RealVector vector, IRandom random) {
    103       return TestFunction.Evaluate(vector);
     105    public double[] Evaluate(RealVector individual, IRandom random) {
     106      return TestFunction.Evaluate(individual);
    104107    }
    105     public sealed override double[] Evaluate(Individual individual, IRandom random) {
     108
     109    public override double[] Evaluate(Individual individual, IRandom random) {
    106110      return Evaluate(individual.RealVector(), random);
    107111    }
     112
    108113
    109114    #region Events
     
    114119    protected override void OnEvaluatorChanged() {
    115120      base.OnEvaluatorChanged();
    116      // Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
     121      // Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
    117122      Parameterize();
    118123    }
     124
    119125    //private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    120126    //  Parameterize();
     
    134140        ProblemSize = Math.Max(TestFunction.MinimumSolutionSize, Math.Min(SolutionSize, TestFunction.MaximumSolutionSize));
    135141      }
    136 
    137142      Bounds = (DoubleMatrix)TestFunction.Bounds.Clone();
    138143      OnReset();
     
    143148        || ProblemSize > TestFunction.MaximumProblemSize)
    144149        ProblemSize = Math.Min(TestFunction.MaximumProblemSize, Math.Max(TestFunction.MinimumProblemSize, ProblemSize));
     150      //TODO problemsize dominates solutionSize
     151      SolutionSizeOnValueChanged(sender, eventArgs);
    145152    }
    146153
    147154    private void SolutionSizeOnValueChanged(object sender, EventArgs eventArgs) {
    148155      if (SolutionSize < TestFunction.MinimumSolutionSize
    149         || ProblemSize > TestFunction.MaximumSolutionSize)
    150         ProblemSize = Math.Min(TestFunction.MaximumSolutionSize, Math.Max(TestFunction.MinimumSolutionSize, SolutionSize));
     156        || SolutionSize > TestFunction.MaximumSolutionSize)
     157        SolutionSize = Math.Min(TestFunction.MaximumSolutionSize, Math.Max(TestFunction.MinimumSolutionSize, SolutionSize));
     158      TestFunction.ActualSolutionSize = SolutionSize;
     159      OnReset();
    151160    }
    152161
     
    163172
    164173    private void Parameterize() {
    165       //empty for now
    166174    }
     175
     176   
    167177    #endregion
    168 
    169 
    170178  }
    171179}
Note: See TracChangeset for help on using the changeset viewer.