Changeset 16800


Ignore:
Timestamp:
04/17/19 14:37:55 (4 months ago)
Author:
chaider
Message:

#2971 Several chanages regarding review comments

Location:
branches/2971_named_intervals
Files:
5 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintConstOptEvaluator.cs

    r16781 r16800  
    6161
    6262      //var constraints = IntervalConstraintsParser.Parse(((RegressionProblemData)problemData).IntervalConstraintsParameter.Value.Value);
    63       var constraints = ((RegressionProblemData)problemData).IntervalConstraintsParameter.Value.Constraints.Where(x => x.IsChecked);
     63      var constraints = ((RegressionProblemData)problemData).IntervalConstraintsParameter.Value.Constraints.Where(x => x.Enabled);
    6464      var intervalInterpreter = new IntervalInterpreter();
    65       var variableRanges = ((RegressionProblemData)problemData).VariableRangesParameter.Value.VariableIntervals;
     65      var variableRanges = ((RegressionProblemData) problemData).VariableRangesParameter.Value.VariableIntervals;
    6666
    6767
     
    9292
    9393    private static bool HasConstraintVioluations(IEnumerable<IntervalConstraint> constraints, IntervalInterpreter intervalInterpreter,
    94       Dictionary<string, Interval> variableRanges, ISymbolicExpressionTree solution) {
     94      IDictionary<string, Interval> variableRanges, ISymbolicExpressionTree solution) {
    9595      foreach (var constraint in constraints) {
    9696        if (constraint.Variable != null && !variableRanges.ContainsKey(constraint.Variable))
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintPearsonRSquaredEvaluator.cs

    r16756 r16800  
    6464      var variableRanges = ((RegressionProblemData)problemData).VariableRangesParameter.Value.VariableIntervals;
    6565
    66 
    67       //foreach (var constraint in constraints) {
    68       //  if (constraint.Variable != null && !variableRanges.ContainsKey(constraint.Variable))
    69       //    throw new ArgumentException($"The given variable {constraint.Variable} in the constraint does not exists in the model.", nameof(IntervalConstraintsParser));
    70       //  if (!constraint.IsDerivation) {
    71       //    var res = intervalInterpreter.GetSymbolicExressionTreeInterval(solution, variableRanges);
    72       //    if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
    73       //      constraint.InclusiveUpperBound)) {
    74       //      return 0;
    75       //    }
    76       //  } else {
    77       //    var tree = solution;
    78       //    for (var i = 0; i < constraint.NumberOfDerivation; ++i) {
    79       //      tree = DerivativeCalculator.Derive(tree, constraint.Variable);
    80       //    }
    81       //    var res = intervalInterpreter.GetSymbolicExressionTreeInterval(tree, variableRanges);
    82       //    if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
    83       //      constraint.InclusiveUpperBound)) {
    84       //      return 0;
    85       //    }
    86       //  }
    87       //}
    88       // TODO
    89       // m = new SymbolicRegressionModel(...)
    90       // m.Scale();
    91 
    92       // var e = m.GetEstimatedValues (TRAINING)
    93       // OnlinePearsonCalc.Calculate(e, TARGET_TRAIING)
    94 
    95       // scaledTree = model.Tree;
    96 
    97       // constraints mit scaledTree berechnen (auch die Ableitungen)
    98 
    9966      double r;
    10067      if (applyLinearScaling) {
     
    142109
    143110    private static bool CheckConstraintsViolations(IEnumerable<IntervalConstraint> constraints, IntervalInterpreter intervalInterpreter,
    144       Dictionary<string, Interval> variableRanges, ISymbolicExpressionTree solution, out double r) {
     111      IDictionary<string, Interval> variableRanges, ISymbolicExpressionTree solution, out double r) {
    145112      foreach (var constraint in constraints) {
    146113        if (constraint.Variable != null && !variableRanges.ContainsKey(constraint.Variable))
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionConstraintAnalyzer.cs

    r16780 r16800  
    3737  public class SymbolicRegressionConstraintAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicDataAnalysisInterpreterOperator, ISymbolicExpressionTreeAnalyzer {
    3838    private const string ConstraintViolationsResultName = "Constraint Violations";
    39 
    4039    private const string ProblemDataParameterName = "ProblemData";
    4140    private const string SymbolicDataAnalysisTreeInterpreterParameterName = "SymbolicDataAnalysisTreeInterpreter";
    4241
    4342    #region parameter properties
     43
    4444    public ILookupParameter<RegressionProblemData> RegressionProblemDataParameter {
    45       get { return (ILookupParameter<RegressionProblemData>)Parameters[ProblemDataParameterName]; }
     45      get { return (ILookupParameter<RegressionProblemData>) Parameters[ProblemDataParameterName]; }
    4646    }
     47
    4748    public ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter> SymbolicDataAnalysisTreeInterpreterParameter {
    48       get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>)Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
     49      get { return (ILookupParameter<ISymbolicDataAnalysisExpressionTreeInterpreter>) Parameters[SymbolicDataAnalysisTreeInterpreterParameterName]; }
    4950    }
     51
    5052    #endregion
     53
    5154    #region properties
    5255
     
    5861      get { return SymbolicDataAnalysisTreeInterpreterParameter.ActualValue; }
    5962    }
     63
    6064    #endregion
    6165
    62     public virtual bool EnabledByDefault {
    63       get { return false; }
    64     }
     66    public override bool EnabledByDefault => false;
    6567
    6668    [StorableConstructor]
     
    6870    }
    6971
    70     protected SymbolicRegressionConstraintAnalyzer(SymbolicRegressionConstraintAnalyzer original, Cloner cloner)
    71       : base(original, cloner) {
     72    protected SymbolicRegressionConstraintAnalyzer(SymbolicRegressionConstraintAnalyzer original, Cloner cloner) : base(original, cloner) {
    7273    }
    7374
     
    8586    }
    8687
    87     public static Dictionary<IntervalConstraint, bool> CheckConstraints(ISymbolicExpressionTree model,
    88       IRegressionProblemData problemData) {
    89       var constraints = ((RegressionProblemData)problemData).IntervalConstraintsParameter.Value.Constraints.Where(x => x.IsChecked);
     88    public static Dictionary<IntervalConstraint, bool> CheckConstraints(ISymbolicExpressionTree model, IRegressionProblemData problemData) {
     89      var constraints = problemData.IntervalConstraints.Constraints.Where(x => x.Enabled);
    9090      var constraintViolations = new Dictionary<IntervalConstraint, bool>();
    91       var variableRanges = ((RegressionProblemData)problemData).VariableRanges.VariableIntervals;
    92 
     91      var variableRanges = problemData.VariableRanges.VariableIntervals;
    9392      foreach (var constraint in constraints) {
    9493        if (!constraintViolations.ContainsKey(constraint)) {
     
    10099    }
    101100
    102     public static Dictionary<IntervalConstraint, bool> CheckConstraints(ISymbolicRegressionModel model,
    103       IRegressionProblemData problemData) {
     101    public static Dictionary<IntervalConstraint, bool> CheckConstraints(ISymbolicRegressionModel model, IRegressionProblemData problemData) {
    104102      return CheckConstraints(model.SymbolicExpressionTree, problemData);
    105103    }
    106104
    107     public static bool CheckConstraint(ISymbolicExpressionTree model, Dictionary<string, Interval> variableRanges,
    108       IntervalConstraint constraint) {
     105    public static bool CheckConstraint(ISymbolicExpressionTree model, IDictionary<string, Interval> variableRanges, IntervalConstraint constraint) {
    109106      var intervalInterpreter = new IntervalInterpreter();
    110       if (constraint.Variable != null) {
    111         if (!constraint.IsDerivation) {
    112           var res = intervalInterpreter.GetSymbolicExpressionTreeInterval(model,
    113             variableRanges);
    114           if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
    115             constraint.InclusiveUpperBound)) {
    116             return false;
    117           }
    118         } else {
    119           var dTree = model;
    120           for (var i = 0; i < constraint.NumberOfDerivation; ++i) {
    121             dTree = DerivativeCalculator.Derive(dTree, constraint.Variable);
    122           }
    123           var res = intervalInterpreter.GetSymbolicExpressionTreeInterval(dTree,
    124             variableRanges);
    125           if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound,
    126             constraint.InclusiveUpperBound)) {
    127             return false;
    128           }
     107      if (!constraint.IsDerivation) {
     108        var res = intervalInterpreter.GetSymbolicExpressionTreeInterval(model, variableRanges);
     109        if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound, constraint.InclusiveUpperBound)) {
     110          return false;
     111        }
     112      } else {
     113        var dTree = model;
     114        for (var i = 0; i < constraint.NumberOfDerivation; ++i) {
     115          dTree = DerivativeCalculator.Derive(dTree, constraint.Variable);
     116        }
     117
     118        var res = intervalInterpreter.GetSymbolicExpressionTreeInterval(dTree, variableRanges);
     119        if (!constraint.Interval.Contains(res, constraint.InclusiveLowerBound, constraint.InclusiveUpperBound)) {
     120          return false;
    129121        }
    130122      }
     123
    131124      return true;
    132125    }
    133126
    134     static bool CheckConstraint(ISymbolicRegressionModel model, Dictionary<string, Interval> variableRanges, IntervalConstraint constraint) {
     127    static bool CheckConstraint(ISymbolicRegressionModel model, IDictionary<string, Interval> variableRanges, IntervalConstraint constraint) {
    135128      return CheckConstraint(model.SymbolicExpressionTree, variableRanges, constraint);
    136129    }
     
    140133      if (!results.ContainsKey(ConstraintViolationsResultName)) {
    141134        var newDataTable = new DataTable(ConstraintViolationsResultName);
    142         results.Add(new Result(ConstraintViolationsResultName, "Chart displaying the constraint violations.",
    143           newDataTable));
     135        results.Add(new Result(ConstraintViolationsResultName, "Chart displaying the constraint violations.", newDataTable));
    144136      }
    145       var dataTable = (DataTable)results[ConstraintViolationsResultName].Value;
     137
     138      var dataTable = (DataTable) results[ConstraintViolationsResultName].Value;
    146139      var problemData = RegressionProblemData;
    147140      var constraintViolations = new Dictionary<string, int>();
    148 
    149       var constraints = problemData.IntervalConstraintsParameter.Value.Constraints.Where(x => x.IsChecked);
    150 
     141      var constraints = problemData.IntervalConstraintsParameter.Value.Constraints.Where(x => x.Enabled);
    151142      if (dataTable.Rows.Count == 0) {
    152143        foreach (var constraint in constraints) {
     
    163154      foreach (var tree in this.SymbolicExpressionTree) {
    164155        var checkedConstraints = CheckConstraints(tree, problemData);
    165 
    166156        foreach (var kvp in checkedConstraints) {
    167           if (!kvp.Value)
    168             constraintViolations[kvp.Key.Expression]++;
     157          if (!kvp.Value) constraintViolations[kvp.Key.Expression]++;
    169158        }
    170159      }
     
    173162        dataTable.Rows[kvp.Key].Values.Add(kvp.Value);
    174163      }
     164
    175165      return base.Apply();
    176166    }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs

    r16761 r16800  
    2121
    2222using System;
     23using System.Collections;
     24using System.Collections.Generic;
    2325using System.Linq;
    2426using HEAL.Attic;
     
    5052
    5153    private const string IntervalEvaluationResultName = "Interval Evaluation";
    52     private const string EstimatedDerivationInterval = "Interval";
    5354
    5455    public new ISymbolicRegressionModel Model {
     
    151152        estimationLimitResults.Add(new Result(TestNaNEvaluationsResultName, "", new IntValue()));
    152153        Add(new Result(EstimationLimitsResultsResultName, "Results concerning the estimation limits of symbolic regression solution", estimationLimitResults));
     154        Add(new Result(IntervalEvaluationResultName, "Results concerning the derivation of symbolic regression solution", GetIntervalEvaluations()));
    153155        CalculateResults();
    154156      }
     
    163165      var intervalEvaluation = new NamedIntervals();
    164166      var interpreter = new IntervalInterpreter();
    165       var variableRanges = (ProblemData as RegressionProblemData)?.VariableRangesParameter.Value.VariableIntervals;
     167      var variableRanges = ProblemData.VariableRanges.VariableIntervals;
    166168
    167169      if (variableRanges != null) {
    168         intervalEvaluation.Add($"Target {ProblemData.TargetVariable}", new Interval(variableRanges[ProblemData.TargetVariable].LowerBound, variableRanges[ProblemData.TargetVariable].UpperBound));
    169         intervalEvaluation.Add("Modell Interval", interpreter.GetSymbolicExpressionTreeInterval(Model.SymbolicExpressionTree, variableRanges));
     170        intervalEvaluation.VariableIntervals.Add($"Target {ProblemData.TargetVariable}", new Interval(variableRanges[ProblemData.TargetVariable].LowerBound, variableRanges[ProblemData.TargetVariable].UpperBound));
     171        intervalEvaluation.VariableIntervals.Add("Modell Interval", interpreter.GetSymbolicExpressionTreeInterval(Model.SymbolicExpressionTree, variableRanges));
    170172     
    171173        foreach (var derivate in variableRanges) {
     
    174176            var derivedResultInterval = interpreter.GetSymbolicExpressionTreeInterval(derived, variableRanges);
    175177
    176             intervalEvaluation.Add(" \u2202f/\u2202" + derivate.Key,
     178            intervalEvaluation.VariableIntervals.Add(" \u2202f/\u2202" + derivate.Key,
    177179              new Interval(derivedResultInterval.LowerBound, derivedResultInterval.UpperBound));
    178180          }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/HeuristicLab.Problems.DataAnalysis.Views-3.4.csproj

    r16790 r16800  
    550550      <DependentUpon>TimeSeriesPrognosisSolutionView.cs</DependentUpon>
    551551    </Compile>
    552     <Compile Include="TextValueView.cs">
    553       <SubType>UserControl</SubType>
    554     </Compile>
    555     <Compile Include="TextValueView.designer.cs">
    556       <DependentUpon>TextValueView.cs</DependentUpon>
    557     </Compile>
    558552    <Compile Include="TimeSeriesPrognosis\TimeSeriesPrognosisResidualsLineChartView.cs">
    559553      <SubType>UserControl</SubType>
     
    630624      <DependentUpon>NamedIntervalsView.cs</DependentUpon>
    631625    </EmbeddedResource>
    632     <EmbeddedResource Include="TextValueView.resx">
    633       <DependentUpon>TextValueView.cs</DependentUpon>
    634     </EmbeddedResource>
    635626    <EmbeddedResource Include="IntervalConstraintView.resx">
    636627      <DependentUpon>IntervalConstraintView.cs</DependentUpon>
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs

    r16787 r16800  
    2929      definitionInput.ReadOnly = true;
    3030      derivationInput.Enabled = false;
    31       derivationInput.Checked = Content?.IsDerivation ?? false;
     31      derivationInput.Checked = false;
    3232      numberderivationInput.DataSource = items;
    3333    }
     
    101101        }
    102102
    103         ischeckedCheckBox.Checked = Content.IsChecked;
     103        ischeckedCheckBox.Checked = Content.Enabled;
    104104      }
    105105      SetEnabledStateOfControls();
    106106    }
    107107
    108     private void UpdateExpression() {
     108    private static string UpdateExpression(IntervalConstraint constraint) {
    109109      var expression = "";
    110110
    111       if (!Content.IsDerivation) {
    112         expression = string.Format("{0} in {1}{2} .. {3}{4}", 
    113           Content.Variable,
    114           (Content.InclusiveLowerBound) ? "[" : "]",
    115           Content.Interval.LowerBound,
    116           Content.Interval.UpperBound,
    117           (Content.InclusiveUpperBound) ? "]" : "[");
     111      if (!constraint.IsDerivation) {
     112        expression = string.Format("{0} in {1}{2} .. {3}{4}",
     113          constraint.Variable,
     114          (constraint.InclusiveLowerBound) ? "[" : "]",
     115          constraint.Interval.LowerBound,
     116          constraint.Interval.UpperBound,
     117          (constraint.InclusiveUpperBound) ? "]" : "[");
    118118      } else {
    119119        expression = string.Format("\u2202{5}Target/\u2202{0}{6} in {1}{2} .. {3}{4}",
    120           Content.Variable,
    121           (Content.InclusiveLowerBound) ? "[" : "]",
    122           Content.Interval.LowerBound,
    123           Content.Interval.UpperBound,
    124           (Content.InclusiveUpperBound) ? "]" : "[",
    125           PrintNumberOfDerivation(Content.numberOfDerivation),
    126           PrintNumberOfDerivation(Content.numberOfDerivation));
    127       }
    128 
    129       Content.Expression = expression;
    130       Content.Name = expression;
    131       UpdateControls();
    132     }
    133 
    134     private string PrintNumberOfDerivation(int derivation) {
     120          constraint.Variable,
     121          (constraint.InclusiveLowerBound) ? "[" : "]",
     122          constraint.Interval.LowerBound,
     123          constraint.Interval.UpperBound,
     124          (constraint.InclusiveUpperBound) ? "]" : "[",
     125          PrintNumberOfDerivation(constraint.numberOfDerivation),
     126          PrintNumberOfDerivation(constraint.numberOfDerivation));
     127      }
     128
     129      return expression;
     130    }
     131
     132    private static string PrintNumberOfDerivation(int derivation) {
    135133      switch (derivation) {
    136134        case 1:
     
    150148    private void lowerboundInput_Validating(object sender, CancelEventArgs e) {
    151149      var value = ParseDoubleValue(lowerboundInput.Text, lowerboundInput);
    152       if (!double.IsNaN(value)) {
    153         if (value <= Content.Interval.UpperBound) {
    154           errorProvider.SetError(lowerboundInput, string.Empty);
    155           e.Cancel = false;
    156         } else {
    157           errorProvider.SetError(lowerboundInput, "Invalid Input: Lowerbound must be smaller than Upperbound!");
    158           e.Cancel = true;
    159         }
    160       } else {
    161         e.Cancel = true;
    162       }
     150      if (double.IsNaN(value)) {
     151        errorProvider.SetError(lowerboundInput, "Invalid Input: Lowerbound must be a double value!");
     152        e.Cancel = true;
     153        return;
     154      }
     155
     156      if (value > Content.Interval.UpperBound) {
     157        errorProvider.SetError(lowerboundInput, "Invalid Input: Lowerbound must be smaller than Upperbound!");
     158        e.Cancel = true;
     159        return;
     160      }
     161
     162      errorProvider.SetError(lowerboundInput, string.Empty);
     163      e.Cancel = false;
    163164    }
    164165
     
    167168      if (!double.IsNaN(value)) {
    168169        Content.Interval = new Interval(value, Content.Interval.UpperBound);
    169         UpdateExpression();
     170        var exp = UpdateExpression(Content);
     171        Content.Name = exp;
     172        Content.Expression = exp;
    170173      }
    171174    }
     
    173176    private void upperboundInput_Validating(object sender, CancelEventArgs e) {
    174177      var value = ParseDoubleValue(upperboundInput.Text, upperboundInput);
    175       if (!double.IsNaN(value)) {
    176         if (value >= Content.Interval.LowerBound) {
    177           errorProvider.SetError(upperboundInput, string.Empty);
    178           e.Cancel = false;
    179         } else {
    180           errorProvider.SetError(lowerboundInput, "Invalid Input: Upperbound must be bigger than Lowerbound!");
    181           e.Cancel = true;
    182         }
    183       } else {
    184         e.Cancel = true;
    185       }
     178      if (double.IsNaN(value)) {
     179        errorProvider.SetError(upperboundInput, "Invalid Input: Upperbound must be a double value!");
     180        e.Cancel = true;
     181        return;
     182      }
     183
     184      if (value < Content.Interval.LowerBound) {
     185        errorProvider.SetError(upperboundInput, "Invalid Input: Upperbound must be bigger than Lowerbound!");
     186        e.Cancel = true;
     187        return;
     188      }
     189
     190      errorProvider.SetError(upperboundInput, string.Empty);
     191      e.Cancel = false;
    186192    }
    187193
     
    190196      if (!double.IsNaN(value)) {
    191197        Content.Interval = new Interval(Content.Interval.LowerBound, value);
    192         UpdateExpression();
     198        var exp = UpdateExpression(Content);
     199        Content.Name = exp;
     200        Content.Expression = exp;
    193201      }
    194202    }
     
    197205      if (Content.InclusiveLowerBound != incllowerboundInput.Checked) {
    198206        Content.InclusiveLowerBound = incllowerboundInput.Checked;
    199         UpdateExpression();
     207        var exp = UpdateExpression(Content);
     208        Content.Name = exp;
     209        Content.Expression = exp;
    200210      }
    201211     
     
    206216      if (Content.InclusiveUpperBound != inclupperboundInput.Checked) {
    207217        Content.InclusiveUpperBound = inclupperboundInput.Checked;
    208         UpdateExpression();
     218        var exp = UpdateExpression(Content);
     219        Content.Name = exp;
     220        Content.Expression = exp;
    209221      }
    210222    }
    211223
    212224    private void ischeckedCheckBox_CheckedChanged(object sender, EventArgs e) {
    213       if (Content.IsChecked != ischeckedCheckBox.Checked) {
    214         Content.IsChecked = ischeckedCheckBox.Checked;
    215         UpdateControls();
     225      if (Content.Enabled != ischeckedCheckBox.Checked) {
     226        Content.Enabled = ischeckedCheckBox.Checked;
     227        //UpdateControls();
    216228      }
    217229    }
     
    225237        Content.numberOfDerivation = 3;
    226238
    227       UpdateExpression();
     239      var exp = UpdateExpression(Content);
     240      Content.Name = exp;
     241      Content.Expression = exp;
    228242    }
    229243
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ParsedConstraintView.cs

    r16787 r16800  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21using System;
    222using System.Collections.Generic;
    323using HeuristicLab.Collections;
     
    3959        foreach (var constraint in parsedConstraints) {
    4060          constraint.Changed += constraint_Changed;
    41           intervalConstraints.Add(constraint, constraint.IsChecked);
     61          intervalConstraints.Add(constraint, constraint.Enabled);
    4262        }
    4363        constraintsOutput.Content = intervalConstraints;
     
    5979        foreach (var constraint in Content.Constraints) {
    6080          constraint.Changed += constraint_Changed;
    61           intervalConstraints.Add(constraint, constraint.IsChecked);
     81          intervalConstraints.Add(constraint, constraint.Enabled);
    6282        }
    6383
     
    6989    private void constraint_Changed(object sender, EventArgs e) {
    7090      var constraint = (IntervalConstraint) sender;
    71       intervalConstraints.SetItemCheckedState(constraint, constraint.IsChecked);
     91      intervalConstraints.SetItemCheckedState(constraint, constraint.Enabled);
    7292    }
    7393
     
    7696      ICheckedItemList<IntervalConstraint> checkedItemList = (ICheckedItemList<IntervalConstraint>) sender;
    7797      foreach (var indexedItem in e.Items) {
    78         indexedItem.Value.IsChecked = checkedItemList.ItemChecked(indexedItem.Value);
     98        indexedItem.Value.Enabled = checkedItemList.ItemChecked(indexedItem.Value);
    7999      }
    80100    }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj

    r16772 r16800  
    233233    <Compile Include="Interfaces\IDataset.cs" />
    234234    <Compile Include="Interfaces\IDependencyCalculator.cs" />
    235     <Compile Include="Interfaces\ITextValue.cs" />
    236235    <Compile Include="Interfaces\ITransformation.cs" />
    237236    <Compile Include="Interfaces\ITransformationMapper.cs" />
     
    307306    <Compile Include="Implementation\Classification\ThresholdCalculators\ThresholdCalculator.cs" />
    308307    <Compile Include="Properties\Annotations.cs" />
    309     <Compile Include="TextValue.cs" />
    310308    <None Include="HeuristicLab.snk" />
    311309    <None Include="packages.config" />
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/NamedIntervals.cs

    r16644 r16800  
    44using System.Collections.Generic;
    55using System.Linq;
     6using HeuristicLab.Collections;
    67using HEAL.Attic;
    78
     
    1011  [StorableType("230B4E4B-41E5-4D33-9BC3-E2DAADDCA5AE")]
    1112  public class NamedIntervals : Item {
    12     Dictionary<string, Interval> variableIntervals = new Dictionary<string, Interval>();
    13     public Dictionary<string, Interval> VariableIntervals => variableIntervals;
     13    public ObservableDictionary<string, Interval> VariableIntervals { get; } = new ObservableDictionary<string, Interval>();
    1414
    1515    [Storable(Name = "StorableIntervalInformation")]
     
    1717      get {
    1818        var l = new List<KeyValuePair<string, double[]>>();
    19         foreach (var varInt in variableIntervals)
     19        foreach (var varInt in VariableIntervals)
    2020
    2121          l.Add(new KeyValuePair<string, double[]>(varInt.Key,
     
    2626      set {
    2727        foreach (var varInt in value)
    28           variableIntervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1]));
     28          VariableIntervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1]));
    2929      }
    3030    }
     
    3636    protected NamedIntervals(NamedIntervals original, Cloner cloner) : base(original, cloner) {
    3737      foreach (var keyValuePair in original.VariableIntervals) {
    38         variableIntervals.Add(keyValuePair.Key, keyValuePair.Value);
     38        VariableIntervals.Add(keyValuePair.Key, new Interval(keyValuePair.Value.LowerBound, keyValuePair.Value.UpperBound));
    3939      }
    4040    }
     
    4646    public bool ReadOnly { get; }
    4747
    48     public bool InsertMany(IEnumerable<KeyValuePair<string, Interval>> entries) {
    49       if (entries == null) throw new ArgumentNullException("The given dataset is null.");
    50       if (entries.Count() != 0) {
    51         foreach (var entry in entries) {
    52           if (variableIntervals.ContainsKey(entry.Key))
    53             variableIntervals[entry.Key] = entry.Value;
    54           else
    55             variableIntervals.Add(entry.Key, entry.Value);
    56         }
    57       }
    58       return true;
    59     }
    60 
    61     public bool Add(string key, Interval value) {
    62       variableIntervals[key] = value;
    63       return true;
    64     }
    65 
    6648  }
    6749}
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Parser/IntervalConstraint.cs

    r16778 r16800  
    1818        if (value != expression) {
    1919          expression = value;
     20          OnChanged(EventArgs.Empty);
    2021        }
    2122      }
     
    2425    public Interval Interval { get; set; }
    2526    private bool inclusiveLowerBound;
    26 
    2727    public bool InclusiveLowerBound {
    2828      get => inclusiveLowerBound;
     
    5959    }
    6060
    61     private bool isChecked;
    62     public bool IsChecked {
    63       get => isChecked;
     61    private bool enabled;
     62    public bool Enabled {
     63      get => enabled;
    6464      set {
    65         if (value != isChecked) {
    66           isChecked = value;
     65        if (value != enabled) {
     66          enabled = value;
    6767          OnChanged(EventArgs.Empty);
    6868        }
     
    7777      inclusiveLowerBound = true;
    7878      IsDerivation = false;
    79       isChecked = false;
     79      enabled = false;
    8080    }
    8181
    8282    public IntervalConstraint(string name) {
    8383      base.name = name;
    84       IsChecked = true;
     84      enabled = true;
    8585    }
    8686
     
    9696      Variable = variable;
    9797      NumberOfDerivation = numberOfDerivation;
    98       IsChecked = isChecked;
     98      enabled = isChecked;
    9999    }
    100100
     
    113113      this.Variable = original.Variable;
    114114      this.NumberOfDerivation = original.NumberOfDerivation;
    115       this.isChecked = original.isChecked;
     115      this.enabled = original.enabled;
    116116    }
    117117
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs

    r16776 r16800  
    170170        if (!dataset.DoubleVariables.Contains(variable.Value)) continue; // intervals are only possible for double variables
    171171        var variableInterval = Interval.GetInterval(dataset.GetDoubleValues(variable.Value));
    172         namedIntervals.Add(variable.Value, variableInterval);
     172        namedIntervals.VariableIntervals.Add(variable.Value, variableInterval);
    173173      }
    174174     
    175       var commentMessage = "#Example of a target variable constraint" + Environment.NewLine +
    176                            "#F1: TargetVariable" + Environment.NewLine +
    177                            "#in: keyword has to follow" + Environment.NewLine +
    178                            "#bracket: open or closed regarding to open or closed interval definition" + Environment.NewLine +
    179                            "#double: lowerbound of the interval" + Environment.NewLine +
    180                            "#..: keyword has to follow to seperate lowerbound from upperbound" + Environment.NewLine +
    181                            "#double: upperbound of the interval" + Environment.NewLine +
    182                            "#bracket: open or closed regarding to open or closed interval definition" + Environment.NewLine +
    183                            "#Target:Y2 in [0 .. 1.2]" + Environment.NewLine + Environment.NewLine +
    184                            "#Constraints on model parameters:" + Environment.NewLine +
    185                            "#derivation symbol: d or ∂" + Environment.NewLine +
    186                            "#derivation in leibniz notation" + Environment.NewLine +
    187                            "#in and interval syntax is the same like above" + Environment.NewLine +
    188                            "#∂Y2/∂X1 in [0 .. inf.[" + Environment.NewLine +
    189                            "#∂²Y2/∂X1² in [0 .. inf.[" + Environment.NewLine +
    190                            "#∂Y2/∂X9 in [-100 .. 0]" + Environment.NewLine +
    191                            "#∂²Y2/∂X9² in [0 .. inf.[";
    192 
    193175      Parameters.Add(new FixedValueParameter<NamedIntervals>(VariableRangesParameterName, namedIntervals));
    194       Parameters.Add(new FixedValueParameter<ParsedConstraint>(IntervalConstraintsParameterName, new ParsedConstraint(commentMessage, this)));
     176      Parameters.Add(new FixedValueParameter<ParsedConstraint>(IntervalConstraintsParameterName, new ParsedConstraint(this)));
    195177      RegisterParameterEvents();
    196178    }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs

    r16640 r16800  
    2121
    2222using System.Collections.Generic;
     23using HeuristicLab.Problems.DataAnalysis.Implementation;
    2324using HEAL.Attic;
    2425
     
    2829    string TargetVariable { get; set; }
    2930
     31    NamedIntervals VariableRanges { get; }
     32    ParsedConstraint IntervalConstraints { get; }
    3033    IEnumerable<double> TargetVariableValues { get; }
    3134    IEnumerable<double> TargetVariableTrainingValues { get; }
  • branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ParsedConstraint.cs

    r16778 r16800  
    11using System;
    22using System.Collections.Generic;
    3 using System.Dynamic;
    4 using System.Linq;
    5 using System.Text;
    6 using System.Threading.Tasks;
    7 using System.Windows.Markup;
    83using HeuristicLab.Common;
    94using HeuristicLab.Core;
    10 using HeuristicLab.Data;
    11 using HeuristicLab.Parameters;
    125using HEAL.Attic;
    136
     
    169  [Item("ParsedConstraint", "Represents parsed constraints.")]
    1710  public class ParsedConstraint : Item {
     11    private static readonly string exampleInput = "#Example for a target variable constraint:" + Environment.NewLine +
     12                                                  "Target:y in [0 .. 100]" + Environment.NewLine + Environment.NewLine +
     13                                                  "#Example for constraint on model parameter: " + Environment.NewLine +
     14                                                  "dy/dx in [0 .. 10]" + Environment.NewLine +
     15                                                  "\u2202²y/\u2202x² in ]-1 .. inf.[";
     16     
     17    public string Input { get; set; }
    1818
    19     protected string input;
    20     public string Input {
    21       get => input;
    22       set => input = value;
    23     }
    24 
    25     protected IEnumerable<IntervalConstraint> constraints;
     19    private IEnumerable<IntervalConstraint> constraints;
    2620    public IEnumerable<IntervalConstraint> Constraints {
    2721      get => constraints;
     
    3125      }
    3226  }
     27    public IRegressionProblemData ProblemData { get; set; }
    3328
    34     protected IRegressionProblemData problemData;
    35     public IRegressionProblemData ProblemData {
    36       get => problemData;
    37       set => problemData = value;
    38     }
     29    [StorableConstructor]
     30    protected ParsedConstraint(StorableConstructorFlag _) : base(_) { }
    3931
    4032    protected ParsedConstraint(ParsedConstraint original, Cloner cloner)
    4133      : base(original, cloner) {
    42       this.input = original.Input ?? string.Empty;
    43       this.constraints = original.Constraints ?? new CheckedItemList<IntervalConstraint>();
    44       this.problemData = original.problemData;
     34      this.Input = original.Input;
     35      this.constraints = original.Constraints;
     36      this.ProblemData = original.ProblemData;
    4537    }
    4638
     
    5042
    5143    public ParsedConstraint() {
    52       this.input = string.Empty;
     44      this.Input = exampleInput;
    5345      this.constraints = new CheckedItemList<IntervalConstraint>();
     46      this.ProblemData = null;
     47    }
     48
     49    public ParsedConstraint(IRegressionProblemData problemData) {
     50      this.Input = exampleInput;
     51      this.constraints = new List<IntervalConstraint>();
     52      this.ProblemData = problemData;
    5453    }
    5554
    5655    public ParsedConstraint(string input, IRegressionProblemData problemData) {
    57       this.input = input;
     56      this.Input = input;
    5857      this.constraints = new CheckedItemList<IntervalConstraint>();
    59       this.problemData = problemData;
     58      this.ProblemData = problemData;
    6059    }
    6160
    6261    public ParsedConstraint(string input, IEnumerable<IntervalConstraint> constraints) {
    63       this.input = input;
     62      this.Input = input;
    6463      this.constraints = constraints;
    6564    }
Note: See TracChangeset for help on using the changeset viewer.