- Timestamp:
- 06/27/17 13:45:50 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.BinPacking/3.3/2D/IntegerVectorEncoding/IntegerVectorProblem.cs
r14162 r15069 24 24 using System.Collections.Generic; 25 25 using System.Linq; 26 using HeuristicLab.Analysis; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; 28 29 using HeuristicLab.Encodings.IntegerVectorEncoding; 29 30 using HeuristicLab.Optimization; 31 using HeuristicLab.Optimization.Operators; 30 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 33 … … 52 54 Encoding = new IntegerVectorEncoding(EncodedSolutionName, Items.Count, min: 0, max: LowerBound + 1); // NOTE: assumes that all items can be packed into LowerBound+1 bins 53 55 AddOperators(); 56 Parameterize(); 54 57 RegisterEventHandlers(); 55 58 } … … 63 66 } 64 67 68 protected override void OnEncodingChanged() { 69 base.OnEncodingChanged(); 70 Parameterize(); 71 } 65 72 66 73 private void AddOperators() { 67 68 74 // move operators are not yet supported (TODO) 69 75 Operators.RemoveAll(x => x is SingleObjectiveMoveGenerator); 70 76 Operators.RemoveAll(x => x is SingleObjectiveMoveMaker); 71 77 Operators.RemoveAll(x => x is SingleObjectiveMoveEvaluator); 78 Operators.Add(new HammingSimilarityCalculator()); 79 Operators.Add(new EuclideanSimilarityCalculator()); 80 Operators.Add(new QualitySimilarityCalculator()); 81 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); 72 82 73 Encoding.ConfigureOperators(Operators.OfType<IOperator>()); // gkronber: not strictly necessary (only when customer ops are added)83 Encoding.ConfigureOperators(Operators.OfType<IOperator>()); 74 84 } 75 85 76 86 private void RegisterEventHandlers() { 77 87 // update encoding length when number of items is changed 78 ItemsParameter.ValueChanged += (sender, args) => Encoding.Length = Items.Count; 79 LowerBoundParameter.Value.ValueChanged += (sender, args) => { 80 for (int i = 0; i < Encoding.Bounds.Rows; i++) { 81 Encoding.Bounds[i, 1] = LowerBound + 1; 82 } 83 }; 88 ItemsParameter.ValueChanged += (sender, args) => Parameterize(); 89 LowerBoundParameter.Value.ValueChanged += (sender, args) => Parameterize(); 84 90 } 85 91 … … 96 102 return result; 97 103 } 104 105 private void Parameterize() { 106 Encoding.Length = Items.Count; 107 for (int i = 0; i < Encoding.Bounds.Rows; i++) { 108 Encoding.Bounds[i, 1] = LowerBound + 1; 109 } 110 foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) { 111 similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.IntegerVectorParameter.ActualName; 112 similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName; 113 } 114 } 98 115 #endregion 99 116 }
Note: See TracChangeset
for help on using the changeset viewer.