Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16806


Ignore:
Timestamp:
04/17/19 23:06:18 (6 years ago)
Author:
mkommend
Message:

#2521: Added StorableType attributes to interfaces and adapted basic problems.

Location:
branches/2521_ProblemRefactoring
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IEncoding.cs

    r16751 r16806  
    4040  }
    4141
     42  [StorableType("DB23907F-BE6E-44E4-9596-3D3BF1532631")]
    4243  public interface IEncoding<TEncodedSolution> : IEncoding
    43     where TEncodedSolution : class, IEncodedSolution {
     44      where TEncodedSolution : class, IEncodedSolution {
    4445    //new ISolutionCreator<TEncodedSolution> SolutionCreator { get; }
    4546  }
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/Interfaces/IMultiObjectiveProblemDefinition.cs

    r16751 r16806  
    2828    where TEncoding : class, IEncoding<TEncodedSolution>
    2929    where TEncodedSolution : class, IEncodedSolution {
     30
     31    int Objectives { get; }
    3032    bool[] Maximization { get; }
    31     double[] Evaluate(TEncodedSolution individual, IRandom random);
    32     void Analyze(TEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random);
     33    double[] Evaluate(TEncodedSolution solution, IRandom random);
     34    void Analyze(TEncodedSolution[] solutions, double[][] qualities, ResultCollection results, IRandom random);
    3335  }
    3436}
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/MultiObjectiveProblem.cs

    r16801 r16806  
    3636    where TEncodedSolution : class, IEncodedSolution {
    3737
     38    protected IValueParameter<BoolArray> MaximizationParameter {
     39      get { return (IValueParameter<BoolArray>)Parameters["Maximization"]; }
     40    }
     41
    3842    [StorableConstructor]
    3943    protected MultiObjectiveProblem(StorableConstructorFlag _) : base(_) { }
     
    4448    }
    4549
    46     protected MultiObjectiveProblem()
    47       : base() {
     50    protected MultiObjectiveProblem() : base() {
     51      Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()));
     52
     53      Operators.Add(Evaluator);
     54      Operators.Add(new MultiObjectiveAnalyzer<TEncodedSolution>());
     55
     56      ParameterizeOperators();
     57    }
     58
     59    protected MultiObjectiveProblem(TEncoding encoding) : base(encoding) {
    4860      Parameters.Add(new ValueParameter<BoolArray>("Maximization", "Set to false if the problem should be minimized.", (BoolArray)new BoolArray(Maximization).AsReadOnly()));
    4961
     
    5971    }
    6072
     73    public int Objectives => Maximization.Length;
    6174    public abstract bool[] Maximization { get; }
    62     public abstract double[] Evaluate(TEncodedSolution individual, IRandom random);
    63     public virtual void Analyze(TEncodedSolution[] individuals, double[][] qualities, ResultCollection results, IRandom random) { }
     75    public abstract double[] Evaluate(TEncodedSolution solution, IRandom random);
     76    public virtual void Analyze(TEncodedSolution[] solutions, double[][] qualities, ResultCollection results, IRandom random) { }
    6477
    6578    protected override void OnOperatorsChanged() {
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/BasicProblems/SingleObjectiveProblem.cs

    r16801 r16806  
    6969    }
    7070
    71     protected SingleObjectiveProblem()
    72       : base() {
     71    protected SingleObjectiveProblem() : base() {
    7372      Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden = true });
    7473      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem."));
     
    8483    }
    8584
    86     protected SingleObjectiveProblem(TEncoding encoding)
    87       : base(encoding) {
     85    protected SingleObjectiveProblem(TEncoding encoding) : base(encoding) {
    8886      Parameters.Add(new FixedValueParameter<BoolValue>("Maximization", "Set to false if the problem should be minimized.", (BoolValue)new BoolValue(Maximization).AsReadOnly()) { Hidden = true });
    8987      Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this problem."));
  • branches/2521_ProblemRefactoring/HeuristicLab.Optimization/3.3/Interfaces/ISolutionCreator.cs

    r16751 r16806  
    3030  public interface ISolutionCreator : IOperator { }
    3131
     32  [StorableType("76F17DA0-A81C-4E16-B591-38541D73C370")]
    3233  public interface ISolutionCreator<TEncodedSolution> : ISolutionCreator where TEncodedSolution : class, IEncodedSolution {
    3334    //ILookupParameter<TEncodedSolution> SolutionParameter { get; } // TODO: unify encoding specific parameters by defining ISolutionOperator and ISolutionsOperator
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/CompiledProblemDefinition.cs

    r16751 r16806  
    7979
    8080    #region ISingleObjectiveProblemDefinition<TEncoding,TEncodedSolution> Members
     81
     82    public int Objectives => Maximization.Length;
    8183    public abstract bool[] Maximization { get; }
    8284    public abstract double[] Evaluate(TEncodedSolution individual, IRandom random);
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Programmable/3.3/MultiObjectiveProblemDefinitionScript.cs

    r16751 r16806  
    4747    }
    4848
     49    int IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Objectives => CompiledProblemDefinition.Objectives;
     50
    4951    bool[] IMultiObjectiveProblemDefinition<TEncoding, TEncodedSolution>.Maximization {
    5052      get { return CompiledProblemDefinition.Maximization; }
Note: See TracChangeset for help on using the changeset viewer.