Changeset 3599


Ignore:
Timestamp:
05/03/10 17:46:09 (12 years ago)
Author:
gkronber
Message:

Changed DataAnalysisProblemData to use a CheckedItemList for the input variables instead of a CheckedItemCollection to preserve the ordering of input variables. #938 (Data types and operators for regression problems)

Location:
trunk/sources
Files:
2 edited

Legend:

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

    r3559 r3599  
    352352    private void UpdateGrammar() {
    353353      foreach (var varSymbol in FunctionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable>()) {
    354         varSymbol.VariableNames = DataAnalysisProblemData.InputVariables.CheckedItems.Select(x => x.Value);
     354        varSymbol.VariableNames = DataAnalysisProblemData.InputVariables.CheckedItems.Select(x => x.Value.Value);
    355355      }
    356356      var globalGrammar = FunctionTreeGrammar as GlobalSymbolicExpressionGrammar;
  • trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblemData.cs

    r3563 r3599  
    4646    }
    4747
    48     public IValueParameter<CheckedItemCollection<StringValue>> InputVariablesParameter {
    49       get { return (IValueParameter<CheckedItemCollection<StringValue>>)Parameters["InputVariables"]; }
     48    public IValueParameter<CheckedItemList<StringValue>> InputVariablesParameter {
     49      get { return (IValueParameter<CheckedItemList<StringValue>>)Parameters["InputVariables"]; }
    5050    }
    5151
     
    8585      }
    8686    }
    87     public CheckedItemCollection<StringValue> InputVariables {
    88       get { return (CheckedItemCollection<StringValue>)InputVariablesParameter.Value; }
     87    public CheckedItemList<StringValue> InputVariables {
     88      get { return (CheckedItemList<StringValue>)InputVariablesParameter.Value; }
    8989      set {
    9090        if (value != InputVariables) {
     
    140140      : base() {
    141141      Parameters.Add(new ValueParameter<Dataset>("Dataset", new Dataset()));
    142       Parameters.Add(new ValueParameter<CheckedItemCollection<StringValue>>("InputVariables", new CheckedItemCollection<StringValue>()));
     142      Parameters.Add(new ValueParameter<CheckedItemList<StringValue>>("InputVariables", new CheckedItemList<StringValue>()));
    143143      Parameters.Add(new ConstrainedValueParameter<StringValue>("TargetVariable"));
    144144      Parameters.Add(new ValueParameter<IntValue>("TrainingSamplesStart", new IntValue()));
     
    249249
    250250    private void RegisterInputVariablesEventHandlers() {
    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);
    254       InputVariables.CheckedItemsChanged += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<StringValue>(InputVariables_ItemsChecked);
     251      InputVariables.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_CollectionReset);
     252      InputVariables.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_ItemsAdded);
     253      InputVariables.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_ItemsRemoved);
     254      InputVariables.CheckedItemsChanged += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_CheckedItemsChanged);
    255255      foreach (var item in InputVariables)
    256256        item.ValueChanged += new EventHandler(InputVariable_ValueChanged);
    257257    }
    258258
    259     void InputVariables_ItemsChecked(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<StringValue> e) {
    260       OnProblemDataChanged(e);
    261     }
    262 
    263     void InputVariables_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<StringValue> e) {
    264       foreach (var item in e.Items)
    265         item.ValueChanged -= new EventHandler(InputVariable_ValueChanged);
    266       OnProblemDataChanged(e);
    267     }
    268 
    269     void InputVariables_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<StringValue> e) {
    270       foreach (var item in e.OldItems)
    271         item.ValueChanged -= new EventHandler(InputVariable_ValueChanged);
    272       OnProblemDataChanged(e);
    273     }
    274 
    275     void InputVariables_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<StringValue> e) {
    276       foreach (var item in e.Items)
    277         item.ValueChanged += new EventHandler(InputVariable_ValueChanged);
    278       OnProblemDataChanged(e);
    279     }
    280 
    281259    private void DeregisterInputVariablesEventHandlers() {
    282       InputVariables.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<StringValue>(InputVariables_CollectionReset);
    283       InputVariables.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<StringValue>(InputVariables_ItemsAdded);
    284       InputVariables.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<StringValue>(InputVariables_ItemsRemoved);
     260      InputVariables.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_CollectionReset);
     261      InputVariables.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_ItemsAdded);
     262      InputVariables.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_ItemsRemoved);
     263      InputVariables.CheckedItemsChanged -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<HeuristicLab.Collections.IndexedItem<StringValue>>(InputVariables_CheckedItemsChanged);
    285264      foreach (var item in InputVariables) {
    286265        item.ValueChanged -= new EventHandler(InputVariable_ValueChanged);
     
    288267    }
    289268 
     269    private void InputVariables_CheckedItemsChanged(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<HeuristicLab.Collections.IndexedItem<StringValue>> e) {
     270      OnProblemDataChanged(e);
     271    }
     272
     273    private void InputVariables_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<HeuristicLab.Collections.IndexedItem<StringValue>> e) {
     274      foreach (var indexedItem in e.Items)
     275        indexedItem.Value.ValueChanged -= new EventHandler(InputVariable_ValueChanged);
     276      OnProblemDataChanged(e);
     277    }
     278
     279    private void InputVariables_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<HeuristicLab.Collections.IndexedItem<StringValue>> e) {
     280      foreach (var indexedItem in e.Items)
     281        indexedItem.Value.ValueChanged += new EventHandler(InputVariable_ValueChanged);
     282      OnProblemDataChanged(e);
     283    }
     284
     285    private void InputVariables_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<HeuristicLab.Collections.IndexedItem<StringValue>> e) {
     286      foreach (var indexedItem in e.OldItems)
     287        indexedItem.Value.ValueChanged -= new EventHandler(InputVariable_ValueChanged);
     288      OnProblemDataChanged(e);
     289    }
     290
    290291    void InputVariable_ValueChanged(object sender, EventArgs e) {
    291292      OnProblemDataChanged(e);
     
    328329        ((ConstrainedValueParameter<StringValue>)TargetVariableParameter).ValidValues.Add(variableName);
    329330      TargetVariable = variableNames.First();
    330       InputVariables = new CheckedItemCollection<StringValue>(variableNames);
     331      InputVariables = new CheckedItemList<StringValue>(variableNames);
    331332      foreach (var variableName in variableNames.Skip(1))
    332333        InputVariables.SetItemCheckedState(variableName, true);
Note: See TracChangeset for help on using the changeset viewer.