Changeset 17958
- Timestamp:
- 04/22/21 14:59:58 (4 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 2 deleted
- 10 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj
r17931 r17958 119 119 </ItemGroup> 120 120 <ItemGroup> 121 <Compile Include="MultiObjective\NMSEConstraintsEvaluator.cs" /> 121 <Compile Include="Interfaces\IMultiObjectiveConstaintsEvaluator.cs" /> 122 <Compile Include="MultiObjective\NMSEMultiObjectiveConstraintsEvaluator.cs" /> 122 123 <Compile Include="MultiObjective\PearsonRSquaredNestedTreeSizeEvaluator.cs" /> 123 124 <Compile Include="MultiObjective\PearsonRSquaredNumberOfVariablesEvaluator.cs" /> 124 125 <Compile Include="MultiObjective\PearsonRSquaredAverageSimilarityEvaluator.cs" /> 125 126 <Compile Include="MultiObjective\PearsonRSquaredTreeComplexityEvaluator.cs" /> 127 <Compile Include="MultiObjective\ShapeConstrainedRegressionMultiObjectiveProblem.cs" /> 126 128 <Compile Include="MultiObjective\SymbolicRegressionMultiObjectiveValidationBestSolutionAnalyzer.cs" /> 127 129 <Compile Include="Plugin.cs" /> 128 130 <Compile Include="ShapeConstraintsAnalyzer.cs" /> 129 131 <Compile Include="SingleObjective\ConstantOptimizationAnalyzer.cs" /> 130 <Compile Include="SingleObjective\Evaluators\NMSE ConstraintsEvaluator.cs" />132 <Compile Include="SingleObjective\Evaluators\NMSESingleObjectiveConstraintsEvaluator.cs" /> 131 133 <Compile Include="SingleObjective\Evaluators\SymbolicRegressionMeanRelativeErrorEvaluator.cs" /> 134 <Compile Include="SingleObjective\ShapeConstrainedRegressionSingleObjectiveProblem.cs" /> 132 135 <Compile Include="SingleObjective\SymbolicRegressionSolutionsAnalyzer.cs" /> 133 136 <Compile Include="SymbolicRegressionPhenotypicDiversityAnalyzer.cs" /> -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveProblem.cs
r17180 r17958 60 60 public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicRegressionMultiObjectiveProblem(this, cloner); } 61 61 62 public SymbolicRegressionMultiObjectiveProblem() 63 : base(new RegressionProblemData(), new SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { 62 public SymbolicRegressionMultiObjectiveProblem() : this(new RegressionProblemData(), new SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { } 63 public SymbolicRegressionMultiObjectiveProblem(IRegressionProblemData problemData, ISymbolicRegressionMultiObjectiveEvaluator evaluator, ISymbolicDataAnalysisSolutionCreator solutionCreator) 64 : base(problemData, evaluator, solutionCreator) { 64 65 Parameters.Add(new FixedValueParameter<DoubleLimit>(EstimationLimitsParameterName, EstimationLimitsParameterDescription)); 65 66 -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/ShapeConstraintsAnalyzer.cs
r17906 r17958 31 31 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression { 32 32 [StorableType("4318C6BD-E0A1-45FE-AC30-96E7F73B51FB")] 33 [Item("ShapeConstraintsAnalyzer", "Analyzes the number of shape -constraint violations of symbolic regression models.")]33 [Item("ShapeConstraintsAnalyzer", "Analyzes the number of shape constraint violations of symbolic regression models.")] 34 34 public class ShapeConstraintsAnalyzer : SymbolicDataAnalysisAnalyzer, ISymbolicExpressionTreeAnalyzer { 35 35 private const string ProblemDataParameterName = "ProblemData"; … … 97 97 98 98 public override IOperation Apply() { 99 var problemData = RegressionProblemData;99 var problemData = (IShapeConstrainedRegressionProblemData)RegressionProblemData; 100 100 var trees = SymbolicExpressionTree.ToArray(); 101 101 … … 115 115 } 116 116 117 var constraintUnsatisfiedSolutionsDataTable = InfeasibleSolutions;118 if ( constraintUnsatisfiedSolutionsDataTable.Rows.Count == 0)119 constraintUnsatisfiedSolutionsDataTable.Rows.Add(new DataRow(InfeasibleSolutionsParameterName));117 var infeasibleSolutionsDataTable = InfeasibleSolutions; 118 if (infeasibleSolutionsDataTable.Rows.Count == 0) 119 infeasibleSolutionsDataTable.Rows.Add(new DataRow(InfeasibleSolutionsParameterName)); 120 120 121 constraintUnsatisfiedSolutionsDataTable.Rows[InfeasibleSolutionsParameterName]121 infeasibleSolutionsDataTable.Rows[InfeasibleSolutionsParameterName] 122 122 .Values 123 123 .Add(trees.Count(t => IntervalUtil.GetConstraintViolations(constraints, estimator, variableRanges, t).Any(x => x > 0.0))); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/SymbolicRegressionSingleObjectiveProblem.cs
r17903 r17958 56 56 public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicRegressionSingleObjectiveProblem(this, cloner); } 57 57 58 public SymbolicRegressionSingleObjectiveProblem() 59 : base(new RegressionProblemData(), new SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { 58 public SymbolicRegressionSingleObjectiveProblem() : this(new RegressionProblemData(), new SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) { 59 } 60 public SymbolicRegressionSingleObjectiveProblem(IRegressionProblemData problemData, ISymbolicRegressionSingleObjectiveEvaluator evaluator, ISymbolicDataAnalysisSolutionCreator solutionCreator) : 61 base(problemData, evaluator, solutionCreator) { 62 60 63 Parameters.Add(new FixedValueParameter<DoubleLimit>(EstimationLimitsParameterName, EstimationLimitsParameterDescription)); 61 64 -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Grammars/LinearScalingGrammar.cs
r17945 r17958 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 31 31 [StorableType("5A2300A0-D0FC-4F2D-B910-F86384FE9052")] 32 [Item(" IntervalArithmeticGrammar", "Represents a grammar for interval arithmeticwhich includes linear scaling parts implicitly.")]33 public class IntervalArithmeticGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar {34 public IntervalArithmeticGrammar() : base(ItemAttribute.GetName(typeof(IntervalArithmeticGrammar)),35 ItemAttribute.GetDescription(typeof( IntervalArithmeticGrammar))) {32 [Item("LinearScalingGrammar", "Represents a grammar which includes linear scaling parts implicitly.")] 33 public class LinearScalingGrammar : DataAnalysisGrammar, ISymbolicDataAnalysisGrammar { 34 public LinearScalingGrammar() : base(ItemAttribute.GetName(typeof(LinearScalingGrammar)), 35 ItemAttribute.GetDescription(typeof(LinearScalingGrammar))) { 36 36 Initialize(); 37 37 } 38 38 39 39 [StorableConstructor] 40 public IntervalArithmeticGrammar(StorableConstructorFlag _) : base(_) { }40 public LinearScalingGrammar(StorableConstructorFlag _) : base(_) { } 41 41 42 protected IntervalArithmeticGrammar(IntervalArithmeticGrammar original, Cloner cloner) : base(original, cloner) { }43 public IntervalArithmeticGrammar(string name, string description) : base(name, description) { }42 protected LinearScalingGrammar(LinearScalingGrammar original, Cloner cloner) : base(original, cloner) { } 43 public LinearScalingGrammar(string name, string description) : base(name, description) { } 44 44 45 45 public override IDeepCloneable Clone(Cloner cloner) { 46 return new IntervalArithmeticGrammar(this, cloner);46 return new LinearScalingGrammar(this, cloner); 47 47 } 48 48 -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r17931 r17958 159 159 <Compile Include="Formatters\SymbolicDataAnalysisExpressionCSharpFormatter.cs" /> 160 160 <Compile Include="Grammars\DataAnalysisGrammar.cs" /> 161 <Compile Include="Grammars\ IntervalArithmeticGrammar.cs" />161 <Compile Include="Grammars\LinearScalingGrammar.cs" /> 162 162 <Compile Include="Hashing\HashExtensions.cs" /> 163 163 <Compile Include="Hashing\HashUtil.cs" /> -
trunk/HeuristicLab.Problems.DataAnalysis/3.4/HeuristicLab.Problems.DataAnalysis-3.4.csproj
r17931 r17958 143 143 <Compile Include="Implementation\Interval\Interval.cs" /> 144 144 <Compile Include="Implementation\Interval\IntervalCollection.cs" /> 145 <Compile Include="Implementation\Interval\IShapeConstrainedRegressionProblem.cs" /> 146 <Compile Include="Implementation\Interval\IShapeConstrainedRegressionProblemData.cs" /> 145 147 <Compile Include="Implementation\Interval\ShapeConstraint.cs" /> 148 <Compile Include="Implementation\Interval\ShapeConstrainedRegressionProblemData.cs" /> 149 <Compile Include="Implementation\Interval\ShapeConstrainedRegressionProblem.cs" /> 146 150 <Compile Include="Implementation\Interval\ShapeConstraintsParser.cs" /> 147 151 <Compile Include="Implementation\Regression\ConfidenceBoundRegressionSolution.cs" /> -
trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/RegressionProblemData.cs
r17911 r17958 35 35 protected const string TargetVariableParameterName = "TargetVariable"; 36 36 protected const string VariableRangesParameterName = "VariableRanges"; 37 protected const string ShapeConstraintsParameterName = "ShapeConstraints";38 37 public string Filename { get; set; } 39 38 … … 78 77 defaultDataset = new Dataset(new string[] { "y", "x" }, kozaF1); 79 78 defaultDataset.Name = "Fourth-order Polynomial Function Benchmark Dataset"; 80 defaultDataset.Description = "f(x) = x^4 + x^3 + x^2 + x ^1";79 defaultDataset.Description = "f(x) = x^4 + x^3 + x^2 + x"; 81 80 defaultAllowedInputVariables = new List<string>() { "x" }; 82 81 defaultTargetVariable = "y"; … … 94 93 problemData.Parameters.Add(new ConstrainedValueParameter<StringValue>(TargetVariableParameterName, new ItemSet<StringValue>())); 95 94 problemData.Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, "", new IntervalCollection())); 96 problemData.Parameters.Add(new FixedValueParameter<ShapeConstraints>(ShapeConstraintsParameterName, "", new ShapeConstraints()));97 95 emptyProblemData = problemData; 98 96 } … … 101 99 #region parameter properties 102 100 public IConstrainedValueParameter<StringValue> TargetVariableParameter => (IConstrainedValueParameter<StringValue>)Parameters[TargetVariableParameterName]; 103 public IFixedValueParameter<ShapeConstraints> ShapeConstraintsParameter => (IFixedValueParameter<ShapeConstraints>)Parameters[ShapeConstraintsParameterName];104 101 public IFixedValueParameter<IntervalCollection> VariableRangesParameter => (IFixedValueParameter<IntervalCollection>)Parameters[VariableRangesParameterName]; 105 102 #endregion … … 109 106 get => VariableRangesParameter.Value; 110 107 } 111 112 113 public ShapeConstraints ShapeConstraints => ShapeConstraintsParameter.Value;114 115 108 116 109 public string TargetVariable { … … 140 133 Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, intervalCollection)); 141 134 } 142 if (Parameters.ContainsKey("IntervalConstraints")) {143 var param = (IFixedValueParameter<ShapeConstraints>)Parameters["IntervalConstraints"];144 Parameters.Remove(param);145 Parameters.Add(new FixedValueParameter<ShapeConstraints>(ShapeConstraintsParameterName, param.Value));146 }147 if (!Parameters.ContainsKey(ShapeConstraintsParameterName)) {148 Parameters.Add(new FixedValueParameter<ShapeConstraints>(ShapeConstraintsParameterName, new ShapeConstraints()));149 }150 135 151 136 RegisterParameterEvents(); … … 174 159 public RegressionProblemData(IDataset dataset, IEnumerable<string> allowedInputVariables, string targetVariable, 175 160 IEnumerable<ITransformation> transformations = null, 176 IntervalCollection variableRanges = null, 177 ShapeConstraints shapeConstraints = null) 161 IntervalCollection variableRanges = null) 178 162 : base(dataset, allowedInputVariables, transformations ?? Enumerable.Empty<ITransformation>()) { 179 163 var variables = InputVariables.Select(x => x.AsReadOnly()).ToList(); … … 183 167 } 184 168 Parameters.Add(new FixedValueParameter<IntervalCollection>(VariableRangesParameterName, variableRanges)); 185 186 if (shapeConstraints == null) {187 shapeConstraints = new ShapeConstraints();188 }189 Parameters.Add(new FixedValueParameter<ShapeConstraints>(ShapeConstraintsParameterName, shapeConstraints));190 RegisterParameterEvents();191 169 } 192 170 private void RegisterParameterEvents() { 193 171 TargetVariableParameter.ValueChanged += new EventHandler(Parameter_ValueChanged); 194 // VariableRanges a nd ShapeConstraints are fixed parameters172 // VariableRanges are fixed parameters 195 173 } 196 174 private void Parameter_ValueChanged(object sender, EventArgs e) { -
trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ShapeConstraints.cs
r17902 r17958 77 77 public event EventHandler Changed; 78 78 79 79 80 private void RaiseChanged() { 80 81 var handlers = Changed; -
trunk/HeuristicLab.Problems.DataAnalysis/3.4/Interfaces/Regression/IRegressionProblemData.cs
r17902 r17958 29 29 public interface IRegressionProblemData : IDataAnalysisProblemData { 30 30 string TargetVariable { get; set; } 31 32 31 IntervalCollection VariableRanges { get; } 33 ShapeConstraints ShapeConstraints { get; }34 35 32 IEnumerable<double> TargetVariableValues { get; } 36 33 IEnumerable<double> TargetVariableTrainingValues { get; } -
trunk/HeuristicLab.Tests/HeuristicLab.Tests.csproj
r17948 r17958 470 470 <Compile Include="HeuristicLab-3.3\Samples\OSESGriewankSampleTest.cs" /> 471 471 <Compile Include="HeuristicLab-3.3\Samples\GAGroupingProblemSampleTest.cs" /> 472 <Compile Include="HeuristicLab-3.3\Samples\ShapeConstrainedRegressionSampleTest.cs" /> 472 473 <Compile Include="HeuristicLab-3.3\Samples\VnsOpSampleTest.cs" /> 473 474 <Compile Include="HeuristicLab-3.3\Samples\EsGriewankSampleTest.cs" />
Note: See TracChangeset
for help on using the changeset viewer.