Changeset 2090
- Timestamp:
- 06/25/09 10:57:18 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.DataAnalysis/3.2/DatasetShuffler.cs
r2039 r2090 34 34 AddVariableInfo(new VariableInfo("Dataset", "Dataset which should be shuffled (random row order)", typeof(Dataset), VariableKind.In | VariableKind.Out)); 35 35 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)); 36 38 } 37 39 … … 40 42 MersenneTwister tw = GetVariableValue<MersenneTwister>("Random", scope, true); 41 43 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); 44 55 ExchangeRows(dataset, i, j); 45 56 } 46 57 58 dataset.FireChanged(); 47 59 return null; 48 60 } … … 50 62 private void ExchangeRows(Dataset dataset, int i, int j) { 51 63 dataset.FireChangeEvents = false; 52 for (int k = 0; k < dataset.Columns; k++) {64 for (int k = 0; k < dataset.Columns; k++) { 53 65 double temp = dataset.GetValue(i, k); 54 66 dataset.SetValue(i, k, dataset.GetValue(j, k)); … … 56 68 } 57 69 dataset.FireChangeEvents = true; 58 dataset.FireChanged();59 70 } 60 71 }
Note: See TracChangeset
for help on using the changeset viewer.