Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/29/19 13:53:26 (5 years ago)
Author:
mkommend
Message:

#2521: Integrated changes of #2943 into problem refactoring branch.

Location:
branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/CompiledProblemDefinition.cs

    r16806 r17225  
    2323using System.Collections.Generic;
    2424using HeuristicLab.Core;
     25using HeuristicLab.Data;
    2526using HeuristicLab.Optimization;
    2627
     
    5152    where TEncoding : class, IEncoding<TEncodedSolution>
    5253    where TEncodedSolution : class, IEncodedSolution {
    53 
    5454    protected CompiledSingleObjectiveProblemDefinition() : base() { }
    5555
     
    7272    where TEncoding : class, IEncoding<TEncodedSolution>
    7373    where TEncodedSolution : class, IEncodedSolution {
    74 
    7574    protected CompiledMultiObjectiveProblemDefinition() : base() { }
    7675
     
    7978
    8079    #region ISingleObjectiveProblemDefinition<TEncoding,TEncodedSolution> Members
    81 
    8280    public int Objectives => Maximization.Length;
    8381    public abstract bool[] Maximization { get; }
     82    public abstract IReadOnlyList<double[]> BestKnownFront { get; }
     83    public abstract double[] ReferencePoint { get; }
    8484    public abstract double[] Evaluate(TEncodedSolution individual, IRandom random);
    8585    public abstract void Analyze(TEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random);
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProblemDefinitionScript.cs

    r16806 r17225  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using HEAL.Attic;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Core;
     26using HeuristicLab.Data;
    2527using HeuristicLab.Optimization;
    2628
     
    4749    }
    4850
    49     int IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Objectives => CompiledProblemDefinition.Objectives;
     51    public int Objectives => CompiledProblemDefinition.Objectives;
     52    public IReadOnlyList<double[]> BestKnownFront => CompiledProblemDefinition.BestKnownFront;
     53    public double[] ReferencePoint => CompiledProblemDefinition.ReferencePoint;
     54    public bool[] Maximization => CompiledProblemDefinition.Maximization;
    5055
    51     bool[] IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Maximization {
    52       get { return CompiledProblemDefinition.Maximization; }
    53     }
    5456
    5557    double[] IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Evaluate(TEncodedSolution individual, IRandom random) {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProgrammableProblem.cs

    r16815 r17225  
    2020#endregion
    2121
     22using System.Collections.Generic;
    2223using System.Drawing;
    2324using HEAL.Attic;
     
    5960    }
    6061
     62
    6163    [StorableConstructor]
    6264    protected MultiObjectiveProgrammableProblem(StorableConstructorFlag _) : base(_) { }
     
    6971      : base(encoding) {
    7072      Parameters.Add(new FixedValueParameter<MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>>("ProblemScript", "Defines the problem.",
    71         new MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>() { Name = Name }));
     73        new MultiObjectiveProblemDefinitionScript<TEncoding, TEncodedSolution>() {Name = Name}));
    7274      ProblemScript.Encoding = (TEncoding)encoding.Clone();
    7375
     
    9395    private void OnProblemDefinitionChanged() {
    9496      Parameters.Remove("Maximization");
    95       Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()) { Hidden = true });
     97      Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()) {Hidden = true});
    9698      Encoding = (TEncoding)ProblemScript.Encoding.Clone();
    9799
     
    108110
    109111    public override bool[] Maximization {
    110       get { return Parameters.ContainsKey("ProblemScript") ? ProblemDefinition.Maximization : new[] { false }; }
     112      get { return Parameters.ContainsKey("ProblemScript") ? ProblemDefinition.Maximization : new[] {false}; }
     113    }
     114
     115    public override IReadOnlyList<double[]> BestKnownFront {
     116      get { return Parameters.ContainsKey("ProblemScript") ? ProblemDefinition.BestKnownFront : null; }
     117    }
     118
     119    public override double[] ReferencePoint {
     120      get { return Parameters.ContainsKey("ProblemScript") ? ProblemDefinition.ReferencePoint : null; }
    111121    }
    112122
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/SingleObjectiveProblemDefinitionScript.cs

    r16751 r17225  
    4848    }
    4949
    50     bool ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Maximization {
    51       get { return CompiledProblemDefinition.Maximization; }
    52     }
     50    public bool Maximization => CompiledProblemDefinition.Maximization;
    5351
    5452    double ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Evaluate(TEncodedSolution individual, IRandom random) {
     
    6361    }
    6462
    65     bool ISingleObjectiveProblemDefinition<TEncoding, TEncodedSolution>.IsBetter(double quality, double bestQuality) {
     63    public bool IsBetter(double quality, double bestQuality) {
    6664      return CompiledProblemDefinition.IsBetter(quality, bestQuality);
    6765    }
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/MultiObjectiveCombinedEncodingProblem_Template.cs

    r16812 r17225  
    1717  public class CompiledMultiObjectiveProblemDefinition : CompiledMultiObjectiveProblemDefinition<CombinedEncoding, CombinedSolution> {
    1818    public override bool[] Maximization { get { return new[] { true, false }; } }
     19    public override double[] ReferencePoint { get { return null; } }
     20    public override IReadOnlyList<double[]> BestKnownFront { get { return null; } }
    1921
    2022    public override void Initialize() {
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/Templates/MultiObjectiveProblem_Template.cs

    r16812 r17225  
    1212  public class CompiledMultiObjectiveProblemDefinition : CompiledMultiObjectiveProblemDefinition<ENCODING_CLASS, SOLUTION_CLASS> {
    1313    public override bool[] Maximization { get { return new[] { false, false }; } }
     14    public override double[] ReferencePoint { get { return null; } }
     15    public override IReadOnlyList<double[]> BestKnownFront { get { return null; } }
    1416
    1517    public override void Initialize() {
Note: See TracChangeset for help on using the changeset viewer.