Changeset 6657
- Timestamp:
- 08/12/11 17:31:18 (13 years ago)
- Location:
- branches/GeneralizedQAP
- Files:
-
- 4 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GeneralizedQuadraticAssignmentProblem.cs
r6651 r6657 21 21 22 22 using System.Drawing; 23 using System.Linq; 23 24 using HeuristicLab.Common; 24 25 using HeuristicLab.Core; … … 28 29 using HeuristicLab.Parameters; 29 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.PluginInfrastructure; 30 32 31 33 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { … … 91 93 #endregion 92 94 95 [Storable] 96 private BestGQAPSolutionAnalyzer bestSolutionAnalyzer; 97 public BestGQAPSolutionAnalyzer BestSolutionAnalyzer { 98 get { return bestSolutionAnalyzer; } 99 set { bestSolutionAnalyzer = value; } 100 } 101 93 102 [StorableConstructor] 94 103 private GeneralizedQuadraticAssignmentProblem(bool deserializing) : base(deserializing) { } 95 104 private GeneralizedQuadraticAssignmentProblem(GeneralizedQuadraticAssignmentProblem original, Cloner cloner) 96 105 : base(original, cloner) { 106 bestSolutionAnalyzer = cloner.Clone(original.bestSolutionAnalyzer); 97 107 AttachEventHandlers(); 98 108 } … … 107 117 Parameters.Add(new OptionalValueParameter<IItem>("BestKnownSolution", "The best known solution (if available)", null)); 108 118 109 Wei 119 Weights = new DoubleMatrix(5, 5); 120 Weights[0, 0] = Weights[1, 1] = Weights[2, 2] = Weights[3, 3] = Weights[4, 4] = 0; 121 Weights[0, 1] = Weights[1, 0] = Weights[0, 2] = Weights[2, 0] = Weights[0, 3] = Weights[3, 0] = Weights[0, 4] = Weights[4, 0] = 10; 122 Weights[1, 2] = Weights[2, 1] = Weights[1, 3] = Weights[3, 1] = Weights[1, 4] = Weights[4, 1] = 5; 123 Weights[2, 3] = Weights[3, 2] = Weights[2, 4] = Weights[4, 2] = 7.5; 124 Weights[3, 4] = Weights[4, 3] = 2.5; 125 126 Distances = new DoubleMatrix(3, 3); 127 Distances[0, 0] = Distances[1, 1] = Distances[2, 2] = 0; 128 Distances[0, 1] = Distances[1, 0] = Distances[1, 2] = Distances[2, 1] = 1; 129 Distances[0, 2] = Distances[2, 0] = 2; 130 131 InstallationCosts = new DoubleMatrix(3, 3); 132 133 TransportationCosts = new DoubleValue(1); 134 135 Demands = new DoubleArray(5); 136 Demands[0] = 2; Demands[1] = 1; Demands[2] = 3; Demands[3] = 1; Demands[4] = 1; 137 138 Capacities = new DoubleArray(3); 139 Capacities[0] = 4; Capacities[1] = 1; Capacities[2] = 4; 110 140 111 141 ParameterizeSolutionCreator(); … … 135 165 136 166 private void InitializeOperators() { 137 // TODO: Add custom problem analyzer to the list 138 // TODO: Add operators from the representation either by direct instantiation, or by using ApplicationManager.Manger.GetInstances<T>().Cast<IOperator>() 167 Operators.AddRange(ApplicationManager.Manager.GetInstances<IIntegerVectorOperator>()); 168 Operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator); 169 Operators.Add(new BestGQAPSolutionAnalyzer()); 170 ParameterizeAnalyzers(); 171 ParameterizeOperators(); 172 } 173 private void ParameterizeAnalyzers() { 174 if (BestSolutionAnalyzer != null) { 175 BestSolutionAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 176 BestSolutionAnalyzer.DistancesParameter.ActualName = DistancesParameter.Name; 177 BestSolutionAnalyzer.WeightsParameter.ActualName = WeightsParameter.Name; 178 BestSolutionAnalyzer.AssignmentParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName; 179 BestSolutionAnalyzer.ResultsParameter.ActualName = "Results"; 180 BestSolutionAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name; 181 BestSolutionAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name; 182 } 183 } 184 private void ParameterizeOperators() { 185 foreach (IIntegerVectorCrossover op in Operators.OfType<IIntegerVectorCrossover>()) { 186 op.ParentsParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName; 187 op.ChildParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName; 188 } 189 foreach (IIntegerVectorManipulator op in Operators.OfType<IIntegerVectorManipulator>()) { 190 op.IntegerVectorParameter.ActualName = SolutionCreator.IntegerVectorParameter.ActualName; 191 } 139 192 } 140 193 private void ParameterizeSolutionCreator() { 141 // TODO: Set the parameters of the solution creator 194 SolutionCreator.LengthParameter.Value = new IntValue(Demands.Length); 195 SolutionCreator.MinimumParameter.Value = new IntValue(0); 196 SolutionCreator.MaximumParameter.Value = new IntValue(Capacities.Length); 197 SolutionCreator.IntegerVectorParameter.ActualName = "Assignment"; 142 198 } 143 199 private void ParameterizeEvaluator() { 144 // TODO: Set the parameters of the evaluator 200 Evaluator.WeightsParameter.ActualName = WeightsParameter.Name; 201 Evaluator.DistancesParameter.ActualName = DistancesParameter.Name; 202 Evaluator.InstallationCostsParameter.ActualName = InstallationCostsParameter.Name; 203 Evaluator.TransportationCostsParameter.ActualName = TransportationCostsParameter.Name; 204 Evaluator.DemandsParameter.ActualName = DemandsParameter.Name; 205 Evaluator.CapacitiesParameter.ActualName = CapacitiesParameter.Name; 206 Evaluator.AssignmentParameter.ActualName = "Assignment"; 145 207 } 146 208 #endregion -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Interfaces/IGQAPEvaluator.cs
r6650 r6657 22 22 using HeuristicLab.Core; 23 23 using HeuristicLab.Data; 24 using HeuristicLab.Encodings.IntegerVectorEncoding; 24 25 using HeuristicLab.Optimization; 25 26 … … 32 33 ILookupParameter<DoubleArray> DemandsParameter { get; } 33 34 ILookupParameter<DoubleArray> CapacitiesParameter { get; } 35 ILookupParameter<IntegerVector> AssignmentParameter { get; } 34 36 } 35 37 }
Note: See TracChangeset
for help on using the changeset viewer.