Changeset 17232 for branches/2521_ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
- Timestamp:
- 09/04/19 09:09:26 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Problems.QuadraticAssignment/3.3/QuadraticAssignmentProblem.cs
r17226 r17232 51 51 52 52 #region Parameter Properties 53 [Storable] 54 private IValueParameter<ItemSet<Permutation>> bestKnownSolutionsParameter; 53 55 public IValueParameter<ItemSet<Permutation>> BestKnownSolutionsParameter { 54 get { return (IValueParameter<ItemSet<Permutation>>)Parameters["BestKnownSolutions"]; } 55 } 56 get { return bestKnownSolutionsParameter; } 57 } 58 [Storable] 59 private IValueParameter<Permutation> bestKnownSolutionParameter; 56 60 public IValueParameter<Permutation> BestKnownSolutionParameter { 57 get { return (IValueParameter<Permutation>)Parameters["BestKnownSolution"]; } 58 } 61 get { return bestKnownSolutionParameter; } 62 } 63 [Storable] 64 private IValueParameter<DoubleMatrix> weightsParameter; 59 65 public IValueParameter<DoubleMatrix> WeightsParameter { 60 get { return (IValueParameter<DoubleMatrix>)Parameters["Weights"]; } 61 } 66 get { return weightsParameter; } 67 } 68 [Storable] 69 private IValueParameter<DoubleMatrix> distancesParameter; 62 70 public IValueParameter<DoubleMatrix> DistancesParameter { 63 get { return (IValueParameter<DoubleMatrix>)Parameters["Distances"]; } 64 } 71 get { return distancesParameter; } 72 } 73 [Storable] 74 private IValueParameter<DoubleValue> lowerBoundParameter; 65 75 public IValueParameter<DoubleValue> LowerBoundParameter { 66 get { return (IValueParameter<DoubleValue>)Parameters["LowerBound"]; } 67 } 76 get { return lowerBoundParameter; } 77 } 78 [Storable] 79 private IValueParameter<DoubleValue> averageQualityParameter; 68 80 public IValueParameter<DoubleValue> AverageQualityParameter { 69 get { return (IValueParameter<DoubleValue>)Parameters["AverageQuality"]; }81 get { return averageQualityParameter; } 70 82 } 71 83 #endregion … … 73 85 #region Properties 74 86 public ItemSet<Permutation> BestKnownSolutions { 75 get { return BestKnownSolutionsParameter.Value; }76 set { BestKnownSolutionsParameter.Value = value; }87 get { return bestKnownSolutionsParameter.Value; } 88 set { bestKnownSolutionsParameter.Value = value; } 77 89 } 78 90 public Permutation BestKnownSolution { 79 get { return BestKnownSolutionParameter.Value; }80 set { BestKnownSolutionParameter.Value = value; }91 get { return bestKnownSolutionParameter.Value; } 92 set { bestKnownSolutionParameter.Value = value; } 81 93 } 82 94 public DoubleMatrix Weights { 83 get { return WeightsParameter.Value; }84 set { WeightsParameter.Value = value; }95 get { return weightsParameter.Value; } 96 set { weightsParameter.Value = value; } 85 97 } 86 98 public DoubleMatrix Distances { 87 get { return DistancesParameter.Value; }88 set { DistancesParameter.Value = value; }99 get { return distancesParameter.Value; } 100 set { distancesParameter.Value = value; } 89 101 } 90 102 public DoubleValue LowerBound { 91 get { return LowerBoundParameter.Value; }92 set { LowerBoundParameter.Value = value; }103 get { return lowerBoundParameter.Value; } 104 set { lowerBoundParameter.Value = value; } 93 105 } 94 106 public DoubleValue AverageQuality { 95 get { return AverageQualityParameter.Value; }96 set { AverageQualityParameter.Value = value; }107 get { return averageQualityParameter.Value; } 108 set { averageQualityParameter.Value = value; } 97 109 } 98 110 … … 114 126 private QuadraticAssignmentProblem(QuadraticAssignmentProblem original, Cloner cloner) 115 127 : base(original, cloner) { 128 bestKnownSolutionsParameter = cloner.Clone(original.bestKnownSolutionsParameter); 129 bestKnownSolutionParameter = cloner.Clone(original.bestKnownSolutionParameter); 130 weightsParameter = cloner.Clone(original.weightsParameter); 131 distancesParameter = cloner.Clone(original.distancesParameter); 132 lowerBoundParameter = cloner.Clone(original.lowerBoundParameter); 133 averageQualityParameter = cloner.Clone(original.averageQualityParameter); 116 134 RegisterEventHandlers(); 117 135 } 118 136 public QuadraticAssignmentProblem() 119 137 : base(new PermutationEncoding("Assignment") { Length = 5 }) { 120 Parameters.Add( new OptionalValueParameter<ItemSet<Permutation>>("BestKnownSolutions", "The list of best known solutions which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null));121 Parameters.Add( new OptionalValueParameter<Permutation>("BestKnownSolution", "The best known solution which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null));122 Parameters.Add( new ValueParameter<DoubleMatrix>("Weights", "The strength of the connection between the facilities.", new DoubleMatrix(5, 5)));123 Parameters.Add( new ValueParameter<DoubleMatrix>("Distances", "The distance matrix which can either be specified directly without the coordinates, or can be calculated automatically from the coordinates.", new DoubleMatrix(5, 5)));124 Parameters.Add( new OptionalValueParameter<DoubleValue>("LowerBound", "The Gilmore-Lawler lower bound to the solution quality."));125 Parameters.Add( new OptionalValueParameter<DoubleValue>("AverageQuality", "The expected quality of a random solution."));138 Parameters.Add(bestKnownSolutionsParameter = new OptionalValueParameter<ItemSet<Permutation>>("BestKnownSolutions", "The list of best known solutions which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null)); 139 Parameters.Add(bestKnownSolutionParameter = new OptionalValueParameter<Permutation>("BestKnownSolution", "The best known solution which is updated whenever a new better solution is found or may be the optimal solution if it is known beforehand.", null)); 140 Parameters.Add(weightsParameter = new ValueParameter<DoubleMatrix>("Weights", "The strength of the connection between the facilities.", new DoubleMatrix(5, 5))); 141 Parameters.Add(distancesParameter = new ValueParameter<DoubleMatrix>("Distances", "The distance matrix which can either be specified directly without the coordinates, or can be calculated automatically from the coordinates.", new DoubleMatrix(5, 5))); 142 Parameters.Add(lowerBoundParameter = new OptionalValueParameter<DoubleValue>("LowerBound", "The Gilmore-Lawler lower bound to the solution quality.")); 143 Parameters.Add(averageQualityParameter = new OptionalValueParameter<DoubleValue>("AverageQuality", "The expected quality of a random solution.")); 126 144 127 145 WeightsParameter.GetsCollected = false; … … 167 185 [StorableHook(HookType.AfterDeserialization)] 168 186 private void AfterDeserialization() { 187 // BackwardsCompatibility3.3 188 #region Backwards compatible code, remove with 3.4 189 if (bestKnownSolutionsParameter == null) 190 bestKnownSolutionsParameter = (IValueParameter<ItemSet<Permutation>>)Parameters["BestKnownSolutions"]; 191 if (bestKnownSolutionParameter == null) 192 bestKnownSolutionParameter = (IValueParameter<Permutation>)Parameters["BestKnownSolution"]; 193 if (weightsParameter == null) 194 weightsParameter = (IValueParameter<DoubleMatrix>)Parameters["Weights"]; 195 if (distancesParameter == null) 196 distancesParameter = (IValueParameter<DoubleMatrix>)Parameters["Distances"]; 197 if (lowerBoundParameter == null) 198 lowerBoundParameter = (IValueParameter<DoubleValue>)Parameters["LowerBound"]; 199 if (averageQualityParameter == null) 200 averageQualityParameter = (IValueParameter<DoubleValue>)Parameters["AverageQuality"]; 201 #endregion 169 202 RegisterEventHandlers(); 170 203 }
Note: See TracChangeset
for help on using the changeset viewer.