Changeset 13209


Ignore:
Timestamp:
11/17/15 13:17:49 (4 years ago)
Author:
mkommend
Message:

#1967: Implemented IStatefulItem in GaussianProcessCovarianceOptimizationProblem to clear the temporary parameters correctly.

File:
1 edited

Legend:

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

    r13201 r13209  
    3737  [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 300)]
    3838  [StorableClass]
    39   public sealed class GaussianProcessCovarianceOptimizationProblem : SymbolicExpressionTreeProblem, IRegressionProblem, IProblemInstanceConsumer<IRegressionProblemData>, IProblemInstanceExporter<IRegressionProblemData> {
     39  public sealed class GaussianProcessCovarianceOptimizationProblem : SymbolicExpressionTreeProblem, IStatefulItem, IRegressionProblem, IProblemInstanceConsumer<IRegressionProblemData>, IProblemInstanceExporter<IRegressionProblemData> {
    4040    #region static variables and ctor
    4141    private static readonly CovarianceMaternIso maternIso1;
     
    140140
    141141    // problem stores a few variables for information exchange from Evaluate() to Analyze()
    142     private object problemStateLocker = new object();
     142    private readonly object problemStateLocker = new object();
    143143    [Storable]
    144144    private double bestQ;
     
    184184    }
    185185
    186     protected override void OnReset() {
    187       base.OnReset();
     186    public void InitializeState() { ClearState(); }
     187    public void ClearState() {
    188188      meanFunc = null;
    189189      covFunc = null;
     
    193193
    194194    public override double Evaluate(ISymbolicExpressionTree tree, IRandom random) {
    195 
    196195      var meanFunction = new MeanConst();
    197196      var problemData = ProblemData;
     
    322321        var gradients = model.HyperparameterGradients;
    323322        Array.Copy(gradients, grad, gradients.Length);
    324       } catch (ArgumentException) {
     323      }
     324      catch (ArgumentException) {
    325325        // building the GaussianProcessModel might fail, in this case we return the worst possible objective value
    326326        func = 1.0E+300;
Note: See TracChangeset for help on using the changeset viewer.