Ignore:
Timestamp:
10/22/15 19:00:13 (7 years ago)
Author:
gkronber
Message:

#1736: merged r13001 from trunk to stable

Location:
stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis

  • stable/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Regression/ConstantRegressionModel.cs

    r12702 r13048  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
     27using HeuristicLab.Data;
    2628using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2729
     
    2931  [StorableClass]
    3032  [Item("Constant Regression Model", "A model that always returns the same constant value regardless of the presented input data.")]
    31   public class ConstantRegressionModel : NamedItem, IRegressionModel {
     33  public class ConstantRegressionModel : NamedItem, IRegressionModel, IStringConvertibleValue {
    3234    [Storable]
    33     protected double constant;
     35    private double constant;
    3436    public double Constant {
    3537      get { return constant; }
     38      // setter not implemented because manipulation of the constant is not allowed
    3639    }
    3740
     
    4952      this.description = ItemDescription;
    5053      this.constant = constant;
     54      this.ReadOnly = true; // changing a constant regression model is not supported
    5155    }
    5256
     
    5862      return new ConstantRegressionSolution(this, new RegressionProblemData(problemData));
    5963    }
     64
     65    public override string ToString() {
     66      return string.Format("Constant: {0}", GetValue());
     67    }
     68
     69    #region IStringConvertibleValue
     70    public bool ReadOnly { get; private set; }
     71    public bool Validate(string value, out string errorMessage) {
     72      throw new NotSupportedException(); // changing a constant regression model is not supported
     73    }
     74
     75    public string GetValue() {
     76      return string.Format("{0:E4}", constant);
     77    }
     78
     79    public bool SetValue(string value) {
     80      throw new NotSupportedException(); // changing a constant regression model is not supported
     81    }
     82
     83    public event EventHandler ValueChanged;
     84    #endregion
    6085  }
    6186}
Note: See TracChangeset for help on using the changeset viewer.