- Timestamp:
- 02/19/22 01:02:08 (3 years ago)
- Location:
- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/NMSESingleObjectiveConstraintsEvaluator.cs
r18213 r18219 210 210 211 211 public static IEnumerable<Tuple<ShapeConstraint, double>> CalculateShapeConstraintsViolations( 212 IShapeConstrainedRegressionProblemData problemData, ISymbolicExpressionTree tree) => 213 CalculateShapeConstraintsViolations(problemData, tree, 214 new SymbolicDataAnalysisExpressionTreeLinearInterpreter(), 215 new IntervalArithBoundsEstimator(), 216 new MersenneTwister()); 217 218 public static IEnumerable<Tuple<ShapeConstraint, double>> CalculateShapeConstraintsViolations( 212 219 IShapeConstrainedRegressionProblemData problemData, ISymbolicExpressionTree tree, 213 220 ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, IBoundsEstimator estimator, … … 234 241 var enabledConstraints = extendedConstraint.ShapeConstraints.EnabledConstraints; 235 242 if (enabledConstraints.Any()) { 236 var extendedConstraintExprValues = interpreter.GetSymbolicExpressionTreeValues(extendedConstraint.Tree, tmpDataset, problemData.AllIndices); 243 var extendedConstraintExprValues = interpreter.GetSymbolicExpressionTreeValues(extendedConstraint.Tree, tmpDataset, problemData.AllIndices) 244 .Where(x => !double.IsNaN(x)); 245 extendedConstraintExprValues = !extendedConstraintExprValues.Any() ? 246 new double[] {double.NegativeInfinity, double.PositiveInfinity} : 247 extendedConstraintExprValues; 237 248 var extendedConstraintExprInterval = new Interval(extendedConstraintExprValues.Min(), extendedConstraintExprValues.Max()); 238 249 … … 258 269 dict[problemData.TargetVariable] = allEstimatedValues.ToList(); 259 270 tmpDataset = new Dataset(dict.Keys, dict.Values); 260 extendedConstraintExprValues = interpreter.GetSymbolicExpressionTreeValues(extendedConstraint.Tree, tmpDataset, problemData.AllIndices); 271 extendedConstraintExprValues = interpreter.GetSymbolicExpressionTreeValues(extendedConstraint.Tree, tmpDataset, problemData.AllIndices) 272 .Where(x => !double.IsNaN(x)); 273 extendedConstraintExprValues = !extendedConstraintExprValues.Any() ? 274 new double[] { double.NegativeInfinity, double.PositiveInfinity } : 275 extendedConstraintExprValues; 261 276 extendedConstraintExprInterval = new Interval(extendedConstraintExprValues.Min(), extendedConstraintExprValues.Max()); 262 277 } -
branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolution.cs
r17911 r18219 47 47 private const string TestNaNEvaluationsResultName = "Test NaN Evaluations"; 48 48 49 private const string ConstraintViolationsResultsResultName = "Constraint Violations"; 50 49 51 private const string ModelBoundsResultName = "Model Bounds"; 50 52 … … 64 66 get { return ((IntValue)this[ModelDepthResultName].Value).Value; } 65 67 private set { ((IntValue)this[ModelDepthResultName].Value).Value = value; } 68 } 69 70 private ResultCollection ConstraintViolationsResultCollection { 71 get => (ResultCollection)this[ConstraintViolationsResultsResultName].Value; 66 72 } 67 73 … … 136 142 estimationLimitResults.Add(new Result(TestNaNEvaluationsResultName, "", new IntValue())); 137 143 Add(new Result(EstimationLimitsResultsResultName, "Results concerning the estimation limits of symbolic regression solution", estimationLimitResults)); 144 145 Add(new Result(ConstraintViolationsResultsResultName, "Constraint Violations", new ResultCollection())); 138 146 139 147 if (IntervalInterpreter.IsCompatible(Model.SymbolicExpressionTree)) … … 168 176 } 169 177 } 178 179 if(!ContainsKey(ConstraintViolationsResultsResultName)) { 180 Add(new Result(ConstraintViolationsResultsResultName, "Constraint Violations", new ResultCollection())); 181 CalculateResults(); 182 } 170 183 } 171 184 … … 192 205 if (IntervalInterpreter.IsCompatible(Model.SymbolicExpressionTree)) 193 206 ModelBoundsCollection = CalculateModelIntervals(this); 207 208 if(ProblemData is IShapeConstrainedRegressionProblemData scpd) { 209 var violations = NMSESingleObjectiveConstraintsEvaluator.CalculateShapeConstraintsViolations(scpd, Model.SymbolicExpressionTree); 210 foreach (var violation in violations) { 211 ConstraintViolationsResultCollection.Add(new Result(violation.Item1.ToString(), new DoubleValue(violation.Item2))); 212 } 213 } 194 214 } 195 215
Note: See TracChangeset
for help on using the changeset viewer.