Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/17/16 15:59:59 (8 years ago)
Author:
bburlacu
Message:

#2679: Guard against NaN values in the setters for Input and Goal parameter values. Re-register input and goal parameter changed events after cloning. Avoid exception when initializing internal dataset when no inputs are available.

Location:
branches/HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/GoalParameter.cs

    r14333 r14338  
    3434      get { return goal; }
    3535      set {
     36        if (double.IsNaN(value) || double.IsInfinity(value)) return;
    3637        if (goal.IsAlmost(value)) return;
    3738        goal = value;
     
    4546      get { return weight; }
    4647      set {
     48        if (double.IsNaN(value) || double.IsInfinity(value)) return;
    4749        if (weight.IsAlmost(value)) return;
    4850        weight = value;
     
    5759      get { return variance; }
    5860      set {
     61        if (double.IsNaN(value) || double.IsInfinity(value)) return;
    5962        if (variance.IsAlmost(value)) return;
    6063        variance = value;
     
    6871      get { return step; }
    6972      set {
     73        if (double.IsNaN(value) || double.IsInfinity(value)) return;
    7074        if (step.IsAlmost(value)) return;
    7175        step = value;
  • branches/HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/InputParameter.cs

    r14333 r14338  
    3434      get { return min; }
    3535      set {
     36        if (double.IsNaN(value) || double.IsInfinity(value)) return;
    3637        if (min.IsAlmost(value)) return;
    3738        min = value;
     
    4546      get { return max; }
    4647      set {
     48        if (double.IsNaN(value) || double.IsInfinity(value)) return;
    4749        if (max.IsAlmost(value)) return;
    4850        max = value;
     
    5658      get { return step; }
    5759      set {
     60        if (double.IsNaN(value) || double.IsInfinity(value)) return;
    5861        if (step.IsAlmost(value)) return;
    5962        step = value;
     
    6770      get { return value; }
    6871      set {
     72        if (double.IsNaN(value) || double.IsInfinity(value)) return;
    6973        if (this.value.IsAlmost(value)) return;
    7074        this.value = value;
  • branches/HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/MultiObjectiveGoalSeekingProblem.cs

    r14336 r14338  
    253253      GoalsParameter.Value.CheckedItemsChanged += GoalSeekingUtil.Goals_CheckedItemsChanged;
    254254      InputsParameter.Value.CheckedItemsChanged += GoalSeekingUtil.Inputs_CheckedItemsChanged;
     255
     256      foreach (var input in Inputs)
     257        input.Changed += InputParameterChanged;
     258
     259      foreach (var goal in Goals)
     260        goal.Changed += GoalParameterChanged;
    255261    }
    256262
     
    259265      GoalSeekingUtil.UpdateInputs(InputsParameter.Value, Models, InputParameterChanged);
    260266      Encoding = GoalSeekingUtil.CreateEncoding(ActiveInputs);
    261       dataset = new ModifiableDataset(Inputs.Select(x => x.Name), Inputs.Select(x => new List<double> { x.Value }));
     267      dataset = Inputs.Any() ? new ModifiableDataset(Inputs.Select(x => x.Name), Inputs.Select(x => new List<double> { x.Value })) : new ModifiableDataset();
    262268      GoalSeekingUtil.UpdateTargets(GoalsParameter.Value, Models, GoalParameterChanged);
    263269      GoalSeekingUtil.RaiseEvent(this, ModelsChanged);
  • branches/HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/Properties/AssemblyInfo.cs

    r14336 r14338  
    5454// [assembly: AssemblyVersion("1.0.*")]
    5555[assembly: AssemblyVersion("3.3.0.0")]
    56 [assembly: AssemblyFileVersion("3.3.11.14334")]
     56[assembly: AssemblyFileVersion("3.3.11.14336")]
  • branches/HeuristicLab.GoalSeekingProblem/HeuristicLab.GoalSeekingProblem/3.4/SingleObjectiveGoalSeekingProblem.cs

    r14336 r14338  
    168168      GoalsParameter.Value.CheckedItemsChanged += GoalSeekingUtil.Goals_CheckedItemsChanged;
    169169      InputsParameter.Value.CheckedItemsChanged += GoalSeekingUtil.Inputs_CheckedItemsChanged;
     170
     171      foreach (var input in Inputs)
     172        input.Changed += InputParameterChanged;
     173
     174      foreach (var goal in Goals)
     175        goal.Changed += GoalParameterChanged;
    170176    }
    171177
     
    174180      GoalSeekingUtil.UpdateInputs(InputsParameter.Value, Models, InputParameterChanged);
    175181      Encoding = GoalSeekingUtil.CreateEncoding(ActiveInputs);
    176       dataset = new ModifiableDataset(Inputs.Select(x => x.Name), Inputs.Select(x => new List<double> { x.Value }));
     182      dataset = Inputs.Any() ? new ModifiableDataset(Inputs.Select(x => x.Name), Inputs.Select(x => new List<double> { x.Value })) : new ModifiableDataset();
    177183      GoalSeekingUtil.UpdateTargets(GoalsParameter.Value, Models, GoalParameterChanged);
    178184      GoalSeekingUtil.RaiseEvent(this, ModelsChanged);
Note: See TracChangeset for help on using the changeset viewer.