Changeset 17506
- Timestamp:
- 04/10/20 14:04:59 (5 years ago)
- Location:
- branches/2971_named_intervals
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveConstraintConstOptEvaluator.cs
r17504 r17506 91 91 if (constraint.Variable != null && !variableRanges.ContainsKey(constraint.Variable)) 92 92 throw new ArgumentException($"The given variable {constraint.Variable} in the constraint does not exists in the model.", nameof(IntervalConstraintsParser)); 93 if (!constraint.IsDerivati on) {93 if (!constraint.IsDerivative) { 94 94 var res = intervalInterpreter.GetSymbolicExpressionTreeInterval(solution, variableRanges); 95 95 if (!constraint.Interval.Contains(res)) { … … 98 98 } else { 99 99 var tree = solution; 100 for (var i = 0; i < constraint.NumberOfDerivation ; ++i) {100 for (var i = 0; i < constraint.NumberOfDerivations; ++i) { 101 101 tree = DerivativeCalculator.Derive(tree, constraint.Variable); 102 102 } -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionConstraintAnalyzer.cs
r17504 r17506 105 105 Interval resultInterval; 106 106 107 if (!constraint.IsDerivati on) {107 if (!constraint.IsDerivative) { 108 108 resultInterval = intervalInterpreter.GetSymbolicExpressionTreeInterval(solution, variableRanges); 109 109 } else { 110 110 var tree = solution; 111 for (var i = 0; i < constraint.NumberOfDerivation ; ++i) {111 for (var i = 0; i < constraint.NumberOfDerivations; ++i) { 112 112 tree = DerivativeCalculator.Derive(tree, constraint.Variable); 113 113 } -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/IntervalConstraintView.cs
r17370 r17506 105 105 106 106 variableInput.Text = Content.Variable; 107 if (!Content.IsDerivati on) {107 if (!Content.IsDerivative) { 108 108 numberderivationInput.Enabled = false; 109 109 numberderivationInput.SelectedItem = null; … … 113 113 numberderivationInput.Visible = true; 114 114 numberderivationInput.Enabled = true; 115 numberderivationInput.SelectedItem = Content.NumberOfDerivation ;115 numberderivationInput.SelectedItem = Content.NumberOfDerivations; 116 116 } 117 117 … … 178 178 private void numberderivationInput_SelectedIndexChanged(object sender, EventArgs e) { 179 179 if (numberderivationInput.SelectedItem == null) { 180 Content.NumberOfDerivation = 0;180 Content.NumberOfDerivations = 0; 181 181 numberderivationInput.Enabled = false; 182 182 return; 183 183 } 184 184 if ((int)numberderivationInput.SelectedItem == 1) 185 Content.NumberOfDerivation = 1;185 Content.NumberOfDerivations = 1; 186 186 else if ((int)numberderivationInput.SelectedItem == 2) 187 Content.NumberOfDerivation = 2;187 Content.NumberOfDerivations = 2; 188 188 else if ((int)numberderivationInput.SelectedItem == 3) 189 Content.NumberOfDerivation = 3;189 Content.NumberOfDerivations = 3; 190 190 } 191 191 -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalCollection.cs
r17145 r17506 33 33 get => HeuristicLab.Common.Resources.VSImageLibrary.Object; 34 34 } 35 private IDictionary<string, Interval> VariableIntervals { get; } = new Dictionary<string, Interval>();35 private IDictionary<string, Interval> intervals { get; } = new Dictionary<string, Interval>(); 36 36 37 37 [Storable(Name = "StorableIntervalInformation")] … … 39 39 get { 40 40 var l = new List<KeyValuePair<string, double[]>>(); 41 foreach (var varInt in VariableIntervals)41 foreach (var varInt in intervals) 42 42 43 43 l.Add(new KeyValuePair<string, double[]>(varInt.Key, … … 48 48 set { 49 49 foreach (var varInt in value) 50 VariableIntervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1]));50 intervals.Add(varInt.Key, new Interval(varInt.Value[0], varInt.Value[1])); 51 51 } 52 52 } … … 57 57 58 58 protected IntervalCollection(IntervalCollection original, Cloner cloner) : base(original, cloner) { 59 foreach (var keyValuePair in original. VariableIntervals) {60 VariableIntervals.Add(keyValuePair.Key, new Interval(keyValuePair.Value.LowerBound, keyValuePair.Value.UpperBound));59 foreach (var keyValuePair in original.intervals) { 60 intervals.Add(keyValuePair.Key, new Interval(keyValuePair.Value.LowerBound, keyValuePair.Value.UpperBound)); 61 61 } 62 62 } … … 65 65 } 66 66 67 public IntervalCollection(IDictionary<string, Interval> variableIntervals) {68 this. VariableIntervals = variableIntervals;67 public IntervalCollection(IDictionary<string, Interval> intervals) { 68 this.intervals = intervals; 69 69 } 70 70 71 public Interval GetInterval(string variable) {72 if (! VariableIntervals.ContainsKey(variable)) throw new ArgumentException($"The given variable:{ variable} is not present!");71 public Interval GetInterval(string identifier) { 72 if (!intervals.ContainsKey(identifier)) throw new ArgumentException($"The given identifier:{ identifier } is not present!"); 73 73 74 return VariableIntervals[variable];74 return intervals[identifier]; 75 75 } 76 76 77 public void SetInterval(string key, Interval interval) {78 VariableIntervals[key] = interval;77 public void SetInterval(string identifier, Interval interval) { 78 intervals[identifier] = interval; 79 79 } 80 80 81 public void AddInterval(string key, Interval interval) {82 VariableIntervals.Add(key, interval);81 public void AddInterval(string identifier, Interval interval) { 82 intervals.Add(identifier, interval); 83 83 } 84 84 85 public void DeleteInterval(string key) {86 VariableIntervals.Remove(key);85 public void DeleteInterval(string identifier) { 86 intervals.Remove(identifier); 87 87 } 88 88 89 89 public IDictionary<string, Interval> GetIntervals() { 90 return VariableIntervals;90 return intervals; 91 91 } 92 92 } -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraint.cs
r17370 r17506 20 20 #endregion 21 21 using System; 22 using HEAL.Attic; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; 24 using HEAL.Attic;25 25 26 26 namespace HeuristicLab.Problems.DataAnalysis { … … 60 60 public string Target { 61 61 get => target; 62 set {62 private set { 63 63 if (target == value) return; 64 64 target = value; … … 68 68 } 69 69 70 public bool IsDerivati on{71 get => numberOfDerivation> 0;70 public bool IsDerivative { 71 get => NumberOfDerivations > 0; 72 72 } 73 73 74 74 [Storable] 75 private int numberOfDerivation ;76 public int NumberOfDerivation {77 get => numberOfDerivation ;75 private int numberOfDerivations; 76 public int NumberOfDerivations { 77 get => numberOfDerivations; 78 78 set { 79 79 if (value < 0 || value > 3) throw new ArgumentException("Number of derivation has to be between 0 - 3."); 80 if (numberOfDerivation == value) return;81 numberOfDerivation = value;80 if (numberOfDerivations == value) return; 81 numberOfDerivations = value; 82 82 UpdateExpression(); 83 83 OnChanged(); … … 111 111 private IntervalConstraint(StorableConstructorFlag _) : base(_) { } 112 112 113 public IntervalConstraint(string expression, string variable, string target, int numberOfDerivation , Interval interval, bool enabled) : base(){113 public IntervalConstraint(string expression, string variable, string target, int numberOfDerivations, Interval interval, bool enabled) : base(){ 114 114 this.expression = expression; 115 115 this.variable = variable; 116 116 this.target = target; 117 this.numberOfDerivation = numberOfDerivation;117 this.numberOfDerivations = numberOfDerivations; 118 118 this.interval = interval; 119 119 this.enabled = enabled; … … 129 129 this.Variable = original.Variable; 130 130 this.Target = original.Target; 131 this.NumberOfDerivation = original.NumberOfDerivation;131 this.NumberOfDerivations = original.NumberOfDerivations; 132 132 this.Interval = original.Interval; 133 133 this.Enabled = original.Enabled; … … 157 157 var expression = ""; 158 158 159 if (!IsDerivati on) {159 if (!IsDerivative) { 160 160 expression = string.Format("Target:{0} in {1}{2} .. {3}{4}", 161 161 Variable, … … 174 174 Interval?.UpperBound, 175 175 "]", 176 GetDerivationString(numberOfDerivation ));176 GetDerivationString(numberOfDerivations)); 177 177 Expression = expression; 178 178 } 179 179 180 180 private string GetDefinitionString() { 181 if (!IsDerivati on) {181 if (!IsDerivative) { 182 182 return "Target " + Variable; 183 183 } 184 var definition = $"∂{GetDerivationString(numberOfDerivation )}Target/∂{Variable}{GetDerivationString(numberOfDerivation)}";184 var definition = $"∂{GetDerivationString(numberOfDerivations)}Target/∂{Variable}{GetDerivationString(numberOfDerivations)}"; 185 185 return definition; 186 186 } -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs
r17210 r17506 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using HEAL.Attic; 25 26 using HeuristicLab.Common; 26 27 using HeuristicLab.Core; 27 28 using HeuristicLab.Data; 28 29 using HeuristicLab.Parameters; 29 using HEAL.Attic;30 30 31 31 namespace HeuristicLab.Problems.DataAnalysis { … … 94 94 problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>())); 95 95 problemData.Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, "", new IntervalCollection())); 96 problemData.Parameters.Add(new FixedValueParameter<ProblemDataConstraint>(IntervalConstraintsParameterName, "", new ProblemDataConstraint( )));96 problemData.Parameters.Add(new FixedValueParameter<ProblemDataConstraint>(IntervalConstraintsParameterName, "", new ProblemDataConstraint(problemData))); 97 97 emptyProblemData = problemData; 98 98 } -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/ProblemDataConstraint.cs
r17504 r17506 35 35 private static readonly string exampleInput = "# Example for a target variable constraint:" + Environment.NewLine + 36 36 "Target:'y' in [0 .. 100]" + Environment.NewLine + Environment.NewLine + 37 "# Example for constraint on model parameter: " + Environment.NewLine +37 "# Example for constraints on model parameters: " + Environment.NewLine + 38 38 "d'y'/d'x' in [0 .. 10]" + Environment.NewLine + 39 39 "∂²'y'/∂'x'² in [-1 .. inf.]";
Note: See TracChangeset
for help on using the changeset viewer.