Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13361


Ignore:
Timestamp:
11/24/15 16:01:02 (9 years ago)
Author:
mkommend
Message:

#2521: Adapted real vector encoding, test function problems, P3, CMA-ES and optimization.

Location:
branches/ProblemRefactoring
Files:
1 deleted
19 edited
1 moved

Legend:

Unmodified
Added
Removed
  • branches/ProblemRefactoring/HeuristicLab.Algorithms.CMAEvolutionStrategy/3.4/CMAEvolutionStrategy.cs

    r13173 r13361  
    6363
    6464    #region Problem Properties
     65
    6566    public override Type ProblemType {
    66       get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); }
    67     }
    68     public new ISingleObjectiveHeuristicOptimizationProblem Problem {
    69       get { return (ISingleObjectiveHeuristicOptimizationProblem)base.Problem; }
     67      get { return typeof(ISingleObjectiveProblem<RealVectorEncoding, RealVector>); }
     68    }
     69    public new ISingleObjectiveProblem<RealVectorEncoding, RealVector> Problem {
     70      get { return (ISingleObjectiveProblem<RealVectorEncoding, RealVector>)base.Problem; }
    7071      set { base.Problem = value; }
    7172    }
     
    378379    }
    379380
    380     protected override void OnStarted() {
    381       if (!(Problem.SolutionCreator is IRealVectorCreator))
    382         throw new InvalidOperationException("Problems that do not use RealVectorEncoding cannot be solved by CMA-ES.");
    383       base.OnStarted();
    384     }
    385 
    386381    #region Events
    387382    protected override void OnProblemChanged() {
  • branches/ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/EvaluationTracker.cs

    r13339 r13361  
    2222
    2323using System;
    24 using HeuristicLab.Common;
     24using System.Collections.Generic;
    2525using HeuristicLab.Core;
    26 using HeuristicLab.Data;
    2726using HeuristicLab.Encodings.BinaryVectorEncoding;
    2827using HeuristicLab.Optimization;
    29 using HeuristicLab.Parameters;
    30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3128
    3229namespace HeuristicLab.Algorithms.ParameterlessPopulationPyramid {
     
    3431  // B. W. Goldman and W. F. Punch, "Parameter-less Population Pyramid," GECCO, pp. 785–792, 2014
    3532  // and the original source code in C++11 available from: https://github.com/brianwgoldman/Parameter-less_Population_Pyramid
    36   internal sealed class EvaluationTracker : SingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> {
    37     private readonly ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> problem;
     33  internal sealed class EvaluationTracker : ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> {
     34    private readonly ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> problem;
    3835
    3936    private int maxEvaluations;
     
    6057    }
    6158
    62     public new BinaryVectorEncoding Encoding {
     59    public BinaryVectorEncoding Encoding {
    6360      get { return problem.Encoding; }
    6461    }
    6562    #endregion
    6663
    67     [StorableConstructor]
    68     private EvaluationTracker(bool deserializing) : base(deserializing) { }
    69     private EvaluationTracker(EvaluationTracker original, Cloner cloner)
    70       : base(original, cloner) {
    71       problem = cloner.Clone(original.problem);
    72       maxEvaluations = original.maxEvaluations;
    73       BestQuality = original.BestQuality;
    74       Evaluations = original.Evaluations;
    75       BestFoundOnEvaluation = original.BestFoundOnEvaluation;
    76       BestSolution = cloner.Clone(BestSolution);
    77     }
    78     public override IDeepCloneable Clone(Cloner cloner) {
    79       return new EvaluationTracker(this, cloner);
    80     }
    81     public EvaluationTracker(ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> problem, int maxEvaluations) {
     64    public EvaluationTracker(ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> problem, int maxEvaluations) {
    8265      this.problem = problem;
    8366      this.maxEvaluations = maxEvaluations;
     
    8669      Evaluations = 0;
    8770      BestFoundOnEvaluation = 0;
    88 
    89       if (Parameters.ContainsKey("Maximization")) Parameters.Remove("Maximization");
    90       Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden = true });
    9171    }
    9272
    93     public override double Evaluate(BinaryVector vector, IRandom random) {
     73
     74
     75    public double Evaluate(BinaryVector vector, IRandom random) {
    9476      if (Evaluations >= maxEvaluations) throw new OperationCanceledException("Maximum Evaluation Limit Reached");
    9577      Evaluations++;
     
    10385    }
    10486
    105     public override bool Maximization {
     87    public bool Maximization {
    10688      get {
    10789        if (problem == null) return false;
     
    11092    }
    11193
    112     public override bool IsBetter(double quality, double bestQuality) {
     94    public bool IsBetter(double quality, double bestQuality) {
    11395      return problem.IsBetter(quality, bestQuality);
    11496    }
    11597
     98    public void Analyze(BinaryVector[] individuals, double[] qualities, ResultCollection results, IRandom random) {
     99      problem.Analyze(individuals, qualities, results, random);
     100    }
     101
     102    public IEnumerable<BinaryVector> GetNeighbors(BinaryVector individual, IRandom random) {
     103      return problem.GetNeighbors(individual, random);
     104    }
    116105  }
    117106}
  • branches/ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/HillClimber.cs

    r13339 r13361  
    4949
    5050    public override Type ProblemType {
    51       get { return typeof(ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector>); }
     51      get { return typeof(ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector>); }
    5252    }
    53     public new ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> Problem {
    54       get { return (ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector>)base.Problem; }
    55       set { base.Problem = value; }
     53    public new ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> Problem {
     54      get { return (ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector>)base.Problem; }
     55      set { base.Problem = (IProblem)value; }
    5656    }
    5757
     
    9797    }
    9898    // In the GECCO paper, Section 2.1
    99     public static double ImproveToLocalOptimum(ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> problem, BinaryVector solution, double fitness, IRandom rand) {
     99    public static double ImproveToLocalOptimum(ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> problem, BinaryVector solution, double fitness, IRandom rand) {
    100100      var tried = new HashSet<int>();
    101101      do {
  • branches/ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/LinkageCrossover.cs

    r13339 r13361  
    3333  public static class LinkageCrossover {
    3434    // In the GECCO paper, Figure 3
    35     public static double ImproveUsingTree(LinkageTree tree, IList<BinaryVector> donors, BinaryVector solution, double fitness, ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> problem, IRandom rand) {
     35    public static double ImproveUsingTree(LinkageTree tree, IList<BinaryVector> donors, BinaryVector solution, double fitness, ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> problem, IRandom rand) {
    3636      var options = Enumerable.Range(0, donors.Count).ToArray();
    3737      foreach (var cluster in tree.Clusters) {
     
    4848    }
    4949
    50     private static double Donate(BinaryVector solution, double fitness, BinaryVector source, IEnumerable<int> cluster, ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> problem, IRandom rand, out bool changed) {
     50    private static double Donate(BinaryVector solution, double fitness, BinaryVector source, IEnumerable<int> cluster, ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> problem, IRandom rand, out bool changed) {
    5151      // keep track of which bits flipped to make the donation
    5252      List<int> flipped = new List<int>();
  • branches/ProblemRefactoring/HeuristicLab.Algorithms.ParameterlessPopulationPyramid/3.3/ParameterlessPopulationPyramid.cs

    r13339 r13361  
    4545      get { return typeof(ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector>); }
    4646    }
    47     public new ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector> Problem {
    48       get { return (ISingleObjectiveProblem<BinaryVectorEncoding, BinaryVector>)base.Problem; }
    49       set { base.Problem = value; }
     47    public new ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector> Problem {
     48      get { return (ISingleObjectiveProblemDefinition<BinaryVectorEncoding, BinaryVector>)base.Problem; }
     49      set { base.Problem = (IProblem)value; }
    5050    }
    5151
     
    182182      if (seen.Contains(solution)) return;
    183183      if (level == pyramid.Count) {
    184         pyramid.Add(new Population(tracker.Encoding.Length, random));
     184        pyramid.Add(new Population(Problem.Encoding.Length, random));
    185185      }
    186186      var copied = (BinaryVector)solution.Clone();
     
    192192    private double iterate() {
    193193      // Create a random solution
    194       BinaryVector solution = new BinaryVector(tracker.Encoding.Length);
     194      BinaryVector solution = new BinaryVector(Problem.Encoding.Length);
    195195      for (int i = 0; i < solution.Length; i++) {
    196196        solution[i] = random.Next(2) == 1;
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/Interfaces/IRealVectorCreator.cs

    r12012 r13361  
    2828  /// An interface which represents an operator for creating vectors of real-valued data.
    2929  /// </summary>
    30   public interface IRealVectorCreator : IRealVectorOperator, ISolutionCreator {
     30  public interface IRealVectorCreator : IRealVectorOperator, ISolutionCreator<RealVector> {
    3131    IValueLookupParameter<IntValue> LengthParameter { get; }
    3232    IValueLookupParameter<DoubleMatrix> BoundsParameter { get; }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVector.cs

    r12012 r13361  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Data;
     25using HeuristicLab.Optimization;
    2526using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2627
     
    2829  [StorableClass]
    2930  [Item("RealVector", "Represents a vector of real values.")]
    30   public class RealVector : DoubleArray {
     31  public class RealVector : DoubleArray, ISolution {
    3132    [StorableConstructor]
    3233    protected RealVector(bool deserializing) : base(deserializing) { }
  • branches/ProblemRefactoring/HeuristicLab.Encodings.RealVectorEncoding/3.3/RealVectorEncoding.cs

    r12837 r13361  
    3434  [Item("RealVectorEncoding", "Describes a real vector encoding.")]
    3535  [StorableClass]
    36   public sealed class RealVectorEncoding : Encoding<IRealVectorCreator> {
     36  public sealed class RealVectorEncoding : Encoding<RealVector> {
    3737    #region Encoding Parameters
    3838    [Storable]
     
    9595    public RealVectorEncoding(string name) : this(name, 10) { }
    9696    public RealVectorEncoding(int length) : this("RealVector", length) { }
    97     public RealVectorEncoding(string name, int length, double min = double.MinValue, double max = double.MaxValue)
     97    public RealVectorEncoding(string name, int length, double min = -1000, double max = 1000)
    9898      : base(name) {
    9999      if (min >= max) throw new ArgumentException("min must be less than max", "min");
     
    318318    #endregion
    319319  }
    320 
    321   public static class IndividualExtensionMethods {
    322     public static RealVector RealVector(this Individual individual) {
    323       var encoding = individual.GetEncoding<RealVectorEncoding>();
    324       return individual.RealVector(encoding.Name);
    325     }
    326     public static RealVector RealVector(this Individual individual, string name) {
    327       return (RealVector)individual[name];
    328     }
    329   }
    330320}
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IProblemDefinition.cs

    r13339 r13361  
    2020#endregion
    2121
     22
    2223namespace HeuristicLab.Optimization {
    2324  public interface IProblemDefinition<TEncoding, TSolution>
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblem.cs

    r13339 r13361  
    2424
    2525namespace HeuristicLab.Optimization {
    26   public interface ISingleObjectiveProblem<TEncoding, TSolution> : IProblem<TEncoding, TSolution>, ISingleObjectiveProblemDefinition<TEncoding, TSolution>, ISingleObjectiveHeuristicOptimizationProblem
     26  public interface ISingleObjectiveProblem<TEncoding, TSolution> : IProblem<TEncoding, TSolution>, ISingleObjectiveHeuristicOptimizationProblem
    2727    where TEncoding : class, IEncoding<TSolution>
    2828    where TSolution : class, ISolution {
    29     bool IsBetter(double quality, double bestQuality);
     29
    3030  }
    3131}
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/ISingleObjectiveProblemDefinition.cs

    r13339 r13361  
    3131    void Analyze(TSolution[] individuals, double[] qualities, ResultCollection results, IRandom random);
    3232    IEnumerable<TSolution> GetNeighbors(TSolution individual, IRandom random);
     33    bool IsBetter(double quality, double bestQuality);
    3334  }
    3435}
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs

    r13339 r13361  
    2929namespace HeuristicLab.Optimization {
    3030  [StorableClass]
    31   public abstract class MultiObjectiveProblem<TEncoding, TSolution> : Problem<TEncoding, TSolution, MultiObjectiveEvaluator<TSolution>>, IMultiObjectiveHeuristicOptimizationProblem, IMultiObjectiveProblemDefinition<TEncoding, TSolution>
     31  public abstract class MultiObjectiveProblem<TEncoding, TSolution> :
     32    Problem<TEncoding, TSolution, MultiObjectiveEvaluator<TSolution>>,
     33    IMultiObjectiveProblem<TEncoding, TSolution>,
     34    IMultiObjectiveProblemDefinition<TEncoding, TSolution>
    3235    where TEncoding : class, IEncoding<TSolution>
    3336    where TSolution : class, ISolution {
     37
    3438    [StorableConstructor]
    3539    protected MultiObjectiveProblem(bool deserializing) : base(deserializing) { }
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs

    r13339 r13361  
    3030namespace HeuristicLab.Optimization {
    3131  [StorableClass]
    32   public abstract class SingleObjectiveProblem<TEncoding, TSolution> : Problem<TEncoding, TSolution, SingleObjectiveEvaluator<TSolution>>, ISingleObjectiveProblem<TEncoding, TSolution>
     32  public abstract class SingleObjectiveProblem<TEncoding, TSolution> :
     33    Problem<TEncoding, TSolution, SingleObjectiveEvaluator<TSolution>>,
     34    ISingleObjectiveProblem<TEncoding, TSolution>,
     35    ISingleObjectiveProblemDefinition<TEncoding, TSolution>
    3336    where TEncoding : class, IEncoding<TSolution>
    3437    where TSolution : class, ISolution {
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/HeuristicLab.Optimization-3.3.csproj

    r13356 r13361  
    123123    <Compile Include="BasicProblems\Individuals\MultiSolution.cs" />
    124124    <Compile Include="BasicProblems\Interfaces\IMultiEncodingOperator.cs" />
     125    <Compile Include="BasicProblems\Interfaces\IMultiObjectiveProblem.cs" />
    125126    <Compile Include="BasicProblems\Interfaces\ISingleObjectiveProblem.cs" />
    126127    <Compile Include="BasicProblems\MultiEncoding.cs" />
  • branches/ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/IProblem.cs

    r13339 r13361  
    3636  }
    3737
    38   public interface IProblem<TEncoding, TSolution> : IHeuristicOptimizationProblem, IProblemDefinition<TEncoding, TSolution>
     38  public interface IProblem<TEncoding, TSolution> : IHeuristicOptimizationProblem
    3939    where TEncoding : class, IEncoding<TSolution>
    4040    where TSolution : class, ISolution {
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/CompiledProblemDefinition.cs

    r13348 r13361  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.Threading;
    2524using HeuristicLab.Core;
    2625using HeuristicLab.Optimization;
     
    6362    public abstract void Analyze(TSolution[] individuals, double[] qualities, ResultCollection results, IRandom random);
    6463    public abstract IEnumerable<TSolution> GetNeighbors(TSolution individual, IRandom random);
     64
     65    public bool IsBetter(double quality, double bestQuality) {
     66      return Maximization ? quality > bestQuality : quality < bestQuality;
     67    }
    6568    #endregion
    6669  }
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/HeuristicLab.Problems.Programmable-3.3.csproj

    r13350 r13361  
    9696    </Compile>
    9797    <Compile Include="ProblemDefinitionScriptException.cs" />
    98     <Compile Include="MultiObjectiveProgrammableProblems.cs" />
    99     <Compile Include="SingleObjectiveProgrammableProblems.cs" />
     98    <Compile Include="ProgrammableProblemInstances.cs" />
    10099    <Content Include="Templates\CompiledSingleObjectiveProblemDefinition_Template.cs" />
    101100    <Content Include="Templates\CompiledMultiObjectiveProblemDefinition_Template.cs">
     
    155154      <Name>HeuristicLab.Encodings.BinaryVectorEncoding-3.3</Name>
    156155    </ProjectReference>
     156    <ProjectReference Include="..\..\HeuristicLab.Encodings.RealVectorEncoding\3.3\HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj">
     157      <Project>{bb6d334a-4bb6-4674-9883-31a6ebb32cab}</Project>
     158      <Name>HeuristicLab.Encodings.RealVectorEncoding-3.3</Name>
     159    </ProjectReference>
    157160    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
    158161      <Project>{23da7ff4-d5b8-41b6-aa96-f0561d24f3ee}</Project>
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/ProgrammableProblemInstances.cs

    r13360 r13361  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.Encodings.BinaryVectorEncoding;
     27using HeuristicLab.Encodings.RealVectorEncoding;
    2728using HeuristicLab.Optimization;
    2829using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2930
    3031namespace HeuristicLab.Problems.Programmable {
     32  #region single-objective
    3133  [Item("Binary Vector Programmable Problem (single-objective)", "Represents a binary vector single-objective problem that can be programmed with a script.")]
    3234  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     
    7678    }
    7779  }
    78   //TODO
    79   /*
    80   [Item("Integer Vector Programmable Problem (single-objective)", "Represents an integer vector single-objective problem that can be programmed with a script.")]
    81   [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    82   [StorableClass]
    83   public sealed class SingleObjectiveIntegerVectorProgrammableProblem : SingleObjectiveProgrammableProblem<IntegerVectorEncoding, IntegerVector> {
    84 
    85     [StorableConstructor]
    86     private SingleObjectiveIntegerVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
    87     private SingleObjectiveIntegerVectorProgrammableProblem(SingleObjectiveIntegerVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
    88     public SingleObjectiveIntegerVectorProgrammableProblem()
    89       : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.IntegerVectorEncoding", "IntegerVectorEncoding", "IntegerVector")) { }
    90 
    91     public override IDeepCloneable Clone(Cloner cloner) {
    92       return new SingleObjectiveIntegerVectorProgrammableProblem(this, cloner);
    93     }
    94   }
     80
     81  //[Item("Integer Vector Programmable Problem (single-objective)", "Represents an integer vector single-objective problem that can be programmed with a script.")]
     82  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     83  //[StorableClass]
     84  //public sealed class SingleObjectiveIntegerVectorProgrammableProblem : SingleObjectiveProgrammableProblem<IntegerVectorEncoding, IntegerVector> {
     85
     86  //  [StorableConstructor]
     87  //  private SingleObjectiveIntegerVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
     88  //  private SingleObjectiveIntegerVectorProgrammableProblem(SingleObjectiveIntegerVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     89  //  public SingleObjectiveIntegerVectorProgrammableProblem()
     90  //    : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.IntegerVectorEncoding", "IntegerVectorEncoding", "IntegerVector")) { }
     91
     92  //  public override IDeepCloneable Clone(Cloner cloner) {
     93  //    return new SingleObjectiveIntegerVectorProgrammableProblem(this, cloner);
     94  //  }
     95  //}
    9596
    9697  [Item("Real Vector Programmable Problem (single-objective)", "Represents a real vector single-objective problem that can be programmed with a script.")]
     
    102103    private SingleObjectiveRealVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
    103104    private SingleObjectiveRealVectorProgrammableProblem(SingleObjectiveRealVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     105
    104106    public SingleObjectiveRealVectorProgrammableProblem()
    105       : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.RealVectorEncoding", "RealVectorEncoding", "RealVector")) { }
     107      : base() {
     108      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
     109      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.RealVectorEncoding");
     110      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "RealVectorEncoding");
     111      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "RealVector");
     112      ProblemScript.Code = codeTemplate;
     113    }
    106114
    107115    public override IDeepCloneable Clone(Cloner cloner) {
     
    110118  }
    111119
    112   [Item("Permutation Programmable Problem (single-objective)", "Represents a permutation single-objective problem that can be programmed with a script.")]
    113   [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    114   [StorableClass]
    115   public sealed class SingleObjectivePermutationProgrammableProblem : SingleObjectiveProgrammableProblem<PermutationEncoding, Permutation> {
    116 
    117     [StorableConstructor]
    118     private SingleObjectivePermutationProgrammableProblem(bool deserializing) : base(deserializing) { }
    119     private SingleObjectivePermutationProgrammableProblem(SingleObjectivePermutationProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
    120     public SingleObjectivePermutationProgrammableProblem()
    121       : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.PermutationEncoding", "PermutationEncoding", "Permutation")) { }
    122 
    123     public override IDeepCloneable Clone(Cloner cloner) {
    124       return new SingleObjectivePermutationProgrammableProblem(this, cloner);
    125     }
    126   }
    127 
    128   [Item("Symbolic Expression Tree Programmable Problem (single-objective)", "Represents a symbolic expression tree single-objective problem that can be programmed with a script.")]
    129   [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    130   [StorableClass]
    131   public sealed class SingleObjectiveSymbolicExpressionTreeProgrammableProblem : SingleObjectiveProgrammableProblem<SymbolicExpressionTreeEncoding, SymbolicExpressionTree> {
    132 
    133     [StorableConstructor]
    134     private SingleObjectiveSymbolicExpressionTreeProgrammableProblem(bool deserializing) : base(deserializing) { }
    135     private SingleObjectiveSymbolicExpressionTreeProgrammableProblem(SingleObjectiveSymbolicExpressionTreeProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
    136     public SingleObjectiveSymbolicExpressionTreeProgrammableProblem()
    137       : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "SymbolicExpressionTreeEncoding", "SymbolicExpressionTree")) { }
    138 
    139     public override IDeepCloneable Clone(Cloner cloner) {
    140       return new SingleObjectiveSymbolicExpressionTreeProgrammableProblem(this, cloner);
    141     }
    142   }
    143 
    144   [Item("Linear Linkage Programmable Problem (single-objective)", "Represents a linear linkage single-objective problem that can be programmed with a script.")]
    145   [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
    146   [StorableClass]
    147   public sealed class SingleObjectiveLinearLinkageProgrammableProblem : SingleObjectiveProgrammableProblem<LinearLinkageEncoding, LinearLinkage> {
    148 
    149     [StorableConstructor]
    150     private SingleObjectiveLinearLinkageProgrammableProblem(bool deserializing) : base(deserializing) { }
    151     private SingleObjectiveLinearLinkageProgrammableProblem(SingleObjectiveLinearLinkageProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
    152     public SingleObjectiveLinearLinkageProgrammableProblem()
    153       : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.LinearLinkageEncoding", "LinearLinkageEncoding", "LinearLinkage")) { }
    154 
    155     public override IDeepCloneable Clone(Cloner cloner) {
    156       return new SingleObjectiveLinearLinkageProgrammableProblem(this, cloner);
    157     }
    158   }*/
     120  //[Item("Permutation Programmable Problem (single-objective)", "Represents a permutation single-objective problem that can be programmed with a script.")]
     121  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     122  //[StorableClass]
     123  //public sealed class SingleObjectivePermutationProgrammableProblem : SingleObjectiveProgrammableProblem<PermutationEncoding, Permutation> {
     124
     125  //  [StorableConstructor]
     126  //  private SingleObjectivePermutationProgrammableProblem(bool deserializing) : base(deserializing) { }
     127  //  private SingleObjectivePermutationProgrammableProblem(SingleObjectivePermutationProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     128  //  public SingleObjectivePermutationProgrammableProblem()
     129  //    : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.PermutationEncoding", "PermutationEncoding", "Permutation")) { }
     130
     131  //  public override IDeepCloneable Clone(Cloner cloner) {
     132  //    return new SingleObjectivePermutationProgrammableProblem(this, cloner);
     133  //  }
     134  //}
     135
     136  //[Item("Symbolic Expression Tree Programmable Problem (single-objective)", "Represents a symbolic expression tree single-objective problem that can be programmed with a script.")]
     137  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     138  //[StorableClass]
     139  //public sealed class SingleObjectiveSymbolicExpressionTreeProgrammableProblem : SingleObjectiveProgrammableProblem<SymbolicExpressionTreeEncoding, SymbolicExpressionTree> {
     140
     141  //  [StorableConstructor]
     142  //  private SingleObjectiveSymbolicExpressionTreeProgrammableProblem(bool deserializing) : base(deserializing) { }
     143  //  private SingleObjectiveSymbolicExpressionTreeProgrammableProblem(SingleObjectiveSymbolicExpressionTreeProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     144  //  public SingleObjectiveSymbolicExpressionTreeProgrammableProblem()
     145  //    : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "SymbolicExpressionTreeEncoding", "SymbolicExpressionTree")) { }
     146
     147  //  public override IDeepCloneable Clone(Cloner cloner) {
     148  //    return new SingleObjectiveSymbolicExpressionTreeProgrammableProblem(this, cloner);
     149  //  }
     150  //}
     151
     152  //[Item("Linear Linkage Programmable Problem (single-objective)", "Represents a linear linkage single-objective problem that can be programmed with a script.")]
     153  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     154  //[StorableClass]
     155  //public sealed class SingleObjectiveLinearLinkageProgrammableProblem : SingleObjectiveProgrammableProblem<LinearLinkageEncoding, LinearLinkage> {
     156
     157  //  [StorableConstructor]
     158  //  private SingleObjectiveLinearLinkageProgrammableProblem(bool deserializing) : base(deserializing) { }
     159  //  private SingleObjectiveLinearLinkageProgrammableProblem(SingleObjectiveLinearLinkageProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     160  //  public SingleObjectiveLinearLinkageProgrammableProblem()
     161  //    : base(string.Format(ScriptTemplates.CompiledSingleObjectiveProblemDefinition, "HeuristicLab.Encodings.LinearLinkageEncoding", "LinearLinkageEncoding", "LinearLinkage")) { }
     162
     163  //  public override IDeepCloneable Clone(Cloner cloner) {
     164  //    return new SingleObjectiveLinearLinkageProgrammableProblem(this, cloner);
     165  //  }
     166  //}
     167  #endregion
     168
     169  #region multi-objective
     170  [Item("Binary Vector Programmable Problem (multi-objective)", "Represents a binary vector multi-objective problem that can be programmed with a script.")]
     171  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     172  [StorableClass]
     173  public sealed class MultiObjectiveBinaryVectorProgrammableProblem : MultiObjectiveProgrammableProblem<BinaryVectorEncoding, BinaryVector> {
     174
     175    [StorableConstructor]
     176    private MultiObjectiveBinaryVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
     177    private MultiObjectiveBinaryVectorProgrammableProblem(MultiObjectiveBinaryVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     178
     179    public MultiObjectiveBinaryVectorProgrammableProblem()
     180      : base() {
     181      var codeTemplate = ScriptTemplates.CompiledMultiObjectiveProblemDefinition_Template;
     182      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
     183      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "BinaryVectorEncoding");
     184      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "BinaryVector");
     185      ProblemScript.Code = codeTemplate;
     186    }
     187
     188
     189    public override IDeepCloneable Clone(Cloner cloner) {
     190      return new MultiObjectiveBinaryVectorProgrammableProblem(this, cloner);
     191    }
     192  }
     193
     194  [Item("Multi Solution Programmable Problem (multi-objective)", "Represents a multi solution multi-objective problem that can be programmed with a script.")]
     195  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     196  [StorableClass]
     197  public sealed class MultiObjectiveMultiSolutionProgrammableProblem : MultiObjectiveProgrammableProblem<MultiEncoding, CombinedSolution> {
     198
     199    [StorableConstructor]
     200    private MultiObjectiveMultiSolutionProgrammableProblem(bool deserializing) : base(deserializing) { }
     201    private MultiObjectiveMultiSolutionProgrammableProblem(MultiObjectiveMultiSolutionProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     202
     203    public MultiObjectiveMultiSolutionProgrammableProblem()
     204      : base() {
     205      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
     206      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.BinaryVectorEncoding");
     207      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "MultiEncoding");
     208      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "CombinedSolution");
     209      ProblemScript.Code = codeTemplate;
     210    }
     211
     212
     213    public override IDeepCloneable Clone(Cloner cloner) {
     214      return new MultiObjectiveMultiSolutionProgrammableProblem(this, cloner);
     215    }
     216  }
     217
     218  //[Item("Integer Vector Programmable Problem (multi-objective)", "Represents an integer vector multi-objective problem that can be programmed with a script.")]
     219  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     220  //[StorableClass]
     221  //public sealed class MultiObjectiveIntegerVectorProgrammableProblem : MultiObjectiveProgrammableProblem<IntegerVectorEncoding, IntegerVector> {
     222
     223  //  [StorableConstructor]
     224  //  private MultiObjectiveIntegerVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
     225  //  private MultiObjectiveIntegerVectorProgrammableProblem(MultiObjectiveIntegerVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     226  //  public MultiObjectiveIntegerVectorProgrammableProblem()
     227  //    : base(string.Format(ScriptTemplates.CompiledMultiObjectiveProblemDefinition, "HeuristicLab.Encodings.IntegerVectorEncoding", "IntegerVectorEncoding", "IntegerVector")) { }
     228
     229  //  public override IDeepCloneable Clone(Cloner cloner) {
     230  //    return new MultiObjectiveIntegerVectorProgrammableProblem(this, cloner);
     231  //  }
     232  //}
     233
     234  [Item("Real Vector Programmable Problem (multi-objective)", "Represents a real vector multi-objective problem that can be programmed with a script.")]
     235  [Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     236  [StorableClass]
     237  public sealed class MultiObjectiveRealVectorProgrammableProblem : MultiObjectiveProgrammableProblem<RealVectorEncoding, RealVector> {
     238
     239    [StorableConstructor]
     240    private MultiObjectiveRealVectorProgrammableProblem(bool deserializing) : base(deserializing) { }
     241    private MultiObjectiveRealVectorProgrammableProblem(MultiObjectiveRealVectorProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     242
     243    public MultiObjectiveRealVectorProgrammableProblem()
     244      : base() {
     245      var codeTemplate = ScriptTemplates.CompiledSingleObjectiveProblemDefinition_Template;
     246      codeTemplate = codeTemplate.Replace(ENCODING_NAMESPACE, "HeuristicLab.Encodings.RealVectorEncoding");
     247      codeTemplate = codeTemplate.Replace(ENCODING_CLASS, "RealVectorEncoding");
     248      codeTemplate = codeTemplate.Replace(SOLUTION_CLASS, "RealVector");
     249      ProblemScript.Code = codeTemplate;
     250    }
     251
     252    public override IDeepCloneable Clone(Cloner cloner) {
     253      return new MultiObjectiveRealVectorProgrammableProblem(this, cloner);
     254    }
     255  }
     256
     257  //[Item("Permutation Programmable Problem (multi-objective)", "Represents a permutation multi-objective problem that can be programmed with a script.")]
     258  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     259  //[StorableClass]
     260  //public sealed class MultiObjectivePermutationProgrammableProblem : MultiObjectiveProgrammableProblem<PermutationEncoding, Permutation> {
     261
     262  //  [StorableConstructor]
     263  //  private MultiObjectivePermutationProgrammableProblem(bool deserializing) : base(deserializing) { }
     264  //  private MultiObjectivePermutationProgrammableProblem(MultiObjectivePermutationProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     265  //  public MultiObjectivePermutationProgrammableProblem()
     266  //    : base(string.Format(ScriptTemplates.CompiledMultiObjectiveProblemDefinition, "HeuristicLab.Encodings.PermutationEncoding", "PermutationEncoding", "Permutation")) { }
     267
     268  //  public override IDeepCloneable Clone(Cloner cloner) {
     269  //    return new MultiObjectivePermutationProgrammableProblem(this, cloner);
     270  //  }
     271  //}
     272
     273  //[Item("Symbolic Expression Tree Programmable Problem (multi-objective)", "Represents a symbolic expression tree multi-objective problem that can be programmed with a script.")]
     274  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     275  //[StorableClass]
     276  //public sealed class MultiObjectiveSymbolicExpressionTreeProgrammableProblem : MultiObjectiveProgrammableProblem<SymbolicExpressionTreeEncoding, SymbolicExpressionTree> {
     277
     278  //  [StorableConstructor]
     279  //  private MultiObjectiveSymbolicExpressionTreeProgrammableProblem(bool deserializing) : base(deserializing) { }
     280  //  private MultiObjectiveSymbolicExpressionTreeProgrammableProblem(MultiObjectiveSymbolicExpressionTreeProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     281  //  public MultiObjectiveSymbolicExpressionTreeProgrammableProblem()
     282  //    : base(string.Format(ScriptTemplates.CompiledMultiObjectiveProblemDefinition, "HeuristicLab.Encodings.SymbolicExpressionTreeEncoding", "SymbolicExpressionTreeEncoding", "SymbolicExpressionTree")) { }
     283
     284  //  public override IDeepCloneable Clone(Cloner cloner) {
     285  //    return new MultiObjectiveSymbolicExpressionTreeProgrammableProblem(this, cloner);
     286  //  }
     287  //}
     288
     289  //[Item("Linear Linkage Programmable Problem (multi-objective)", "Represents a linear linkage multi-objective problem that can be programmed with a script.")]
     290  //[Creatable(CreatableAttribute.Categories.Problems, Priority = 100)]
     291  //[StorableClass]
     292  //public sealed class MultiObjectiveLinearLinkageProgrammableProblem : MultiObjectiveProgrammableProblem<LinearLinkageEncoding, LinearLinkage> {
     293
     294  //  [StorableConstructor]
     295  //  private MultiObjectiveLinearLinkageProgrammableProblem(bool deserializing) : base(deserializing) { }
     296  //  private MultiObjectiveLinearLinkageProgrammableProblem(MultiObjectiveLinearLinkageProgrammableProblem original, Cloner cloner) : base(original, cloner) { }
     297  //  public MultiObjectiveLinearLinkageProgrammableProblem()
     298  //    : base(string.Format(ScriptTemplates.CompiledMultiObjectiveProblemDefinition, "HeuristicLab.Encodings.LinearLinkageEncoding", "LinearLinkageEncoding", "LinearLinkage")) { }
     299
     300  //  public override IDeepCloneable Clone(Cloner cloner) {
     301  //    return new MultiObjectiveLinearLinkageProgrammableProblem(this, cloner);
     302  //  }
     303  //}
     304  #endregion
    159305}
  • branches/ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProblemDefinitionScript.cs

    r13350 r13361  
    6262      return CompiledProblemDefinition.GetNeighbors(individual, random);
    6363    }
     64
     65    bool ISingleObjectiveProblemDefinition<TEncoding, TSolution>.IsBetter(double quality, double bestQuality) {
     66      return CompiledProblemDefinition.IsBetter(quality, bestQuality);
     67    }
    6468  }
    6569}
  • branches/ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r12504 r13361  
    3939  [StorableClass]
    4040  [Creatable(CreatableAttribute.Categories.Problems, Priority = 90)]
    41   public sealed class SingleObjectiveTestFunctionProblem : SingleObjectiveHeuristicOptimizationProblem<ISingleObjectiveTestFunctionProblemEvaluator, IRealVectorCreator>, IStorableContent, IProblemInstanceConsumer<SOTFData> {
     41  public sealed class SingleObjectiveTestFunctionProblem :
     42    SingleObjectiveHeuristicOptimizationProblem<ISingleObjectiveTestFunctionProblemEvaluator, IRealVectorCreator>,
     43    ISingleObjectiveProblem<RealVectorEncoding, RealVector>, IStorableContent, IProblemInstanceConsumer<SOTFData> {
    4244    public string Filename { get; set; }
    4345
Note: See TracChangeset for help on using the changeset viewer.