Changeset 7970 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators
- Timestamp:
- 06/06/12 04:29:56 (13 years ago)
- Location:
- branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Crossovers/CordeauCrossover.cs
r7523 r7970 34 34 IQualitiesAwareGQAPOperator, IWeightsAwareGQAPOperator, IDistancesAwareGQAPOperator, IInstallationCostsAwareGQAPOperator, 35 35 IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator, ITransportationCostsAwareGQAPOperator, 36 I OverbookedCapacityPenaltyAwareGQAPOperator {36 IExpectedRandomQualityAwareGQAPOperator { 37 37 38 38 public ILookupParameter<BoolValue> MaximizationParameter { … … 69 69 get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; } 70 70 } 71 public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter { 72 get { return (IValueLookupParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; } 71 public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter { 72 get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; } 73 } 74 public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter { 75 get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; } 73 76 } 74 77 … … 91 94 Parameters.Add(new LookupParameter<DoubleArray>("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription)); 92 95 Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription)); 93 Parameters.Add(new ValueLookupParameter<DoubleValue>("OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription)); 96 Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription)); 97 Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator used to evaluate solutions.")); 94 98 } 95 99 … … 103 107 DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts, 104 108 DoubleArray demands, DoubleArray capacities, 105 DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty) {109 double transportationCosts, double expectedRandomQuality, IGQAPEvaluator evaluator) { 106 110 var mediana = Inizialize(distances); 107 111 int m = capacities.Length; … … 158 162 } 159 163 if (!nofound) { 160 double sonQual = GQAPEvaluator.Evaluate(son, weights, distances, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty);164 double sonQual = evaluator.Evaluate(son, weights, distances, installationCosts, demands, capacities, transportationCosts, expectedRandomQuality); 161 165 if (sonQual < fbest) { 162 166 fbest = sonQual; … … 197 201 onefound = true; 198 202 } else { 199 double sonQual = GQAPEvaluator.Evaluate(son, weights, distances, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty);203 double sonQual = evaluator.Evaluate(son, weights, distances, installationCosts, demands, capacities, transportationCosts, expectedRandomQuality); 200 204 if (sonQual < fbest) { 201 205 fbest = sonQual; … … 227 231 WeightsParameter.ActualValue, DistancesParameter.ActualValue, InstallationCostsParameter.ActualValue, 228 232 DemandsParameter.ActualValue, CapacitiesParameter.ActualValue, 229 TransportationCostsParameter.ActualValue, OverbookedCapacityPenaltyParameter.ActualValue); 233 TransportationCostsParameter.ActualValue.Value, ExpectedRandomQualityParameter.ActualValue.Value, 234 EvaluatorParameter.ActualValue); 230 235 } 231 236 -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/Crossovers/GQAPPathRelinking.cs
r7813 r7970 37 37 public class GQAPPathRelinking : GQAPCrossover, IQualitiesAwareGQAPOperator, IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator, 38 38 IWeightsAwareGQAPOperator, IDistancesAwareGQAPOperator, IInstallationCostsAwareGQAPOperator, ITransportationCostsAwareGQAPOperator, 39 I OverbookedCapacityPenaltyAwareGQAPOperator {39 IExpectedRandomQualityAwareGQAPOperator, IEvaluatorAwareGQAPOperator { 40 40 41 41 public ILookupParameter<BoolValue> MaximizationParameter { … … 72 72 get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; } 73 73 } 74 public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter { 75 get { return (IValueLookupParameter<DoubleValue>)Parameters["OverbookedCapacityPenalty"]; } 74 public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter { 75 get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; } 76 } 77 public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter { 78 get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; } 76 79 } 77 80 … … 96 99 Parameters.Add(new LookupParameter<DoubleMatrix>("InstallationCosts", GeneralizedQuadraticAssignmentProblem.InstallationCostsDescription)); 97 100 Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription)); 98 Parameters.Add(new ValueLookupParameter<DoubleValue>("OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription)); 101 Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription)); 102 Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions.")); 99 103 Parameters.Add(new ValueParameter<PercentValue>("CandidateSizeFactor", "(η) Determines the size of the set of feasible moves in each path-relinking step relative to the maximum size. A value of 50% means that only half of all possible moves are considered each step.", new PercentValue(0.5))); 100 104 } … … 107 111 ItemArray<DoubleValue> flowDistanceQualities, ItemArray<DoubleValue> installationQualities, ItemArray<DoubleValue> overbookedCapacities, 108 112 DoubleArray demands, DoubleArray capacities, DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts, 109 DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty, DoubleValue candidateSizeFactor) {113 DoubleValue transportationCosts, DoubleValue expectedRandomQuality, DoubleValue candidateSizeFactor, IGQAPEvaluator evaluator) { 110 114 if (random == null) throw new ArgumentNullException("random", "No IRandom provider is given."); 111 115 if (parents == null || !parents.Any()) throw new ArgumentException("No parents given for path relinking.", "parents"); … … 145 149 146 150 double currentFDQ, currentIQ, currentOC; 147 GQAPEvaluator.Evaluate(pi2, weights, distances, installationCosts, demands, capacities,151 evaluator.Evaluate(pi2, weights, distances, installationCosts, demands, capacities, 148 152 out currentFDQ, out currentIQ, out currentOC); 149 153 150 154 if (currentOC <= 0.0) { 151 var quality = GQAPEvaluator.GetCombinedQuality(currentFDQ, currentIQ, currentOC,152 transportationCosts.Value, overbookedCapacityPenalty.Value);155 var quality = evaluator.GetFitness(currentFDQ, currentIQ, currentOC, 156 transportationCosts.Value, expectedRandomQuality.Value); 153 157 var solution = new GQAPSolution(pi2, new DoubleValue(quality), new DoubleValue(currentFDQ), 154 158 new DoubleValue(currentIQ), new DoubleValue(currentOC)); … … 211 215 CapacitiesParameter.ActualValue, WeightsParameter.ActualValue, DistancesParameter.ActualValue, 212 216 InstallationCostsParameter.ActualValue, TransportationCostsParameter.ActualValue, 213 OverbookedCapacityPenaltyParameter.ActualValue, CandidateSizeFactorParameter.Value); 217 ExpectedRandomQualityParameter.ActualValue, CandidateSizeFactorParameter.Value, 218 EvaluatorParameter.ActualValue); 214 219 } 215 220 -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/LocalImprovers/ApproximateLocalSearch.cs
r7523 r7970 37 37 public class ApproximateLocalSearch : SingleSuccessorOperator, IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator, 38 38 IWeightsAwareGQAPOperator, IDistancesAwareGQAPOperator, IInstallationCostsAwareGQAPOperator, 39 ITransportationCostsAwareGQAPOperator, IOverbookedCapacityPenaltyAwareGQAPOperator, 40 IAssignmentAwareGQAPOperator, IQualityAwareGQAPOperator, IGQAPLocalImprovementOperator, IStochasticOperator { 39 ITransportationCostsAwareGQAPOperator, IExpectedRandomQualityAwareGQAPOperator, 40 IAssignmentAwareGQAPOperator, IQualityAwareGQAPOperator, IGQAPLocalImprovementOperator, 41 IEvaluatorAwareGQAPOperator, IStochasticOperator { 41 42 public IProblem Problem { get; set; } 42 43 public Type ProblemType { … … 62 63 get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; } 63 64 } 64 public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {65 get { return (IValueLookupParameter<DoubleValue>)Parameters[" OverbookedCapacityPenalty"]; }65 public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter { 66 get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; } 66 67 } 67 68 public ILookupParameter<IntegerVector> AssignmentParameter { … … 100 101 public ILookupParameter<ResultCollection> ResultsParameter { 101 102 get { return (ILookupParameter<ResultCollection>)Parameters["Results"]; } 103 } 104 public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter { 105 get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; } 102 106 } 103 107 … … 113 117 Parameters.Add(new LookupParameter<DoubleMatrix>("InstallationCosts", GeneralizedQuadraticAssignmentProblem.InstallationCostsDescription)); 114 118 Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription)); 115 Parameters.Add(new ValueLookupParameter<DoubleValue>(" OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription));119 Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription)); 116 120 Parameters.Add(new LookupParameter<IntegerVector>("Assignment", GQAPSolutionCreator.AssignmentDescription)); 117 121 Parameters.Add(new LookupParameter<BoolValue>("Maximization", GeneralizedQuadraticAssignmentProblem.MaximizationDescription)); … … 126 130 Parameters.Add(new ValueLookupParameter<PercentValue>("OneMoveProbability", "The probability for performing a 1-move, which is the opposite of performing a 2-move.", new PercentValue(.5))); 127 131 Parameters.Add(new LookupParameter<ResultCollection>("Results", "The result collection that stores the results.")); 132 Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions.")); 128 133 } 129 134 … … 157 162 IntValue maxCLS, IntValue maximumIterations, 158 163 DoubleMatrix weights, DoubleMatrix distances, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities, 159 DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty, PercentValue oneMoveProbability) { 164 DoubleValue transportationCosts, DoubleValue expectedRandomQuality, PercentValue oneMoveProbability, 165 IGQAPEvaluator evaluator) { 160 166 161 167 while (true) { … … 171 177 double moveFlowDistanceQuality, moveInstallationQuality, moveOverbookedCapacity; 172 178 GQAPNMoveEvaluator.Evaluate(move, assignment, weights, distances, installationCosts, 173 demands, capacities, out moveFlowDistanceQuality, out moveInstallationQuality, out moveOverbookedCapacity);174 double moveQuality = GQAPEvaluator.GetCombinedQuality(moveFlowDistanceQuality, moveInstallationQuality, moveOverbookedCapacity,175 transportationCosts.Value, overbookedCapacityPenalty.Value);179 demands, capacities, evaluator, out moveFlowDistanceQuality, out moveInstallationQuality, out moveOverbookedCapacity); 180 double moveQuality = evaluator.GetFitness(moveFlowDistanceQuality, moveInstallationQuality, moveOverbookedCapacity, 181 transportationCosts.Value, expectedRandomQuality.Value); 176 182 177 183 if (moveOverbookedCapacity <= 0.0 && moveQuality < 0.0) { … … 216 222 DemandsParameter.ActualValue, CapacitiesParameter.ActualValue, 217 223 TransportationCostsParameter.ActualValue, 218 OverbookedCapacityPenaltyParameter.ActualValue, 219 OneMoveProbabilityParameter.ActualValue); 224 ExpectedRandomQualityParameter.ActualValue, 225 OneMoveProbabilityParameter.ActualValue, 226 EvaluatorParameter.ActualValue); 220 227 return base.Apply(); 221 228 }
Note: See TracChangeset
for help on using the changeset viewer.