- Timestamp:
- 03/19/10 10:46:02 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Knapsack/3.3/Knapsack.cs
r3107 r3109 52 52 get { return (ValueParameter<IntValue>)Parameters["KnapsackCapacity"]; } 53 53 } 54 public ValueParameter<IntArray> WeightsParameter { 55 get { return (ValueParameter<IntArray>)Parameters["Weights"]; } 56 } 57 public ValueParameter<IntArray> ValuesParameter { 58 get { return (ValueParameter<IntArray>)Parameters["Values"]; } 59 } 54 60 public ValueParameter<DoubleValue> PenaltyParameter { 55 61 get { return (ValueParameter<DoubleValue>)Parameters["Penalty"]; } 56 62 } 57 public ValueParameter<IntArray> WeightsParameter {58 get { return (ValueParameter<IntArray>)Parameters["Weights"]; }59 }60 public ValueParameter<IntArray> ValuesParameter {61 get { return (ValueParameter<IntArray>)Parameters["Values"]; }62 }63 63 public ValueParameter<IBinaryVectorCreator> SolutionCreatorParameter { 64 64 get { return (ValueParameter<IBinaryVectorCreator>)Parameters["SolutionCreator"]; } … … 85 85 86 86 #region Properties 87 public IntValue KnapsackCapacity { 88 get { return KnapsackCapacityParameter.Value; } 89 set { KnapsackCapacityParameter.Value = value; } 90 } 91 public IntArray Weights { 92 get { return WeightsParameter.Value; } 93 set { WeightsParameter.Value = value; } 94 } 95 public IntArray Values { 96 get { return ValuesParameter.Value; } 97 set { ValuesParameter.Value = value; } 98 } 99 public DoubleValue Penalty { 100 get { return PenaltyParameter.Value; } 101 set { PenaltyParameter.Value = value; } 102 } 87 103 public IBinaryVectorCreator SolutionCreator { 88 104 get { return SolutionCreatorParameter.Value; } … … 123 139 Parameters.Add(new ValueParameter<IntValue>("KnapsackCapacity", "Capacity of the Knapsack.", new IntValue(0))); 124 140 Parameters.Add(new ValueParameter<IntArray>("Weights", "The weights of the items.", new IntArray(5))); 125 WeightsParameter.ActualValue.ToStringChanged += new EventHandler(WeightsActualValue_ToStringChanged);126 141 Parameters.Add(new ValueParameter<IntArray>("Values", "The values of the items.", new IntArray(5))); 127 ValuesParameter.ActualValue.ToStringChanged += new EventHandler(ValuesActualValue_ToStringChanged);128 142 Parameters.Add(new ValueParameter<DoubleValue>("Penalty", "The penalty value for each unit of overweight.", new DoubleValue(1))); 129 143 Parameters.Add(new ValueParameter<IBinaryVectorCreator>("SolutionCreator", "The operator which should be used to create new Knapsack solutions.", creator)); … … 160 174 } 161 175 public event EventHandler VisualizerChanged; 176 private void OnVisualizerChanged() { 177 if (VisualizerChanged != null) 178 VisualizerChanged(this, EventArgs.Empty); 179 } 180 162 181 public event EventHandler OperatorsChanged; 163 182 private void OnOperatorsChanged() { … … 181 200 OnEvaluatorChanged(); 182 201 } 183 184 void ValuesActualValue_ToStringChanged(object sender, EventArgs e) { 185 ParameterizeSolutionCreator(); 186 } 187 188 void WeightsActualValue_ToStringChanged(object sender, EventArgs e) { 189 ParameterizeSolutionCreator(); 202 void KnapsackCapacityParameter_ValueChanged(object sender, EventArgs e) { 203 ParameterizeEvaluator(); 204 } 205 void WeightsParameter_ValueChanged(object sender, EventArgs e) { 206 ParameterizeEvaluator(); 207 } 208 void ValuesParameter_ValueChanged(object sender, EventArgs e) { 209 ParameterizeEvaluator(); 210 } 211 void PenaltyParameter_ValueChanged(object sender, EventArgs e) { 212 ParameterizeEvaluator(); 190 213 } 191 214 #endregion … … 198 221 SolutionCreator.BinaryVectorParameter.ActualNameChanged += new EventHandler(SolutionCreator_PermutationParameter_ActualNameChanged); 199 222 EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged); 223 KnapsackCapacityParameter.ValueChanged += new EventHandler(KnapsackCapacityParameter_ValueChanged); 224 WeightsParameter.ValueChanged += new EventHandler(WeightsParameter_ValueChanged); 225 ValuesParameter.ValueChanged += new EventHandler(ValuesParameter_ValueChanged); 226 PenaltyParameter.ValueChanged += new EventHandler(PenaltyParameter_ValueChanged); 200 227 } 201 228 private void ParameterizeSolutionCreator() { … … 209 236 (KnapsackEvaluator)Evaluator; 210 237 knapsackEvaluator.BinaryVectorParameter.ActualName = SolutionCreator.BinaryVectorParameter.ActualName; 238 knapsackEvaluator.KnapsackCapacityParameter.ActualName = KnapsackCapacityParameter.Name; 211 239 knapsackEvaluator.WeightsParameter.ActualName = WeightsParameter.Name; 212 240 knapsackEvaluator.ValuesParameter.ActualName = ValuesParameter.Name; 213 knapsackEvaluator.KnapsackCapacityParameter.ActualName = KnapsackCapacityParameter.Name;214 241 knapsackEvaluator.PenaltyParameter.ActualName = PenaltyParameter.Name; 215 242 }
Note: See TracChangeset
for help on using the changeset viewer.