Free cookie consent management tool by TermsFeed Policy Generator

Changeset 18107


Ignore:
Timestamp:
12/08/21 15:37:43 (3 years ago)
Author:
gkronber
Message:

#3073 changed ProblemData loading of IShapeConstrainedRegressionProblems to make sure we can also load ShapeConstrainedRegressionProblemData objects correctly without losing shape constraints

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ShapeConstrainedRegressionSingleObjectiveProblem.cs

    r17964 r18107  
    2828  [StorableType("B35ADCA7-E902-4BEE-9DDE-DF8BBC1E27FE")]
    2929  [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 150)]
    30   public class ShapeConstrainedRegressionSingleObjectiveProblem : SymbolicRegressionSingleObjectiveProblem {
     30  public class ShapeConstrainedRegressionSingleObjectiveProblem : SymbolicRegressionSingleObjectiveProblem, IShapeConstrainedRegressionProblem {
    3131    [StorableConstructor]
    3232    protected ShapeConstrainedRegressionSingleObjectiveProblem(StorableConstructorFlag _) : base(_) { }
     
    3434    public override IDeepCloneable Clone(Cloner cloner) { return new ShapeConstrainedRegressionSingleObjectiveProblem(this, cloner); }
    3535
     36    public ShapeConstrainedRegressionProblemData ShapeConstrainedRegressionProblemData {
     37      get => (ShapeConstrainedRegressionProblemData)ProblemData;
     38      set => ProblemData = value;
     39    }
    3640    public ShapeConstrainedRegressionSingleObjectiveProblem()
    3741      : base(new ShapeConstrainedRegressionProblemData(), new NMSESingleObjectiveConstraintsEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) {
     
    5155
    5256    public override void Load(IRegressionProblemData data) {
    53       var scProblemData = new ShapeConstrainedRegressionProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable,
    54                                                                     data.TrainingPartition, data.TestPartition) {
    55         Name = data.Name,
    56         Description = data.Description
    57       };
     57      if (data is ShapeConstrainedRegressionProblemData scProblemData) {
     58      } else {
     59        scProblemData = new ShapeConstrainedRegressionProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable,
     60                                                                  data.TrainingPartition, data.TestPartition) {
     61          Name = data.Name,
     62          Description = data.Description
     63        };
     64      }
    5865
    5966      base.Load(scProblemData);
  • trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblem.cs

    r17180 r18107  
    9292
    9393    #region Import & Export
    94     public void Load(T data) {
     94    public virtual void Load(T data) {
    9595      Name = data.Name;
    9696      Description = data.Description;
     
    9898    }
    9999
    100     public T Export() {
     100    public virtual T Export() {
    101101      return ProblemData;
    102102    }
  • trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ShapeConstrainedRegressionProblem.cs

    r17960 r18107  
    2424using HeuristicLab.Core;
    2525
    26 namespace HeuristicLab.Problems.DataAnalysis{
     26namespace HeuristicLab.Problems.DataAnalysis {
    2727  [StorableType("B53C4C71-3715-4BB1-9A95-4E969D8135C6")]
    2828  [Item("Shape-constrained Regression Problem", "A regression problem with shape constraints.")]
    29   public class ShapeConstrainedRegressionProblem : DataAnalysisProblem<IShapeConstrainedRegressionProblemData>, IShapeConstrainedRegressionProblem {
     29  public class ShapeConstrainedRegressionProblem : DataAnalysisProblem<IRegressionProblemData>, IShapeConstrainedRegressionProblem {
    3030    [StorableConstructor]
    3131    protected ShapeConstrainedRegressionProblem(StorableConstructorFlag _) : base(_) { }
     
    3333    public override IDeepCloneable Clone(Cloner cloner) { return new ShapeConstrainedRegressionProblem(this, cloner); }
    3434
     35    public ShapeConstrainedRegressionProblemData ShapeConstrainedRegressionProblemData {
     36      get => (ShapeConstrainedRegressionProblemData)ProblemData;
     37      set => ProblemData = value;
     38    }
    3539    public ShapeConstrainedRegressionProblem() : base(new ShapeConstrainedRegressionProblemData()) { }
     40
     41
     42    public override void Load(IRegressionProblemData data) {
     43      if (data is ShapeConstrainedRegressionProblemData scProblemData) {
     44        // use directly
     45      } else {
     46        scProblemData = new ShapeConstrainedRegressionProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable,
     47                                                                      data.TrainingPartition, data.TestPartition) {
     48          Name = data.Name,
     49          Description = data.Description
     50        };
     51      }
     52      base.Load(scProblemData);
     53    }
    3654  }
    3755}
  • trunk/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IShapeConstrainedRegressionProblem.cs

    r17960 r18107  
    2424namespace HeuristicLab.Problems.DataAnalysis {
    2525  [StorableType("C6E9D32A-7727-487E-859C-DF24EDCC5922")]
    26   public interface  IShapeConstrainedRegressionProblem : IDataAnalysisProblem<IShapeConstrainedRegressionProblemData> {
     26  public interface IShapeConstrainedRegressionProblem : IRegressionProblem {
     27    ShapeConstrainedRegressionProblemData ShapeConstrainedRegressionProblemData { get; set; }
    2728  }
    2829}
Note: See TracChangeset for help on using the changeset viewer.