Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2090


Ignore:
Timestamp:
06/25/09 10:57:18 (15 years ago)
Author:
mkommend
Message:

added ShuffleStart and ShuffleEnd to DatasetShuffler (ticket #677)
and improved firing of DatasetChanged-Events

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataAnalysis/3.2/DatasetShuffler.cs

    r2039 r2090  
    3434      AddVariableInfo(new VariableInfo("Dataset", "Dataset which should be shuffled (random row order)", typeof(Dataset), VariableKind.In | VariableKind.Out));
    3535      AddVariableInfo(new VariableInfo("Random", "Randomizer", typeof(MersenneTwister), VariableKind.In));
     36      AddVariableInfo(new VariableInfo("ShuffleStart", "Start of part of dataset which should be shuffeled", typeof(IntData), VariableKind.In));
     37      AddVariableInfo(new VariableInfo("ShuffleEnd", "End of part of dataset which should be shuffeled", typeof(IntData), VariableKind.In));
    3638    }
    3739
     
    4042      MersenneTwister tw = GetVariableValue<MersenneTwister>("Random", scope, true);
    4143
    42       for(int i = 0; i < dataset.Rows - 1; i++) {
    43         int j = tw.Next(i, dataset.Rows);
     44      int start = 0;
     45      int end = dataset.Rows;
     46      IntData temp = GetVariableValue<IntData>("ShuffleStart", scope, true, false);
     47      if (temp != null)
     48        start = temp.Data;
     49      temp = GetVariableValue<IntData>("ShuffleEnd", scope, true, false);
     50      if (temp != null)
     51        end = temp.Data;
     52
     53      for (int i = start; i < end - 1; i++) {
     54        int j = tw.Next(i, end);
    4455        ExchangeRows(dataset, i, j);
    4556      }
    4657
     58      dataset.FireChanged();
    4759      return null;
    4860    }
     
    5062    private void ExchangeRows(Dataset dataset, int i, int j) {
    5163      dataset.FireChangeEvents = false;
    52       for(int k = 0; k < dataset.Columns; k++) {
     64      for (int k = 0; k < dataset.Columns; k++) {
    5365        double temp = dataset.GetValue(i, k);
    5466        dataset.SetValue(i, k, dataset.GetValue(j, k));
     
    5668      }
    5769      dataset.FireChangeEvents = true;
    58       dataset.FireChanged();
    5970    }
    6071  }
Note: See TracChangeset for help on using the changeset viewer.