- Timestamp:
- 06/27/17 13:45:50 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.BinPacking/3.3/3D/IntegerVectorEncoding/IntegerVectorProblem.cs
r14167 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 … … 51 53 Encoding = new IntegerVectorEncoding(EncodedSolutionName, Items.Count, min: 0, max: LowerBound + 1); // NOTE: assumes that all items can be packed into LowerBound+1 bins 52 54 AddOperators(); 55 Parameterize(); 53 56 RegisterEventHandlers(); 54 57 } … … 62 65 } 63 66 67 protected override void OnEncodingChanged() { 68 base.OnEncodingChanged(); 69 Parameterize(); 70 } 64 71 65 72 private void AddOperators() { 66 67 73 // move operators are not yet supported (TODO) 68 74 Operators.RemoveAll(x => x is SingleObjectiveMoveGenerator); 69 75 Operators.RemoveAll(x => x is SingleObjectiveMoveMaker); 70 76 Operators.RemoveAll(x => x is SingleObjectiveMoveEvaluator); 77 Operators.Add(new HammingSimilarityCalculator()); 78 Operators.Add(new EuclideanSimilarityCalculator()); 79 Operators.Add(new QualitySimilarityCalculator()); 80 Operators.Add(new PopulationSimilarityAnalyzer(Operators.OfType<ISolutionSimilarityCalculator>())); 71 81 72 82 Encoding.ConfigureOperators(Operators.OfType<IOperator>()); // gkronber: not strictly necessary (only when customer ops are added) … … 75 85 private void RegisterEventHandlers() { 76 86 // update encoding length when number of items is changed 77 ItemsParameter.ValueChanged += (sender, args) => Encoding.Length = Items.Count; 78 LowerBoundParameter.Value.ValueChanged += (sender, args) => { 79 for (int i = 0; i < Encoding.Bounds.Rows; i++) { 80 Encoding.Bounds[i, 1] = LowerBound + 1; 81 } 82 }; 87 ItemsParameter.ValueChanged += (sender, args) => Parameterize(); 88 LowerBoundParameter.Value.ValueChanged += (sender, args) => Parameterize(); 83 89 } 84 90 85 91 #region helpers 86 87 92 public static List<List<int>> GenerateSequenceMatrix(IntegerVector intVec) { 88 93 List<List<int>> result = new List<List<int>>(); … … 95 100 return result; 96 101 } 102 103 private void Parameterize() { 104 Encoding.Length = Items.Count; 105 for (int i = 0; i < Encoding.Bounds.Rows; i++) { 106 Encoding.Bounds[i, 1] = LowerBound + 1; 107 } 108 foreach (var similarityCalculator in Operators.OfType<ISolutionSimilarityCalculator>()) { 109 similarityCalculator.SolutionVariableName = Encoding.SolutionCreator.IntegerVectorParameter.ActualName; 110 similarityCalculator.QualityVariableName = Evaluator.QualityParameter.ActualName; 111 } 112 } 97 113 #endregion 98 114 }
Note: See TracChangeset
for help on using the changeset viewer.