Changeset 13403


Ignore:
Timestamp:
11/25/15 23:24:01 (4 years ago)
Author:
abeham
Message:

#2521:

  • Adapted single-objective test function problem to new problem infrastructure
  • Added additional interfaces to RealVectorEncoding
  • Fixed IParticleUpdater interface (must implement IStochasticOperator if it contains a Random parameter)
Location:
branches/ProblemRefactoring
Files:
5 added
33 deleted
34 edited
16 copied
3 moved

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj

    r11961 r13403  
    115115  <ItemGroup>
    116116    <Compile Include="Creators\NormalDistributedRealVectorCreator.cs" />
     117    <Compile Include="Interfaces\IRealVectorAdditiveMoveQualityOperator.cs" />
     118    <Compile Include="Interfaces\IRealVectorBoundedOperator.cs" />
    117119    <Compile Include="Interfaces\IRealVectorMultiNeighborhoodShakingOperator.cs" />
     120    <Compile Include="Interfaces\IRealVectorSolutionsOperator.cs" />
     121    <Compile Include="Interfaces\IRealVectorSolutionOperator.cs" />
    118122    <Compile Include="ParticleOperators\RealVectorParticleCreator.cs" />
    119123    <Compile Include="Crossovers\BlendAlphaBetaCrossover.cs" />
     
    157161    <Compile Include="Interfaces\IRealVectorStdDevStrategyParameterManipulator.cs" />
    158162    <Compile Include="Interfaces\IRealVectorStdDevStrategyParameterOperator.cs" />
    159     <Compile Include="Interfaces\IAdditiveRealVectorMoveOperator.cs" />
     163    <Compile Include="Interfaces\IRealVectorAdditiveMoveOperator.cs" />
    160164    <Compile Include="Interfaces\IRealVectorBoundsChecker.cs" />
    161165    <Compile Include="Interfaces\IRealVectorMoveGenerator.cs" />
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorAdditiveMoveOperator.cs

    r13402 r13403  
    2323
    2424namespace HeuristicLab.Encodings.RealVectorEncoding {
    25   public interface IAdditiveRealVectorMoveOperator : IRealVectorMoveOperator {
     25  public interface IRealVectorAdditiveMoveOperator : IRealVectorMoveOperator {
    2626    ILookupParameter<AdditiveMove> AdditiveMoveParameter { get; }
    2727  }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorAdditiveMoveQualityOperator.cs

    r13393 r13403  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Data;
    2324
    2425namespace HeuristicLab.Encodings.RealVectorEncoding {
    25   public interface IAdditiveRealVectorMoveOperator : IRealVectorMoveOperator {
    26     ILookupParameter<AdditiveMove> AdditiveMoveParameter { get; }
     26  public interface IRealVectorAdditiveMoveQualityOperator : IRealVectorAdditiveMoveOperator {
     27    ILookupParameter<DoubleValue> MoveQualityParameter { get; }
    2728  }
    2829}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorCreator.cs

    r13361 r13403  
    2828  /// An interface which represents an operator for creating vectors of real-valued data.
    2929  /// </summary>
    30   public interface IRealVectorCreator : IRealVectorOperator, ISolutionCreator<RealVector> {
     30  public interface IRealVectorCreator : IRealVectorSolutionOperator, IRealVectorBoundedOperator, ISolutionCreator<RealVector> {
    3131    IValueLookupParameter<IntValue> LengthParameter { get; }
    32     IValueLookupParameter<DoubleMatrix> BoundsParameter { get; }
    33     ILookupParameter<RealVector> RealVectorParameter { get; }
    3432  }
    3533}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorCrossover.cs

    r12012 r13403  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2423using HeuristicLab.Optimization;
    2524
     
    2827  /// An interface which represents an operator for crossing vectors of real-valued data.
    2928  /// </summary>
    30   public interface IRealVectorCrossover : IRealVectorOperator, ICrossover {
     29  public interface IRealVectorCrossover : IRealVectorBoundedOperator, ICrossover {
    3130    ILookupParameter<ItemArray<RealVector>> ParentsParameter { get; }
    3231    ILookupParameter<RealVector> ChildParameter { get; }
    33     IValueLookupParameter<DoubleMatrix> BoundsParameter { get; }
    3432  }
    3533}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorManipulator.cs

    r12012 r13403  
    2020#endregion
    2121
    22 using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2422using HeuristicLab.Optimization;
    2523
     
    2826  /// An interface which represents an operator for manipulating vectors of real-valued data.
    2927  /// </summary>
    30   public interface IRealVectorManipulator : IRealVectorOperator, IManipulator {
    31     ILookupParameter<RealVector> RealVectorParameter { get; }
    32     IValueLookupParameter<DoubleMatrix> BoundsParameter { get; }
     28  public interface IRealVectorManipulator : IRealVectorSolutionOperator, IRealVectorBoundedOperator, IManipulator {
    3329  }
    3430}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorMoveGenerator.cs

    r12012 r13403  
    2020#endregion
    2121
    22 using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2422using HeuristicLab.Optimization;
    2523
    2624namespace HeuristicLab.Encodings.RealVectorEncoding {
    27   public interface IRealVectorMoveGenerator : IRealVectorMoveOperator, IMoveGenerator {
    28     IValueLookupParameter<DoubleMatrix> BoundsParameter { get; }
     25  public interface IRealVectorMoveGenerator : IRealVectorMoveOperator, IRealVectorBoundedOperator, IMoveGenerator {
    2926  }
    3027}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorMoveOperator.cs

    r12012 r13403  
    2020#endregion
    2121
    22 using HeuristicLab.Core;
    2322using HeuristicLab.Optimization;
    2423
    2524namespace HeuristicLab.Encodings.RealVectorEncoding {
    26   public interface IRealVectorMoveOperator : IRealVectorOperator, IMoveOperator {
    27     ILookupParameter<RealVector> RealVectorParameter { get; }
     25  public interface IRealVectorMoveOperator : IRealVectorSolutionOperator, IMoveOperator {
    2826  }
    2927}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorMultiNeighborhoodShakingOperator.cs

    r12012 r13403  
    2020#endregion
    2121
    22 using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2422
    2523namespace HeuristicLab.Encodings.RealVectorEncoding {
    26   public interface IRealVectorMultiNeighborhoodShakingOperator : IRealVectorOperator {
    27     ILookupParameter<RealVector> RealVectorParameter { get; }
    28     IValueLookupParameter<DoubleMatrix> BoundsParameter { get; }
     24  public interface IRealVectorMultiNeighborhoodShakingOperator : IRealVectorSolutionOperator, IRealVectorBoundedOperator {
    2925  }
    3026}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorParticleCreator.cs

    r12012 r13403  
    2020#endregion
    2121
    22 using HeuristicLab.Optimization;
    2322using HeuristicLab.Core;
    2423using HeuristicLab.Data;
     24using HeuristicLab.Optimization;
    2525
    2626namespace HeuristicLab.Encodings.RealVectorEncoding {
    27   public interface IRealVectorParticleCreator : IParticleCreator, IRealVectorOperator {
     27  public interface IRealVectorParticleCreator : IParticleCreator, IRealVectorSolutionOperator, IRealVectorBoundedOperator {
    2828    ILookupParameter<IntValue> ProblemSizeParameter { get; }
    29     ILookupParameter<RealVector> RealVectorParameter { get; }
    3029    ILookupParameter<RealVector> PersonalBestParameter { get; }
    31     IValueLookupParameter<DoubleMatrix> BoundsParameter { get; }
    3230    ILookupParameter<RealVector> VelocityParameter { get; }
    3331  }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorParticleUpdater.cs

    r12012 r13403  
    2525
    2626namespace HeuristicLab.Encodings.RealVectorEncoding {
    27   public interface IRealVectorParticleUpdater : IParticleUpdater, IRealVectorOperator {
     27  public interface IRealVectorParticleUpdater : IParticleUpdater, IRealVectorSolutionOperator, IRealVectorBoundedOperator {
    2828    ILookupParameter<RealVector> VelocityParameter { get; }
    2929    ILookupParameter<DoubleMatrix> CurrentVelocityBoundsParameter { get; }
    30     ILookupParameter<RealVector> RealVectorParameter { get; }
    31     ILookupParameter<DoubleMatrix> BoundsParameter { get; }
    3230    ILookupParameter<RealVector> PersonalBestParameter { get; }
    3331    ILookupParameter<RealVector> NeighborBestParameter { get; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorStdDevStrategyParameterCreator.cs

    r12012 r13403  
    2525
    2626namespace HeuristicLab.Encodings.RealVectorEncoding {
    27   public interface IRealVectorStdDevStrategyParameterCreator : IRealVectorStdDevStrategyParameterOperator, IStrategyParameterCreator {
     27  public interface IRealVectorStdDevStrategyParameterCreator : IRealVectorStdDevStrategyParameterOperator, IStrategyParameterCreator, IRealVectorBoundedOperator {
    2828    ILookupParameter<RealVector> StrategyParameterParameter { get; }
    2929    IValueLookupParameter<IntValue> LengthParameter { get; }
    30     IValueLookupParameter<DoubleMatrix> BoundsParameter { get; }
    3130  }
    3231}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorStdDevStrategyParameterManipulator.cs

    r12012 r13403  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Data;
    2423using HeuristicLab.Optimization;
    2524
    2625namespace HeuristicLab.Encodings.RealVectorEncoding {
    27   public interface IRealVectorStdDevStrategyParameterManipulator : IRealVectorStdDevStrategyParameterOperator, IStrategyParameterManipulator {
     26  public interface IRealVectorStdDevStrategyParameterManipulator : IRealVectorStdDevStrategyParameterOperator, IStrategyParameterManipulator, IRealVectorBoundedOperator {
    2827    ILookupParameter<RealVector> StrategyParameterParameter { get; }
    29     IValueLookupParameter<DoubleMatrix> BoundsParameter { get; }
    3028  }
    3129}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorSwarmUpdater.cs

    r12012 r13403  
    2121
    2222using HeuristicLab.Core;
    23 using HeuristicLab.Optimization; 
     23using HeuristicLab.Optimization;
    2424
    2525namespace HeuristicLab.Encodings.RealVectorEncoding {
    26   public interface IRealVectorSwarmUpdater : ISwarmUpdater, IRealVectorOperator {
     26  public interface IRealVectorSwarmUpdater : ISwarmUpdater, IRealVectorSolutionsOperator {
    2727    IScopeTreeLookupParameter<RealVector> NeighborBestParameter { get; }
    2828    IScopeTreeLookupParameter<RealVector> PersonalBestParameter { get; }
    29     IScopeTreeLookupParameter<RealVector> RealVectorParameter { get; }
    3029  }
    3130}
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Moves/AdditiveMoveGenerator.cs

    r12012 r13403  
    3131  [Item("AdditiveMoveGenerator", "Base class for all additive move generators.")]
    3232  [StorableClass]
    33   public abstract class AdditiveMoveGenerator : SingleSuccessorOperator, IAdditiveRealVectorMoveOperator, IMoveGenerator, IStochasticOperator {
     33  public abstract class AdditiveMoveGenerator : SingleSuccessorOperator, IRealVectorAdditiveMoveOperator, IMoveGenerator, IStochasticOperator {
    3434    public override bool CanChangeName {
    3535      get { return false; }
     
    4343    public ILookupParameter<AdditiveMove> AdditiveMoveParameter {
    4444      get { return (LookupParameter<AdditiveMove>)Parameters["AdditiveMove"]; }
    45     }
    46     protected ScopeParameter CurrentScopeParameter {
    47       get { return (ScopeParameter)Parameters["CurrentScope"]; }
    4845    }
    4946    public IValueLookupParameter<DoubleMatrix> BoundsParameter {
     
    5956      Parameters.Add(new LookupParameter<RealVector>("RealVector", "The real vector for which moves should be generated."));
    6057      Parameters.Add(new LookupParameter<AdditiveMove>("AdditiveMove", "The moves that should be generated in subscopes."));
    61       Parameters.Add(new ScopeParameter("CurrentScope", "The current scope where the moves should be added as subscopes."));
    6258      Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "A 2 column matrix specifying the lower and upper bound for each dimension. If there are less rows than dimension the bounds vector is cycled."));
    6359    }
     
    7268        moveScopes[i].Variables.Add(new Variable(AdditiveMoveParameter.ActualName, moves[i]));
    7369      }
    74       CurrentScopeParameter.ActualValue.SubScopes.AddRange(moveScopes);
     70      ExecutionContext.Scope.SubScopes.AddRange(moveScopes);
    7571      return base.Apply();
    7672    }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Moves/AdditiveMoveMaker.cs

    r12012 r13403  
    3131  [Item("AdditiveMoveMaker", "Peforms an additive move on a given real vector and updates the quality.")]
    3232  [StorableClass]
    33   public class AdditiveMoveMaker : SingleSuccessorOperator, IAdditiveRealVectorMoveOperator, IMoveMaker, ISingleObjectiveOperator {
     33  public class AdditiveMoveMaker : SingleSuccessorOperator, IRealVectorAdditiveMoveQualityOperator, IMoveMaker, ISingleObjectiveOperator {
    3434    public override bool CanChangeName {
    3535      get { return false; }
     
    6363    }
    6464
     65    public static void Apply(RealVector realVector, AdditiveMove move) {
     66      realVector[move.Dimension] += move.MoveDistance;
     67    }
     68
    6569    public override IOperation Apply() {
    66       AdditiveMove move = AdditiveMoveParameter.ActualValue;
    67       RealVector realVector = RealVectorParameter.ActualValue;
    68       DoubleValue moveQuality = MoveQualityParameter.ActualValue;
    69       DoubleValue quality = QualityParameter.ActualValue;
     70      Apply(RealVectorParameter.ActualValue, AdditiveMoveParameter.ActualValue);
     71      var moveQuality = MoveQualityParameter.ActualValue;
     72      var quality = QualityParameter.ActualValue;
    7073
    71       realVector[move.Dimension] += move.MoveDistance;
    7274      quality.Value = moveQuality.Value;
    7375
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Moves/AdditiveMoveTabuChecker.cs

    r12012 r13403  
    3232  [Item("AdditiveMoveTabuChecker", "Prevents falling back into ranges that have been moved over before.")]
    3333  [StorableClass]
    34   public class AdditiveMoveTabuChecker : SingleSuccessorOperator, IAdditiveRealVectorMoveOperator, ITabuChecker {
     34  public class AdditiveMoveTabuChecker : SingleSuccessorOperator, IRealVectorAdditiveMoveQualityOperator, ITabuChecker {
    3535    public override bool CanChangeName {
    3636      get { return false; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Moves/AdditiveMoveTabuMaker.cs

    r12012 r13403  
    2929  [Item("AdditiveMoveTabuMaker", "Sets the move tabu.")]
    3030  [StorableClass]
    31   public class AdditiveMoveTabuMaker : TabuMaker, IAdditiveRealVectorMoveOperator {
     31  public class AdditiveMoveTabuMaker : TabuMaker, IRealVectorAdditiveMoveQualityOperator {
    3232    public ILookupParameter<AdditiveMove> AdditiveMoveParameter {
    3333      get { return (ILookupParameter<AdditiveMove>)Parameters["AdditiveMove"]; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorParticleUpdater.cs

    r12012 r13403  
    5757      get { return (ILookupParameter<RealVector>)Parameters["RealVector"]; }
    5858    }
    59     public ILookupParameter<DoubleMatrix> BoundsParameter {
    60       get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
     59    public IValueLookupParameter<DoubleMatrix> BoundsParameter {
     60      get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
    6161    }
    6262    public ILookupParameter<DoubleMatrix> CurrentVelocityBoundsParameter {
     
    124124      Parameters.Add(new LookupParameter<RealVector>("BestRealVector", "Global best position."));
    125125      Parameters.Add(new LookupParameter<RealVector>("NeighborBest", "Best neighboring solution."));
    126       Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
     126      Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds for each dimension of the position vector for the current problem."));
    127127      Parameters.Add(new LookupParameter<DoubleMatrix>("CurrentVelocityBounds", "Upper and lower bounds for the particle's velocity vector."));
    128128      Parameters.Add(new LookupParameter<DoubleValue>("CurrentInertia", "The weight for the particle's velocity vector."));
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/ParticleOperators/RealVectorSwarmUpdater.cs

    r12012 r13403  
    5454      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["NeighborBestQuality"]; }
    5555    }
    56     public IScopeTreeLookupParameter<RealVector> RealVectorParameter {
    57       get { return (IScopeTreeLookupParameter<RealVector>)Parameters["RealVector"]; }
     56    public IScopeTreeLookupParameter<RealVector> RealVectorsParameter {
     57      get { return (IScopeTreeLookupParameter<RealVector>)Parameters["RealVectors"]; }
    5858    }
    5959    public IScopeTreeLookupParameter<RealVector> PersonalBestParameter {
     
    131131      set { NeighborBestQualityParameter.ActualValue = value; }
    132132    }
    133     private ItemArray<RealVector> RealVector {
    134       get { return RealVectorParameter.ActualValue; }
     133    private ItemArray<RealVector> RealVectors {
     134      get { return RealVectorsParameter.ActualValue; }
    135135    }
    136136    private ItemArray<RealVector> PersonalBest {
     
    186186      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("PersonalBestQuality", "Particles' personal best qualities."));
    187187      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("NeighborBestQuality", "Best neighbor particles' qualities."));
    188       Parameters.Add(new ScopeTreeLookupParameter<RealVector>("RealVector", "Particles' positions."));
     188      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("RealVectors", "Particles' positions."));
    189189      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("PersonalBest", "Particles' personal best positions."));
    190190      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("NeighborBest", "Neighborhood (or global in case of totally connected neighborhood) best particle positions."));
     
    288288        SwarmBestQuality = new DoubleValue();
    289289      SwarmBestQuality.Value = Maximization ? Quality.Max(v => v.Value) : Quality.Min(v => v.Value);
    290       BestRealVector = (RealVector)RealVector[Quality.FindIndex(v => v.Value == SwarmBestQuality.Value)].Clone();
     290      BestRealVector = (RealVector)RealVectors[Quality.FindIndex(v => v.Value == SwarmBestQuality.Value)].Clone();
    291291    }
    292292
     
    296296        var neighborBestQuality = new ItemArray<DoubleValue>(Neighbors.Length);
    297297        for (int n = 0; n < Neighbors.Length; n++) {
    298           var pairs = Quality.Zip(RealVector, (q, p) => new { Quality = q, Point = p })
     298          var pairs = Quality.Zip(RealVectors, (q, p) => new { Quality = q, Point = p })
    299299            .Where((p, i) => i == n || Neighbors[n].Contains(i));
    300300          var bestNeighbor = Maximization ?
     
    312312      if (PersonalBestQuality.Length == 0)
    313313        PersonalBestQuality = (ItemArray<DoubleValue>)Quality.Clone();
    314       for (int i = 0; i < RealVector.Length; i++) {
     314      for (int i = 0; i < RealVectors.Length; i++) {
    315315        if (Maximization && Quality[i].Value > PersonalBestQuality[i].Value ||
    316316          !Maximization && Quality[i].Value < PersonalBestQuality[i].Value) {
    317317          PersonalBestQuality[i].Value = Quality[i].Value;
    318           PersonalBest[i] = RealVector[i];
     318          PersonalBest[i] = RealVectors[i];
    319319        }
    320320      }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorEncoding.cs

    r13396 r13403  
    171171          typeof (IRealVectorBoundsChecker),
    172172          typeof (IRealVectorMoveOperator),
    173           typeof (IRealVectorMoveGenerator)
     173          typeof (IRealVectorMoveGenerator),
     174          typeof (IRealVectorSolutionOperator),
     175          typeof (IRealVectorSolutionsOperator),
     176          typeof (IRealVectorBoundedOperator)
    174177      };
    175178    }
     
    209212      ConfigureMoveGenerators(operators.OfType<IRealVectorMoveGenerator>());
    210213      ConfigureMoveOperators(operators.OfType<IRealVectorMoveOperator>());
    211       ConfigureAdditiveMoveOperator(operators.OfType<IAdditiveRealVectorMoveOperator>());
     214      ConfigureAdditiveMoveOperator(operators.OfType<IRealVectorAdditiveMoveOperator>());
     215      ConfigureRealVectorSolutionOperators(operators.OfType<IRealVectorSolutionOperator>());
     216      ConfigureRealVectorSolutionsOperators(operators.OfType<IRealVectorSolutionsOperator>());
     217      ConfigureRealVectorBoundedOperators(operators.OfType<IRealVectorBoundedOperator>());
    212218    }
    213219
     
    215221    private void ConfigureCreators(IEnumerable<IRealVectorCreator> creators) {
    216222      foreach (var creator in creators) {
    217         creator.RealVectorParameter.ActualName = Name;
    218223        creator.LengthParameter.ActualName = LengthParameter.Name;
    219         creator.BoundsParameter.ActualName = BoundsParameter.Name;
    220224      }
    221225    }
     
    224228        crossover.ChildParameter.ActualName = Name;
    225229        crossover.ParentsParameter.ActualName = Name;
    226         crossover.BoundsParameter.ActualName = BoundsParameter.Name;
    227230      }
    228231    }
    229232    private void ConfigureManipulators(IEnumerable<IRealVectorManipulator> manipulators) {
    230233      foreach (var manipulator in manipulators) {
    231         manipulator.RealVectorParameter.ActualName = Name;
    232         manipulator.BoundsParameter.ActualName = BoundsParameter.Name;
    233         manipulator.BoundsParameter.Hidden = true;
    234234        var sm = manipulator as ISelfAdaptiveManipulator;
    235235        if (sm != null) {
     
    272272    }
    273273    private void ConfigureSwarmUpdaters(IEnumerable<IRealVectorSwarmUpdater> swarmUpdaters) {
    274       foreach (var su in swarmUpdaters) {
    275         su.RealVectorParameter.ActualName = Name;
    276       }
     274      // swarm updaters don't have additional parameters besides the solution parameter
    277275    }
    278276    private void ConfigureParticleCreators(IEnumerable<IRealVectorParticleCreator> particleCreators) {
    279277      foreach (var particleCreator in particleCreators) {
    280         particleCreator.RealVectorParameter.ActualName = Name;
    281         particleCreator.BoundsParameter.ActualName = BoundsParameter.Name;
    282278        particleCreator.ProblemSizeParameter.ActualName = LengthParameter.Name;
    283279      }
    284280    }
    285281    private void ConfigureParticleUpdaters(IEnumerable<IRealVectorParticleUpdater> particleUpdaters) {
    286       foreach (var particleUpdater in particleUpdaters) {
    287         particleUpdater.RealVectorParameter.ActualName = Name;
    288         particleUpdater.BoundsParameter.ActualName = BoundsParameter.Name;
    289       }
     282      // particle updaters don't have additional parameters besides solution and bounds parameter
    290283    }
    291284    private void ConfigureShakingOperators(IEnumerable<IRealVectorMultiNeighborhoodShakingOperator> shakingOperators) {
    292       foreach (var shakingOperator in shakingOperators) {
    293         shakingOperator.RealVectorParameter.ActualName = Name;
    294         shakingOperator.BoundsParameter.ActualName = BoundsParameter.Name;
    295       }
     285      // shaking operators don't have additional parameters besides solution and bounds parameter
    296286    }
    297287    private void ConfigureBoundsCheckers(IEnumerable<IRealVectorBoundsChecker> boundsCheckers) {
     
    302292    }
    303293    private void ConfigureMoveOperators(IEnumerable<IRealVectorMoveOperator> moveOperators) {
    304       foreach (var moveOperator in moveOperators)
    305         moveOperator.RealVectorParameter.ActualName = Name;
    306     }
    307 
     294      // move operators don't have additional parameters besides the solution parameter
     295    }
    308296    private void ConfigureMoveGenerators(IEnumerable<IRealVectorMoveGenerator> moveGenerators) {
    309       foreach (var moveGenerator in moveGenerators)
    310         moveGenerator.BoundsParameter.ActualName = BoundsParameter.Name;
    311     }
    312 
    313     private void ConfigureAdditiveMoveOperator(IEnumerable<IAdditiveRealVectorMoveOperator> additiveMoveOperators) {
     297      // move generators don't have additional parameters besides solution and bounds parameter
     298    }
     299    private void ConfigureAdditiveMoveOperator(IEnumerable<IRealVectorAdditiveMoveOperator> additiveMoveOperators) {
    314300      foreach (var additiveMoveOperator in additiveMoveOperators) {
    315301        additiveMoveOperator.AdditiveMoveParameter.ActualName = Name + ".AdditiveMove";
     302      }
     303    }
     304    private void ConfigureRealVectorSolutionOperators(IEnumerable<IRealVectorSolutionOperator> solutionOperators) {
     305      foreach (var solutionOperator in solutionOperators)
     306        solutionOperator.RealVectorParameter.ActualName = Name;
     307    }
     308    private void ConfigureRealVectorSolutionsOperators(IEnumerable<IRealVectorSolutionsOperator> solutionsOperators) {
     309      foreach (var solutionsOperator in solutionsOperators)
     310        solutionsOperator.RealVectorsParameter.ActualName = Name;
     311    }
     312    private void ConfigureRealVectorBoundedOperators(IEnumerable<IRealVectorBoundedOperator> boundedOperators) {
     313      foreach (var boundedOperator in boundedOperators) {
     314        boundedOperator.BoundsParameter.ActualName = BoundsParameter.Name;
    316315      }
    317316    }
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/IParticleUpdater.cs

    r12012 r13403  
    2727  /// Interface to represent an operator that updates a particle
    2828  /// </summary>
    29   public interface IParticleUpdater : IOperator {
     29  public interface IParticleUpdater : IStochasticOperator {
    3030    ILookupParameter<DoubleValue> InertiaParameter { get; }
    3131    ILookupParameter<DoubleValue> NeighborBestAttractionParameter { get; }
    3232    ILookupParameter<DoubleValue> PersonalBestAttractionParameter { get; }
    33     ILookupParameter<IRandom> RandomParameter { get; }
    3433  }
    3534}
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions.Views/3.3/SingleObjectiveTestFunctionSolutionView.cs

    r12012 r13403  
    146146          pictureBox.Refresh();
    147147          DoubleMatrix bounds = Content.Bounds;
    148           if (bounds == null) bounds = Content.Evaluator.Bounds;
     148          if (bounds == null) bounds = Content.TestFunction.Bounds;
    149149          double xMin = bounds[0, 0], xMax = bounds[0, 1], yMin = bounds[1 % bounds.Rows, 0], yMax = bounds[1 % bounds.Rows, 1];
    150150          double xStep = backgroundImage.Width / (xMax - xMin), yStep = backgroundImage.Height / (yMax - yMin);
     
    174174      backgroundImage = new Bitmap(pictureBox.Width, pictureBox.Height);
    175175      DoubleMatrix bounds = Content.Bounds;
    176       if (bounds == null) bounds = Content.Evaluator.Bounds;
     176      if (bounds == null) bounds = Content.TestFunction.Bounds;
    177177      double xMin = bounds[0, 0], xMax = bounds[0, 1], yMin = bounds[1 % bounds.Rows, 0], yMax = bounds[1 % bounds.Rows, 1];
    178178      double xStep = (xMax - xMin) / backgroundImage.Width, yStep = (yMax - yMin) / backgroundImage.Height;
     
    181181      for (int i = 0; i < backgroundImage.Width; i++)
    182182        for (int j = 0; j < backgroundImage.Height; j++) {
    183           points[j, i] = Content.Evaluator.Evaluate2D(xMin + i * xStep, yMin + j * yStep);
     183          points[j, i] = Content.TestFunction.Evaluate2D(xMin + i * xStep, yMin + j * yStep);
    184184          if (points[j, i] < minPoint) minPoint = points[j, i];
    185185          if (points[j, i] > maxPoint) maxPoint = points[j, i];
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Analyzers/BestSingleObjectiveTestFunctionSolutionAnalyzer.cs

    r12012 r13403  
    4444      get { return (LookupParameter<BoolValue>)Parameters["Maximization"]; }
    4545    }
    46     public ScopeTreeLookupParameter<RealVector> RealVectorParameter {
    47       get { return (ScopeTreeLookupParameter<RealVector>)Parameters["RealVector"]; }
     46    public IScopeTreeLookupParameter<RealVector> RealVectorsParameter {
     47      get { return (IScopeTreeLookupParameter<RealVector>)Parameters["RealVectors"]; }
    4848    }
    49     ILookupParameter IBestSingleObjectiveTestFunctionSolutionAnalyzer.RealVectorParameter {
    50       get { return RealVectorParameter; }
    51     }
    52     public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
    53       get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    54     }
    55     ILookupParameter IBestSingleObjectiveTestFunctionSolutionAnalyzer.QualityParameter {
    56       get { return QualityParameter; }
     49    public IScopeTreeLookupParameter<DoubleValue> QualityParameter {
     50      get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
    5751    }
    5852    public ILookupParameter<SingleObjectiveTestFunctionSolution> BestSolutionParameter {
     
    6862      get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; }
    6963    }
    70     public IValueLookupParameter<ISingleObjectiveTestFunctionProblemEvaluator> EvaluatorParameter {
    71       get { return (IValueLookupParameter<ISingleObjectiveTestFunctionProblemEvaluator>)Parameters["Evaluator"]; }
     64    public IValueLookupParameter<ISingleObjectiveTestFunction> TestFunctionParameter {
     65      get { return (IValueLookupParameter<ISingleObjectiveTestFunction>)Parameters["TestFunction"]; }
    7266    }
    73     public ILookupParameter<DoubleMatrix> BoundsParameter {
    74       get { return (ILookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
     67    public IValueLookupParameter<DoubleMatrix> BoundsParameter {
     68      get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
    7569    }
    7670
     
    8175      : base() {
    8276      Parameters.Add(new LookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem."));
    83       Parameters.Add(new ScopeTreeLookupParameter<RealVector>("RealVector", "The SingleObjectiveTestFunction solutions from which the best solution should be visualized."));
     77      Parameters.Add(new ScopeTreeLookupParameter<RealVector>("RealVectors", "The SingleObjectiveTestFunction solutions from which the best solution should be visualized."));
    8478      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The qualities of the SingleObjectiveTestFunction solutions which should be visualized."));
    8579      Parameters.Add(new LookupParameter<SingleObjectiveTestFunctionSolution>("BestSolution", "The best SingleObjectiveTestFunction solution."));
     
    8781      Parameters.Add(new LookupParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution."));
    8882      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the SingleObjectiveTestFunction solution should be stored."));
    89       Parameters.Add(new ValueLookupParameter<ISingleObjectiveTestFunctionProblemEvaluator>("Evaluator", "The evaluator with which the solution is evaluated."));
    90       Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The bounds of the function."));
     83      Parameters.Add(new ValueLookupParameter<ISingleObjectiveTestFunction>("TestFunction", "The evaluator with which the solution is evaluated."));
     84      Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The bounds of the function."));
    9185
    9286      MaximizationParameter.Hidden = true;
    93       RealVectorParameter.Hidden = true;
     87      RealVectorsParameter.Hidden = true;
    9488      QualityParameter.Hidden = true;
    9589      BestSolutionParameter.Hidden = true;
     
    9791      BestKnownQualityParameter.Hidden = true;
    9892      ResultsParameter.Hidden = true;
    99       EvaluatorParameter.Hidden = true;
     93      TestFunctionParameter.Hidden = true;
    10094      BoundsParameter.Hidden = true;
    101     }
    102 
    103     /// <summary>
    104     /// This method can simply be removed when the plugin version is > 3.3
    105     /// </summary>
    106     [StorableHook(HookType.AfterDeserialization)]
    107     private void AfterDeserialization() {
    108       // BackwardsCompatibility3.3
    109       // Bounds are introduced in 3.3.0.3894
    110       if (!Parameters.ContainsKey("Bounds"))
    111         Parameters.Add(new LookupParameter<DoubleMatrix>("Bounds", "The bounds of the function."));
    11295    }
    11396
     
    117100
    118101    public override IOperation Apply() {
    119       ItemArray<RealVector> realVectors = RealVectorParameter.ActualValue;
     102      ItemArray<RealVector> realVectors = RealVectorsParameter.ActualValue;
    120103      ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
    121104      bool max = MaximizationParameter.ActualValue.Value;
     
    140123        solution = new SingleObjectiveTestFunctionSolution((RealVector)realVectors[i].Clone(),
    141124                                                           (DoubleValue)qualities[i].Clone(),
    142                                                            EvaluatorParameter.ActualValue);
     125                                                           TestFunctionParameter.ActualValue);
    143126        solution.Population = realVectors[i].Length == 2
    144127          ? new ItemArray<RealVector>(realVectors.Select(x => x.Clone()).Cast<RealVector>())
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Ackley.cs

    r13393 r13403  
    3232  /// is highly multimodal. It has a single global minimum at the origin with value 0.
    3333  /// </summary
    34   [Item("AckleyEvaluator", "Evaluates the Ackley function on a given point. The optimum of this function is 0 at the origin. It is implemented as described in Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg.")]
     34  [Item("Ackley", "Evaluates the Ackley function on a given point. The optimum of this function is 0 at the origin. It is implemented as described in Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg.")]
    3535  [StorableClass]
    36   public class AckleyEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    37     public override string FunctionName { get { return "Ackley"; } }
     36  public class Ackley : SingleObjectiveTestFunction {
    3837    /// <summary>
    3938    /// Returns false as the Ackley function is a minimization problem.
     
    6867
    6968    [StorableConstructor]
    70     protected AckleyEvaluator(bool deserializing) : base(deserializing) { }
    71     protected AckleyEvaluator(AckleyEvaluator original, Cloner cloner) : base(original, cloner) { }
    72     public AckleyEvaluator() : base() { }
     69    protected Ackley(bool deserializing) : base(deserializing) { }
     70    protected Ackley(Ackley original, Cloner cloner) : base(original, cloner) { }
     71    public Ackley() : base() { }
    7372
    7473    public override IDeepCloneable Clone(Cloner cloner) {
    75       return new AckleyEvaluator(this, cloner);
     74      return new Ackley(this, cloner);
    7675    }
    7776
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Beale.cs

    r13393 r13403  
    3232  /// It is implemented as described in Moré, J.J., Garbow, B., and Hillstrom, K. 1981. Testing unconstrained optimization software. ACM Transactions on Mathematical Software 7, pp. 136-140, ACM.
    3333  /// </summary>
    34   [Item("BealeEvaluator", "Evaluates the Beale function on a given point. The optimum of this function is 0 at (3,0.5). It is implemented as described in Moré, J.J., Garbow, B., and Hillstrom, K. 1981. Testing unconstrained optimization software. ACM Transactions on Mathematical Software 7, pp. 136-140, ACM.")]
     34  [Item("Beale", "Evaluates the Beale function on a given point. The optimum of this function is 0 at (3,0.5). It is implemented as described in Moré, J.J., Garbow, B., and Hillstrom, K. 1981. Testing unconstrained optimization software. ACM Transactions on Mathematical Software 7, pp. 136-140, ACM.")]
    3535  [StorableClass]
    36   public class BealeEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    37     public override string FunctionName { get { return "Beale"; } }
     36  public class Beale : SingleObjectiveTestFunction {
    3837    /// <summary>
    3938    /// Returns false as the Beale function is a minimization problem.
     
    6867
    6968    [StorableConstructor]
    70     protected BealeEvaluator(bool deserializing) : base(deserializing) { }
    71     protected BealeEvaluator(BealeEvaluator original, Cloner cloner) : base(original, cloner) { }
    72     public BealeEvaluator() : base() { }
     69    protected Beale(bool deserializing) : base(deserializing) { }
     70    protected Beale(Beale original, Cloner cloner) : base(original, cloner) { }
     71    public Beale() : base() { }
    7372
    7473    public override IDeepCloneable Clone(Cloner cloner) {
    75       return new BealeEvaluator(this, cloner);
     74      return new Beale(this, cloner);
    7675    }
    7776
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Booth.cs

    r13393 r13403  
    3131  /// The Booth function is implemented as described on http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO_files/Page816.htm, last accessed April 12th, 2010.
    3232  /// </summary>
    33   [Item("BoothEvaluator", "Evaluates the Booth function on a given point. The optimum of this function is 0 at (1,3). It is implemented as described on http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO_files/Page816.htm, last accessed April 12th, 2010.")]
     33  [Item("Booth", "Evaluates the Booth function on a given point. The optimum of this function is 0 at (1,3). It is implemented as described on http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO_files/Page816.htm, last accessed April 12th, 2010.")]
    3434  [StorableClass]
    35   public class BoothEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    36     public override string FunctionName { get { return "Booth"; } }
     35  public class Booth : SingleObjectiveTestFunction {
    3736    /// <summary>
    3837    /// Returns false as the Booth function is a minimization problem.
     
    6766
    6867    [StorableConstructor]
    69     protected BoothEvaluator(bool deserializing) : base(deserializing) { }
    70     protected BoothEvaluator(BoothEvaluator original, Cloner cloner) : base(original, cloner) { }
    71     public BoothEvaluator() : base() { }
     68    protected Booth(bool deserializing) : base(deserializing) { }
     69    protected Booth(Booth original, Cloner cloner) : base(original, cloner) { }
     70    public Booth() : base() { }
    7271
    7372    public override IDeepCloneable Clone(Cloner cloner) {
    74       return new BoothEvaluator(this, cloner);
     73      return new Booth(this, cloner);
    7574    }
    7675
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Griewank.cs

    r13393 r13403  
    3333  /// Here it is implemented as described (without the modifications) in Locatelli, M. 2003. A note on the Griewank test function. Journal of Global Optimization 25, pp. 169-174, Springer.
    3434  /// </summary>
    35   [Item("GriewankEvaluator", "Evaluates the Griewank function on a given point. The optimum of this function is 0 at the origin. It is introduced by Griewank A.O. 1981 and implemented as described (without the modifications) in Locatelli, M. 2003. A note on the Griewank test function. Journal of Global Optimization 25, pp. 169-174, Springer.")]
     35  [Item("Griewank", "Evaluates the Griewank function on a given point. The optimum of this function is 0 at the origin. It is introduced by Griewank A.O. 1981 and implemented as described (without the modifications) in Locatelli, M. 2003. A note on the Griewank test function. Journal of Global Optimization 25, pp. 169-174, Springer.")]
    3636  [StorableClass]
    37   public class GriewankEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    38     public override string FunctionName { get { return "Griewank"; } }
     37  public class Griewank : SingleObjectiveTestFunction {
    3938    /// <summary>
    4039    /// Returns false as the Griewank function is a minimization problem.
     
    6968
    7069    [StorableConstructor]
    71     protected GriewankEvaluator(bool deserializing) : base(deserializing) { }
    72     protected GriewankEvaluator(GriewankEvaluator original, Cloner cloner) : base(original, cloner) { }
    73     public GriewankEvaluator() : base() { }
     70    protected Griewank(bool deserializing) : base(deserializing) { }
     71    protected Griewank(Griewank original, Cloner cloner) : base(original, cloner) { }
     72    public Griewank() : base() { }
    7473
    7574    public override IDeepCloneable Clone(Cloner cloner) {
    76       return new GriewankEvaluator(this, cloner);
     75      return new Griewank(this, cloner);
    7776    }
    7877
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Levy.cs

    r13393 r13403  
    3131  /// The Levy function is implemented as described on http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO_files/Page2056.htm, last accessed April 12th, 2010.
    3232  /// </summary>
    33   [Item("LevyEvaluator", "Evaluates the Levy function on a given point. The optimum of this function is 0 at (1,1,...,1). It is implemented as described on http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO_files/Page2056.htm, last accessed April 12th, 2010.")]
     33  [Item("Levy", "Evaluates the Levy function on a given point. The optimum of this function is 0 at (1,1,...,1). It is implemented as described on http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO_files/Page2056.htm, last accessed April 12th, 2010.")]
    3434  [StorableClass]
    35   public class LevyEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    36     public override string FunctionName { get { return "Levy"; } }
     35  public class Levy : SingleObjectiveTestFunction {
    3736    /// <summary>
    3837    /// Returns false as the Levy function is a minimization problem.
     
    6766
    6867    [StorableConstructor]
    69     protected LevyEvaluator(bool deserializing) : base(deserializing) { }
    70     protected LevyEvaluator(LevyEvaluator original, Cloner cloner) : base(original, cloner) { }
    71     public LevyEvaluator() : base() { }
     68    protected Levy(bool deserializing) : base(deserializing) { }
     69    protected Levy(Levy original, Cloner cloner) : base(original, cloner) { }
     70    public Levy() : base() { }
    7271
    7372    public override IDeepCloneable Clone(Cloner cloner) {
    74       return new LevyEvaluator(this, cloner);
     73      return new Levy(this, cloner);
    7574    }
    7675
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Matyas.cs

    r13393 r13403  
    3131  /// The Matyas function is implemented as described on http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO_files/Page2213.htm, last accessed April 12th, 2010.
    3232  /// </summary>
    33   [Item("MatyasEvaluator", "Evaluates the Matyas function on a given point. The optimum of this function is 0 at the origin. It is implemented as described on http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO_files/Page2213.htm, last accessed April 12th, 2010.")]
     33  [Item("Matyas", "Evaluates the Matyas function on a given point. The optimum of this function is 0 at the origin. It is implemented as described on http://www-optima.amp.i.kyoto-u.ac.jp/member/student/hedar/Hedar_files/TestGO_files/Page2213.htm, last accessed April 12th, 2010.")]
    3434  [StorableClass]
    35   public class MatyasEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    36     public override string FunctionName { get { return "Matyas"; } }
     35  public class Matyas : SingleObjectiveTestFunction {
    3736    /// <summary>
    3837    /// Returns false as the Matyas function is a minimization problem.
     
    6766
    6867    [StorableConstructor]
    69     protected MatyasEvaluator(bool deserializing) : base(deserializing) { }
    70     protected MatyasEvaluator(MatyasEvaluator original, Cloner cloner) : base(original, cloner) { }
    71     public MatyasEvaluator() : base() { }
     68    protected Matyas(bool deserializing) : base(deserializing) { }
     69    protected Matyas(Matyas original, Cloner cloner) : base(original, cloner) { }
     70    public Matyas() : base() { }
    7271
    7372    public override IDeepCloneable Clone(Cloner cloner) {
    74       return new MatyasEvaluator(this, cloner);
     73      return new Matyas(this, cloner);
    7574    }
    7675
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Multinormal.cs

    r13393 r13403  
    3030using HeuristicLab.Parameters;
    3131using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     32using HeuristicLab.Random;
    3233
    3334namespace HeuristicLab.Problems.TestFunctions.Evaluators {
    34   [Item("MultinormalFunction", "Evaluates a random multinormal function on a given point.")]
     35  [Item("Multinormal", "Evaluates a random multinormal function on a given point.")]
    3536  [StorableClass]
    36   public class MultinormalEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    37     public override string FunctionName { get { return "Multinormal"; } }
     37  public class Multinormal : SingleObjectiveTestFunction {
    3838
    3939    private ItemList<RealVector> centers {
     
    4545      set { Parameters["s^2s"].ActualValue = value; }
    4646    }
    47     private static System.Random Random = new System.Random();
     47
     48    public IRandom Random {
     49      get { return ((ValueParameter<IRandom>)Parameters["Random"]).Value; }
     50      set { ((ValueParameter<IRandom>)Parameters["Random"]).Value = value; }
     51    }
    4852
    4953    private Dictionary<int, List<RealVector>> stdCenters;
     
    8791
    8892    [StorableConstructor]
    89     protected MultinormalEvaluator(bool deserializing) : base(deserializing) { }
    90     protected MultinormalEvaluator(MultinormalEvaluator original, Cloner cloner) : base(original, cloner) { }
    91     public MultinormalEvaluator() {
     93    protected Multinormal(bool deserializing) : base(deserializing) { }
     94    protected Multinormal(Multinormal original, Cloner cloner) : base(original, cloner) { }
     95    public Multinormal() {
    9296      Parameters.Add(new ValueParameter<ItemList<RealVector>>("Centers", "Centers of normal distributions"));
    9397      Parameters.Add(new ValueParameter<RealVector>("s^2s", "sigma^2 of normal distributions"));
    94       Parameters.Add(new LookupParameter<IRandom>("Random", "Random number generator"));
     98      Parameters.Add(new ValueParameter<IRandom>("Random", "The random number generator that will make random instances", new MersenneTwister(0)));
    9599      centers = new ItemList<RealVector>();
    96100      s_2s = new RealVector();
     
    98102
    99103    public override IDeepCloneable Clone(Cloner cloner) {
    100       return new MultinormalEvaluator(this, cloner);
     104      return new Multinormal(this, cloner);
    101105    }
    102106
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Random.cs

    r13393 r13403  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.Encodings.RealVectorEncoding;
    26 using HeuristicLab.Optimization;
    2726using HeuristicLab.Parameters;
    2827using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     28using HeuristicLab.Random;
    2929
    3030namespace HeuristicLab.Problems.TestFunctions {
     
    3232  /// A function that returns a random variable in [0;1) independent of the inputs.
    3333  /// </summary
    34   [Item("RandomEvaluator", "Returns a random value in [0;1) that is independent of the inputs.")]
     34  [Item("Random", "Returns a random value in [0;1) that is independent of the inputs.")]
    3535  [StorableClass]
    36   public class RandomEvaluator : SingleObjectiveTestFunctionProblemEvaluator, IStochasticOperator {
    37     public override string FunctionName { get { return "Random"; } }
     36  public class Random : SingleObjectiveTestFunction {
    3837    /// <summary>
    3938    /// It does not really matter.
     
    6766    }
    6867
    69     public ILookupParameter<IRandom> RandomParameter {
    70       get { return (ILookupParameter<IRandom>)Parameters["Random"]; }
     68    public IValueParameter<IRandom> RandomParameter {
     69      get { return (IValueParameter<IRandom>)Parameters["Random"]; }
    7170    }
    7271
    7372    [StorableConstructor]
    74     protected RandomEvaluator(bool deserializing) : base(deserializing) { }
    75     protected RandomEvaluator(RandomEvaluator original, Cloner cloner) : base(original, cloner) { }
    76     public RandomEvaluator()
     73    protected Random(bool deserializing) : base(deserializing) { }
     74    protected Random(Random original, Cloner cloner) : base(original, cloner) { }
     75    public Random()
    7776      : base() {
    78       Parameters.Add(new LookupParameter<IRandom>("Random", "The random number generator to use."));
     77      Parameters.Add(new ValueParameter<IRandom>("Random", "The random number generator to use.", new MersenneTwister(0)));
    7978    }
    8079
    8180    public override IDeepCloneable Clone(Cloner cloner) {
    82       return new RandomEvaluator(this, cloner);
     81      return new Random(this, cloner);
    8382    }
    8483
    8584    public override RealVector GetBestKnownSolution(int dimension) {
    86       return new RealVector(dimension);
     85      return null;
    8786    }
    8887
    8988    public override double Evaluate(RealVector point) {
    90       return ExecutionContext == null ? new System.Random().NextDouble() : RandomParameter.ActualValue.NextDouble();
     89      return RandomParameter.Value.NextDouble();
    9190    }
    9291  }
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Rastrigin.cs

    r13393 r13403  
    3333  /// It is implemented as described in Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg.
    3434  /// </summary
    35   [Item("RastriginEvaluator", "Evaluates the generalized Rastrigin function y = Sum((x_i)^2 + A * (1 - Cos(2pi*x_i))) on a given point. The optimum of this function is 0 at the origin. It is implemented as described in Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg.")]
     35  [Item("Rastrigin", "Evaluates the generalized Rastrigin function y = Sum((x_i)^2 + A * (1 - Cos(2pi*x_i))) on a given point. The optimum of this function is 0 at the origin. It is implemented as described in Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg.")]
    3636  [StorableClass]
    37   public class RastriginEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    38     public override string FunctionName { get { return "Rastrigin"; } }
     37  public class Rastrigin : SingleObjectiveTestFunction {
    3938    /// <summary>
    4039    /// Returns false as the Rastrigin function is a minimization problem.
     
    8685
    8786    [StorableConstructor]
    88     protected RastriginEvaluator(bool deserializing) : base(deserializing) { }
    89     protected RastriginEvaluator(RastriginEvaluator original, Cloner cloner) : base(original, cloner) { }
     87    protected Rastrigin(bool deserializing) : base(deserializing) { }
     88    protected Rastrigin(Rastrigin original, Cloner cloner) : base(original, cloner) { }
    9089    /// <summary>
    9190    /// Initializes a new instance of the RastriginEvaluator with one parameter (<c>A</c>).
    9291    /// </summary>
    93     public RastriginEvaluator()
     92    public Rastrigin()
    9493      : base() {
    9594      Parameters.Add(new ValueParameter<DoubleValue>("A", "The parameter A is a parameter of the objective function y = Sum((x_i)^2 + A * (1 - Cos(2pi*x_i))). Default is A = 10.", new DoubleValue(10)));
     
    9796
    9897    public override IDeepCloneable Clone(Cloner cloner) {
    99       return new RastriginEvaluator(this, cloner);
     98      return new Rastrigin(this, cloner);
    10099    }
    101100
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Rosenbrock.cs

    r13393 r13403  
    3232  /// It is implemented as generalized Rosenbrock function as for example given in Shang, Y.-W. and Qiu, Y.-H. 2006. A Note on the Extended Rosenbrock Function. Evolutionary Computation 14, pp. 119-126, MIT Press.
    3333  /// </summary>
    34   [Item("RosenbrockEvaluator", @"The Rosenbrock function features a flat valley in which the global optimum is located.
     34  [Item("Rosenbrock", @"The Rosenbrock function features a flat valley in which the global optimum is located.
    3535For 2 and 3 dimensions the single minimum of this function is 0 at (1,1,...,1), for 4 to 30 dimensions there is an additional local minimum close to (-1,1,...,1).
    3636It is unknown how many local minima there are for dimensions greater than 30.
    3737It is implemented as generalized Rosenbrock function for which the 2 dimensional function is a special case, as for example given in Shang, Y.-W. and Qiu, Y.-H. 2006. A Note on the Extended Rosenbrock Function. Evolutionary Computation 14, pp. 119-126, MIT Press.")]
    3838  [StorableClass]
    39   public class RosenbrockEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    40     public override string FunctionName { get { return "Rosenbrock"; } }
     39  public class Rosenbrock : SingleObjectiveTestFunction {
    4140    /// <summary>
    4241    /// Returns false as the Rosenbrock function is a minimization problem.
     
    7170
    7271    [StorableConstructor]
    73     protected RosenbrockEvaluator(bool deserializing) : base(deserializing) { }
    74     protected RosenbrockEvaluator(RosenbrockEvaluator original, Cloner cloner) : base(original, cloner) { }
    75     public RosenbrockEvaluator() : base() { }
     72    protected Rosenbrock(bool deserializing) : base(deserializing) { }
     73    protected Rosenbrock(Rosenbrock original, Cloner cloner) : base(original, cloner) { }
     74    public Rosenbrock() : base() { }
    7675
    7776    public override IDeepCloneable Clone(Cloner cloner) {
    78       return new RosenbrockEvaluator(this, cloner);
     77      return new Rosenbrock(this, cloner);
    7978    }
    8079
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Schwefel.cs

    r13393 r13403  
    3131  /// The Schwefel function (sine root) is implemented as described in Affenzeller, M. and Wagner, S. 2005. Offspring Selection: A New Self-Adaptive Selection Scheme for Genetic Algorithms.  Ribeiro, B., Albrecht, R. F., Dobnikar, A., Pearson, D. W., and Steele, N. C. (eds.). Adaptive and Natural Computing Algorithms, pp. 218-221, Springer.
    3232  /// </summary>
    33   [Item("SchwefelEvaluator", "Evaluates the Schwefel function (sine root) on a given point. In the given bounds [-500;500] the optimum of this function is close to 0 at (420.968746453712,420.968746453712,...,420.968746453712). It is implemented as described in Affenzeller, M. and Wagner, S. 2005. Offspring Selection: A New Self-Adaptive Selection Scheme for Genetic Algorithms.  Ribeiro, B., Albrecht, R. F., Dobnikar, A., Pearson, D. W., and Steele, N. C. (eds.). Adaptive and Natural Computing Algorithms, pp. 218-221, Springer.")]
     33  [Item("Schwefel", "Evaluates the Schwefel function (sine root) on a given point. In the given bounds [-500;500] the optimum of this function is close to 0 at (420.968746453712,420.968746453712,...,420.968746453712). It is implemented as described in Affenzeller, M. and Wagner, S. 2005. Offspring Selection: A New Self-Adaptive Selection Scheme for Genetic Algorithms.  Ribeiro, B., Albrecht, R. F., Dobnikar, A., Pearson, D. W., and Steele, N. C. (eds.). Adaptive and Natural Computing Algorithms, pp. 218-221, Springer.")]
    3434  [StorableClass]
    35   public class SchwefelEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    36     public override string FunctionName { get { return "Schwefel"; } }
     35  public class Schwefel : SingleObjectiveTestFunction {
    3736    /// <summary>
    3837    /// Returns false as the Schwefel (sine root) function is a minimization problem.
     
    6766
    6867    [StorableConstructor]
    69     protected SchwefelEvaluator(bool deserializing) : base(deserializing) { }
    70     protected SchwefelEvaluator(SchwefelEvaluator original, Cloner cloner) : base(original, cloner) { }
    71     public SchwefelEvaluator() : base() { }
     68    protected Schwefel(bool deserializing) : base(deserializing) { }
     69    protected Schwefel(Schwefel original, Cloner cloner) : base(original, cloner) { }
     70    public Schwefel() : base() { }
    7271
    7372    public override IDeepCloneable Clone(Cloner cloner) {
    74       return new SchwefelEvaluator(this, cloner);
     73      return new Schwefel(this, cloner);
    7574    }
    7675
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/SingleObjectiveTestFunction.cs

    r13393 r13403  
    2424using HeuristicLab.Data;
    2525using HeuristicLab.Encodings.RealVectorEncoding;
    26 using HeuristicLab.Operators;
    27 using HeuristicLab.Parameters;
    2826using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2927
     
    3230  /// Base class for a test function evaluator.
    3331  /// </summary>
    34   [Item("Evaluator", "Base calls for single objective test function evaluators.")]
     32  [Item("Single-Objective Function", "Base class for single objective functions.")]
    3533  [StorableClass]
    36   public abstract class SingleObjectiveTestFunctionProblemEvaluator : InstrumentedOperator, ISingleObjectiveTestFunctionProblemEvaluator {
    37     /// <summary>
    38     /// The name of the function
    39     /// </summary>
    40     public abstract string FunctionName { get; }
     34  public abstract class SingleObjectiveTestFunction : ParameterizedNamedItem, ISingleObjectiveTestFunction {
    4135    /// <summary>
    4236    /// These operators should not change their name through the GUI
     
    6660    public abstract int MaximumProblemSize { get; }
    6761
    68     public ILookupParameter<DoubleValue> QualityParameter {
    69       get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
    70     }
    71     public ILookupParameter<RealVector> PointParameter {
    72       get { return (ILookupParameter<RealVector>)Parameters["Point"]; }
    73     }
    74 
    7562    [StorableConstructor]
    76     protected SingleObjectiveTestFunctionProblemEvaluator(bool deserializing) : base(deserializing) { }
    77     protected SingleObjectiveTestFunctionProblemEvaluator(SingleObjectiveTestFunctionProblemEvaluator original, Cloner cloner) : base(original, cloner) { }
    78     /// <summary>
    79     /// Initializes a new instance of <see cref="SingleObjectiveTestFunctionEvaluator"/> with two parameters
    80     /// (<c>Quality</c> and <c>Point</c>).
    81     /// </summary>
    82     public SingleObjectiveTestFunctionProblemEvaluator()
    83       : base() {
    84       Parameters.Add(new LookupParameter<DoubleValue>("Quality", "Result of the evaluation of a solution."));
    85       Parameters.Add(new LookupParameter<RealVector>("Point", "The point at which the function should be evaluated."));
    86     }
    87 
    88     public override IOperation InstrumentedApply() {
    89       RealVector point = PointParameter.ActualValue;
    90       double quality = Evaluate(point);
    91       QualityParameter.ActualValue = new DoubleValue(quality);
    92       return base.InstrumentedApply();
    93     }
     63    protected SingleObjectiveTestFunction(bool deserializing) : base(deserializing) { }
     64    protected SingleObjectiveTestFunction(SingleObjectiveTestFunction original, Cloner cloner) : base(original, cloner) { }
     65    protected SingleObjectiveTestFunction() : base() { }
    9466
    9567    public virtual double Evaluate2D(double x, double y) {
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Sphere.cs

    r13393 r13403  
    3333  /// It is implemented as described in Beyer, H.-G. and Schwefel, H.-P. 2002. Evolution Strategies - A Comprehensive Introduction Natural Computing, 1, pp. 3-52.
    3434  /// </summary>
    35   [Item("SphereEvaluator", "Evaluates the Sphere function y = C * ||X||^Alpha on a given point. The optimum of this function is 0 at the origin. It is implemented as described in Beyer, H.-G. and Schwefel, H.-P. 2002. Evolution Strategies - A Comprehensive Introduction Natural Computing, 1, pp. 3-52.")]
     35  [Item("Sphere", "Evaluates the Sphere function y = C * ||X||^Alpha on a given point. The optimum of this function is 0 at the origin. It is implemented as described in Beyer, H.-G. and Schwefel, H.-P. 2002. Evolution Strategies - A Comprehensive Introduction Natural Computing, 1, pp. 3-52.")]
    3636  [StorableClass]
    37   public class SphereEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    38     public override string FunctionName { get { return "Sphere"; } }
     37  public class Sphere : SingleObjectiveTestFunction {
    3938    /// <summary>
    4039    /// Returns false as the Sphere function is a minimization problem.
     
    6968
    7069    public override IDeepCloneable Clone(Cloner cloner) {
    71       return new SphereEvaluator(this, cloner);
     70      return new Sphere(this, cloner);
    7271    }
    7372
     
    104103
    105104    [StorableConstructor]
    106     protected SphereEvaluator(bool deserializing) : base(deserializing) { }
    107     protected SphereEvaluator(SphereEvaluator original, Cloner cloner) : base(original, cloner) { }
     105    protected Sphere(bool deserializing) : base(deserializing) { }
     106    protected Sphere(Sphere original, Cloner cloner) : base(original, cloner) { }
    108107    /// <summary>
    109108    /// Initializes a new instance of the SphereEvaluator with two parameters (<c>C</c> and <c>Alpha</c>).
    110109    /// </summary>
    111     public SphereEvaluator()
     110    public Sphere()
    112111      : base() {
    113112      Parameters.Add(new ValueParameter<DoubleValue>("C", "The parameter C modifies the steepness of the objective function y = C * ||X||^Alpha. Default is C = 1.", new DoubleValue(1)));
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/SumSquares.cs

    r13393 r13403  
    3030  /// The Sum Squares function is defined as sum(i * x_i * x_i) for i = 1..n
    3131  /// </summary>
    32   [Item("SumSquaresEvaluator", "Evaluates the sum squares function on a given point. The optimum of this function is 0 at the origin. The Sum Squares function is defined as sum(i * x_i * x_i) for i = 1..n.")]
     32  [Item("SumSquares", "Evaluates the sum squares function on a given point. The optimum of this function is 0 at the origin. The Sum Squares function is defined as sum(i * x_i * x_i) for i = 1..n.")]
    3333  [StorableClass]
    34   public class SumSquaresEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    35     public override string FunctionName { get { return "SumSquares"; } }
     34  public class SumSquares : SingleObjectiveTestFunction {
    3635    /// <summary>
    3736    /// Returns false as the Sum Squares function is a minimization problem.
     
    6665
    6766    [StorableConstructor]
    68     protected SumSquaresEvaluator(bool deserializing) : base(deserializing) { }
    69     protected SumSquaresEvaluator(SumSquaresEvaluator original, Cloner cloner) : base(original, cloner) { }
    70     public SumSquaresEvaluator() : base() { }
     67    protected SumSquares(bool deserializing) : base(deserializing) { }
     68    protected SumSquares(SumSquares original, Cloner cloner) : base(original, cloner) { }
     69    public SumSquares() : base() { }
    7170
    7271    public override IDeepCloneable Clone(Cloner cloner) {
    73       return new SumSquaresEvaluator(this, cloner);
     72      return new SumSquares(this, cloner);
    7473    }
    7574
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/Zakharov.cs

    r13393 r13403  
    3030  /// The Zakharov function is implemented as described in Hedar, A. & Fukushima, M. 2004. Heuristic pattern search and its hybridization with simulated annealing for nonlinear global optimization. Optimization Methods and Software 19, pp. 291-308, Taylor & Francis.
    3131  /// </summary>
    32   [Item("ZakharovEvaluator", "Evaluates the Zakharov function on a given point. The optimum of this function is 0 at the origin. It is implemented as described in Hedar, A. & Fukushima, M. 2004. Heuristic pattern search and its hybridization with simulated annealing for nonlinear global optimization. Optimization Methods and Software 19, pp. 291-308, Taylor & Francis.")]
     32  [Item("Zakharov", "Evaluates the Zakharov function on a given point. The optimum of this function is 0 at the origin. It is implemented as described in Hedar, A. & Fukushima, M. 2004. Heuristic pattern search and its hybridization with simulated annealing for nonlinear global optimization. Optimization Methods and Software 19, pp. 291-308, Taylor & Francis.")]
    3333  [StorableClass]
    34   public class ZakharovEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    35     public override string FunctionName { get { return "Zakharov"; } }
     34  public class Zakharov : SingleObjectiveTestFunction {
    3635    /// <summary>
    3736    /// Returns false as the Zakharov function is a minimization problem.
     
    7069
    7170    [StorableConstructor]
    72     protected ZakharovEvaluator(bool deserializing) : base(deserializing) { }
    73     protected ZakharovEvaluator(ZakharovEvaluator original, Cloner cloner) : base(original, cloner) { }
    74     public ZakharovEvaluator() : base() { }
     71    protected Zakharov(bool deserializing) : base(deserializing) { }
     72    protected Zakharov(Zakharov original, Cloner cloner) : base(original, cloner) { }
     73    public Zakharov() : base() { }
    7574
    7675    public override IDeepCloneable Clone(Cloner cloner) {
    77       return new ZakharovEvaluator(this, cloner);
     76      return new Zakharov(this, cloner);
    7877    }
    7978
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/HeuristicLab.Problems.TestFunctions-3.3.csproj

    r11623 r13403  
    114114  </ItemGroup>
    115115  <ItemGroup>
    116     <Compile Include="Evaluators\RandomEvaluator.cs" />
     116    <Compile Include="Functions\Random.cs" />
    117117    <Compile Include="Improvers\SingleObjectiveTestFunctionImprovementOperator.cs" />
    118118    <Compile Include="Instances\SOTFData.cs" />
    119119    <Compile Include="Instances\SOTFDataDescriptor.cs" />
    120120    <Compile Include="Instances\SOTFInstanceProvider.cs" />
    121     <Compile Include="MoveEvaluators\RandomAdditiveMoveEvaluator.cs" />
     121    <Compile Include="Interfaces\ITestFunctionSolutionSimilarityCalculator.cs" />
     122    <Compile Include="Interfaces\ISingleObjectiveTestFuntionImprovementOperator.cs" />
    122123    <Compile Include="PathRelinkers\SingleObjectiveTestFunctionPathRelinker.cs" />
    123124    <Compile Include="Plugin.cs" />
     
    128129      <SubType>Code</SubType>
    129130    </Compile>
    130     <Compile Include="Evaluators\AckleyEvaluator.cs" />
    131     <Compile Include="Evaluators\BealeEvaluator.cs" />
    132     <Compile Include="Evaluators\BoothEvaluator.cs" />
    133     <Compile Include="Evaluators\GriewankEvaluator.cs" />
    134     <Compile Include="Evaluators\LevyEvaluator.cs" />
    135     <Compile Include="Evaluators\MatyasEvaluator.cs" />
    136     <Compile Include="Evaluators\MultinormalEvaluator.cs" />
    137     <Compile Include="Evaluators\RastriginEvaluator.cs" />
    138     <Compile Include="Evaluators\RosenbrockEvaluator.cs" />
    139     <Compile Include="Evaluators\SchwefelEvaluator.cs" />
    140     <Compile Include="Evaluators\SingleObjectiveTestFunctionProblemEvaluator.cs" />
    141     <Compile Include="Evaluators\SphereEvaluator.cs" />
    142     <Compile Include="Evaluators\SumSquaresEvaluator.cs" />
    143     <Compile Include="Evaluators\ZakharovEvaluator.cs" />
     131    <Compile Include="Functions\Ackley.cs" />
     132    <Compile Include="Functions\Beale.cs" />
     133    <Compile Include="Functions\Booth.cs" />
     134    <Compile Include="Functions\Griewank.cs" />
     135    <Compile Include="Functions\Levy.cs" />
     136    <Compile Include="Functions\Matyas.cs" />
     137    <Compile Include="Functions\Multinormal.cs" />
     138    <Compile Include="Functions\Rastrigin.cs" />
     139    <Compile Include="Functions\Rosenbrock.cs" />
     140    <Compile Include="Functions\Schwefel.cs" />
     141    <Compile Include="Functions\SingleObjectiveTestFunction.cs" />
     142    <Compile Include="Functions\Sphere.cs" />
     143    <Compile Include="Functions\SumSquares.cs" />
     144    <Compile Include="Functions\Zakharov.cs" />
    144145    <Compile Include="Interfaces\IBestSingleObjectiveTestFunctionSolutionAnalyzer.cs" />
    145     <Compile Include="Interfaces\IRastriginMoveEvaluator.cs" />
    146146    <Compile Include="Interfaces\ISingleObjectiveTestFunctionAdditiveMoveEvaluator.cs" />
    147147    <Compile Include="Interfaces\ISingleObjectiveTestFunctionMoveEvaluator.cs" />
    148     <Compile Include="Interfaces\ISingleObjectiveTestFunctionProblemEvaluator.cs" />
     148    <Compile Include="Interfaces\ISingleObjectiveTestFunction.cs" />
    149149    <Compile Include="Interfaces\ISingleObjectiveTestFunctionProblemSolutionsVisualizer.cs" />
    150     <Compile Include="Interfaces\ISphereMoveEvaluator.cs" />
    151     <Compile Include="MoveEvaluators\AckleyAdditiveMoveEvaluator.cs" />
    152     <Compile Include="MoveEvaluators\BealeAdditiveMoveEvaluator.cs" />
    153     <Compile Include="MoveEvaluators\BoothAdditiveMoveEvaluator.cs" />
    154     <Compile Include="MoveEvaluators\MultinormalAdditiveMoveEvaluator.cs" />
    155     <Compile Include="MoveEvaluators\GriewankAdditiveMoveEvaluator.cs" />
    156     <Compile Include="MoveEvaluators\ZakharovAdditiveMoveEvaluator.cs" />
    157     <Compile Include="MoveEvaluators\SumSquaresAdditiveMoveEvaluator.cs" />
    158     <Compile Include="MoveEvaluators\SphereAdditiveMoveEvaluator.cs" />
    159     <Compile Include="MoveEvaluators\SchwefelAdditiveMoveEvaluator.cs" />
    160     <Compile Include="MoveEvaluators\MatyasAdditiveMoveEvaluator.cs" />
    161     <Compile Include="MoveEvaluators\RosenbrockAdditiveMoveEvaluator.cs" />
    162     <Compile Include="MoveEvaluators\RastriginAdditiveMoveEvaluator.cs" />
    163     <Compile Include="MoveEvaluators\LevyAdditiveMoveEvaluator.cs" />
    164150    <Compile Include="MoveEvaluators\AdditiveMoveEvaluator.cs" />
    165     <Compile Include="MoveEvaluators\RealVectorAdditiveMoveWrapper.cs" />
    166     <Compile Include="RealVectorToRealVectorEncoder.cs" />
    167151    <Compile Include="SimilarityCalculators\SingleObjectiveTestFunctionSimilarityCalculator.cs" />
    168152    <Compile Include="SingleObjectiveTestFunctionSolution.cs" />
     
    239223      <Project>{3540e29e-4793-49e7-8ee2-fea7f61c3994}</Project>
    240224      <Name>HeuristicLab.Problems.Instances-3.3</Name>
     225      <Private>False</Private>
     226    </ProjectReference>
     227    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
     228      <Project>{f4539fb6-4708-40c9-be64-0a1390aea197}</Project>
     229      <Name>HeuristicLab.Random-3.3</Name>
    241230      <Private>False</Private>
    242231    </ProjectReference>
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Improvers/SingleObjectiveTestFunctionImprovementOperator.cs

    r12012 r13403  
    2626using HeuristicLab.Encodings.RealVectorEncoding;
    2727using HeuristicLab.Operators;
    28 using HeuristicLab.Optimization;
    2928using HeuristicLab.Parameters;
    3029using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    4039  [Item("SingleObjectiveTestFunctionImprovementOperator", "An operator that improves test functions solutions. It is implemented as described in Laguna, M. and Martí, R. (2003). Scatter Search: Methodology and Implementations in C. Operations Research/Computer Science Interfaces Series, Vol. 24. Springer.")]
    4140  [StorableClass]
    42   public sealed class SingleObjectiveTestFunctionImprovementOperator : SingleSuccessorOperator, ISingleObjectiveImprovementOperator {
     41  public sealed class SingleObjectiveTestFunctionImprovementOperator : SingleSuccessorOperator, ISingleObjectiveTestFunctionImprovementOperator {
    4342    #region Parameter properties
    4443    public IValueParameter<DoubleValue> AlphaParameter {
     
    5150      get { return (IValueLookupParameter<DoubleMatrix>)Parameters["Bounds"]; }
    5251    }
    53     public ScopeParameter CurrentScopeParameter {
    54       get { return (ScopeParameter)Parameters["CurrentScope"]; }
    55     }
    5652    public IValueParameter<DoubleValue> DeltaParameter {
    5753      get { return (IValueParameter<DoubleValue>)Parameters["Delta"]; }
    5854    }
    59     public IValueLookupParameter<ISingleObjectiveTestFunctionProblemEvaluator> EvaluatorParameter {
    60       get { return (IValueLookupParameter<ISingleObjectiveTestFunctionProblemEvaluator>)Parameters["Evaluator"]; }
     55    public IValueLookupParameter<ISingleObjectiveTestFunction> TestFunctionParameter {
     56      get { return (IValueLookupParameter<ISingleObjectiveTestFunction>)Parameters["TestFunction"]; }
    6157    }
    6258    public IValueParameter<DoubleValue> GammaParameter {
     
    7874      get { return BetaParameter.Value; }
    7975    }
    80     private DoubleMatrix Bounds {
    81       get { return BoundsParameter.ActualValue; }
    82     }
    83     public IScope CurrentScope {
    84       get { return CurrentScopeParameter.ActualValue; }
    85     }
    8676    private DoubleValue Delta {
    8777      get { return DeltaParameter.Value; }
    8878    }
    89     public ISingleObjectiveTestFunctionProblemEvaluator Evaluator {
    90       get { return EvaluatorParameter.ActualValue; }
    91     }
    9279    private DoubleValue Gamma {
    9380      get { return GammaParameter.Value; }
    94     }
    95     public IntValue ImprovementAttempts {
    96       get { return ImprovementAttemptsParameter.ActualValue; }
    9781    }
    9882    #endregion
     
    10690      Parameters.Add(new ValueParameter<DoubleValue>("Alpha", new DoubleValue(1.0)));
    10791      Parameters.Add(new ValueParameter<DoubleValue>("Beta", new DoubleValue(2.0)));
     92      Parameters.Add(new ValueParameter<DoubleValue>("Delta", new DoubleValue(0.5)));
     93      Parameters.Add(new ValueParameter<DoubleValue>("Gamma", new DoubleValue(0.5)));
     94      Parameters.Add(new ValueLookupParameter<ISingleObjectiveTestFunction>("TestFunction", "The operator used to evaluate solutions."));
    10895      Parameters.Add(new ValueLookupParameter<DoubleMatrix>("Bounds", "The lower and upper bounds in each dimension."));
    109       Parameters.Add(new ScopeParameter("CurrentScope", "The current scope that contains the solution to be improved."));
    110       Parameters.Add(new ValueParameter<DoubleValue>("Delta", new DoubleValue(0.5)));
    111       Parameters.Add(new ValueLookupParameter<ISingleObjectiveTestFunctionProblemEvaluator>("Evaluator", "The operator used to evaluate solutions."));
    112       Parameters.Add(new ValueParameter<DoubleValue>("Gamma", new DoubleValue(0.5)));
    11396      Parameters.Add(new ValueLookupParameter<IntValue>("ImprovementAttempts", "The number of improvement attempts the operator should perform.", new IntValue(100)));
    114       Parameters.Add(new ValueLookupParameter<IItem>("Solution", "The solution to be improved. This parameter is used for name translation only."));
     97      Parameters.Add(new ValueLookupParameter<IItem>("Solution", "The solution to be improved. This parameter is used for name translation only.")); // TODO: Problematic, this cannot be wired! IImprovementOperators need to be generic
    11598      #endregion
    11699    }
     
    121104
    122105    public override IOperation Apply() {
    123       RealVector bestSol = CurrentScope.Variables[SolutionParameter.ActualName].Value as RealVector;
     106      RealVector bestSol = ExecutionContext.Scope.Variables[SolutionParameter.ActualName].Value as RealVector;
    124107      if (bestSol == null)
    125108        throw new ArgumentException("Cannot improve solution because it has the wrong type.");
    126109
    127       var evaluator = Evaluator;
     110      var bounds = BoundsParameter.ActualValue;
     111      var function = TestFunctionParameter.ActualValue;
     112      var maxIterations = ImprovementAttemptsParameter.ActualValue.Value;
    128113
    129       double bestSolQuality = evaluator.Evaluate(bestSol);
     114      double bestSolQuality = function.Evaluate(bestSol);
    130115
    131116      // create perturbed solutions
     
    133118      for (int i = 0; i < simplex.Length; i++) {
    134119        simplex[i] = bestSol.Clone() as RealVector;
    135         simplex[i][i] += 0.1 * (Bounds[0, 1] - Bounds[0, 0]);
    136         if (simplex[i][i] > Bounds[0, 1]) simplex[i][i] = Bounds[0, 1];
    137         if (simplex[i][i] < Bounds[0, 0]) simplex[i][i] = Bounds[0, 0];
     120        simplex[i][i] += 0.1 * (bounds[0, 1] - bounds[0, 0]);
     121        if (simplex[i][i] > bounds[0, 1]) simplex[i][i] = bounds[0, 1];
     122        if (simplex[i][i] < bounds[0, 0]) simplex[i][i] = bounds[0, 0];
    138123      }
    139124
    140125      // improve solutions
    141       for (int i = 0; i < ImprovementAttempts.Value; i++) {
     126      for (int i = 0; i < maxIterations; i++) {
    142127        // order according to their objective function value
    143         Array.Sort(simplex, (x, y) => evaluator.Evaluate(x).CompareTo(evaluator.Evaluate(y)));
     128        Array.Sort(simplex, (x, y) => function.Evaluate(x).CompareTo(function.Evaluate(y)));
    144129
    145130        // calculate centroid
     
    155140        for (int j = 0; j < reflectionPoint.Length; j++)
    156141          reflectionPoint[j] = centroid[j] + Alpha.Value * (centroid[j] - simplex[simplex.Length - 1][j]);
    157         double reflectionPointQuality = evaluator.Evaluate(reflectionPoint);
    158         if (evaluator.Evaluate(simplex[0]) <= reflectionPointQuality
    159             && reflectionPointQuality < evaluator.Evaluate(simplex[simplex.Length - 2]))
     142        double reflectionPointQuality = function.Evaluate(reflectionPoint);
     143        if (function.Evaluate(simplex[0]) <= reflectionPointQuality
     144            && reflectionPointQuality < function.Evaluate(simplex[simplex.Length - 2]))
    160145          simplex[simplex.Length - 1] = reflectionPoint;
    161146
    162147        // expansion
    163         if (reflectionPointQuality < evaluator.Evaluate(simplex[0])) {
     148        if (reflectionPointQuality < function.Evaluate(simplex[0])) {
    164149          RealVector expansionPoint = new RealVector(bestSol.Length);
    165150          for (int j = 0; j < expansionPoint.Length; j++)
    166151            expansionPoint[j] = centroid[j] + Beta.Value * (reflectionPoint[j] - centroid[j]);
    167           simplex[simplex.Length - 1] = evaluator.Evaluate(expansionPoint) < reflectionPointQuality ? expansionPoint : reflectionPoint;
     152          simplex[simplex.Length - 1] = function.Evaluate(expansionPoint) < reflectionPointQuality ? expansionPoint : reflectionPoint;
    168153        }
    169154
    170155        // contraction
    171         if (evaluator.Evaluate(simplex[simplex.Length - 2]) <= reflectionPointQuality
    172             && reflectionPointQuality < evaluator.Evaluate(simplex[simplex.Length - 1])) {
     156        if (function.Evaluate(simplex[simplex.Length - 2]) <= reflectionPointQuality
     157            && reflectionPointQuality < function.Evaluate(simplex[simplex.Length - 1])) {
    173158          RealVector outsideContractionPoint = new RealVector(bestSol.Length);
    174159          for (int j = 0; j < outsideContractionPoint.Length; j++)
    175160            outsideContractionPoint[j] = centroid[j] + Gamma.Value * (reflectionPoint[j] - centroid[j]);
    176           if (evaluator.Evaluate(outsideContractionPoint) <= reflectionPointQuality) {
     161          if (function.Evaluate(outsideContractionPoint) <= reflectionPointQuality) {
    177162            simplex[simplex.Length - 1] = outsideContractionPoint;
    178             if (evaluator.Evaluate(reflectionPoint) >= evaluator.Evaluate(simplex[simplex.Length - 1])) {
     163            if (function.Evaluate(reflectionPoint) >= function.Evaluate(simplex[simplex.Length - 1])) {
    179164              RealVector insideContractionPoint = new RealVector(bestSol.Length);
    180165              for (int j = 0; j < insideContractionPoint.Length; j++)
    181166                insideContractionPoint[j] = centroid[j] - Gamma.Value * (reflectionPoint[j] - centroid[j]);
    182               if (evaluator.Evaluate(insideContractionPoint) < evaluator.Evaluate(simplex[simplex.Length - 1])) simplex[simplex.Length - 1] = insideContractionPoint;
     167              if (function.Evaluate(insideContractionPoint) < function.Evaluate(simplex[simplex.Length - 1])) simplex[simplex.Length - 1] = insideContractionPoint;
    183168            }
    184169          }
     
    192177
    193178      for (int i = 0; i < simplex[0].Length; i++) {
    194         if (simplex[0][i] > Bounds[0, 1]) simplex[0][i] = Bounds[0, 1];
    195         if (simplex[0][i] < Bounds[0, 0]) simplex[0][i] = Bounds[0, 0];
     179        if (simplex[0][i] > bounds[0, 1]) simplex[0][i] = bounds[0, 1];
     180        if (simplex[0][i] < bounds[0, 0]) simplex[0][i] = bounds[0, 0];
    196181      }
    197182
    198       CurrentScope.Variables[SolutionParameter.ActualName].Value = simplex[0];
    199       CurrentScope.Variables.Add(new Variable("LocalEvaluatedSolutions", ImprovementAttempts));
     183      ExecutionContext.Scope.Variables[SolutionParameter.ActualName].Value = simplex[0];
     184      ExecutionContext.Scope.Variables.Add(new Variable("LocalEvaluatedSolutions", new IntValue(maxIterations)));
    200185
    201186      return base.Apply();
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Instances/SOTFData.cs

    r12012 r13403  
    3939    /// The operator used for evaluations
    4040    /// </summary>
    41     public ISingleObjectiveTestFunctionProblemEvaluator Evaluator { get; set; }
     41    public ISingleObjectiveTestFunction TestFunction { get; set; }
    4242  }
    4343}
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Instances/SOTFDataDescriptor.cs

    r12012 r13403  
    2424namespace HeuristicLab.Problems.TestFunctions {
    2525  internal class SOTFDataDescriptor : IDataDescriptor {
    26     public string Name { get { return Evaluator.FunctionName + " Function"; } }
     26    public string Name { get { return TestFunction.ItemName + " Function"; } }
    2727
    2828    public string Description {
    29       get { return Evaluator.Description; }
     29      get { return TestFunction.Description; }
    3030    }
    3131
    32     internal ISingleObjectiveTestFunctionProblemEvaluator Evaluator { get; set; }
     32    internal ISingleObjectiveTestFunction TestFunction { get; set; }
    3333
    34     public SOTFDataDescriptor(ISingleObjectiveTestFunctionProblemEvaluator evaluator) {
    35       Evaluator = evaluator;
     34    public SOTFDataDescriptor(ISingleObjectiveTestFunction testFunction) {
     35      TestFunction = testFunction;
    3636    }
    3737  }
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Instances/SOTFInstanceProvider.cs

    r12012 r13403  
    4545
    4646    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    47       var evaluators = ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionProblemEvaluator>()
     47      var evaluators = ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunction>()
    4848                                                 .OrderBy(x => x.Name);
    4949      return evaluators.Select(x => new SOTFDataDescriptor(x));
     
    5555        Name = descriptor.Name,
    5656        Description = descriptor.Description,
    57         Evaluator = descriptor.Evaluator
     57        TestFunction = descriptor.TestFunction
    5858      };
    5959    }
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Interfaces/IBestSingleObjectiveTestFunctionSolutionAnalyzer.cs

    r12012 r13403  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Data;
     24using HeuristicLab.Encodings.RealVectorEncoding;
    2325using HeuristicLab.Optimization;
    2426
     
    2729  /// An interface which represents operators for analyzing the best solution of single objective TestFunction Problems given in real vector representation.
    2830  /// </summary>
    29   public interface IBestSingleObjectiveTestFunctionSolutionAnalyzer : IAnalyzer, ISingleObjectiveOperator {
    30     ILookupParameter RealVectorParameter { get; }
    31     ILookupParameter QualityParameter { get; }
     31  public interface IBestSingleObjectiveTestFunctionSolutionAnalyzer : IAnalyzer, ISingleObjectiveOperator,
     32    IRealVectorSolutionsOperator, IRealVectorBoundedOperator {
     33    IScopeTreeLookupParameter<DoubleValue> QualityParameter { get; }
    3234    ILookupParameter<SingleObjectiveTestFunctionSolution> BestSolutionParameter { get; }
    3335    IValueLookupParameter<ResultCollection> ResultsParameter { get; }
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Interfaces/ISingleObjectiveTestFunction.cs

    r13393 r13403  
    2323using HeuristicLab.Data;
    2424using HeuristicLab.Encodings.RealVectorEncoding;
    25 using HeuristicLab.Optimization;
    2625
    2726namespace HeuristicLab.Problems.TestFunctions {
     
    2928  /// An interface which represents an evaluation operator for single objective test functions.
    3029  /// </summary>
    31   public interface ISingleObjectiveTestFunctionProblemEvaluator : ISingleObjectiveEvaluator {
     30  public interface ISingleObjectiveTestFunction : INamedItem {
    3231    bool Maximization { get; }
    3332    DoubleMatrix Bounds { get; }
     
    3534    int MinimumProblemSize { get; }
    3635    int MaximumProblemSize { get; }
    37     string FunctionName { get; }
    38 
    39     ILookupParameter<RealVector> PointParameter { get; }
    4036
    4137    double Evaluate2D(double x, double y);
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Interfaces/ISingleObjectiveTestFunctionAdditiveMoveEvaluator.cs

    r12012 r13403  
    2323
    2424namespace HeuristicLab.Problems.TestFunctions {
    25   public interface ISingleObjectiveTestFunctionAdditiveMoveEvaluator : ISingleObjectiveTestFunctionMoveEvaluator, IAdditiveRealVectorMoveOperator {
     25  public interface ISingleObjectiveTestFunctionAdditiveMoveEvaluator : ISingleObjectiveTestFunctionMoveEvaluator, IRealVectorAdditiveMoveOperator {
    2626  }
    2727}
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Interfaces/ISingleObjectiveTestFunctionMoveEvaluator.cs

    r12012 r13403  
    2020#endregion
    2121
    22 using System;
    2322using HeuristicLab.Optimization;
    2423
    2524namespace HeuristicLab.Problems.TestFunctions {
    2625  public interface ISingleObjectiveTestFunctionMoveEvaluator : ISingleObjectiveMoveEvaluator, IMoveOperator {
    27     Type EvaluatorType { get; }
    2826  }
    2927}
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/MoveEvaluators/AdditiveMoveEvaluator.cs

    r12012 r13403  
    2020#endregion
    2121
    22 using System;
    2322using HeuristicLab.Common;
    2423using HeuristicLab.Core;
     
    3231  [Item("AdditiveMoveEvaluator", "Base class for evaluating an additive move.")]
    3332  [StorableClass]
    34   public abstract class AdditiveMoveEvaluator : SingleSuccessorOperator, ISingleObjectiveTestFunctionAdditiveMoveEvaluator {
     33  public class AdditiveMoveEvaluator : SingleSuccessorOperator, ISingleObjectiveTestFunctionAdditiveMoveEvaluator {
    3534
    36     public abstract Type EvaluatorType { get; }
    3735    public override bool CanChangeName {
    3836      get { return false; }
     
    5149      get { return (ILookupParameter<AdditiveMove>)Parameters["AdditiveMove"]; }
    5250    }
     51    public ILookupParameter<ISingleObjectiveTestFunction> TestFunctionParameter {
     52      get { return (ILookupParameter<ISingleObjectiveTestFunction>)Parameters["TestFunction"]; }
     53    }
    5354
    5455    [StorableConstructor]
    5556    protected AdditiveMoveEvaluator(bool deserializing) : base(deserializing) { }
    5657    protected AdditiveMoveEvaluator(AdditiveMoveEvaluator original, Cloner cloner) : base(original, cloner) { }
    57     protected AdditiveMoveEvaluator()
     58    public AdditiveMoveEvaluator()
    5859      : base() {
    5960      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "The quality of a test function solution."));
     
    6162      Parameters.Add(new LookupParameter<RealVector>("Point", "The point to evaluate the move on."));
    6263      Parameters.Add(new LookupParameter<AdditiveMove>("AdditiveMove", "The move to evaluate."));
     64      Parameters.Add(new LookupParameter<ISingleObjectiveTestFunction>("TestFunction", "The test function that is used."));
     65    }
     66
     67    public override IDeepCloneable Clone(Cloner cloner) {
     68      return new AdditiveMoveEvaluator(this, cloner);
    6369    }
    6470
    6571    public override IOperation Apply() {
    66       double mq = Evaluate(QualityParameter.ActualValue.Value, RealVectorParameter.ActualValue, AdditiveMoveParameter.ActualValue);
    67       DoubleValue moveQuality = MoveQualityParameter.ActualValue;
     72      var function = TestFunctionParameter.ActualValue;
     73      var move = AdditiveMoveParameter.ActualValue;
     74      var vector = RealVectorParameter.ActualValue;
     75      var clone = (RealVector)vector.Clone();
     76
     77      AdditiveMoveMaker.Apply(clone, move);
     78      var mq = function.Evaluate(clone);
     79
     80      var moveQuality = MoveQualityParameter.ActualValue;
    6881      if (moveQuality == null) {
    6982        MoveQualityParameter.ActualValue = new DoubleValue(mq);
     
    7184      return base.Apply();
    7285    }
    73 
    74     protected abstract double Evaluate(double quality, RealVector point, AdditiveMove move);
    7586  }
    7687}
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/SimilarityCalculators/SingleObjectiveTestFunctionSimilarityCalculator.cs

    r12070 r13403  
    3737  [Item("SingleObjectiveTestFunctionSimilarityCalculator", "An operator that performs similarity calculation between two test functions solutions. The operator calculates the similarity based on the euclidean distance of the two solutions in n-dimensional space.")]
    3838  [StorableClass]
    39   public sealed class SingleObjectiveTestFunctionSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     39  public sealed class SingleObjectiveTestFunctionSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator, ITestFunctionSolutionSimilarityCalculator {
    4040    protected override bool IsCommutative { get { return true; } }
    4141
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r13361 r13403  
    3232using HeuristicLab.Parameters;
    3333using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    34 using HeuristicLab.PluginInfrastructure;
    3534using HeuristicLab.Problems.Instances;
    3635
     
    4039  [Creatable(CreatableAttribute.Categories.Problems, Priority = 90)]
    4140  public sealed class SingleObjectiveTestFunctionProblem :
    42     SingleObjectiveHeuristicOptimizationProblem<ISingleObjectiveTestFunctionProblemEvaluator, IRealVectorCreator>,
    43     ISingleObjectiveProblem<RealVectorEncoding, RealVector>, IStorableContent, IProblemInstanceConsumer<SOTFData> {
    44     public string Filename { get; set; }
    45 
    46     [Storable]
    47     private StdDevStrategyVectorCreator strategyVectorCreator;
    48     [Storable]
    49     private StdDevStrategyVectorCrossover strategyVectorCrossover;
    50     [Storable]
    51     private StdDevStrategyVectorManipulator strategyVectorManipulator;
     41    SingleObjectiveProblem<RealVectorEncoding, RealVector>,
     42    IProblemInstanceConsumer<SOTFData> {
     43
     44    public override bool Maximization {
     45      get { return Parameters.ContainsKey("TestFunction") && TestFunction.Maximization; }
     46    }
    5247
    5348    #region Parameter Properties
    54     public ValueParameter<DoubleMatrix> BoundsParameter {
    55       get { return (ValueParameter<DoubleMatrix>)Parameters["Bounds"]; }
    56     }
    57     public ValueParameter<IntValue> ProblemSizeParameter {
    58       get { return (ValueParameter<IntValue>)Parameters["ProblemSize"]; }
     49    private IFixedValueParameter<IntValue> ProblemSizeParameter {
     50      get { return (IFixedValueParameter<IntValue>)Parameters["ProblemSize"]; }
     51    }
     52    private IValueParameter<DoubleMatrix> BoundsParameter {
     53      get { return (IValueParameter<DoubleMatrix>)Parameters["Bounds"]; }
    5954    }
    6055    public OptionalValueParameter<RealVector> BestKnownSolutionParameter {
    6156      get { return (OptionalValueParameter<RealVector>)Parameters["BestKnownSolution"]; }
    6257    }
     58    public IValueParameter<ISingleObjectiveTestFunction> TestFunctionParameter {
     59      get { return (IValueParameter<ISingleObjectiveTestFunction>)Parameters["TestFunction"]; }
     60    }
    6361    #endregion
    6462
    6563    #region Properties
     64    public int ProblemSize {
     65      get { return ProblemSizeParameter.Value.Value; }
     66      set { ProblemSizeParameter.Value.Value = value; }
     67    }
    6668    public DoubleMatrix Bounds {
    6769      get { return BoundsParameter.Value; }
    6870      set { BoundsParameter.Value = value; }
    6971    }
    70     public IntValue ProblemSize {
    71       get { return ProblemSizeParameter.Value; }
    72       set { ProblemSizeParameter.Value = value; }
    73     }
     72    public ISingleObjectiveTestFunction TestFunction {
     73      get { return TestFunctionParameter.Value; }
     74      set { TestFunctionParameter.Value = value; }
     75    }
     76
    7477    private BestSingleObjectiveTestFunctionSolutionAnalyzer BestSingleObjectiveTestFunctionSolutionAnalyzer {
    7578      get { return Operators.OfType<BestSingleObjectiveTestFunctionSolutionAnalyzer>().FirstOrDefault(); }
    76     }
    77     #endregion
    78 
    79     // BackwardsCompatibility3.3
    80     #region Backwards compatible code, remove with 3.4
    81     [Obsolete]
    82     [Storable(Name = "operators")]
    83     private IEnumerable<IOperator> oldOperators {
    84       get { return null; }
    85       set {
    86         if (value != null && value.Any())
    87           Operators.AddRange(value);
    88       }
    8979    }
    9080    #endregion
     
    9484    private SingleObjectiveTestFunctionProblem(SingleObjectiveTestFunctionProblem original, Cloner cloner)
    9585      : base(original, cloner) {
    96       strategyVectorCreator = cloner.Clone(original.strategyVectorCreator);
    97       strategyVectorCrossover = cloner.Clone(original.strategyVectorCrossover);
    98       strategyVectorManipulator = cloner.Clone(original.strategyVectorManipulator);
    9986      RegisterEventHandlers();
    10087    }
    10188    public SingleObjectiveTestFunctionProblem()
    102       : base(new AckleyEvaluator(), new UniformRandomRealVectorCreator()) {
    103       Parameters.Add(new ValueParameter<DoubleMatrix>("Bounds", "The lower and upper bounds in each dimension.", Evaluator.Bounds));
    104       Parameters.Add(new ValueParameter<IntValue>("ProblemSize", "The dimension of the problem.", new IntValue(2)));
     89      : base(new RealVectorEncoding("Point")) {
     90      Parameters.Add(new FixedValueParameter<IntValue>("ProblemSize", "The dimensionality of the problem instance (number of variables in the function).", new IntValue(2)));
     91      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 } })));
    10592      Parameters.Add(new OptionalValueParameter<RealVector>("BestKnownSolution", "The best known solution for this test function instance."));
    106 
    107       Maximization.Value = Evaluator.Maximization;
    108       BestKnownQuality = new DoubleValue(Evaluator.BestKnownQuality);
    109 
    110       strategyVectorCreator = new StdDevStrategyVectorCreator();
    111       strategyVectorCreator.LengthParameter.ActualName = ProblemSizeParameter.Name;
    112       strategyVectorCrossover = new StdDevStrategyVectorCrossover();
    113       strategyVectorManipulator = new StdDevStrategyVectorManipulator();
    114       strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(0.5);
    115       strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(0.5);
    116 
    117       SolutionCreator.RealVectorParameter.ActualName = "Point";
    118       ParameterizeSolutionCreator();
    119       ParameterizeEvaluator();
     93      Parameters.Add(new ValueParameter<ISingleObjectiveTestFunction>("TestFunction", "The function that is to be optimized.", new Ackley()));
     94
     95      Encoding.LengthParameter = ProblemSizeParameter;
     96      Encoding.BoundsParameter = BoundsParameter;
     97      BestKnownQuality = TestFunction.BestKnownQuality;
    12098
    12199      InitializeOperators();
    122100      RegisterEventHandlers();
    123       UpdateStrategyVectorBounds();
    124101    }
    125102
     
    128105    }
    129106
     107    [StorableHook(HookType.AfterDeserialization)]
     108    private void AfterDeserialization() {
     109      RegisterEventHandlers();
     110    }
     111
     112    private void RegisterEventHandlers() {
     113      Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
     114      TestFunctionParameter.ValueChanged += TestFunctionParameterOnValueChanged;
     115      ProblemSizeParameter.Value.ValueChanged += ProblemSizeOnValueChanged;
     116      BoundsParameter.ValueChanged += BoundsParameterOnValueChanged;
     117    }
     118
     119    public override double Evaluate(RealVector individual, IRandom random) {
     120      return TestFunction.Evaluate(individual);
     121    }
     122
    130123    #region Events
    131     protected override void OnSolutionCreatorChanged() {
    132       base.OnSolutionCreatorChanged();
    133       ParameterizeSolutionCreator();
    134       ParameterizeAnalyzers();
    135       SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged);
    136       SolutionCreator_RealVectorParameter_ActualNameChanged(null, EventArgs.Empty);
     124    protected override void OnEncodingChanged() {
     125      base.OnEncodingChanged();
     126      Parameterize();
    137127    }
    138128    protected override void OnEvaluatorChanged() {
    139129      base.OnEvaluatorChanged();
    140       bool problemSizeChange = ProblemSize.Value < Evaluator.MinimumProblemSize
    141         || ProblemSize.Value > Evaluator.MaximumProblemSize;
     130      Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
     131      Parameterize();
     132    }
     133    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
     134      Parameterize();
     135    }
     136    private void TestFunctionParameterOnValueChanged(object sender, EventArgs eventArgs) {
     137      var problemSizeChange = ProblemSize < TestFunction.MinimumProblemSize
     138                              || ProblemSize > TestFunction.MaximumProblemSize;
    142139      if (problemSizeChange) {
    143         ProblemSize.Value = Math.Max(Evaluator.MinimumProblemSize, Math.Min(ProblemSize.Value, Evaluator.MaximumProblemSize));
    144       } else {
    145         ParameterizeEvaluator();
    146       }
    147       UpdateMoveEvaluators();
    148       ParameterizeAnalyzers();
    149       Maximization.Value = Evaluator.Maximization;
    150       BoundsParameter.Value = Evaluator.Bounds;
    151       BestKnownQuality = new DoubleValue(Evaluator.BestKnownQuality);
    152       Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    153       Evaluator_QualityParameter_ActualNameChanged(null, EventArgs.Empty);
     140        ProblemSize = Math.Max(TestFunction.MinimumProblemSize, Math.Min(ProblemSize, TestFunction.MaximumProblemSize));
     141      }
     142      BestKnownQuality = TestFunction.BestKnownQuality;
     143      Bounds = (DoubleMatrix)TestFunction.Bounds.Clone();
     144      var bestSolution = TestFunction.GetBestKnownSolution(ProblemSize);
     145      BestKnownSolutionParameter.Value = bestSolution;
     146
    154147      OnReset();
    155148    }
    156     private void ProblemSizeParameter_ValueChanged(object sender, EventArgs e) {
    157       ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
    158       ProblemSize_ValueChanged(null, EventArgs.Empty);
    159     }
    160     private void ProblemSize_ValueChanged(object sender, EventArgs e) {
    161       if (ProblemSize.Value < 1) ProblemSize.Value = 1;
    162       ParameterizeSolutionCreator();
    163       ParameterizeEvaluator();
    164       strategyVectorManipulator.GeneralLearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * ProblemSize.Value));
    165       strategyVectorManipulator.LearningRateParameter.Value = new DoubleValue(1.0 / Math.Sqrt(2 * Math.Sqrt(ProblemSize.Value)));
    166       OnReset();
    167     }
    168     private void SolutionCreator_RealVectorParameter_ActualNameChanged(object sender, EventArgs e) {
    169       ParameterizeEvaluator();
    170       ParameterizeOperators();
    171       ParameterizeAnalyzers();
    172     }
    173     private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    174       ParameterizeOperators();
    175     }
    176     private void BoundsParameter_ValueChanged(object sender, EventArgs e) {
    177       Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged);
    178       Bounds_ToStringChanged(null, EventArgs.Empty);
    179     }
    180     private void Bounds_ToStringChanged(object sender, EventArgs e) {
    181       if (Bounds.Columns != 2 || Bounds.Rows < 1)
    182         Bounds = new DoubleMatrix(1, 2);
    183       ParameterizeOperators();
    184       UpdateStrategyVectorBounds();
    185     }
    186     private void Bounds_ItemChanged(object sender, EventArgs<int, int> e) {
    187       if (e.Value2 == 0 && Bounds[e.Value, 1] <= Bounds[e.Value, 0])
    188         Bounds[e.Value, 1] = Bounds[e.Value, 0] + 0.1;
    189       if (e.Value2 == 1 && Bounds[e.Value, 0] >= Bounds[e.Value, 1])
    190         Bounds[e.Value, 0] = Bounds[e.Value, 1] - 0.1;
    191       ParameterizeOperators();
    192       UpdateStrategyVectorBounds();
    193     }
    194     private void MoveGenerator_AdditiveMoveParameter_ActualNameChanged(object sender, EventArgs e) {
    195       string name = ((ILookupParameter<AdditiveMove>)sender).ActualName;
    196       foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) {
    197         op.AdditiveMoveParameter.ActualName = name;
    198       }
    199     }
    200     private void SphereEvaluator_Parameter_ValueChanged(object sender, EventArgs e) {
    201       SphereEvaluator eval = (Evaluator as SphereEvaluator);
    202       if (eval != null) {
    203         foreach (ISphereMoveEvaluator op in Operators.OfType<ISphereMoveEvaluator>()) {
    204           op.C = eval.C;
    205           op.Alpha = eval.Alpha;
    206         }
    207       }
    208     }
    209     private void RastriginEvaluator_Parameter_ValueChanged(object sender, EventArgs e) {
    210       RastriginEvaluator eval = (Evaluator as RastriginEvaluator);
    211       if (eval != null) {
    212         foreach (IRastriginMoveEvaluator op in Operators.OfType<IRastriginMoveEvaluator>()) {
    213           op.A = eval.A;
    214         }
    215       }
    216     }
    217     private void strategyVectorCreator_BoundsParameter_ValueChanged(object sender, EventArgs e) {
    218       strategyVectorManipulator.BoundsParameter.Value = (DoubleMatrix)strategyVectorCreator.BoundsParameter.Value.Clone();
    219     }
    220     private void strategyVectorCreator_StrategyParameterParameter_ActualNameChanged(object sender, EventArgs e) {
    221       string name = strategyVectorCreator.StrategyParameterParameter.ActualName;
    222       strategyVectorCrossover.ParentsParameter.ActualName = name;
    223       strategyVectorCrossover.StrategyParameterParameter.ActualName = name;
    224       strategyVectorManipulator.StrategyParameterParameter.ActualName = name;
     149    private void ProblemSizeOnValueChanged(object sender, EventArgs eventArgs) {
     150      if (ProblemSize < TestFunction.MinimumProblemSize
     151        || ProblemSize > TestFunction.MaximumProblemSize)
     152        ProblemSize = Math.Min(TestFunction.MaximumProblemSize, Math.Max(TestFunction.MinimumProblemSize, ProblemSize));
     153    }
     154    private void BoundsParameterOnValueChanged(object sender, EventArgs eventArgs) {
     155      Parameterize();
    225156    }
    226157    #endregion
    227158
    228159    #region Helpers
    229     [StorableHook(HookType.AfterDeserialization)]
    230     private void AfterDeserialization() {
    231       // BackwardsCompatibility3.3
    232       #region Backwards compatible code (remove with 3.4)
    233       if (Operators.Count == 0) InitializeOperators();
    234       #endregion
    235       RegisterEventHandlers();
    236     }
    237 
    238     private void RegisterEventHandlers() {
    239       ProblemSizeParameter.ValueChanged += new EventHandler(ProblemSizeParameter_ValueChanged);
    240       ProblemSize.ValueChanged += new EventHandler(ProblemSize_ValueChanged);
    241       BoundsParameter.ValueChanged += new EventHandler(BoundsParameter_ValueChanged);
    242       Bounds.ToStringChanged += new EventHandler(Bounds_ToStringChanged);
    243       Bounds.ItemChanged += new EventHandler<EventArgs<int, int>>(Bounds_ItemChanged);
    244       SolutionCreator.RealVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_RealVectorParameter_ActualNameChanged);
    245       Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    246       strategyVectorCreator.BoundsParameter.ValueChanged += new EventHandler(strategyVectorCreator_BoundsParameter_ValueChanged);
    247       strategyVectorCreator.StrategyParameterParameter.ActualNameChanged += new EventHandler(strategyVectorCreator_StrategyParameterParameter_ActualNameChanged);
    248     }
    249     private void ParameterizeAnalyzers() {
    250       if (BestSingleObjectiveTestFunctionSolutionAnalyzer != null) {
    251         BestSingleObjectiveTestFunctionSolutionAnalyzer.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    252         BestSingleObjectiveTestFunctionSolutionAnalyzer.ResultsParameter.ActualName = "Results";
    253         BestSingleObjectiveTestFunctionSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    254         BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
    255         BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
    256         BestSingleObjectiveTestFunctionSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
    257         BestSingleObjectiveTestFunctionSolutionAnalyzer.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
    258         BestSingleObjectiveTestFunctionSolutionAnalyzer.BoundsParameter.ActualName = BoundsParameter.Name;
    259       }
    260     }
    261160    private void InitializeOperators() {
    262161      Operators.Add(new SingleObjectiveTestFunctionImprovementOperator());
     
    265164      Operators.Add(new QualitySimilarityCalculator());
    266165      Operators.Add(new NoSimilarityCalculator());
     166      Operators.Add(new AdditiveMoveEvaluator());
    267167
    268168      Operators.Add(new BestSingleObjectiveTestFunctionSolutionAnalyzer());
    269169      Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>()));
    270       ParameterizeAnalyzers();
    271       Operators.AddRange(ApplicationManager.Manager.GetInstances<IRealVectorOperator>().Cast<IOperator>());
    272       Operators.Add(strategyVectorCreator);
    273       Operators.Add(strategyVectorCrossover);
    274       Operators.Add(strategyVectorManipulator);
    275       UpdateMoveEvaluators();
    276       ParameterizeOperators();
    277       InitializeMoveGenerators();
    278     }
    279     private void InitializeMoveGenerators() {
    280       foreach (IAdditiveRealVectorMoveOperator op in Operators.OfType<IAdditiveRealVectorMoveOperator>()) {
    281         if (op is IMoveGenerator) {
    282           op.AdditiveMoveParameter.ActualNameChanged += new EventHandler(MoveGenerator_AdditiveMoveParameter_ActualNameChanged);
    283         }
    284       }
    285     }
    286     private void UpdateMoveEvaluators() {
    287       foreach (ISingleObjectiveTestFunctionMoveEvaluator op in Operators.OfType<ISingleObjectiveTestFunctionMoveEvaluator>().ToList())
    288         Operators.Remove(op);
    289       foreach (ISingleObjectiveTestFunctionMoveEvaluator op in ApplicationManager.Manager.GetInstances<ISingleObjectiveTestFunctionMoveEvaluator>())
    290         if (op.EvaluatorType == Evaluator.GetType()) {
    291           Operators.Add(op);
    292           #region Synchronize evaluator specific parameters with the parameters of the corresponding move evaluators
    293           if (op is ISphereMoveEvaluator) {
    294             SphereEvaluator e = (Evaluator as SphereEvaluator);
    295             e.AlphaParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged);
    296             e.CParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged);
    297             ISphereMoveEvaluator em = (op as ISphereMoveEvaluator);
    298             em.C = e.C;
    299             em.Alpha = e.Alpha;
    300           } else if (op is IRastriginMoveEvaluator) {
    301             RastriginEvaluator e = (Evaluator as RastriginEvaluator);
    302             e.AParameter.ValueChanged += new EventHandler(RastriginEvaluator_Parameter_ValueChanged);
    303             IRastriginMoveEvaluator em = (op as IRastriginMoveEvaluator);
    304             em.A = e.A;
    305           }
    306           #endregion
    307         }
    308       ParameterizeOperators();
    309       OnOperatorsChanged();
    310     }
    311     private void ParameterizeSolutionCreator() {
    312       SolutionCreator.LengthParameter.Value = new IntValue(ProblemSize.Value);
    313       SolutionCreator.LengthParameter.Hidden = true;
    314       SolutionCreator.BoundsParameter.ActualName = BoundsParameter.Name;
    315       SolutionCreator.BoundsParameter.Hidden = true;
    316     }
    317     private void ParameterizeEvaluator() {
    318       Evaluator.PointParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    319       Evaluator.PointParameter.Hidden = true;
    320       try {
    321         BestKnownSolutionParameter.Value = Evaluator.GetBestKnownSolution(ProblemSize.Value);
    322       }
    323       catch (ArgumentException e) {
    324         ErrorHandling.ShowErrorDialog(e);
    325         ProblemSize.Value = Evaluator.MinimumProblemSize;
    326       }
    327     }
    328     private void ParameterizeOperators() {
    329       foreach (var op in Operators.OfType<IRealVectorCrossover>()) {
    330         op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    331         op.ParentsParameter.Hidden = true;
    332         op.ChildParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    333         op.ChildParameter.Hidden = true;
    334         op.BoundsParameter.ActualName = BoundsParameter.Name;
    335         op.BoundsParameter.Hidden = true;
    336       }
    337       foreach (var op in Operators.OfType<IRealVectorManipulator>()) {
    338         op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    339         op.RealVectorParameter.Hidden = true;
    340         op.BoundsParameter.ActualName = BoundsParameter.Name;
    341         op.BoundsParameter.Hidden = true;
    342       }
    343       foreach (var op in Operators.OfType<IRealVectorMoveOperator>()) {
    344         op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    345         op.RealVectorParameter.Hidden = true;
    346       }
    347       foreach (var op in Operators.OfType<IRealVectorMoveGenerator>()) {
    348         op.BoundsParameter.ActualName = BoundsParameter.Name;
    349         op.BoundsParameter.Hidden = true;
     170      Parameterize();
     171    }
     172
     173    private void Parameterize() {
     174      var operators = new List<IItem>();
     175      if (BestSingleObjectiveTestFunctionSolutionAnalyzer != null) {
     176        operators.Add(BestSingleObjectiveTestFunctionSolutionAnalyzer);
     177        BestSingleObjectiveTestFunctionSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
     178        BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name;
     179        BestSingleObjectiveTestFunctionSolutionAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name;
     180        BestSingleObjectiveTestFunctionSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
     181        BestSingleObjectiveTestFunctionSolutionAnalyzer.TestFunctionParameter.ActualName = TestFunctionParameter.Name;
    350182      }
    351183      foreach (var op in Operators.OfType<ISingleObjectiveTestFunctionAdditiveMoveEvaluator>()) {
     184        operators.Add(op);
    352185        op.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
    353186        op.QualityParameter.Hidden = true;
    354         op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    355         op.RealVectorParameter.Hidden = true;
    356       }
    357       foreach (var op in Operators.OfType<IRealVectorParticleCreator>()) {
    358         op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    359         op.RealVectorParameter.Hidden = true;
    360         op.BoundsParameter.ActualName = BoundsParameter.Name;
    361         op.BoundsParameter.Hidden = true;
    362         op.ProblemSizeParameter.ActualName = ProblemSizeParameter.Name;
    363         op.ProblemSizeParameter.Hidden = true;
    364       }
    365       foreach (var op in Operators.OfType<IRealVectorParticleUpdater>()) {
    366         op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    367         op.RealVectorParameter.Hidden = true;
    368         op.BoundsParameter.ActualName = BoundsParameter.Name;
    369         op.BoundsParameter.Hidden = true;
     187        foreach (var movOp in Encoding.Operators.OfType<IRealVectorAdditiveMoveQualityOperator>())
     188          movOp.MoveQualityParameter.ActualName = op.MoveQualityParameter.ActualName;
    370189      }
    371190      foreach (var op in Operators.OfType<IRealVectorSwarmUpdater>()) {
    372         op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    373         op.RealVectorParameter.Hidden = true;
    374191        op.MaximizationParameter.ActualName = MaximizationParameter.Name;
    375192        op.MaximizationParameter.Hidden = true;
    376193      }
    377       foreach (var op in Operators.OfType<IRealVectorMultiNeighborhoodShakingOperator>()) {
    378         op.RealVectorParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    379         op.RealVectorParameter.Hidden = true;
    380       }
    381194      foreach (var op in Operators.OfType<ISingleObjectiveImprovementOperator>()) {
    382         op.SolutionParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
     195        operators.Add(op);
     196        op.SolutionParameter.ActualName = Encoding.Name;
    383197        op.SolutionParameter.Hidden = true;
    384198      }
    385       foreach (var op in Operators.OfType<ISingleObjectivePathRelinker>()) {
    386         op.ParentsParameter.ActualName = SolutionCreator.RealVectorParameter.ActualName;
    387         op.ParentsParameter.Hidden = true;
    388       }
    389       foreach (var op in Operators.OfType<ISolutionSimilarityCalculator>()) {
    390         op.SolutionVariableName = SolutionCreator.RealVectorParameter.ActualName;
     199      foreach (var op in Operators.OfType<ITestFunctionSolutionSimilarityCalculator>()) {
     200        operators.Add(op);
     201        op.SolutionVariableName = Encoding.Name;
    391202        op.QualityVariableName = Evaluator.QualityParameter.ActualName;
    392         var calc = op as SingleObjectiveTestFunctionSimilarityCalculator;
    393         if (calc != null) calc.Bounds = Bounds;
    394       }
    395     }
    396     private void UpdateStrategyVectorBounds() {
    397       var strategyBounds = (DoubleMatrix)Bounds.Clone();
    398       for (int i = 0; i < strategyBounds.Rows; i++) {
    399         if (strategyBounds[i, 0] < 0) strategyBounds[i, 0] = 0;
    400         strategyBounds[i, 1] = 0.1 * (Bounds[i, 1] - Bounds[i, 0]);
    401       }
    402       strategyVectorCreator.BoundsParameter.Value = strategyBounds;
     203        op.Bounds = Bounds;
     204      }
     205
     206      if (operators.Count > 0) Encoding.ConfigureOperators(operators);
    403207    }
    404208    #endregion
     
    407211      Name = data.Name;
    408212      Description = data.Description;
    409       Evaluator = data.Evaluator;
     213      TestFunction = data.TestFunction;
    410214    }
    411215  }
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionSolution.cs

    r12012 r13403  
    9797
    9898    [Storable]
    99     private ISingleObjectiveTestFunctionProblemEvaluator evaluator;
    100     public ISingleObjectiveTestFunctionProblemEvaluator Evaluator {
    101       get { return evaluator; }
    102       set {
    103         if (evaluator != value) {
    104           evaluator = value;
     99    private ISingleObjectiveTestFunction testFunction;
     100    public ISingleObjectiveTestFunction TestFunction {
     101      get { return testFunction; }
     102      set {
     103        if (testFunction != value) {
     104          testFunction = value;
    105105          OnEvaluatorChanged();
    106106        }
     
    130130      bestQuality = cloner.Clone(original.bestQuality);
    131131      population = cloner.Clone(original.population);
    132       evaluator = cloner.Clone(original.evaluator);
     132      testFunction = cloner.Clone(original.testFunction);
    133133      bounds = cloner.Clone(original.bounds);
    134134      Initialize();
    135135    }
    136136    public SingleObjectiveTestFunctionSolution() : base() { }
    137     public SingleObjectiveTestFunctionSolution(RealVector realVector, DoubleValue quality, ISingleObjectiveTestFunctionProblemEvaluator evaluator)
     137    public SingleObjectiveTestFunctionSolution(RealVector realVector, DoubleValue quality, ISingleObjectiveTestFunction testFunction)
    138138      : base() {
    139139      this.bestRealVector = realVector;
    140140      this.bestQuality = quality;
    141       this.evaluator = evaluator;
     141      this.testFunction = testFunction;
    142142      Initialize();
    143143    }
Note: See TracChangeset for help on using the changeset viewer.