Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3545 for trunk/sources


Ignore:
Timestamp:
04/27/10 16:25:51 (15 years ago)
Author:
gkronber
Message:

Fixed bugs in wiring of data analysis and symbolic regression problems. #938 (Data types and operators for regression problems)

Location:
trunk/sources
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblem.cs

    r3539 r3545  
    4444  [Creatable("Problems")]
    4545  [StorableClass]
    46   public sealed class SymbolicRegressionProblem : DataAnalysisProblem, ISingleObjectiveProblem {
     46  public class SymbolicRegressionProblem : DataAnalysisProblem, ISingleObjectiveProblem {
    4747
    4848    #region Parameter Properties
     
    169169    public DoubleValue PunishmentFactor {
    170170      get { return new DoubleValue(10.0); }
     171    }
     172    public IntValue TrainingSamplesStart {
     173      get { return new IntValue(DataAnalysisProblemData.TrainingSamplesStart.Value); }
     174    }
     175    public IntValue TrainingSamplesEnd {
     176      get {
     177        return new IntValue((DataAnalysisProblemData.TrainingSamplesStart.Value +
     178          DataAnalysisProblemData.TrainingSamplesEnd.Value) / 2);
     179      }
     180    }
     181    public IntValue ValidationSamplesStart {
     182      get { return TrainingSamplesEnd; }
     183    }
     184    public IntValue ValidationSamplesEnd {
     185      get { return new IntValue(DataAnalysisProblemData.TrainingSamplesEnd.Value); }
    171186    }
    172187    #endregion
     
    180195      var visualizer = new BestValidationSymbolicRegressionSolutionVisualizer();
    181196      var interpreter = new SimpleArithmeticExpressionInterpreter();
    182       Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the error of the regression model should be minimized.", new BoolValue(false)));
     197      Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the error of the regression model should be minimized.", (BoolValue)new BoolValue(false).AsReadOnly()));
    183198      Parameters.Add(new ValueParameter<SymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new symbolic regression solutions.", creator));
    184199      Parameters.Add(new ValueParameter<ISymbolicExpressionTreeInterpreter>("SymbolicExpressionTreeInterpreter", "The interpreter that should be used to evaluate the symbolic expression tree.", interpreter));
     
    190205      Parameters.Add(new ValueParameter<IntValue>("MaxExpressionLength", "Maximal length of the symbolic expression.", new IntValue(100)));
    191206      Parameters.Add(new ValueParameter<IntValue>("MaxExpressionDepth", "Maximal depth of the symbolic expression.", new IntValue(10)));
    192       Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefiningBranches", "Maximal number of automatically defined functions.", new IntValue(3)));
    193       Parameters.Add(new ValueParameter<IntValue>("MaxFunctionArguments", "Maximal number of arguments of automatically defined functions.", new IntValue(3)));
     207      Parameters.Add(new ValueParameter<IntValue>("MaxFunctionDefiningBranches", "Maximal number of automatically defined functions.", (IntValue)new IntValue(0).AsReadOnly()));
     208      Parameters.Add(new ValueParameter<IntValue>("MaxFunctionArguments", "Maximal number of arguments of automatically defined functions.", (IntValue)new IntValue(0).AsReadOnly()));
    194209      Parameters.Add(new ValueParameter<ISingleObjectiveSolutionsVisualizer>("Visualizer", "The operator which should be used to visualize symbolic regression solutions.", visualizer));
    195210
    196211      creator.SymbolicExpressionTreeParameter.ActualName = "SymbolicRegressionModel";
    197       creator.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
    198       creator.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefiningBranchesParameter.Name;
    199       DataAnalysisProblemDataParameter.ValueChanged += new EventHandler(DataAnalysisProblemDataParameter_ValueChanged);
    200       DataAnalysisProblemData.ProblemDataChanged += new EventHandler(DataAnalysisProblemData_Changed);
    201       MaxFunctionArgumentsParameter.ValueChanged += new EventHandler(ArchitectureParameter_Changed);
    202       MaxFunctionArgumentsParameter.Value.ValueChanged += new EventHandler(ArchitectureParameter_Changed);
    203       MaxFunctionDefiningBranchesParameter.ValueChanged += new EventHandler(ArchitectureParameter_Changed);
    204       MaxFunctionDefiningBranchesParameter.Value.ValueChanged += new EventHandler(ArchitectureParameter_Changed);
     212      evaluator.QualityParameter.ActualName = "TrainingMeanSquaredError";
     213
    205214      ParameterizeSolutionCreator();
    206215      ParameterizeEvaluator();
    207216      ParameterizeVisualizer();
    208217
     218      UpdateGrammar();
     219      UpdateEstimationLimits();
    209220      Initialize();
    210221    }
    211 
    212222
    213223    [StorableConstructor]
    214224    private SymbolicRegressionProblem(bool deserializing) : base() { }
     225
     226    [StorableHook(HookType.AfterDeserialization)]
     227    private void AfterDeserializationHook() {
     228      Initialize();
     229    }
    215230
    216231    public override IDeepCloneable Clone(Cloner cloner) {
     
    220235    }
    221236
    222     #region Events
    223     void DataAnalysisProblemDataParameter_ValueChanged(object sender, EventArgs e) {
    224       DataAnalysisProblemData.ProblemDataChanged += new EventHandler(DataAnalysisProblemData_Changed);
    225     }
    226 
    227     void DataAnalysisProblemData_Changed(object sender, EventArgs e) {
     237    private void RegisterParameterValueEvents() {
     238      MaxFunctionArgumentsParameter.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
     239      MaxFunctionDefiningBranchesParameter.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
     240      SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
     241      EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
     242      VisualizerParameter.ValueChanged += new EventHandler(VisualizerParameter_ValueChanged);
     243    }
     244
     245    private void RegisterParameterEvents() {
     246      MaxFunctionArgumentsParameter.Value.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
     247      MaxFunctionDefiningBranchesParameter.Value.ValueChanged += new EventHandler(ArchitectureParameter_ValueChanged);
     248      SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
     249      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
     250    }
     251
     252    #region event handling
     253    protected override void OnDataAnalysisProblemChanged(EventArgs e) {
     254      base.OnDataAnalysisProblemChanged(e);
     255      // paritions could be changed
     256      ParameterizeEvaluator();
     257      ParameterizeVisualizer();
     258      // input variables could have been changed
    228259      UpdateGrammar();
    229       UpdatePartitioningParameters();
    230     }
    231 
    232     void ArchitectureParameter_Changed(object sender, EventArgs e) {
     260      // estimation limits have to be recalculated
     261      UpdateEstimationLimits();
     262    }
     263    protected virtual void OnArchitectureParameterChanged(EventArgs e) {
    233264      var globalGrammar = FunctionTreeGrammar as GlobalSymbolicExpressionGrammar;
    234       globalGrammar.MaxFunctionArguments = MaxFunctionArguments.Value;
    235       globalGrammar.MaxFunctionDefinitions = MaxFunctionDefiningBranches.Value;
     265      if (globalGrammar != null) {
     266        globalGrammar.MaxFunctionArguments = MaxFunctionArguments.Value;
     267        globalGrammar.MaxFunctionDefinitions = MaxFunctionDefiningBranches.Value;
     268      }
     269    }
     270    protected virtual void OnGrammarChanged(EventArgs e) { }
     271    protected virtual void OnOperatorsChanged(EventArgs e) { RaiseOperatorsChanged(e); }
     272    protected virtual void OnSolutionCreatorChanged(EventArgs e) {
     273      SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
     274      ParameterizeSolutionCreator();
     275      OnSolutionParameterNameChanged(e);
     276      RaiseSolutionCreatorChanged(e);
     277    }
     278
     279    protected virtual void OnSolutionParameterNameChanged(EventArgs e) {
     280      ParameterizeEvaluator();
     281      ParameterizeVisualizer();
     282      ParameterizeOperators();
     283    }
     284
     285    protected virtual void OnEvaluatorChanged(EventArgs e) {
     286      Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
     287      ParameterizeEvaluator();
     288      ParameterizeVisualizer();
     289      RaiseEvaluatorChanged(e);
     290    }
     291    protected virtual void OnQualityParameterNameChanged(EventArgs e) {
     292      ParameterizeVisualizer();
     293    }
     294    protected virtual void OnVisualizerChanged(EventArgs e) {
     295      ParameterizeVisualizer();
     296      RaiseVisualizerChanged(e);
     297    }
     298    #endregion
     299
     300    #region event handlers
     301    private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
     302      OnSolutionCreatorChanged(e);
     303    }
     304    private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
     305      OnSolutionParameterNameChanged(e);
     306    }
     307    private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
     308      OnEvaluatorChanged(e);
     309    }
     310    private void VisualizerParameter_ValueChanged(object sender, EventArgs e) {
     311      OnVisualizerChanged(e);
     312    }
     313    private void ArchitectureParameter_ValueChanged(object sender, EventArgs e) {
     314      OnArchitectureParameterChanged(e);
     315    }
     316    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
     317      OnQualityParameterNameChanged(e);
     318    }
     319    #endregion
     320
     321    #region events
     322    public event EventHandler SolutionCreatorChanged;
     323    private void RaiseSolutionCreatorChanged(EventArgs e) {
     324      var changed = SolutionCreatorChanged;
     325      if (changed != null)
     326        changed(this, e);
     327    }
     328    public event EventHandler EvaluatorChanged;
     329    private void RaiseEvaluatorChanged(EventArgs e) {
     330      var changed = EvaluatorChanged;
     331      if (changed != null)
     332        changed(this, e);
     333    }
     334    public event EventHandler VisualizerChanged;
     335    private void RaiseVisualizerChanged(EventArgs e) {
     336      var changed = VisualizerChanged;
     337      if (changed != null)
     338        changed(this, e);
     339    }
     340
     341    public event EventHandler OperatorsChanged;
     342    private void RaiseOperatorsChanged(EventArgs e) {
     343      var changed = OperatorsChanged;
     344      if (changed != null)
     345        changed(this, e);
     346    }
     347    #endregion
     348
     349    #region Helpers
     350    private void Initialize() {
     351      InitializeOperators();
     352      RegisterParameterEvents();
     353      RegisterParameterValueEvents();
    236354    }
    237355
     
    242360    }
    243361
    244     private void UpdatePartitioningParameters() {
    245       int trainingStart = DataAnalysisProblemData.TrainingSamplesStart.Value;
    246       int validationEnd = DataAnalysisProblemData.TrainingSamplesEnd.Value;
    247       int trainingEnd = trainingStart + (validationEnd - trainingStart) / 2;
    248       int validationStart = trainingEnd;
    249       var solutionVisualizer = Visualizer as BestValidationSymbolicRegressionSolutionVisualizer;
    250       if (solutionVisualizer != null) {
    251         solutionVisualizer.ValidationSamplesStartParameter.Value = new IntValue(validationStart);
    252         solutionVisualizer.ValidationSamplesEndParameter.Value = new IntValue(validationEnd);
    253       }
    254       Evaluator.SamplesStartParameter.Value = new IntValue(trainingStart);
    255       Evaluator.SamplesEndParameter.Value = new IntValue(trainingEnd);
    256 
    257       if (trainingEnd - trainingStart > 0 && DataAnalysisProblemData.TargetVariable.Value != string.Empty) {
    258         var targetValues = DataAnalysisProblemData.Dataset.GetVariableValues(DataAnalysisProblemData.TargetVariable.Value, trainingStart, trainingEnd);
     362    private void UpdateEstimationLimits() {
     363      if (TrainingSamplesStart.Value < TrainingSamplesEnd.Value &&
     364        DataAnalysisProblemData.Dataset.VariableNames.Contains(DataAnalysisProblemData.TargetVariable.Value)) {
     365        var targetValues = DataAnalysisProblemData.Dataset.GetVariableValues(DataAnalysisProblemData.TargetVariable.Value, TrainingSamplesStart.Value, TrainingSamplesEnd.Value);
    259366        var mean = targetValues.Average();
    260367        var range = targetValues.Max() - targetValues.Min();
     
    264371    }
    265372
    266     public event EventHandler SolutionCreatorChanged;
    267     private void OnSolutionCreatorChanged() {
    268       var changed = SolutionCreatorChanged;
    269       if (changed != null)
    270         changed(this, EventArgs.Empty);
    271     }
    272     public event EventHandler EvaluatorChanged;
    273     private void OnEvaluatorChanged() {
    274       var changed = EvaluatorChanged;
    275       if (changed != null)
    276         changed(this, EventArgs.Empty);
    277     }
    278     public event EventHandler VisualizerChanged;
    279     private void OnVisualizerChanged() {
    280       var changed = VisualizerChanged;
    281       if (changed != null)
    282         changed(this, EventArgs.Empty);
    283     }
    284 
    285     public event EventHandler OperatorsChanged;
    286     private void OnOperatorsChanged() {
    287       var changed = OperatorsChanged;
    288       if (changed != null)
    289         changed(this, EventArgs.Empty);
    290     }
    291 
    292     private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
    293       SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
    294       ParameterizeSolutionCreator();
    295       ParameterizeEvaluator();
    296       ParameterizeVisualizer();
    297       ParameterizeOperators();
    298       OnSolutionCreatorChanged();
    299     }
    300     private void SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged(object sender, EventArgs e) {
    301       ParameterizeEvaluator();
    302       ParameterizeVisualizer();
    303       ParameterizeOperators();
    304     }
    305     private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
    306       Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    307       ParameterizeEvaluator();
    308       ParameterizeVisualizer();
    309       OnEvaluatorChanged();
    310     }
    311 
    312     private void VisualizerParameter_ValueChanged(object sender, EventArgs e) {
    313       ParameterizeVisualizer();
    314       OnVisualizerChanged();
    315     }
    316 
    317     private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
    318       ParameterizeVisualizer();
    319     }
    320 
    321     #endregion
    322 
    323     #region Helpers
    324     [StorableHook(HookType.AfterDeserialization)]
    325     private void Initialize() {
    326       InitializeOperators();
    327       SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
    328       SolutionCreator.SymbolicExpressionTreeParameter.ActualNameChanged += new EventHandler(SolutionCreator_SymbolicExpressionTreeParameter_ActualNameChanged);
    329       EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
    330       Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
    331       VisualizerParameter.ValueChanged += new EventHandler(VisualizerParameter_ValueChanged);
    332     }
    333 
    334373    private void InitializeOperators() {
    335374      operators = new List<ISymbolicExpressionTreeOperator>();
    336375      operators.AddRange(ApplicationManager.Manager.GetInstances<ISymbolicExpressionTreeOperator>());
    337376      ParameterizeOperators();
    338       UpdateGrammar();
    339       UpdatePartitioningParameters();
    340377    }
    341378
     
    344381      SolutionCreator.MaxTreeHeightParameter.ActualName = MaxExpressionDepthParameter.Name;
    345382      SolutionCreator.MaxTreeSizeParameter.ActualName = MaxExpressionLengthParameter.Name;
    346     }
     383      SolutionCreator.MaxFunctionArgumentsParameter.ActualName = MaxFunctionArgumentsParameter.Name;
     384      SolutionCreator.MaxFunctionDefinitionsParameter.ActualName = MaxFunctionDefiningBranchesParameter.Name;
     385    }
     386
    347387    private void ParameterizeEvaluator() {
    348388      Evaluator.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    349389      Evaluator.RegressionProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
    350       Evaluator.QualityParameter.ActualName = "TrainingMeanSquaredError";
    351       Evaluator.SamplesStartParameter.Value = new IntValue(DataAnalysisProblemData.TrainingSamplesStart.Value);
    352       Evaluator.SamplesEndParameter.Value = new IntValue((DataAnalysisProblemData.TrainingSamplesStart.Value + DataAnalysisProblemData.TrainingSamplesEnd.Value) / 2);
    353     }
     390      Evaluator.SamplesStartParameter.Value = TrainingSamplesStart;
     391      Evaluator.SamplesEndParameter.Value = TrainingSamplesEnd;
     392    }
     393
    354394    private void ParameterizeVisualizer() {
    355       if (Visualizer != null) {
    356         var solutionVisualizer = Visualizer as BestValidationSymbolicRegressionSolutionVisualizer;
    357         if (solutionVisualizer != null) {
    358           solutionVisualizer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    359           solutionVisualizer.DataAnalysisProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
    360           solutionVisualizer.ValidationSamplesStartParameter.Value = new IntValue((DataAnalysisProblemData.TrainingSamplesStart.Value + DataAnalysisProblemData.TrainingSamplesEnd.Value) / 2);
    361           solutionVisualizer.ValidationSamplesEndParameter.Value = new IntValue(DataAnalysisProblemData.TrainingSamplesEnd.Value);
    362         }
     395      var solutionVisualizer = Visualizer as BestValidationSymbolicRegressionSolutionVisualizer;
     396      if (solutionVisualizer != null) {
     397        solutionVisualizer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
     398        solutionVisualizer.DataAnalysisProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
     399        solutionVisualizer.UpperEstimationLimitParameter.ActualName = UpperEstimationLimitParameter.Name;
     400        solutionVisualizer.LowerEstimationLimitParameter.ActualName = LowerEstimationLimitParameter.Name;
     401        solutionVisualizer.QualityParameter.ActualName = Evaluator.QualityParameter.Name;
     402        solutionVisualizer.SymbolicExpressionTreeInterpreterParameter.ActualName = SymbolicExpressionTreeInterpreterParameter.Name;
     403        solutionVisualizer.ValidationSamplesStartParameter.Value = ValidationSamplesStart;
     404        solutionVisualizer.ValidationSamplesEndParameter.Value = ValidationSamplesEnd;
    363405      }
    364406    }
     
    370412        op.SymbolicExpressionGrammarParameter.ActualName = FunctionTreeGrammarParameter.Name;
    371413      }
    372       foreach (ISymbolicRegressionEvaluator op in Operators.OfType<ISymbolicRegressionEvaluator>()) {
    373         op.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
    374         op.RegressionProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
    375       }
    376414      foreach (ISymbolicExpressionTreeCrossover op in Operators.OfType<ISymbolicExpressionTreeCrossover>()) {
    377415        op.ParentsParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/DataAnalysisProblemDataView.Designer.cs

    r3496 r3545  
    2424    /// </summary>
    2525    private void InitializeComponent() {
    26       this.variableCollectionView = new HeuristicLab.Core.Views.VariableCollectionView();
    2726      this.importButton = new System.Windows.Forms.Button();
    2827      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    2928      this.SuspendLayout();
     29      //
     30      // parameterCollectionView
     31      //
     32      this.parameterCollectionView.Size = new System.Drawing.Size(585, 366);
    3033      //
    3134      // nameTextBox
     
    3841      //
    3942      this.descriptionTextBox.Size = new System.Drawing.Size(513, 20);
    40       //
    41       // variableCollectionView
    42       //
    43       this.variableCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    44                   | System.Windows.Forms.AnchorStyles.Left)
    45                   | System.Windows.Forms.AnchorStyles.Right)));
    46       this.variableCollectionView.Caption = "VariableCollection";
    47       this.variableCollectionView.Content = null;
    48       this.variableCollectionView.Location = new System.Drawing.Point(0, 52);
    49       this.variableCollectionView.Name = "variableCollectionView";
    50       this.variableCollectionView.ReadOnly = false;
    51       this.variableCollectionView.Size = new System.Drawing.Size(588, 366);
    52       this.variableCollectionView.TabIndex = 0;
    5343      //
    5444      // importButton
     
    6858      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    6959      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    70       this.Controls.Add(this.variableCollectionView);
    7160      this.Controls.Add(this.importButton);
    7261      this.Name = "DataAnalysisProblemDataView";
    7362      this.Size = new System.Drawing.Size(588, 450);
     63      this.Controls.SetChildIndex(this.parameterCollectionView, 0);
    7464      this.Controls.SetChildIndex(this.importButton, 0);
    75       this.Controls.SetChildIndex(this.variableCollectionView, 0);
    7665      this.Controls.SetChildIndex(this.nameLabel, 0);
    7766      this.Controls.SetChildIndex(this.descriptionLabel, 0);
     
    8675    #endregion
    8776
    88     private HeuristicLab.Core.Views.VariableCollectionView variableCollectionView;
    8977    private System.Windows.Forms.Button importButton;
    9078  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.3/DataAnalysisProblemDataView.cs

    r3462 r3545  
    1212namespace HeuristicLab.Problems.DataAnalysis.Views {
    1313  [View("Data-Analysis Problem View")]
    14   [Content(typeof(DataAnalysisProblemData))]
    15   public partial class DataAnalysisProblemDataView : NamedItemView {
     14  [Content(typeof(DataAnalysisProblemData), true)]
     15  public partial class DataAnalysisProblemDataView : ParameterizedNamedItemView {
    1616    private OpenFileDialog openFileDialog;
    1717    public new DataAnalysisProblemData Content {
     
    3131    }
    3232
    33     protected override void OnContentChanged() {
    34       base.OnContentChanged();
    35       variableCollectionView.Content = Content.Variables.AsReadOnly();
    36     }
    37 
    3833    private void importButton_Click(object sender, EventArgs e) {
    3934      if (openFileDialog == null) openFileDialog = new OpenFileDialog();
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblem.cs

    r3528 r3545  
    5050    public DataAnalysisProblemData DataAnalysisProblemData {
    5151      get { return DataAnalysisProblemDataParameter.Value; }
    52       set { DataAnalysisProblemDataParameter.Value = value; }
    5352    }
    5453    #endregion
     
    5756      : base() {
    5857      Parameters.Add(new ValueParameter<DataAnalysisProblemData>(DataAnalysisProblemDataParameterName, "The data set, target variable and input variables of the data analysis problem.", new DataAnalysisProblemData()));
     58      RegisterParameterEvents();
     59      RegisterParameterValueEvents();
    5960    }
    6061
    6162    [StorableConstructor]
    6263    private DataAnalysisProblem(bool deserializing) : base() { }
     64
     65    [StorableHook(HookType.AfterDeserialization)]
     66    private void AfterDeserializationHook() {
     67      RegisterParameterEvents();
     68      RegisterParameterValueEvents();
     69    }
     70
     71    #region events
     72    protected virtual void OnDataAnalysisProblemChanged(EventArgs e) { }
     73
     74    private void RegisterParameterEvents() {
     75      DataAnalysisProblemDataParameter.ValueChanged += new EventHandler(DataAnalysisProblemDataParameter_ValueChanged);
     76    }
     77
     78    private void RegisterParameterValueEvents() {
     79      DataAnalysisProblemData.ProblemDataChanged += new EventHandler(DataAnalysisProblemData_ProblemDataChanged);
     80    }
     81
     82    private void DataAnalysisProblemDataParameter_ValueChanged(object sender, EventArgs e) {
     83      OnDataAnalysisProblemChanged(e);
     84    }
     85
     86    private void DataAnalysisProblemData_ProblemDataChanged(object sender, EventArgs e) {
     87      OnDataAnalysisProblemChanged(e);
     88    }
     89    #endregion
     90
     91    public override IDeepCloneable Clone(Cloner cloner) {
     92      DataAnalysisProblem clone = (DataAnalysisProblem) base.Clone(cloner);
     93      clone.RegisterParameterEvents();
     94      clone.RegisterParameterValueEvents();
     95      return clone;
     96    }
    6397  }
    6498}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblemData.cs

    r3442 r3545  
    3535  [Item("DataAnalysisProblemData", "Represents an item containing all data defining a data analysis problem.")]
    3636  [StorableClass]
    37   public class DataAnalysisProblemData : NamedItem {
    38     [Storable]
    39     private VariableCollection variables;
    40     public VariableCollection Variables {
    41       get { return variables; }
    42     }
    43 
    44     #region variable properties
    45     public IVariable DatasetVariable {
    46       get { return variables["Dataset"]; }
    47     }
    48 
    49     public IVariable TargetVariableVariable {
    50       get { return variables["TargetVariable"]; }
    51     }
    52 
    53     public IVariable InputVariablesVariable {
    54       get { return variables["InputVariables"]; }
    55     }
    56 
    57     public IVariable TrainingSamplesStartVariable {
    58       get { return variables["TrainingSamplesStart"]; }
    59     }
    60     public IVariable TrainingSamplesEndVariable {
    61       get { return variables["TrainingSamplesEnd"]; }
    62     }
    63 
    64     public IVariable TestSamplesStartVariable {
    65       get { return variables["TestSamplesStart"]; }
    66     }
    67     public IVariable TestSamplesEndVariable {
    68       get { return variables["TestSamplesEnd"]; }
     37  public class DataAnalysisProblemData : ParameterizedNamedItem {
     38    private bool suppressEvents = false;
     39    #region parameter properties
     40    public IValueParameter<Dataset> DatasetParameter {
     41      get { return (IValueParameter<Dataset>)Parameters["Dataset"]; }
     42    }
     43
     44    public IValueParameter<StringValue> TargetVariableParameter {
     45      get { return (IValueParameter<StringValue>)Parameters["TargetVariable"]; }
     46    }
     47
     48    public IValueParameter<ItemSet<StringValue>> InputVariablesParameter {
     49      get { return (IValueParameter<ItemSet<StringValue>>)Parameters["InputVariables"]; }
     50    }
     51
     52    public IValueParameter<IntValue> TrainingSamplesStartParameter {
     53      get { return (IValueParameter<IntValue>)Parameters["TrainingSamplesStart"]; }
     54    }
     55    public IValueParameter<IntValue> TrainingSamplesEndParameter {
     56      get { return (IValueParameter<IntValue>)Parameters["TrainingSamplesEnd"]; }
     57    }
     58    public IValueParameter<IntValue> TestSamplesStartParameter {
     59      get { return (IValueParameter<IntValue>)Parameters["TestSamplesStart"]; }
     60    }
     61    public IValueParameter<IntValue> TestSamplesEndParameter {
     62      get { return (IValueParameter<IntValue>)Parameters["TestSamplesEnd"]; }
    6963    }
    7064    #endregion
     
    7266    #region properties
    7367    public Dataset Dataset {
    74       get { return (Dataset)DatasetVariable.Value; }
     68      get { return (Dataset)DatasetParameter.Value; }
    7569      set {
    7670        if (value != Dataset) {
    7771          if (value == null) throw new ArgumentNullException();
    7872          if (Dataset != null) DeregisterDatasetEventHandlers();
    79           DatasetVariable.Value = value;
    80           RegisterDatasetEventHandlers();
    81           OnProblemDataChanged(EventArgs.Empty);
     73          DatasetParameter.Value = value;
    8274        }
    8375      }
    8476    }
    8577    public StringValue TargetVariable {
    86       get { return (StringValue)TargetVariableVariable.Value; }
    87       set {
    88         if (value != TargetVariableVariable) {
     78      get { return (StringValue)TargetVariableParameter.Value; }
     79      set {
     80        if (value != TargetVariableParameter.Value) {
    8981          if (value == null) throw new ArgumentNullException();
    9082          if (TargetVariable != null) DeregisterStringValueEventHandlers(TargetVariable);
    91           TargetVariableVariable.Value = value;
    92           RegisterStringValueEventHandlers(TargetVariable);
    93           OnProblemDataChanged(EventArgs.Empty);
    94         }
    95       }
    96     }
    97     public ItemList<StringValue> InputVariables {
    98       get { return (ItemList<StringValue>)InputVariablesVariable.Value; }
     83          TargetVariableParameter.Value = value;
     84        }
     85      }
     86    }
     87    public ItemSet<StringValue> InputVariables {
     88      get { return (ItemSet<StringValue>)InputVariablesParameter.Value; }
    9989      set {
    10090        if (value != InputVariables) {
    10191          if (value == null) throw new ArgumentNullException();
    10292          if (InputVariables != null) DeregisterInputVariablesEventHandlers();
    103           InputVariablesVariable.Value = value;
    104           RegisterInputVariablesEventHandlers();
    105           OnProblemDataChanged(EventArgs.Empty);
     93          InputVariablesParameter.Value = value;
    10694        }
    10795      }
    10896    }
    10997    public IntValue TrainingSamplesStart {
    110       get { return (IntValue)TrainingSamplesStartVariable.Value; }
     98      get { return (IntValue)TrainingSamplesStartParameter.Value; }
    11199      set {
    112100        if (value != TrainingSamplesStart) {
    113101          if (value == null) throw new ArgumentNullException();
    114102          if (TrainingSamplesStart != null) DeregisterValueTypeEventHandlers(TrainingSamplesStart);
    115           TrainingSamplesStartVariable.Value = value;
    116           RegisterValueTypeEventHandlers(TrainingSamplesStart);
    117           OnProblemDataChanged(EventArgs.Empty);
     103          TrainingSamplesStartParameter.Value = value;
    118104        }
    119105      }
    120106    }
    121107    public IntValue TrainingSamplesEnd {
    122       get { return (IntValue)TrainingSamplesEndVariable.Value; }
     108      get { return (IntValue)TrainingSamplesEndParameter.Value; }
    123109      set {
    124110        if (value != TrainingSamplesEnd) {
    125111          if (value == null) throw new ArgumentNullException();
    126112          if (TrainingSamplesEnd != null) DeregisterValueTypeEventHandlers(TrainingSamplesEnd);
    127           TrainingSamplesEndVariable.Value = value;
    128           RegisterValueTypeEventHandlers(TrainingSamplesEnd);
    129           OnProblemDataChanged(EventArgs.Empty);
     113          TrainingSamplesEndParameter.Value = value;
    130114        }
    131115      }
    132116    }
    133117    public IntValue TestSamplesStart {
    134       get { return (IntValue)TestSamplesStartVariable.Value; }
     118      get { return (IntValue)TestSamplesStartParameter.Value; }
    135119      set {
    136120        if (value != TestSamplesStart) {
    137121          if (value == null) throw new ArgumentNullException();
    138122          if (TestSamplesStart != null) DeregisterValueTypeEventHandlers(TestSamplesStart);
    139           TestSamplesStartVariable.Value = value;
    140           RegisterValueTypeEventHandlers(TestSamplesStart);
    141           OnProblemDataChanged(EventArgs.Empty);
     123          TestSamplesStartParameter.Value = value;
    142124        }
    143125      }
    144126    }
    145127    public IntValue TestSamplesEnd {
    146       get { return (IntValue)TestSamplesEndVariable.Value; }
     128      get { return (IntValue)TestSamplesEndParameter.Value; }
    147129      set {
    148130        if (value != TestSamplesEnd) {
    149131          if (value == null) throw new ArgumentNullException();
    150132          if (TestSamplesEnd != null) DeregisterValueTypeEventHandlers(TestSamplesEnd);
    151           TestSamplesEndVariable.Value = value;
    152           RegisterValueTypeEventHandlers(TestSamplesEnd);
    153           OnProblemDataChanged(EventArgs.Empty);
     133          TestSamplesEndParameter.Value = value;
    154134        }
    155135      }
     
    159139    public DataAnalysisProblemData()
    160140      : base() {
    161       variables = new VariableCollection();
    162       variables.Add(new Variable("Dataset", new Dataset()));
    163       variables.Add(new Variable("InputVariables", new ItemList<StringValue>()));
    164       variables.Add(new Variable("TargetVariable", new StringValue()));
    165       variables.Add(new Variable("TrainingSamplesStart", new IntValue()));
    166       variables.Add(new Variable("TrainingSamplesEnd", new IntValue()));
    167       variables.Add(new Variable("TestSamplesStart", new IntValue()));
    168       variables.Add(new Variable("TestSamplesEnd", new IntValue()));
    169       RegisterEventHandlers();
    170     }
     141      Parameters.Add(new ValueParameter<Dataset>("Dataset", new Dataset()));
     142      Parameters.Add(new ValueParameter<ItemSet<StringValue>>("InputVariables", new ItemSet<StringValue>()));
     143      Parameters.Add(new ConstrainedValueParameter<StringValue>("TargetVariable"));
     144      Parameters.Add(new ValueParameter<IntValue>("TrainingSamplesStart", new IntValue()));
     145      Parameters.Add(new ValueParameter<IntValue>("TrainingSamplesEnd", new IntValue()));
     146      Parameters.Add(new ValueParameter<IntValue>("TestSamplesStart", new IntValue()));
     147      Parameters.Add(new ValueParameter<IntValue>("TestSamplesEnd", new IntValue()));
     148      RegisterParameterEventHandlers();
     149      RegisterParameterValueEventHandlers();
     150    }
     151
    171152
    172153    [StorableConstructor]
     
    175156    [StorableHook(HookType.AfterDeserialization)]
    176157    private void AfterDeserializationHook() {
    177       RegisterEventHandlers();
     158      RegisterParameterEventHandlers();
     159      RegisterParameterValueEventHandlers();
    178160    }
    179161
    180162    #region events
    181     private void RegisterEventHandlers() {
     163    public event EventHandler ProblemDataChanged;
     164    protected virtual void OnProblemDataChanged(EventArgs e) {
     165      if (!suppressEvents) {
     166        var listeners = ProblemDataChanged;
     167        if (listeners != null) listeners(this, e);
     168      }
     169    }
     170
     171    private void RegisterParameterEventHandlers() {
     172      DatasetParameter.ValueChanged += new EventHandler(DatasetParameter_ValueChanged);
     173      InputVariablesParameter.ValueChanged += new EventHandler(InputVariablesParameter_ValueChanged);
     174      TargetVariableParameter.ValueChanged += new EventHandler(TargetVariableParameter_ValueChanged);
     175      TrainingSamplesStartParameter.ValueChanged += new EventHandler(TrainingSamplesStartParameter_ValueChanged);
     176      TrainingSamplesEndParameter.ValueChanged += new EventHandler(TrainingSamplesEndParameter_ValueChanged);
     177      TestSamplesStartParameter.ValueChanged += new EventHandler(TestSamplesStartParameter_ValueChanged);
     178      TestSamplesEndParameter.ValueChanged += new EventHandler(TestSamplesEndParameter_ValueChanged);
     179    }
     180
     181    private void RegisterParameterValueEventHandlers() {
    182182      RegisterDatasetEventHandlers();
    183183      RegisterInputVariablesEventHandlers();
    184       RegisterStringValueEventHandlers(TargetVariable);
     184      if (TargetVariable != null) RegisterStringValueEventHandlers(TargetVariable);
    185185      RegisterValueTypeEventHandlers(TrainingSamplesStart);
    186186      RegisterValueTypeEventHandlers(TrainingSamplesEnd);
     
    189189    }
    190190
    191     public event EventHandler ProblemDataChanged;
    192     protected virtual void OnProblemDataChanged(EventArgs e) {
    193       var listeners = ProblemDataChanged;
    194       if (listeners != null) listeners(this, e);
    195     }
    196 
    197 
    198     private void RegisterValueTypeEventHandlers<T>(ValueTypeValue<T> value) where T : struct {
    199       value.ValueChanged += new EventHandler(value_ValueChanged);
    200     }
    201 
    202     private void DeregisterValueTypeEventHandlers<T>(ValueTypeValue<T> value) where T : struct {
    203       value.ValueChanged -= new EventHandler(value_ValueChanged);
    204     }
    205 
    206     void value_ValueChanged(object sender, EventArgs e) {
    207       OnProblemDataChanged(e);
    208     }
    209 
    210     private void RegisterStringValueEventHandlers(StringValue value) {
    211       value.ValueChanged += new EventHandler(value_ValueChanged);
    212     }
    213 
    214     private void DeregisterStringValueEventHandlers(StringValue value) {
    215       value.ValueChanged -= new EventHandler(value_ValueChanged);
    216     }
     191
     192    #region parameter value changed event handlers
     193    void DatasetParameter_ValueChanged(object sender, EventArgs e) {
     194      RegisterDatasetEventHandlers();
     195      OnProblemDataChanged(EventArgs.Empty);
     196    }
     197    void InputVariablesParameter_ValueChanged(object sender, EventArgs e) {
     198      RegisterInputVariablesEventHandlers();
     199      OnProblemDataChanged(EventArgs.Empty);
     200    }
     201    void TargetVariableParameter_ValueChanged(object sender, EventArgs e) {
     202      if (TargetVariable != null) {
     203        RegisterStringValueEventHandlers(TargetVariable);
     204        OnProblemDataChanged(EventArgs.Empty);
     205      }
     206    }
     207    void TrainingSamplesStartParameter_ValueChanged(object sender, EventArgs e) {
     208      RegisterValueTypeEventHandlers(TrainingSamplesStart);
     209      OnProblemDataChanged(EventArgs.Empty);
     210    }
     211    void TrainingSamplesEndParameter_ValueChanged(object sender, EventArgs e) {
     212      RegisterValueTypeEventHandlers(TrainingSamplesEnd);
     213      OnProblemDataChanged(EventArgs.Empty);
     214    }
     215    void TestSamplesStartParameter_ValueChanged(object sender, EventArgs e) {
     216      RegisterValueTypeEventHandlers(TestSamplesStart);
     217      OnProblemDataChanged(EventArgs.Empty);
     218    }
     219    void TestSamplesEndParameter_ValueChanged(object sender, EventArgs e) {
     220      RegisterValueTypeEventHandlers(TestSamplesEnd);
     221      OnProblemDataChanged(EventArgs.Empty);
     222    }
     223    #endregion
     224
    217225
    218226    private void RegisterDatasetEventHandlers() {
     
    241249
    242250    private void RegisterInputVariablesEventHandlers() {
    243       InputVariables.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_CollectionReset);
    244       InputVariables.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_ItemsAdded);
    245       InputVariables.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_ItemsRemoved);
    246       InputVariables.ItemsReplaced += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_ItemsReplaced);
     251      InputVariables.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<StringValue>(InputVariables_CollectionReset);
     252      InputVariables.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<StringValue>(InputVariables_ItemsAdded);
     253      InputVariables.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<StringValue>(InputVariables_ItemsRemoved);
    247254      foreach (var item in InputVariables)
    248         item.ValueChanged += new EventHandler(InputVariables_Value_ValueChanged);
     255        item.ValueChanged += new EventHandler(InputVariable_ValueChanged);
     256    }
     257
     258    void InputVariables_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<StringValue> e) {
     259      foreach (var item in e.Items)
     260        item.ValueChanged -= new EventHandler(InputVariable_ValueChanged);
     261      OnProblemDataChanged(e);
     262    }
     263
     264    void InputVariables_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<StringValue> e) {
     265      foreach (var item in e.OldItems)
     266        item.ValueChanged -= new EventHandler(InputVariable_ValueChanged);
     267      OnProblemDataChanged(e);
     268    }
     269
     270    void InputVariables_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<StringValue> e) {
     271      foreach (var item in e.Items)
     272        item.ValueChanged += new EventHandler(InputVariable_ValueChanged);
     273      OnProblemDataChanged(e);
    249274    }
    250275
    251276    private void DeregisterInputVariablesEventHandlers() {
    252       InputVariables.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_CollectionReset);
    253       InputVariables.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_ItemsAdded);
    254       InputVariables.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_ItemsRemoved);
    255       InputVariables.ItemsReplaced -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_ItemsReplaced);
     277      InputVariables.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<StringValue>(InputVariables_CollectionReset);
     278      InputVariables.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<StringValue>(InputVariables_ItemsAdded);
     279      InputVariables.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<StringValue>(InputVariables_ItemsRemoved);
    256280      foreach (var item in InputVariables) {
    257         item.ValueChanged -= new EventHandler(InputVariables_Value_ValueChanged);
    258       }
    259     }
    260 
    261     void InputVariables_ItemsReplaced(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<HeuristicLab.Collections.IndexedItem<StringValue>> e) {
    262       foreach (var indexedItem in e.OldItems)
    263         indexedItem.Value.ValueChanged -= new EventHandler(InputVariables_Value_ValueChanged);
    264       foreach (var indexedItem in e.Items)
    265         indexedItem.Value.ValueChanged += new EventHandler(InputVariables_Value_ValueChanged);
    266       OnProblemDataChanged(e);
    267     }
    268 
    269     void InputVariables_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<HeuristicLab.Collections.IndexedItem<StringValue>> e) {
    270       foreach (var indexedItem in e.Items)
    271         indexedItem.Value.ValueChanged -= new EventHandler(InputVariables_Value_ValueChanged);
    272       OnProblemDataChanged(e);
    273     }
    274 
    275     void InputVariables_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<HeuristicLab.Collections.IndexedItem<StringValue>> e) {
    276       foreach (var indexedItem in e.Items)
    277         indexedItem.Value.ValueChanged += new EventHandler(InputVariables_Value_ValueChanged);
    278       OnProblemDataChanged(e);
    279     }
    280 
    281     void InputVariables_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<HeuristicLab.Collections.IndexedItem<StringValue>> e) {
    282       foreach (var indexedItem in e.OldItems)
    283         indexedItem.Value.ValueChanged -= new EventHandler(InputVariables_Value_ValueChanged);
    284 
    285       OnProblemDataChanged(e);
    286     }
    287     void InputVariables_Value_ValueChanged(object sender, EventArgs e) {
    288       OnProblemDataChanged(e);
    289     }
    290 
     281        item.ValueChanged -= new EventHandler(InputVariable_ValueChanged);
     282      }
     283    }
     284 
     285    void InputVariable_ValueChanged(object sender, EventArgs e) {
     286      OnProblemDataChanged(e);
     287    }
     288    #region helper
     289
     290    private void RegisterValueTypeEventHandlers<T>(ValueTypeValue<T> value) where T : struct {
     291      value.ValueChanged += new EventHandler(value_ValueChanged);
     292    }
     293
     294    private void DeregisterValueTypeEventHandlers<T>(ValueTypeValue<T> value) where T : struct {
     295      value.ValueChanged -= new EventHandler(value_ValueChanged);
     296    }
     297
     298    void value_ValueChanged(object sender, EventArgs e) {
     299      OnProblemDataChanged(e);
     300    }
     301
     302    private void RegisterStringValueEventHandlers(StringValue value) {
     303      value.ValueChanged += new EventHandler(value_ValueChanged);
     304    }
     305
     306    private void DeregisterStringValueEventHandlers(StringValue value) {
     307      value.ValueChanged -= new EventHandler(value_ValueChanged);
     308    }
     309
     310    #endregion
    291311    #endregion
    292312
     
    294314      var csvFileParser = new CsvFileParser();
    295315      csvFileParser.Parse(fileName);
     316      suppressEvents = true;
    296317      Name = "Data imported from " + Path.GetFileName(fileName);
    297318      Dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
    298319      Dataset.Name = Path.GetFileName(fileName);
    299       TargetVariable = new StringValue(Dataset.VariableNames.First());
    300       InputVariables = new ItemList<StringValue>(Dataset.VariableNames.Skip(1).Select(s => new StringValue(s)));
     320      var variableNames = Dataset.VariableNames.Select(x => new StringValue(x).AsReadOnly()).ToList();
     321      ((ConstrainedValueParameter<StringValue>)TargetVariableParameter).ValidValues.Clear();
     322      foreach (var variableName in variableNames)
     323        ((ConstrainedValueParameter<StringValue>)TargetVariableParameter).ValidValues.Add(variableName);
     324      TargetVariable = variableNames.First();
     325      InputVariables = new ItemSet<StringValue>(variableNames.Skip(1));
    301326      int middle = (int)(csvFileParser.Rows * 0.5);
    302327      TrainingSamplesStart = new IntValue(0);
     
    304329      TestSamplesStart = new IntValue(middle);
    305330      TestSamplesEnd = new IntValue(csvFileParser.Rows);
     331      suppressEvents = false;
     332      OnProblemDataChanged(EventArgs.Empty);
    306333    }
    307334
    308335    public override IDeepCloneable Clone(Cloner cloner) {
    309336      DataAnalysisProblemData clone = (DataAnalysisProblemData)base.Clone(cloner);
    310       clone.variables = (VariableCollection)variables.Clone(cloner);
    311 
    312       clone.RegisterEventHandlers();
     337      clone.RegisterParameterEventHandlers();
     338      clone.RegisterParameterValueEventHandlers();
    313339      return clone;
    314340    }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/SimpleArithmeticExpressionInterpreter.cs

    r3513 r3545  
    5252    private Instruction[] code;
    5353    private int pc;
     54
     55    public override bool CanChangeName {
     56      get { return false; }
     57    }
     58    public override bool CanChangeDescription {
     59      get { return false; }
     60    }
    5461
    5562    public SimpleArithmeticExpressionInterpreter()
Note: See TracChangeset for help on using the changeset viewer.