Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16884


Ignore:
Timestamp:
05/02/19 12:01:12 (6 years ago)
Author:
chaider
Message:

#2971 fixed storable problem within RegressionProblemData

Location:
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r16841 r16884  
    146146    [StorableHook(HookType.AfterDeserialization)]
    147147    private void AfterDeserialization() {
    148       var variables = InputVariables.Select(x => x.AsReadOnly()).ToList();
    149       NamedIntervals namedIntervals = new NamedIntervals();
    150       foreach (var variable in variables) {
    151         if (!this.Dataset.DoubleVariables.Contains(variable.Value)) continue; // intervals are only possible for double variables
    152         var variableInterval = Interval.GetInterval(this.Dataset.GetDoubleValues(variable.Value));
    153         namedIntervals.VariableIntervals.Add(variable.Value, variableInterval);
    154       }
    155 
    156       Parameters.Add(new FixedValueParameter<NamedIntervals>(VariableRangesParameterName, namedIntervals));
    157       Parameters.Add(new FixedValueParameter<ParsedConstraint>(IntervalConstraintsParameterName, new ParsedConstraint(this)));
     148      if (!Parameters.ContainsKey(VariableRangesParameterName)) {
     149        var variables = InputVariables.Select(x => x.AsReadOnly()).ToList();
     150        NamedIntervals namedIntervals = new NamedIntervals();
     151        foreach (var variable in variables) {
     152          if (!this.Dataset.DoubleVariables.Contains(variable.Value)) continue; // intervals are only possible for double variables
     153          var variableInterval = Interval.GetInterval(this.Dataset.GetDoubleValues(variable.Value));
     154          namedIntervals.VariableIntervals.Add(variable.Value, variableInterval);
     155        }
     156
     157        Parameters.Add(new FixedValueParameter<NamedIntervals>(VariableRangesParameterName, namedIntervals));
     158      }
     159      if (!Parameters.ContainsKey(IntervalConstraintsParameterName)) {
     160        Parameters.Add(new FixedValueParameter<ParsedConstraint>(IntervalConstraintsParameterName, new ParsedConstraint(this)));
     161      }
    158162      RegisterParameterEvents();
    159163    }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ParsedConstraint.cs

    r16881 r16884  
    3131  [Item("ParsedConstraint", "Represents parsed constraints.")]
    3232  public class ParsedConstraint : Item {
    33     private static readonly string exampleInput = "#Example for a target variable constraint:" + Environment.NewLine +
     33    private static readonly string exampleInput = "# Example for a target variable constraint:" + Environment.NewLine +
    3434                                                  "Target:'y' in [0 .. 100]" + Environment.NewLine + Environment.NewLine +
    35                                                   "#Example for constraint on model parameter: " + Environment.NewLine +
     35                                                  "# Example for constraint on model parameter: " + Environment.NewLine +
    3636                                                  "d'y'/d'x' in [0 .. 10]" + Environment.NewLine +
    3737                                                  "\u2202²'y'/\u2202'x'² in ]-1 .. inf.[";
    38      
     38     
     39    [Storable]
    3940    public string Input { get; set; }
    4041
    4142    private IEnumerable<IntervalConstraint> constraints;
     43    [Storable]
    4244    public IEnumerable<IntervalConstraint> Constraints {
    4345      get => constraints;
     
    4648        OnChanged(EventArgs.Empty);
    4749      }
    48   }
    49     public IRegressionProblemData ProblemData { get; set; }
     50    }
     51    [Storable]
     52    public IRegressionProblemData ProblemData { get; private set; }
    5053
    5154    [StorableConstructor]
Note: See TracChangeset for help on using the changeset viewer.