Changeset 3467 for trunk/sources/HeuristicLab.Problems.Knapsack
- Timestamp:
- 04/21/10 18:33:42 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.Knapsack/3.3
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Knapsack/3.3/HeuristicLab.Problems.Knapsack-3.3.csproj
r3384 r3467 87 87 <Compile Include="Interfaces\IKnapsackMoveEvaluator.cs" /> 88 88 <Compile Include="KnapsackProblem.cs" /> 89 <Compile Include="KnapsackSolution.cs" /> 89 90 <Compile Include="MoveEvaluators\KnapsackMoveEvaluator.cs" /> 90 91 <Compile Include="MoveEvaluators\KnapsackOneBitflipMoveEvaluator.cs" /> 91 92 <Compile Include="Properties\AssemblyInfo.cs" /> 93 <Compile Include="Visualizers\BestKnapsackVisualizer.cs" /> 92 94 </ItemGroup> 93 95 <ItemGroup> -
trunk/sources/HeuristicLab.Problems.Knapsack/3.3/Interfaces/IKnapsackSolutionsVisualizer.cs
r3116 r3467 21 21 22 22 using HeuristicLab.Optimization; 23 using HeuristicLab.Core; 24 using HeuristicLab.Encodings.BinaryVectorEncoding; 25 using HeuristicLab.Data; 23 26 24 27 namespace HeuristicLab.Problems.Knapsack { … … 26 29 /// An interface which represents an operator for visualizing solutions of Knapsack Problems. 27 30 /// </summary> 28 public interface IKnapsackSolutionsVisualizer : ISingleObjectiveSolutionsVisualizer { } 31 public interface IKnapsackSolutionsVisualizer : ISingleObjectiveSolutionsVisualizer { 32 ILookupParameter<ItemArray<BinaryVector>> BinaryVectorParameter { get; } 33 ILookupParameter<IntValue> KnapsackCapacityParameter { get; } 34 ILookupParameter<IntArray> WeightsParameter { get; } 35 ILookupParameter<IntArray> ValuesParameter { get; } 36 } 29 37 } -
trunk/sources/HeuristicLab.Problems.Knapsack/3.3/KnapsackProblem.cs
r3463 r3467 32 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 33 using HeuristicLab.PluginInfrastructure; 34 using HeuristicLab.Problems.Knapsack.Visualizers; 34 35 35 36 namespace HeuristicLab.Problems.Knapsack { … … 161 162 RandomBinaryVectorCreator creator = new RandomBinaryVectorCreator(); 162 163 KnapsackEvaluator evaluator = new KnapsackEvaluator(); 164 IKnapsackSolutionsVisualizer visualizer = new BestKnapsackVisualizer(); 163 165 164 166 Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to true as the Knapsack Problem is a maximization problem.", new BoolValue(true))); … … 170 172 Parameters.Add(new ValueParameter<IKnapsackEvaluator>("Evaluator", "The operator which should be used to evaluate Knapsack solutions.", evaluator)); 171 173 Parameters.Add(new OptionalValueParameter<DoubleValue>("BestKnownQuality", "The quality of the best known solution of this Knapsack instance.")); 172 Parameters.Add(new ValueParameter<IKnapsackSolutionsVisualizer>("Visualizer", "The operator which should be used to visualize Knapsack solutions.", null));174 Parameters.Add(new ValueParameter<IKnapsackSolutionsVisualizer>("Visualizer", "The operator which should be used to visualize Knapsack solutions.", visualizer)); 173 175 174 176 creator.BinaryVectorParameter.ActualName = "KnapsackSolution"; … … 179 181 ParameterizeSolutionCreator(); 180 182 ParameterizeEvaluator(); 183 ParameterizeVisualizer(); 181 184 182 185 Initialize(); … … 219 222 ParameterizeSolutionCreator(); 220 223 ParameterizeEvaluator(); 224 ParameterizeVisualizer(); 221 225 ParameterizeOperators(); 222 226 OnSolutionCreatorChanged(); … … 224 228 private void SolutionCreator_PermutationParameter_ActualNameChanged(object sender, EventArgs e) { 225 229 ParameterizeEvaluator(); 230 ParameterizeVisualizer(); 226 231 ParameterizeOperators(); 227 232 } 228 233 private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) { 229 234 ParameterizeEvaluator(); 235 ParameterizeVisualizer(); 230 236 OnEvaluatorChanged(); 231 237 } 232 238 void KnapsackCapacityParameter_ValueChanged(object sender, EventArgs e) { 233 239 ParameterizeEvaluator(); 240 ParameterizeVisualizer(); 234 241 } 235 242 void WeightsParameter_ValueChanged(object sender, EventArgs e) { 236 243 ParameterizeEvaluator(); 244 ParameterizeVisualizer(); 237 245 ParameterizeSolutionCreator(); 238 246 … … 247 255 void ValuesParameter_ValueChanged(object sender, EventArgs e) { 248 256 ParameterizeEvaluator(); 257 ParameterizeVisualizer(); 249 258 ParameterizeSolutionCreator(); 250 259 … … 302 311 } 303 312 } 313 private void ParameterizeVisualizer() { 314 if (Visualizer is IKnapsackSolutionsVisualizer) { 315 IKnapsackSolutionsVisualizer visualizer = 316 (IKnapsackSolutionsVisualizer)Visualizer; 317 visualizer.BinaryVectorParameter.ActualName = SolutionCreator.BinaryVectorParameter.ActualName; 318 visualizer.KnapsackCapacityParameter.ActualName = KnapsackCapacityParameter.Name; 319 visualizer.WeightsParameter.ActualName = WeightsParameter.Name; 320 visualizer.ValuesParameter.ActualName = ValuesParameter.Name; 321 } 322 } 304 323 private void InitializeOperators() { 305 324 operators = new List<IBinaryVectorOperator>();
Note: See TracChangeset
for help on using the changeset viewer.