Changeset 7418 for branches/GeneralizedQAP
- Timestamp:
- 01/27/12 02:01:25 (13 years ago)
- Location:
- branches/GeneralizedQAP
- Files:
-
- 7 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentView.cs
r7415 r7418 46 46 protected override void DeregisterContentEvents() { 47 47 Content.PropertyChanged -= new PropertyChangedEventHandler(Content_PropertyChanged); 48 Content.Solution.PropertyChanged -= new PropertyChangedEventHandler(ContentSolution_PropertyChanged); 48 49 base.DeregisterContentEvents(); 49 50 } … … 51 52 base.RegisterContentEvents(); 52 53 Content.PropertyChanged += new PropertyChangedEventHandler(Content_PropertyChanged); 54 Content.Solution.PropertyChanged += new PropertyChangedEventHandler(ContentSolution_PropertyChanged); 53 55 } 54 56 #endregion … … 57 59 base.OnContentChanged(); 58 60 UpdateQuality(); 61 UpdateFlowDistanceQuality(); 62 UpdateInstallationQuality(); 63 UpdateOverbookedCapacity(); 59 64 UpdateAssignment(); 60 65 } … … 67 72 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) { 68 73 switch (e.PropertyName) { 74 case "EquipmentNames": UpdateAssignment(); break; 75 case "LocationNames": UpdateAssignment(); break; 76 default: break; 77 } 78 } 79 private void ContentSolution_PropertyChanged(object sender, PropertyChangedEventArgs e) { 80 switch (e.PropertyName) { 69 81 case "Quality": UpdateQuality(); break; 70 82 case "FlowDistanceQuality": UpdateFlowDistanceQuality(); break; … … 72 84 case "OverbookedCapacity": UpdateOverbookedCapacity(); break; 73 85 case "Assignment": UpdateAssignment(); break; 74 case "EquipmentNames": UpdateAssignment(); break;75 case "LocationNames": UpdateAssignment(); break;76 86 default: break; 77 87 } … … 85 95 qualityLabel.Text = "-"; 86 96 } else { 87 qualityLabel.Text = Content. Quality.ToString();97 qualityLabel.Text = Content.Solution.Quality.ToString(); 88 98 } 89 99 } … … 93 103 if (InvokeRequired) Invoke((Action)UpdateFlowDistanceQuality); 94 104 else { 95 if (Content == null || Content. FlowDistanceQuality == null) {105 if (Content == null || Content.Solution.FlowDistanceQuality == null) { 96 106 flowDistanceQualityLabel.Text = "-"; 97 107 } else { 98 flowDistanceQualityLabel.Text = Content. FlowDistanceQuality.ToString();108 flowDistanceQualityLabel.Text = Content.Solution.FlowDistanceQuality.ToString(); 99 109 } 100 110 } … … 104 114 if (InvokeRequired) Invoke((Action)UpdateInstallationQuality); 105 115 else { 106 if (Content == null || Content. InstallationQuality == null) {116 if (Content == null || Content.Solution.InstallationQuality == null) { 107 117 installationQualityLabel.Text = "-"; 108 118 } else { 109 installationQualityLabel.Text = Content. InstallationQuality.ToString();119 installationQualityLabel.Text = Content.Solution.InstallationQuality.ToString(); 110 120 } 111 121 } … … 115 125 if (InvokeRequired) Invoke((Action)UpdateOverbookedCapacity); 116 126 else { 117 if (Content == null || Content. OverbookedCapacity == null) {127 if (Content == null || Content.Solution.OverbookedCapacity == null) { 118 128 overbookedCapacityLabel.Text = "-"; 119 129 } else { 120 overbookedCapacityLabel.Text = Content. OverbookedCapacity.ToString();130 overbookedCapacityLabel.Text = Content.Solution.OverbookedCapacity.ToString(); 121 131 } 122 132 } … … 128 138 assignmentTreeView.Nodes.Clear(); 129 139 if (Content != null) { 130 IntegerVector assignment = Content. Assignment;140 IntegerVector assignment = Content.Solution.Assignment; 131 141 Dictionary<int, TreeNode> locationNodes = new Dictionary<int, TreeNode>(); 132 142 for (int i = 0; i < assignment.Length; i++) { -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views-3.3.csproj
r7412 r7418 38 38 </PropertyGroup> 39 39 <ItemGroup> 40 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 40 41 <Reference Include="HeuristicLab.Common-3.3"> 41 42 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath> … … 74 75 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 75 76 </Reference> 77 <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" /> 76 78 <Reference Include="System" /> 77 79 <Reference Include="System.Core" /> 78 80 <Reference Include="System.Drawing" /> 79 81 <Reference Include="System.Windows.Forms" /> 82 <Reference Include="System.Windows.Forms.DataVisualization" /> 80 83 <Reference Include="System.Xml.Linq" /> 81 84 <Reference Include="System.Data.DataSetExtensions" /> … … 85 88 </ItemGroup> 86 89 <ItemGroup> 90 <Compile Include="GQAPAssignmentArchiveView.cs"> 91 <SubType>UserControl</SubType> 92 </Compile> 93 <Compile Include="GQAPAssignmentArchiveView.Designer.cs"> 94 <DependentUpon>GQAPAssignmentArchiveView.cs</DependentUpon> 95 </Compile> 87 96 <Compile Include="GQAPAssignmentView.cs"> 88 97 <SubType>UserControl</SubType> … … 106 115 </ItemGroup> 107 116 <ItemGroup> 117 <EmbeddedResource Include="GQAPAssignmentArchiveView.resx"> 118 <DependentUpon>GQAPAssignmentArchiveView.cs</DependentUpon> 119 </EmbeddedResource> 108 120 <EmbeddedResource Include="GQAPAssignmentView.resx"> 109 121 <DependentUpon>GQAPAssignmentView.cs</DependentUpon> -
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.