Changeset 17767
- Timestamp:
- 09/29/20 10:18:12 (4 years ago)
- Location:
- branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraint.cs
r17765 r17767 23 23 using System; 24 24 using System.Collections.Generic; 25 using System.Linq; 25 26 using HEAL.Attic; 26 27 using HeuristicLab.Common; … … 114 115 } 115 116 116 [Storable] 117 private /*IDictionary<string, Interval>*/ IEnumerable<Region> regions; //= new Dictionary<string, Interval>(); 118 public IEnumerable<Region> Regions 119 { 117 [Storable] private IEnumerable<Region> regions; 118 public IEnumerable<Region> Regions { 120 119 get => regions; 121 set 122 { 123 if (regions != value) 124 { 120 set { 121 if (regions != value) { 125 122 regions = value; 126 123 UpdateExpression(); … … 132 129 [Storable] 133 130 private double weight = 1.0; 134 public double Weight 135 { 131 public double Weight { 136 132 get => weight; 137 set 138 { 139 if(weight != value) 140 { 133 set { 134 if (weight != value) { 141 135 weight = value; 142 136 UpdateExpression(); … … 149 143 private IntervalConstraint(StorableConstructorFlag _) : base(_) { } 150 144 151 public IntervalConstraint(string expression, string variable, string target, int numberOfDerivations,152 Interval interval, double weight, bool enabled)153 : this(expression, variable, target, numberOfDerivations,154 interval, new List<Region>(), weight, enabled) { }155 156 145 public IntervalConstraint(string expression, string variable, string target, int numberOfDerivations, 157 Interval interval, IEnumerable<Region> regions, double weight, bool enabled) 158 { 146 Interval interval, double weight, bool enabled) 147 : this(expression, variable, target, numberOfDerivations, 148 interval, Enumerable.Empty<Region>(), weight, enabled) { } 149 150 public IntervalConstraint(string expression, string variable, string target, int numberOfDerivations, 151 Interval interval, IEnumerable<Region> regions, double weight, bool enabled) { 152 this.regions = regions; 153 this.weight = weight; 159 154 this.expression = expression; 160 155 this.variable = variable; … … 162 157 this.numberOfDerivations = numberOfDerivations; 163 158 this.interval = interval; 164 this.regions = regions;165 this.weight = weight;166 159 this.enabled = enabled; 167 160 } … … 173 166 private IntervalConstraint(IntervalConstraint original, Cloner cloner) 174 167 : base(original, cloner) { 175 Expression = original.Expression; 176 Variable = original.Variable; 177 Target = original.Target; 168 Regions = new List<Region>(original.Regions?.Select(r => cloner.Clone(r)) ?? Enumerable.Empty<Region>()); 169 Expression = original.Expression; 170 Variable = original.Variable; 171 Target = original.Target; 178 172 NumberOfDerivations = original.NumberOfDerivations; 179 Interval = original.Interval; 180 Regions = original.Regions; 181 Enabled = original.Enabled; 173 Interval = original.Interval; 174 Enabled = original.Enabled; 182 175 } 183 176 … … 213 206 Interval?.UpperBound, 214 207 "]"); 215 foreach(var region in Regions) 216 expression += $", {region.VariableName}=({region.Interval.LowerBound} .. {region.Interval.UpperBound})"; 208 if(Regions != null) { 209 foreach (var region in Regions) 210 expression += $", {region.VariableName}=({region.Interval.LowerBound} .. {region.Interval.UpperBound})"; 211 } 212 217 213 Expression = expression; 218 214 return; 219 215 } 220 216 221 expression = string.Format("∂{6}{1}/∂{0}{6} in {2}{3} .. {4}{5}", 217 expression = string.Format("∂{6}{1}/∂{0}{6} in {2}{3} .. {4}{5}", 222 218 Variable, 223 219 Target, … … 227 223 "]", 228 224 GetDerivationString(numberOfDerivations)); 229 foreach (var region in Regions) 230 expression += $", {region.VariableName}=({region.Interval.LowerBound} .. {region.Interval.UpperBound})"; 225 if (Regions != null) { 226 foreach (var region in Regions) 227 expression += $", {region.VariableName}=({region.Interval.LowerBound} .. {region.Interval.UpperBound})"; 228 } 231 229 Expression = expression; 232 230 } -
branches/3073_IA_constraint_splitting/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/Region.cs
r17765 r17767 17 17 get => variableName; 18 18 private set { 19 if(variableName != value) {19 if(variableName == null || variableName != value) { 20 20 variableName = value; 21 21 OnChanged(); … … 26 26 [Storable] private Interval interval; 27 27 public Interval Interval { 28 get => Interval;28 get => interval; 29 29 private set { 30 if ( !interval.Equals(value)) {30 if (interval == null || !interval.Equals(value)) { 31 31 interval = value; 32 32 OnChanged(); … … 34 34 } 35 35 } 36 37 [StorableConstructor] 38 private Region(StorableConstructorFlag _) : base(_) { } 36 39 37 40 public Region(string variableName, Interval interval) {
Note: See TracChangeset
for help on using the changeset viewer.