Changeset 7970 for branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Analyzers
- Timestamp:
- 06/06/12 04:29:56 (12 years ago)
- Location:
- branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Analyzers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Analyzers/BestGQAPSolutionAnalyzer.cs
r7807 r7970 29 29 using HeuristicLab.Parameters; 30 30 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 31 using HeuristicLab.Problems.GeneralizedQuadraticAssignment.Common;32 31 33 32 namespace HeuristicLab.Problems.GeneralizedQuadraticAssignment { … … 40 39 IQualitiesAwareGQAPOperator, IDistancesAwareGQAPOperator, IWeightsAwareGQAPOperator, IInstallationCostsAwareGQAPOperator, 41 40 IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator, ITransportationCostsAwareGQAPOperator, 42 IOverbookedCapacityPenaltyAwareGQAPOperator, IEquipmentNamesAwareGQAPOperator, ILocationNamesAwareGQAPOperator, 43 IBestKnownQualityAwareGQAPOperator, IBestKnownSolutionAwareGQAPOperator, IAnalyzer { 41 IExpectedRandomQualityAwareGQAPOperator, IEquipmentNamesAwareGQAPOperator, ILocationNamesAwareGQAPOperator, 42 IBestKnownQualityAwareGQAPOperator, IBestKnownSolutionAwareGQAPOperator, 43 IEvaluatorAwareGQAPOperator, IAnalyzer { 44 44 45 45 public bool EnabledByDefault { … … 84 84 get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; } 85 85 } 86 public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {87 get { return (IValueLookupParameter<DoubleValue>)Parameters[" OverbookedCapacityPenalty"]; }86 public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter { 87 get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; } 88 88 } 89 89 public ILookupParameter<StringArray> EquipmentNamesParameter { … … 104 104 public IValueLookupParameter<ResultCollection> ResultsParameter { 105 105 get { return (IValueLookupParameter<ResultCollection>)Parameters["Results"]; } 106 } 107 public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter { 108 get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; } 106 109 } 107 110 #endregion … … 122 125 Parameters.Add(new LookupParameter<DoubleArray>("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription)); 123 126 Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription)); 124 Parameters.Add(new ValueLookupParameter<DoubleValue>(" OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription));127 Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription)); 125 128 Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>("Assignment", GQAPSolutionCreator.AssignmentDescription)); 126 129 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", GQAPEvaluator.QualityDescription)); … … 134 137 Parameters.Add(new LookupParameter<GQAPAssignment>("BestSolution", "The best GQAP solution found so far.")); 135 138 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best GQAP solution should be stored.")); 139 Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions.")); 136 140 } 137 141 138 142 public override IOperation Apply() { 143 var evaluator = EvaluatorParameter.ActualValue; 139 144 var assignments = AssignmentParameter.ActualValue; 140 145 var qualities = QualityParameter.ActualValue; … … 150 155 var capacities = CapacitiesParameter.ActualValue; 151 156 var transportationCosts = TransportationCostsParameter.ActualValue; 152 var overbookedCapacityPenalty = OverbookedCapacityPenaltyParameter.ActualValue;157 var expectedRandomQuality = ExpectedRandomQualityParameter.ActualValue; 153 158 var results = ResultsParameter.ActualValue; 154 159 var maximization = MaximizationParameter.ActualValue.Value; … … 162 167 if (bestKnownQuality == null || HasSolutionImproved(bestKnownQuality.Value, qualities[bestIndex].Value, maximization)) { 163 168 BestKnownQualityParameter.ActualValue = new DoubleValue(qualities[bestIndex].Value); 164 BestKnownSolutionParameter.ActualValue = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(), flowDistanceQualities[bestIndex], installationQualities[bestIndex], overbookedCapacities[bestIndex], equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty);169 BestKnownSolutionParameter.ActualValue = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(), flowDistanceQualities[bestIndex], installationQualities[bestIndex], overbookedCapacities[bestIndex], equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, expectedRandomQuality, evaluator); 165 170 } 166 171 167 172 var assignment = BestSolutionParameter.ActualValue; 168 173 if (assignment == null) { 169 assignment = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(), flowDistanceQualities[bestIndex], installationQualities[bestIndex], overbookedCapacities[bestIndex], equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty);174 assignment = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(), flowDistanceQualities[bestIndex], installationQualities[bestIndex], overbookedCapacities[bestIndex], equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, expectedRandomQuality, evaluator); 170 175 assignment.Distances = distances; 171 176 BestSolutionParameter.ActualValue = assignment; … … 185 190 assignment.Capacities = capacities; 186 191 assignment.TransportationCosts = transportationCosts; 187 assignment.OverbookedCapacityPenalty = overbookedCapacityPenalty; 192 assignment.ExpectedRandomQuality = expectedRandomQuality; 193 assignment.Evaluator = evaluator; 188 194 } 189 195 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Analyzers/GQAPSolutionArchiveAnalyzer.cs
r7470 r7970 39 39 IQualitiesAwareGQAPOperator, IDistancesAwareGQAPOperator, IWeightsAwareGQAPOperator, IInstallationCostsAwareGQAPOperator, 40 40 IDemandsAwareGQAPOperator, ICapacitiesAwareGQAPOperator, ITransportationCostsAwareGQAPOperator, 41 I OverbookedCapacityPenaltyAwareGQAPOperator, IEquipmentNamesAwareGQAPOperator, ILocationNamesAwareGQAPOperator,42 IBestKnownSolutionsAwareGQAPOperator, I Analyzer {41 IExpectedRandomQualityAwareGQAPOperator, IEquipmentNamesAwareGQAPOperator, ILocationNamesAwareGQAPOperator, 42 IBestKnownSolutionsAwareGQAPOperator, IEvaluatorAwareGQAPOperator, IAnalyzer { 43 43 44 44 public bool EnabledByDefault { … … 82 82 get { return (IValueLookupParameter<DoubleValue>)Parameters["TransportationCosts"]; } 83 83 } 84 public IValueLookupParameter<DoubleValue> OverbookedCapacityPenaltyParameter {85 get { return (IValueLookupParameter<DoubleValue>)Parameters[" OverbookedCapacityPenalty"]; }84 public IValueLookupParameter<DoubleValue> ExpectedRandomQualityParameter { 85 get { return (IValueLookupParameter<DoubleValue>)Parameters["ExpectedRandomQuality"]; } 86 86 } 87 87 public ILookupParameter<StringArray> EquipmentNamesParameter { … … 96 96 public ILookupParameter<GQAPAssignmentArchive> BestKnownSolutionsParameter { 97 97 get { return (ILookupParameter<GQAPAssignmentArchive>)Parameters["BestKnownSolutions"]; } 98 } 99 public IValueLookupParameter<IGQAPEvaluator> EvaluatorParameter { 100 get { return (IValueLookupParameter<IGQAPEvaluator>)Parameters["Evaluator"]; } 98 101 } 99 102 … … 113 116 Parameters.Add(new LookupParameter<DoubleArray>("Capacities", GeneralizedQuadraticAssignmentProblem.CapacitiesDescription)); 114 117 Parameters.Add(new ValueLookupParameter<DoubleValue>("TransportationCosts", GeneralizedQuadraticAssignmentProblem.TransportationCostsDescription)); 115 Parameters.Add(new ValueLookupParameter<DoubleValue>(" OverbookedCapacityPenalty", GeneralizedQuadraticAssignmentProblem.OverbookedCapacityPenaltyDescription));118 Parameters.Add(new ValueLookupParameter<DoubleValue>("ExpectedRandomQuality", GeneralizedQuadraticAssignmentProblem.ExpectedRandomQualityDescription)); 116 119 Parameters.Add(new ScopeTreeLookupParameter<IntegerVector>("Assignment", GQAPSolutionCreator.AssignmentDescription)); 117 120 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", GQAPEvaluator.QualityDescription)); … … 123 126 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best GQAP solution should be stored.")); 124 127 Parameters.Add(new LookupParameter<GQAPAssignmentArchive>("BestKnownSolutions", GeneralizedQuadraticAssignmentProblem.BestKnownSolutionsDescription)); 128 Parameters.Add(new ValueLookupParameter<IGQAPEvaluator>("Evaluator", "The evaluator that is used to evaluate GQAP solutions.")); 125 129 } 126 130 127 131 public override IOperation Apply() { 132 var evaluator = EvaluatorParameter.ActualValue; 128 133 var assignments = AssignmentParameter.ActualValue; 129 134 var qualities = QualityParameter.ActualValue; … … 139 144 var capacities = CapacitiesParameter.ActualValue; 140 145 var transportationCosts = TransportationCostsParameter.ActualValue; 141 var overbookedCapacityPenalty = OverbookedCapacityPenaltyParameter.ActualValue;146 var expectedRandomQuality = ExpectedRandomQualityParameter.ActualValue; 142 147 var results = ResultsParameter.ActualValue; 143 148 var maximization = MaximizationParameter.ActualValue.Value; … … 145 150 GQAPAssignmentArchive archive = results.ContainsKey("Solution Archive") ? results["Solution Archive"].Value as GQAPAssignmentArchive : null; 146 151 if (archive == null) { 147 archive = new GQAPAssignmentArchive(equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty);152 archive = new GQAPAssignmentArchive(equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, expectedRandomQuality, evaluator); 148 153 results.Add(new Result("Solution Archive", archive)); 149 154 } else { … … 156 161 archive.Capacities = capacities; 157 162 archive.TransportationCosts = transportationCosts; 158 archive.OverbookedCapacityPenalty = overbookedCapacityPenalty; 163 archive.ExpectedRandomQuality = expectedRandomQuality; 164 archive.Evaluator = evaluator; 159 165 } 160 166
Note: See TracChangeset
for help on using the changeset viewer.