Changeset 17965
- Timestamp:
- 04/27/21 10:41:43 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Tests/HeuristicLab-3.3/Samples/ShapeConstrainedRegressionSampleTest.cs
r17958 r17965 19 19 */ 20 20 #endregion 21 22 using System; 21 23 using System.IO; 22 24 using System.Linq; … … 24 26 using HeuristicLab.Algorithms.GeneticAlgorithm; 25 27 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 28 using HeuristicLab.Problems.DataAnalysis; 26 29 using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression; 27 30 using HeuristicLab.Problems.Instances.DataAnalysis; … … 36 39 37 40 [TestMethod] 38 [TestCategory("Samples.Create")]39 [TestProperty("Time", "medium")]40 public void CreateShapeConstrainedRegressionSampleTest() {41 var ga = CreateShapeConstrainedRegressionSample();42 string path = Path.Combine(SamplesUtils.SamplesDirectory, SampleFileName + SamplesUtils.SampleFileExtension);43 serializer.Serialize(ga, path);44 }45 [TestMethod]46 41 [TestCategory("Samples.Execute")] 47 42 [TestProperty("Time", "long")] … … 51 46 SamplesUtils.RunAlgorithm(ga); 52 47 53 Assert.AreEqual(0. 0780908301423225, SamplesUtils.GetDoubleResult(ga, "BestQuality"), 1E-8);54 Assert.AreEqual( 0.381314019205066, SamplesUtils.GetDoubleResult(ga, "CurrentAverageQuality"), 1E-8);55 Assert.AreEqual( 1.0000000000000002, SamplesUtils.GetDoubleResult(ga, "CurrentWorstQuality"), 1E-8);48 Assert.AreEqual(0.317642788600248, SamplesUtils.GetDoubleResult(ga, "BestQuality"), 1E-8); 49 Assert.AreEqual(40.9805778810063, SamplesUtils.GetDoubleResult(ga, "CurrentAverageQuality"), 1E-8); 50 Assert.AreEqual(3359.91748220025, SamplesUtils.GetDoubleResult(ga, "CurrentWorstQuality"), 1E-8); 56 51 Assert.AreEqual(150200, SamplesUtils.GetIntResult(ga, "EvaluatedSolutions")); 57 52 } … … 63 58 var problem = new ShapeConstrainedRegressionSingleObjectiveProblem(); 64 59 problem.Load(provider.LoadData(instance)); 60 var problemData = (IShapeConstrainedRegressionProblemData)problem.ProblemData; 61 problemData.ShapeConstraints.Add(new ShapeConstraint(new Interval(double.NegativeInfinity, 0), 1.0)); 62 problemData.ShapeConstraints.Add(new ShapeConstraint("G", 1, new Interval(double.NegativeInfinity, 0), 1.0)); 63 problemData.ShapeConstraints.Add(new ShapeConstraint("c", 1, new Interval(0, double.PositiveInfinity), 1.0)); 64 problemData.ShapeConstraints.Add(new ShapeConstraint("m1", 1, new Interval(double.NegativeInfinity, 0), 1.0)); 65 problemData.ShapeConstraints.Add(new ShapeConstraint("m2", 1, new Interval(double.NegativeInfinity, 0), 1.0)); 66 problemData.ShapeConstraints.Add(new ShapeConstraint("r", 1, new Interval(0, double.PositiveInfinity), 1.0)); 67 68 problemData.VariableRanges.SetInterval("G", new Interval(1, 2)); 69 problemData.VariableRanges.SetInterval("c", new Interval(1, 2)); 70 problemData.VariableRanges.SetInterval("m1", new Interval(1, 5)); 71 problemData.VariableRanges.SetInterval("m2", new Interval(1, 5)); 72 problemData.VariableRanges.SetInterval("r", new Interval(1, 2)); 73 problem.ProblemData = problemData; 74 65 75 66 76 #region Algorithm Configuration
Note: See TracChangeset
for help on using the changeset viewer.