- Timestamp:
- 07/20/09 20:14:47 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/Variable.cs
r2166 r2174 38 38 public const string INDEX = "Variable"; 39 39 40 private int minIndex;41 private int maxIndex;42 40 private int minOffset; 43 41 private int maxOffset; … … 53 51 public Variable() 54 52 : base() { 55 AddVariableInfo(new VariableInfo(INDEX, " Index of the variable in the dataset representing this feature", typeof(ConstrainedIntData), VariableKind.None));53 AddVariableInfo(new VariableInfo(INDEX, "The variable name", typeof(StringData), VariableKind.None)); 56 54 GetVariableInfo(INDEX).Local = true; 57 AddVariableInfo(new VariableInfo(WEIGHT, "Weight is multiplied to the feature value", typeof( ConstrainedDoubleData), VariableKind.None));55 AddVariableInfo(new VariableInfo(WEIGHT, "Weight is multiplied to the feature value", typeof(DoubleData), VariableKind.None)); 58 56 GetVariableInfo(WEIGHT).Local = true; 59 57 AddVariableInfo(new VariableInfo(OFFSET, "SampleOffset is added to the sample index", typeof(ConstrainedIntData), VariableKind.None)); … … 67 65 AddVariable(new HeuristicLab.Core.Variable(WEIGHT, weight)); 68 66 69 ConstrainedIntData variable = new ConstrainedIntData();67 StringData variable = new StringData(); 70 68 AddVariable(new HeuristicLab.Core.Variable(INDEX, variable)); 71 minIndex = 0; maxIndex = 1000;72 69 73 70 ConstrainedIntData sampleOffset = new ConstrainedIntData(); … … 84 81 CombinedOperator combinedOp = new CombinedOperator(); 85 82 SequentialProcessor seq = new SequentialProcessor(); 86 UniformRandomizer indexRandomizer = new UniformRandomizer(); 87 indexRandomizer.Min = minIndex; 88 indexRandomizer.Max = maxIndex + 1; // uniform randomizer generates numbers in the range [min, max[ 89 indexRandomizer.GetVariableInfo("Value").ActualName = INDEX; 90 indexRandomizer.Name = "Index Randomizer"; 83 UniformItemChooser variableRandomizer = new UniformItemChooser(); 84 variableRandomizer.GetVariableInfo("Value").ActualName = INDEX; 85 variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables"; 86 variableRandomizer.Name = "Variable randomizer"; 91 87 NormalRandomizer weightRandomizer = new NormalRandomizer(); 92 88 weightRandomizer.Mu = 0.0; … … 101 97 102 98 combinedOp.OperatorGraph.AddOperator(seq); 103 combinedOp.OperatorGraph.AddOperator( indexRandomizer);99 combinedOp.OperatorGraph.AddOperator(variableRandomizer); 104 100 combinedOp.OperatorGraph.AddOperator(weightRandomizer); 105 101 combinedOp.OperatorGraph.AddOperator(offsetRandomizer); 106 102 combinedOp.OperatorGraph.InitialOperator = seq; 107 seq.AddSubOperator( indexRandomizer);103 seq.AddSubOperator(variableRandomizer); 108 104 seq.AddSubOperator(weightRandomizer); 109 105 seq.AddSubOperator(offsetRandomizer); … … 120 116 CombinedOperator combinedOp = new CombinedOperator(); 121 117 SequentialProcessor seq = new SequentialProcessor(); 122 UniformRandomizer indexRandomizer = new UniformRandomizer(); 123 indexRandomizer.Min = minIndex; 124 indexRandomizer.Max = maxIndex + 1; 125 indexRandomizer.GetVariableInfo("Value").ActualName = INDEX; 126 indexRandomizer.Name = "Index Randomizer"; 118 UniformItemChooser variableRandomizer = new UniformItemChooser(); 119 variableRandomizer.GetVariableInfo("Value").ActualName = INDEX; 120 variableRandomizer.GetVariableInfo("Values").ActualName = "InputVariables"; 121 variableRandomizer.Name = "Variable randomizer"; 127 122 NormalRandomAdder weightRandomAdder = new NormalRandomAdder(); 128 123 weightRandomAdder.Mu = 0.0; … … 137 132 138 133 combinedOp.OperatorGraph.AddOperator(seq); 139 combinedOp.OperatorGraph.AddOperator( indexRandomizer);134 combinedOp.OperatorGraph.AddOperator(variableRandomizer); 140 135 combinedOp.OperatorGraph.AddOperator(weightRandomAdder); 141 136 combinedOp.OperatorGraph.AddOperator(offsetRandomAdder); 142 137 combinedOp.OperatorGraph.InitialOperator = seq; 143 seq.AddSubOperator( indexRandomizer);138 seq.AddSubOperator(variableRandomizer); 144 139 seq.AddSubOperator(weightRandomAdder); 145 140 seq.AddSubOperator(offsetRandomAdder); … … 152 147 } 153 148 154 public void SetConstraints(int min InputIndex, int maxInputIndex, int minSampleOffset, int maxSampleOffset) {149 public void SetConstraints(int minSampleOffset, int maxSampleOffset) { 155 150 ConstrainedIntData offset = GetVariableValue<ConstrainedIntData>(OFFSET, null, false); 156 151 IntBoundedConstraint offsetConstraint = new IntBoundedConstraint(); … … 165 160 offset.AddConstraint(offsetConstraint); 166 161 167 ConstrainedIntData index = GetVariableValue<ConstrainedIntData>(INDEX, null, false);168 IntBoundedConstraint indexConstraint = new IntBoundedConstraint();169 minIndex = minInputIndex;170 maxIndex = maxInputIndex;171 indexConstraint.LowerBound = minInputIndex;172 indexConstraint.LowerBoundEnabled = true;173 indexConstraint.LowerBoundIncluded = true;174 indexConstraint.UpperBound = maxInputIndex;175 indexConstraint.UpperBoundEnabled = true;176 indexConstraint.UpperBoundIncluded = true;177 index.AddConstraint(indexConstraint);162 //ConstrainedIntData index = GetVariableValue<ConstrainedIntData>(INDEX, null, false); 163 //IntBoundedConstraint indexConstraint = new IntBoundedConstraint(); 164 //minIndex = minInputIndex; 165 //maxIndex = maxInputIndex; 166 //indexConstraint.LowerBound = minInputIndex; 167 //indexConstraint.LowerBoundEnabled = true; 168 //indexConstraint.LowerBoundIncluded = true; 169 //indexConstraint.UpperBound = maxInputIndex; 170 //indexConstraint.UpperBoundEnabled = true; 171 //indexConstraint.UpperBoundIncluded = true; 172 //index.AddConstraint(indexConstraint); 178 173 179 174 SetupInitialization();
Note: See TracChangeset
for help on using the changeset viewer.