Changeset 17964


Ignore:
Timestamp:
04/27/21 10:40:49 (3 months ago)
Author:
chaider
Message:

#3073 Added sample on start page and default problem in shape constrained regression problem data

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Optimizer/3.3/HeuristicLab.Optimizer-3.3.csproj

    r16997 r17964  
    153153    <EmbeddedResource Include="Documents\PSO_Rastrigin.hl" />
    154154    <EmbeddedResource Include="Documents\OSGP_SymReg.hl" />
     155    <EmbeddedResource Include="Documents\GA_Shape_Constrained_Regression.hl" />
    155156    <None Include="Plugin.cs.frame" />
    156157    <Compile Include="ChangeNestingLevelDialog.cs">
  • trunk/HeuristicLab.Optimizer/3.3/StartPage.cs

    r17180 r17964  
    130130        };
    131131      groupLookup[standardProblemsGroup] = standardProblems;
    132       var dataAnalysisProblems = new List<string> { "ALPSGP_SymReg", "SGP_SymbClass", "SGP_SymbReg", "OSGP_SymReg", "OSGP_TimeSeries", "GE_SymbReg", "GPR" };
     132      var dataAnalysisProblems = new List<string> { "ALPSGP_SymReg", "SGP_SymbClass", "SGP_SymbReg", "OSGP_SymReg", "OSGP_TimeSeries", "GE_SymbReg", "GPR", "GA_Shape_Constrained_Regression" };
    133133      groupLookup[dataAnalysisGroup] = dataAnalysisProblems;
    134134      var scripts = new List<string> { "GA_QAP_Script", "GUI_Automation_Script", "OSGA_Rastrigin_Script",
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ShapeConstrainedRegressionSingleObjectiveProblem.cs

    r17958 r17964  
    3838
    3939      ApplyLinearScalingParameter.Value.Value = true;
     40      Maximization.Value = false;
    4041      SymbolicExpressionTreeGrammarParameter.Value = new LinearScalingGrammar();
    4142
  • trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interpreter/IntervalArithBoundsEstimator.cs

    r17911 r17964  
    223223            break;
    224224          }
     225        case OpCodes.Power: {
     226          var a = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals);
     227          var b = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals);
     228          // support only integer powers
     229          if (b.LowerBound == b.UpperBound && Math.Truncate(b.LowerBound) == b.LowerBound) {
     230            result = Interval.Power(a, (int)b.LowerBound);
     231          } else {
     232            throw new NotSupportedException("Interval is only supported for integer powers");
     233          }
     234          break;
     235        }
    225236        case OpCodes.Absolute: {
    226237            var argumentInterval = Evaluate(instructions, ref instructionCounter, nodeIntervals, variableIntervals);
     
    329340          !(n.Symbol is Cube) &&
    330341          !(n.Symbol is CubeRoot) &&
     342          !(n.Symbol is Power) &&
    331343          !(n.Symbol is Absolute) &&
    332344          !(n.Symbol is AnalyticQuotient)
  • trunk/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ShapeConstrainedRegressionProblemData.cs

    r17961 r17964  
    3535    protected const string ShapeConstraintsParameterName = "ShapeConstraints";
    3636
    37     private static double[,] kozaF1 = new double[,] {
    38           {2.017885919, -1.449165046},
    39           {1.30060506,  -1.344523885},
    40           {1.147134798, -1.317989331},
    41           {0.877182504, -1.266142284},
    42           {0.852562452, -1.261020794},
    43           {0.431095788, -1.158793317},
    44           {0.112586002, -1.050908405},
    45           {0.04594507,  -1.021989402},
    46           {0.042572879, -1.020438113},
    47           {-0.074027291,  -0.959859562},
    48           {-0.109178553,  -0.938094706},
    49           {-0.259721109,  -0.803635355},
    50           {-0.272991057,  -0.387519561},
    51           {-0.161978191,  -0.193611001},
    52           {-0.102489983,  -0.114215349},
    53           {-0.01469968, -0.014918985},
    54           {-0.008863365,  -0.008942626},
    55           {0.026751057, 0.026054094},
    56           {0.166922436, 0.14309643},
    57           {0.176953808, 0.1504144},
    58           {0.190233418, 0.159916534},
    59           {0.199800708, 0.166635331},
    60           {0.261502822, 0.207600348},
    61           {0.30182879,  0.232370249},
    62           {0.83763905,  0.468046718}
     37    private static double[,] sigmoid = new double[,] {
     38      {1.00, 0.09, 0.01390952},
     39      {1.10, 0.11, 0.048256016},
     40      {1.20, 0.14, 0.010182641},
     41      {1.30, 0.17, 0.270361269},
     42      {1.40, 0.20, 0.091503971},
     43      {1.50, 0.24, 0.338157191},
     44      {1.60, 0.28, 0.328508579},
     45      {1.70, 0.34, 0.21867684},
     46      {1.80, 0.40, 0.34515433},
     47      {1.90, 0.46, 0.562746903},
     48      {2.00, 0.54, 0.554800831},
     49      {2.10, 0.62, 0.623018787},
     50      {2.20, 0.71, 0.626224329},
     51      {2.30, 0.80, 0.909006688},
     52      {2.40, 0.90, 0.92514929},
     53      {2.50, 1.00, 1.097199936},
     54      {2.60, 1.10, 1.138309608},
     55      {2.70, 1.20, 1.087880692},
     56      {2.80, 1.29, 1.370491683},
     57      {2.90, 1.38, 1.422048792},
     58      {3.00, 1.46, 1.505242141},
     59      {3.10, 1.54, 1.684790135},
     60      {3.20, 1.60, 1.480232277},
     61      {3.30, 1.66, 1.577412501},
     62      {3.40, 1.72, 1.664822534},
     63      {3.50, 1.76, 1.773580664},
     64      {3.60, 1.80, 1.941034478},
     65      {3.70, 1.83, 1.730361986},
     66      {3.80, 1.86, 1.9785952},
     67      {3.90, 1.89, 1.946698641},
     68      {4.00, 1.91, 1.766502803},
     69      {4.10, 1.92, 1.847756843},
     70      {4.20, 1.94, 1.894506213},
     71      {4.30, 1.95, 2.029194724},
     72      {4.40, 1.96, 2.01830679},
     73      {4.50, 1.96, 1.924316332},
     74      {4.60, 1.97, 1.971354792},
     75      {4.70, 1.98, 1.85665728},
     76      {4.80, 1.98, 1.831400496},
     77      {4.90, 1.98, 2.057843156},
     78      {5.00, 1.99, 2.128769896},
    6379    };
    6480
     
    6682    private static readonly IEnumerable<string> defaultAllowedInputVariables;
    6783    private static readonly string defaultTargetVariable;
     84    private static readonly ShapeConstraints defaultShapeConstraints;
     85    private static readonly IntervalCollection defaultVariableRanges;
    6886
    6987    private static readonly ShapeConstrainedRegressionProblemData emptyProblemData;
    70     public new static ShapeConstrainedRegressionProblemData EmptyProblemData {
    71       get { return emptyProblemData; }
    72     }
     88    public new static ShapeConstrainedRegressionProblemData EmptyProblemData => emptyProblemData;
    7389
    7490    static ShapeConstrainedRegressionProblemData() {
    75       defaultDataset = new Dataset(new string[] { "y", "x" }, kozaF1);
    76       defaultDataset.Name = "Fourth-order Polynomial Function Benchmark Dataset";
    77       defaultDataset.Description = "f(x) = x^4 + x^3 + x^2 + x^1";
     91      defaultDataset = new Dataset(new string[] { "x", "y", "y_noise" }, sigmoid) {
     92        Name = "Sigmoid function to show shape-constrained symbolic regression.",
     93        Description = "f(x) = 1 + tanh(x - 2.5)"
     94      };
    7895      defaultAllowedInputVariables = new List<string>() { "x" };
    79       defaultTargetVariable = "y";
     96      defaultTargetVariable = "y_noise";
     97      defaultShapeConstraints = new ShapeConstraints {
     98        new ShapeConstraint(new Interval(0, 2), 1.0),
     99        new ShapeConstraint("x", 1, new Interval(0, double.PositiveInfinity), 1.0)
     100      };
     101      defaultVariableRanges = defaultDataset.GetIntervals();
     102      defaultVariableRanges.SetInterval("x", new Interval(0, 6));
     103
    80104      var problemData = new ShapeConstrainedRegressionProblemData();
    81       problemData.Parameters.Clear(); // parameters are cleared and added below because we cannot set / change parameters of ProblemData
     105      problemData.Parameters.Clear();
    82106      problemData.Name = "Empty Regression ProblemData";
    83107      problemData.Description = "This ProblemData acts as place holder before the correct problem data is loaded.";
     
    94118    }
    95119
    96     public IFixedValueParameter<ShapeConstraints> ShapeConstraintsParameter => (IFixedValueParameter<ShapeConstraints>)Parameters[ShapeConstraintsParameterName];
    97     public ShapeConstraints ShapeConstraints => ShapeConstraintsParameter.Value;
     120    public IFixedValueParameter<ShapeConstraints> ShapeConstraintParameter => (IFixedValueParameter<ShapeConstraints>)Parameters[ShapeConstraintsParameterName];
     121    public ShapeConstraints ShapeConstraints => ShapeConstraintParameter.Value;
    98122
    99123    [StorableConstructor]
     
    109133    }
    110134    public override IDeepCloneable Clone(Cloner cloner) {
    111       if (this == emptyProblemData) return emptyProblemData;
    112       return new ShapeConstrainedRegressionProblemData(this, cloner);
     135      return this == emptyProblemData ? emptyProblemData : new ShapeConstrainedRegressionProblemData(this, cloner);
    113136    }
    114137
    115138    public ShapeConstrainedRegressionProblemData() : this(defaultDataset, defaultAllowedInputVariables, defaultTargetVariable,
    116139                                                          trainingPartition: new IntRange(0, defaultDataset.Rows),
    117                                                           testPartition: new IntRange(0, 0)) { } // no test partition for the demo problem
     140                                                          testPartition: new IntRange(0, 0), sc: defaultShapeConstraints, variableRanges: defaultVariableRanges) { } // no test partition for the demo problem
    118141
    119142    public ShapeConstrainedRegressionProblemData(IRegressionProblemData regressionProblemData)
Note: See TracChangeset for help on using the changeset viewer.