Free cookie consent management tool by TermsFeed Policy Generator

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/HeuristicLab.Problems.DataAnalysis/3.4
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • 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.