Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/17/15 11:47:52 (9 years ago)
Author:
gkronber
Message:

#2385: added CreateSolution flag to Gaussian process algorithms

Location:
trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassification.cs

    r12504 r13205  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2728using HeuristicLab.Optimization;
    2829using HeuristicLab.Parameters;
     
    4849
    4950    private const string ModelParameterName = "Model";
     51    private const string CreateSolutionParameterName = "CreateSolution";
    5052
    5153    #region parameter properties
     
    5557    public IFixedValueParameter<GaussianProcessClassificationSolutionCreator> GaussianProcessSolutionCreatorParameter {
    5658      get { return (IFixedValueParameter<GaussianProcessClassificationSolutionCreator>)Parameters[SolutionCreatorParameterName]; }
     59    }
     60    public IFixedValueParameter<BoolValue> CreateSolutionParameter {
     61      get { return (IFixedValueParameter<BoolValue>)Parameters[CreateSolutionParameterName]; }
     62    }
     63    #endregion
     64    #region properties
     65    public bool CreateSolution {
     66      get { return CreateSolutionParameter.Value.Value; }
     67      set { CreateSolutionParameter.Value.Value = value; }
    5768    }
    5869    #endregion
     
    8293        new GaussianProcessClassificationSolutionCreator()));
    8394      Parameters[SolutionCreatorParameterName].Hidden = true;
     95      // TODO: it would be better to deactivate the solution creator when this parameter is changed
     96      Parameters.Add(new FixedValueParameter<BoolValue>(CreateSolutionParameterName, "Flag that indicates if a solution should be produced at the end of the run", new BoolValue(true)));
     97      Parameters[CreateSolutionParameterName].Hidden = true;
    8498
    8599      ParameterizedModelCreators();
     
    91105    [StorableHook(HookType.AfterDeserialization)]
    92106    private void AfterDeserialization() {
     107      // BackwardsCompatibility3.3
     108      #region Backwards compatible code, remove with 3.4
     109      if (!Parameters.ContainsKey(CreateSolutionParameterName)) {
     110        Parameters.Add(new FixedValueParameter<BoolValue>(CreateSolutionParameterName, "Flag that indicates if a solution should be produced at the end of the run", new BoolValue(true)));
     111        Parameters[CreateSolutionParameterName].Hidden = true;
     112      }
     113      #endregion
    93114      RegisterEventHandlers();
    94115    }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessClassificationSolutionCreator.cs

    r12012 r13205  
    4040    private const string TrainingAccuracyResultName = "Accuracy (training)";
    4141    private const string TestAccuracyResultName = "Accuracy (test)";
     42    private const string CreateSolutionParameterName = "CreateSolution";
    4243
    4344    #region Parameter Properties
     
    5455      get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
    5556    }
     57    public ILookupParameter<BoolValue> CreateSolutionParameter {
     58      get { return (ILookupParameter<BoolValue>)Parameters[CreateSolutionParameterName]; }
     59    }
    5660    #endregion
    5761
     
    6468      Parameters.Add(new LookupParameter<IClassificationProblemData>(ProblemDataParameterName, "The classification problem data for the Gaussian process solution."));
    6569      Parameters.Add(new LookupParameter<IGaussianProcessModel>(ModelParameterName, "The Gaussian process classification model to use for the solution."));
     70      Parameters.Add(new LookupParameter<BoolValue>(CreateSolutionParameterName, "Flag that indicates if a solution should be produced at the end of the run"));
     71
    6672      // in & out
    6773      Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection of the algorithm."));
    6874      // out
    6975      Parameters.Add(new LookupParameter<IDiscriminantFunctionClassificationSolution>(SolutionParameterName, "The produced Gaussian process solution."));
     76    }
     77
     78    [StorableHook(HookType.AfterDeserialization)]
     79    private void AfterDeserialization() {
     80      // BackwardsCompatibility3.3
     81      #region Backwards compatible code, remove with 3.4
     82      if (!Parameters.ContainsKey(CreateSolutionParameterName)) {
     83        Parameters.Add(new LookupParameter<BoolValue>(CreateSolutionParameterName, "Flag that indicates if a solution should be produced at the end of the run"));
     84      }
     85      #endregion
    7086    }
    7187
     
    7591
    7692    public override IOperation Apply() {
    77       if (ModelParameter.ActualValue != null) {
     93      if (ModelParameter.ActualValue != null && CreateSolutionParameter.ActualValue.Value == true) {
    7894        var m = (IGaussianProcessModel)ModelParameter.ActualValue.Clone();
    7995        m.FixParameters();
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegression.cs

    r12504 r13205  
    2525using HeuristicLab.Common;
    2626using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2728using HeuristicLab.Optimization;
    2829using HeuristicLab.Parameters;
     
    4849
    4950    private const string ModelParameterName = "Model";
     51    private const string CreateSolutionParameterName = "CreateSolution";
     52
    5053
    5154    #region parameter properties
     
    5558    public IFixedValueParameter<GaussianProcessRegressionSolutionCreator> GaussianProcessSolutionCreatorParameter {
    5659      get { return (IFixedValueParameter<GaussianProcessRegressionSolutionCreator>)Parameters[SolutionCreatorParameterName]; }
     60    }
     61    public IFixedValueParameter<BoolValue> CreateSolutionParameter {
     62      get { return (IFixedValueParameter<BoolValue>)Parameters[CreateSolutionParameterName]; }
     63    }
     64    #endregion
     65    #region properties
     66    public bool CreateSolution {
     67      get { return CreateSolutionParameter.Value.Value; }
     68      set { CreateSolutionParameter.Value.Value = value; }
    5769    }
    5870    #endregion
     
    7890      Parameters.Add(new ConstrainedValueParameter<IGaussianProcessRegressionModelCreator>(ModelCreatorParameterName, "The operator to create the Gaussian process model.",
    7991        new ItemSet<IGaussianProcessRegressionModelCreator>(modelCreators), defaultModelCreator));
    80       // this parameter is not intended to be changed,
     92      // the solution creator cannot be changed
    8193      Parameters.Add(new FixedValueParameter<GaussianProcessRegressionSolutionCreator>(SolutionCreatorParameterName, "The solution creator for the algorithm",
    8294        new GaussianProcessRegressionSolutionCreator()));
    8395      Parameters[SolutionCreatorParameterName].Hidden = true;
     96      // TODO: it would be better to deactivate the solution creator when this parameter is changed
     97      Parameters.Add(new FixedValueParameter<BoolValue>(CreateSolutionParameterName, "Flag that indicates if a solution should be produced at the end of the run", new BoolValue(true)));
     98      Parameters[CreateSolutionParameterName].Hidden = true;
    8499
    85100      ParameterizedModelCreators();
     
    91106    [StorableHook(HookType.AfterDeserialization)]
    92107    private void AfterDeserialization() {
     108      // BackwardsCompatibility3.3
     109      #region Backwards compatible code, remove with 3.4
     110      if (!Parameters.ContainsKey(CreateSolutionParameterName)) {
     111        Parameters.Add(new FixedValueParameter<BoolValue>(CreateSolutionParameterName, "Flag that indicates if a solution should be produced at the end of the run", new BoolValue(true)));
     112        Parameters[CreateSolutionParameterName].Hidden = true;
     113      }
     114      #endregion
    93115      RegisterEventHandlers();
    94116    }
  • trunk/sources/HeuristicLab.Algorithms.DataAnalysis/3.4/GaussianProcess/GaussianProcessRegressionSolutionCreator.cs

    r12012 r13205  
    4040    private const string TrainingRSquaredResultName = "Training R²";
    4141    private const string TestRSquaredResultName = "Test R²";
     42    private const string CreateSolutionParameterName = "CreateSolution";
    4243
    4344    #region Parameter Properties
     
    5455      get { return (ILookupParameter<ResultCollection>)Parameters[ResultsParameterName]; }
    5556    }
     57    public ILookupParameter<BoolValue> CreateSolutionParameter {
     58      get { return (ILookupParameter<BoolValue>)Parameters[CreateSolutionParameterName]; }
     59    }
    5660    #endregion
    5761
     
    6468      Parameters.Add(new LookupParameter<IRegressionProblemData>(ProblemDataParameterName, "The regression problem data for the Gaussian process solution."));
    6569      Parameters.Add(new LookupParameter<IGaussianProcessModel>(ModelParameterName, "The Gaussian process regression model to use for the solution."));
     70      Parameters.Add(new LookupParameter<BoolValue>(CreateSolutionParameterName, "Flag that indicates if a solution should be produced at the end of the run"));
     71
    6672      // in & out
    6773      Parameters.Add(new LookupParameter<ResultCollection>(ResultsParameterName, "The result collection of the algorithm."));
    6874      // out
    6975      Parameters.Add(new LookupParameter<IGaussianProcessSolution>(SolutionParameterName, "The produced Gaussian process solution."));
     76    }
     77
     78    [StorableHook(HookType.AfterDeserialization)]
     79    private void AfterDeserialization() {
     80      // BackwardsCompatibility3.3
     81      #region Backwards compatible code, remove with 3.4
     82      if (!Parameters.ContainsKey(CreateSolutionParameterName)) {
     83        Parameters.Add(new LookupParameter<BoolValue>(CreateSolutionParameterName, "Flag that indicates if a solution should be produced at the end of the run"));
     84      }
     85      #endregion
    7086    }
    7187
     
    7591
    7692    public override IOperation Apply() {
    77       if (ModelParameter.ActualValue != null) {
     93      if (ModelParameter.ActualValue != null && CreateSolutionParameter.ActualValue.Value == true) {
    7894        var m = (IGaussianProcessModel)ModelParameter.ActualValue.Clone();
    7995        m.FixParameters();
Note: See TracChangeset for help on using the changeset viewer.