Changeset 17722
- Timestamp:
- 08/11/20 14:20:01 (4 years ago)
- Location:
- branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMultiSoftConstraintEvaluator.cs
r17705 r17722 30 30 using HeuristicLab.Data; 31 31 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 32 using HeuristicLab.Parameters; 32 33 33 34 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.MultiObjective { … … 37 38 public class 38 39 SymbolicRegressionMultiObjectiveMultiSoftConstraintEvaluator : SymbolicRegressionMultiObjectiveSplittingEvaluator { 40 public const string DimensionsParameterName = "Dimensions"; 41 42 public IFixedValueParameter<IntValue> DimensionsParameter => (IFixedValueParameter<IntValue>)Parameters[DimensionsParameterName]; 43 39 44 #region Constructors 40 41 public SymbolicRegressionMultiObjectiveMultiSoftConstraintEvaluator() { } 45 public SymbolicRegressionMultiObjectiveMultiSoftConstraintEvaluator() { 46 Parameters.Add(new FixedValueParameter<IntValue>(DimensionsParameterName, new IntValue(2))); 47 } 42 48 43 49 [StorableConstructor] … … 48 54 49 55 #endregion 56 57 [StorableHook(HookType.AfterDeserialization)] 58 private void AfterDeserialization() { 59 if(!Parameters.ContainsKey(DimensionsParameterName)) 60 Parameters.Add(new FixedValueParameter<IntValue>(DimensionsParameterName, new IntValue(2))); 61 } 50 62 51 63 public override IDeepCloneable Clone(Cloner cloner) { … … 193 205 intervalInterpreter.GetSymbolicExpressionTreeInterval(tree, variableRanges /*, splitting: splitting*/); 194 206 } 195 207 196 208 //Calculate soft-constraints for intervals 197 209 if (constraint.Interval.Contains(resultInterval)) return 0; … … 219 231 get { 220 232 var objectives = new List<bool> {false}; //First NMSE ==> min 221 objectives.AddRange(Enumerable.Repeat(false, 2)); //Constraints ==> min233 objectives.AddRange(Enumerable.Repeat(false, DimensionsParameter.Value.Value)); //Constraints ==> min 222 234 223 235 return objectives; -
branches/3076_IA_evaluators_analyzers/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionConstraintAnalyzer.cs
r17636 r17722 1 1 using System; 2 2 using System.Collections.Generic; 3 using System.Collections.ObjectModel; 3 4 using System.Linq; 4 5 using HEAL.Attic; … … 91 92 Interval resultInterval; 92 93 94 // create new variable ranges for defined regions 95 IDictionary<string, Interval> regionRanges = new Dictionary<string, Interval>(); 96 foreach (var kvp in variableRanges) 97 { 98 if (kvp.Key != constraint.Target && constraint.Regions.TryGetValue(kvp.Key, out Interval val)) 99 { 100 regionRanges.Add(kvp.Key, val); 101 } 102 else 103 { 104 regionRanges.Add(kvp); 105 } 106 } 107 108 // calculate result interval 93 109 if (!constraint.IsDerivative) { 94 resultInterval = intervalInterpreter.GetSymbolicExpressionTreeInterval(solution, variableRanges);110 resultInterval = intervalInterpreter.GetSymbolicExpressionTreeInterval(solution, new ReadOnlyDictionary<string, Interval>(regionRanges)); 95 111 } 96 112 else { … … 102 118 } 103 119 104 resultInterval = intervalInterpreter.GetSymbolicExpressionTreeInterval(tree, variableRanges);120 resultInterval = intervalInterpreter.GetSymbolicExpressionTreeInterval(tree, new ReadOnlyDictionary<string, Interval>(regionRanges)); 105 121 } 106 122
Note: See TracChangeset
for help on using the changeset viewer.