- Timestamp:
- 01/27/12 02:01:25 (13 years ago)
- Location:
- branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Analyzers/BestGQAPSolutionAnalyzer.cs
r7415 r7418 130 130 } 131 131 132 [StorableHook(HookType.AfterDeserialization)]133 private void AfterDeserialization() {134 // BackwardsCompatibility3.3135 #region Backwards compatible code, remove with 3.4136 if (!Parameters.ContainsKey("EquipmentNames"))137 Parameters.Add(new LookupParameter<StringArray>("EquipmentNames", "Optional: A list of names that describes the equipments."));138 if (!Parameters.ContainsKey("LocationNames"))139 Parameters.Add(new LookupParameter<StringArray>("LocationNames", "Optional: A list of names that describes the locations."));140 #endregion141 }142 143 132 public override IOperation Apply() { 144 133 var assignments = AssignmentParameter.ActualValue; … … 172 161 GQAPAssignment assignment = BestSolutionParameter.ActualValue; 173 162 if (assignment == null) { 174 assignment = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(), 175 equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, 176 overbookedCapacityPenalty, flowDistanceQualities[bestIndex], installationQualities[bestIndex], overbookedCapacities[bestIndex]); 163 assignment = new GQAPAssignment((IntegerVector)assignments[bestIndex].Clone(), (DoubleValue)qualities[bestIndex].Clone(), flowDistanceQualities[bestIndex], overbookedCapacities[bestIndex], installationQualities[bestIndex], equipmentNames, locationNames, distances, weights, installationCosts, demands, capacities, transportationCosts, overbookedCapacityPenalty); 177 164 assignment.Distances = distances; 178 165 BestSolutionParameter.ActualValue = assignment; 179 166 results.Add(new Result("Best GQAP Solution", assignment)); 180 167 } else { 181 if (HasSolutionImproved(assignment.Quality.Value, qualities[bestIndex].Value, maximization)) { 182 assignment.Assignment = (IntegerVector)assignments[bestIndex].Clone(); 183 assignment.Quality = (DoubleValue)qualities[bestIndex].Clone(); 168 if (HasSolutionImproved(assignment.Solution.Quality.Value, qualities[bestIndex].Value, maximization)) { 169 assignment.Solution = new GQAPSolution((IntegerVector)assignments[bestIndex].Clone(), 170 (DoubleValue)qualities[bestIndex].Clone(), (DoubleValue)flowDistanceQualities[bestIndex].Clone(), 171 (DoubleValue)installationQualities[bestIndex].Clone(), (DoubleValue)overbookedCapacities[bestIndex].Clone()); 184 172 assignment.EquipmentNames = equipmentNames; 185 173 assignment.LocationNames = locationNames; … … 191 179 assignment.TransportationCosts = transportationCosts; 192 180 assignment.OverbookedCapacityPenalty = overbookedCapacityPenalty; 193 assignment.FlowDistanceQuality = (DoubleValue)flowDistanceQualities[bestIndex].Clone();194 assignment.InstallationQuality = (DoubleValue)installationQualities[bestIndex].Clone();195 assignment.OverbookedCapacity = (DoubleValue)overbookedCapacities[bestIndex].Clone();196 181 } 197 182 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GQAPAssignment.cs
r7415 r7418 33 33 34 34 [Storable] 35 private IntegerVector assignment;36 public IntegerVector Assignment{37 get { return assignment; }35 private GQAPSolution solution; 36 public GQAPSolution Solution { 37 get { return solution; } 38 38 set { 39 bool changed = (assignment != value); 40 assignment = value; 41 if (changed) OnPropertyChanged("Assignment"); 42 } 43 } 44 45 [Storable] 46 private DoubleValue quality; 47 public DoubleValue Quality { 48 get { return quality; } 49 set { 50 bool changed = (quality != value); 51 quality = value; 52 if (changed) OnPropertyChanged("Quality"); 39 bool changed = (solution != value); 40 solution = value; 41 if (changed) OnPropertyChanged("Solution"); 53 42 } 54 43 } … … 153 142 } 154 143 155 [Storable]156 private DoubleValue flowDistanceQuality;157 public DoubleValue FlowDistanceQuality {158 get { return flowDistanceQuality; }159 set {160 bool changed = (flowDistanceQuality != value);161 flowDistanceQuality = value;162 if (changed) OnPropertyChanged("FlowDistanceQuality");163 }164 }165 166 [Storable]167 private DoubleValue installationQuality;168 public DoubleValue InstallationQuality {169 get { return installationQuality; }170 set {171 bool changed = (installationQuality != value);172 installationQuality = value;173 if (changed) OnPropertyChanged("InstallationQuality");174 }175 }176 177 [Storable]178 private DoubleValue overbookedCapacity;179 public DoubleValue OverbookedCapacity {180 get { return overbookedCapacity; }181 set {182 bool changed = (overbookedCapacity != value);183 overbookedCapacity = value;184 if (changed) OnPropertyChanged("OverbookedCapacity");185 }186 }187 188 144 [StorableConstructor] 189 145 private GQAPAssignment(bool deserializing) : base(deserializing) { } 190 146 private GQAPAssignment(GQAPAssignment original, Cloner cloner) 191 147 : base(original, cloner) { 192 assignment = cloner.Clone(original.assignment);193 quality = cloner.Clone(original.quality);194 148 equipmentNames = cloner.Clone(original.equipmentNames); 195 149 locationNames = cloner.Clone(original.locationNames); … … 201 155 transportationCosts = cloner.Clone(original.transportationCosts); 202 156 overbookedCapacityPenalty = cloner.Clone(original.overbookedCapacityPenalty); 203 flowDistanceQuality = cloner.Clone(original.flowDistanceQuality);204 installationQuality = cloner.Clone(original.installationQuality);205 overbookedCapacity = cloner.Clone(original.overbookedCapacity);206 157 } 207 public GQAPAssignment(IntegerVector assignment, DoubleValue quality )158 public GQAPAssignment(IntegerVector assignment, DoubleValue quality, DoubleValue flowDistanceQuality, DoubleValue installationQuality, DoubleValue overbookedCapacity) 208 159 : base() { 209 this.assignment = assignment; 210 this.quality = quality; 160 this.solution = new GQAPSolution(assignment, quality, flowDistanceQuality, installationQuality, overbookedCapacity); 211 161 } 212 public GQAPAssignment(IntegerVector assignment, DoubleValue quality, StringArray equipmentNames, StringArray locationNames) 213 : this(assignment, quality) { 214 this.equipmentNames = equipmentNames; 215 this.locationNames = locationNames; 216 } 217 public GQAPAssignment(IntegerVector assignment, DoubleValue quality, StringArray equipmentNames, StringArray locationNames, 218 DoubleMatrix distances, DoubleMatrix weights, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities, 219 DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty, DoubleValue flowDistanceQuality, 220 DoubleValue installationQuality, DoubleValue overbookedCapacity) 221 : this(assignment, quality, equipmentNames, locationNames) { 162 public GQAPAssignment(IntegerVector assignment, DoubleValue quality, DoubleValue flowDistanceQuality, DoubleValue overbookedCapacity, DoubleValue installationQuality, StringArray equipmentNames, StringArray locationNames, DoubleMatrix distances, DoubleMatrix weights, DoubleMatrix installationCosts, DoubleArray demands, DoubleArray capacities, DoubleValue transportationCosts, DoubleValue overbookedCapacityPenalty) 163 : this(assignment, quality, flowDistanceQuality, installationQuality, overbookedCapacity) { 222 164 this.distances = distances; 223 165 this.weights = weights; … … 227 169 this.transportationCosts = transportationCosts; 228 170 this.overbookedCapacityPenalty = overbookedCapacityPenalty; 229 this.flowDistanceQuality = flowDistanceQuality;230 this.installationQuality = installationQuality;231 this.overbookedCapacity = overbookedCapacity;232 171 } 233 172 -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GeneralizedQuadraticAssignmentProblem.cs
r7415 r7418 116 116 117 117 public BestGQAPSolutionAnalyzer BestSolutionAnalyzer { 118 get { return Operators.OfType<BestGQAPSolutionAnalyzer>().First(); } 118 get { return Operators.OfType<BestGQAPSolutionAnalyzer>().FirstOrDefault(); } 119 } 120 public GQAPSolutionArchiveAnalyzer SolutionArchiveAnalyzer { 121 get { return Operators.OfType<GQAPSolutionArchiveAnalyzer>().FirstOrDefault(); } 119 122 } 120 123 … … 165 168 166 169 SolutionCreator.AssignmentParameter.ActualName = "Assignment"; 167 Parameterize();168 170 169 171 InitializeOperators(); … … 212 214 private void InitializeOperators() { 213 215 Operators.Add(new BestGQAPSolutionAnalyzer()); 216 Operators.Add(new GQAPSolutionArchiveAnalyzer()); 214 217 Operators.AddRange(ApplicationManager.Manager.GetInstances<IGQAPOperator>()); 215 218 Operators.AddRange(ApplicationManager.Manager.GetInstances<IIntegerVectorOperator>()); … … 263 266 } 264 267 foreach (var op in Operators.OfType<IGQAPManipulator>()) { 265 op. IntegerVectorParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName;268 op.AssignmentParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName; 266 269 } 267 270 foreach (var op in Operators.OfType<IGQAPMerger>()) { … … 305 308 BestSolutionAnalyzer.LocationNamesParameter.ActualName = LocationNamesParameter.Name; 306 309 } 310 if (SolutionArchiveAnalyzer != null) { 311 SolutionArchiveAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name; 312 SolutionArchiveAnalyzer.DistancesParameter.ActualName = DistancesParameter.Name; 313 SolutionArchiveAnalyzer.WeightsParameter.ActualName = WeightsParameter.Name; 314 SolutionArchiveAnalyzer.InstallationCostsParameter.ActualName = InstallationCostsParameter.Name; 315 SolutionArchiveAnalyzer.DemandsParameter.ActualName = DemandsParameter.Name; 316 SolutionArchiveAnalyzer.CapacitiesParameter.ActualName = CapacitiesParameter.Name; 317 SolutionArchiveAnalyzer.TransportationCostsParameter.ActualName = TransportationCostsParameter.Name; 318 SolutionArchiveAnalyzer.OverbookedCapacityPenaltyParameter.ActualName = OverbookedCapacityPenaltyParameter.Name; 319 SolutionArchiveAnalyzer.AssignmentParameter.ActualName = SolutionCreator.AssignmentParameter.ActualName; 320 SolutionArchiveAnalyzer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName; 321 SolutionArchiveAnalyzer.FlowDistanceQualityParameter.ActualName = Evaluator.FlowDistanceQualityParameter.ActualName; 322 SolutionArchiveAnalyzer.InstallationQualityParameter.ActualName = Evaluator.InstallationQualityParameter.ActualName; 323 SolutionArchiveAnalyzer.OverbookedCapacityParameter.ActualName = Evaluator.OverbookedCapacityParameter.ActualName; 324 SolutionArchiveAnalyzer.ResultsParameter.ActualName = "Results"; 325 SolutionArchiveAnalyzer.BestKnownQualityParameter.ActualName = BestKnownQualityParameter.Name; 326 SolutionArchiveAnalyzer.BestKnownSolutionParameter.ActualName = BestKnownSolutionParameter.Name; 327 SolutionArchiveAnalyzer.EquipmentNamesParameter.ActualName = EquipmentNamesParameter.Name; 328 SolutionArchiveAnalyzer.LocationNamesParameter.ActualName = LocationNamesParameter.Name; 329 } 307 330 } 308 331 #endregion -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment-3.3.csproj
r7412 r7418 70 70 <Private>False</Private> 71 71 </Reference> 72 <Reference Include="HeuristicLab.Optimization.Operators-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 72 73 <Reference Include="HeuristicLab.Parameters-3.3"> 73 74 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Parameters-3.3.dll</HintPath> … … 89 90 <ItemGroup> 90 91 <Compile Include="Analyzers\BestGQAPSolutionAnalyzer.cs" /> 92 <Compile Include="Analyzers\GQAPSolutionArchiveAnalyzer.cs" /> 91 93 <Compile Include="Evaluators\GQAPNMoveEvaluator.cs" /> 92 94 <Compile Include="GQAPAssignment.cs" /> … … 94 96 <Compile Include="Evaluators\GQAPEvaluator.cs" /> 95 97 <Compile Include="GeneralizedQuadraticAssignmentProblem.cs" /> 98 <Compile Include="GQAPAssignmentArchive.cs" /> 96 99 <Compile Include="GQAPIntegerVectorProximityCalculator.cs" /> 100 <Compile Include="GQAPSolution.cs" /> 97 101 <Compile Include="Interfaces\IGQAPMerger.cs" /> 98 102 <Compile Include="Interfaces\IGQAPNMoveEvaluator.cs" /> … … 122 126 <Compile Include="Operators\GQAPSolutionCreator.cs" /> 123 127 <Compile Include="Operators\GreedyRandomizedSolutionCreator.cs" /> 128 <Compile Include="Operators\NMoveShakingOperator.cs" /> 124 129 <Compile Include="Operators\QualitySimilarityMerger.cs" /> 125 130 <Compile Include="Operators\RandomSolutionCreator.cs" /> -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Interfaces/IGQAPManipulator.cs
r7363 r7418 27 27 public interface IGQAPManipulator : IGQAPOperator, IManipulator { 28 28 ILookupParameter<IRandom> RandomParameter { get; } 29 ILookupParameter<IntegerVector> IntegerVectorParameter { get; }29 ILookupParameter<IntegerVector> AssignmentParameter { get; } 30 30 } 31 31 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Operators/GQAPManipulator.cs
r7319 r7418 38 38 get { return (LookupParameter<IRandom>)Parameters["Random"]; } 39 39 } 40 public ILookupParameter<IntegerVector> IntegerVectorParameter {40 public ILookupParameter<IntegerVector> AssignmentParameter { 41 41 get { return (ILookupParameter<IntegerVector>)Parameters["IntegerVector"]; } 42 42 } … … 52 52 53 53 public sealed override IOperation Apply() { 54 Manipulate(RandomParameter.ActualValue, IntegerVectorParameter.ActualValue);54 Manipulate(RandomParameter.ActualValue, AssignmentParameter.ActualValue); 55 55 return base.Apply(); 56 56 }
Note: See TracChangeset
for help on using the changeset viewer.