- Timestamp:
- 12/11/17 22:10:01 (7 years ago)
- Location:
- branches/GeneralizedQAP
- Files:
-
- 1 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentView.cs
r15504 r15510 61 61 protected override void OnContentChanged() { 62 62 base.OnContentChanged(); 63 UpdateQuality(); 64 UpdateFlowDistanceQuality(); 65 UpdateInstallationQuality(); 66 UpdateOverbookedCapacity(); 63 UpdateEvaluation(); 67 64 UpdateAssignment(); 68 65 if (Content != null) assignmentView.Content = Content.Assignment; … … 77 74 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) { 78 75 switch (e.PropertyName) { 79 case "Quality": UpdateQuality(); break; 80 case "FlowDistanceQuality": UpdateFlowDistanceQuality(); break; 81 case "InstallationQuality": UpdateInstallationQuality(); break; 82 case "OverbookedCapacity": UpdateOverbookedCapacity(); break; 83 case "Assignment": UpdateAssignment(); break; 84 case "EquipmentNames": UpdateAssignment(); break; 85 case "LocationNames": UpdateAssignment(); break; 76 case nameof(Content.Evaluation): UpdateEvaluation(); break; 77 case nameof(Content.Assignment): UpdateAssignment(); break; 78 case nameof(Content.ProblemInstance): UpdateEvaluation(); UpdateAssignment(); break; 86 79 default: break; 87 80 } … … 124 117 125 118 #region Helpers 126 private void Update Quality() {127 if (InvokeRequired) Invoke((Action)Update Quality);119 private void UpdateEvaluation() { 120 if (InvokeRequired) Invoke((Action)UpdateEvaluation); 128 121 else { 129 122 if (Content == null) { 130 123 qualityLabel.Text = "-"; 124 flowDistanceQualityLabel.Text = "-"; 125 installationQualityLabel.Text = "-"; 126 overbookedCapacityLabel.Text = "-"; 131 127 } else { 132 128 qualityLabel.Text = Content.ProblemInstance.ToSingleObjective(Content.Evaluation).ToString(); 133 }134 }135 }136 137 private void UpdateFlowDistanceQuality() {138 if (InvokeRequired) Invoke((Action)UpdateFlowDistanceQuality);139 else {140 if (Content == null || Content.Evaluation == null) {141 flowDistanceQualityLabel.Text = "-";142 } else {143 129 flowDistanceQualityLabel.Text = Content.Evaluation.FlowCosts.ToString(); 144 }145 }146 }147 148 private void UpdateInstallationQuality() {149 if (InvokeRequired) Invoke((Action)UpdateInstallationQuality);150 else {151 if (Content == null || Content.Evaluation == null) {152 installationQualityLabel.Text = "-";153 } else {154 130 installationQualityLabel.Text = Content.Evaluation.InstallationCosts.ToString(); 155 }156 }157 }158 159 private void UpdateOverbookedCapacity() {160 if (InvokeRequired) Invoke((Action)UpdateOverbookedCapacity);161 else {162 if (Content == null || Content.Evaluation == null) {163 overbookedCapacityLabel.Text = "-";164 } else {165 131 overbookedCapacityLabel.Text = Content.Evaluation.ExcessDemand.ToString(); 166 132 } -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3
- Property svn:ignore
-
old new 1 *.user 1 2 Plugin.cs 3 bin 2 4 obj 3 bin
-
- Property svn:ignore
-
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluation/Evaluation.cs
r15504 r15510 1 using System.Linq; 1 using System.Collections.Generic; 2 using System.Linq; 2 3 using HeuristicLab.Common; 3 4 using HeuristicLab.Core; … … 18 19 /// </summary> 19 20 [Storable] 20 public double ExcessDemand { get; set; }21 public double ExcessDemand { get; private set; } 21 22 /// <summary> 22 23 /// The amount of slack at each location, is negative in case of excess demand. … … 26 27 /// </remarks> 27 28 [Storable] 28 public double[] Slack { get; set; } 29 private double[] slack; 30 public IReadOnlyList<double> Slack { 31 get { return slack; } 32 } 29 33 /// <summary> 30 34 /// The quadratic part of the fitness function that represents the flow or transportation costs. 31 35 /// </summary> 32 36 [Storable] 33 public double FlowCosts { get; set; }37 public double FlowCosts { get; private set; } 34 38 /// <summary> 35 39 /// The linear part of the fitness function that represents the installation costs. 36 40 /// </summary> 37 41 [Storable] 38 public double InstallationCosts { get; set; }42 public double InstallationCosts { get; private set; } 39 43 40 44 [StorableConstructor] … … 43 47 : base(original, cloner) { 44 48 ExcessDemand = original.ExcessDemand; 45 if (original. Slack != null)46 Slack = original.Slack.ToArray();49 if (original.slack != null) 50 slack = original.slack.ToArray(); 47 51 FlowCosts = original.FlowCosts; 48 52 InstallationCosts = original.InstallationCosts; 49 53 } 50 public Evaluation() { } 54 public Evaluation(double flowCosts, double installationCosts, double excessDemand, double[] slack) { 55 FlowCosts = flowCosts; 56 InstallationCosts = installationCosts; 57 ExcessDemand = excessDemand; 58 this.slack = slack; 59 } 51 60 52 61 public override IDeepCloneable Clone(Cloner cloner) { -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/Evaluation/GQAPNMoveEvaluator.cs
r15507 r15510 85 85 public static Evaluation Evaluate(NMove move, IntegerVector assignment, Evaluation evaluation, GQAPInstance problemInstance) { 86 86 int moves = move.N; 87 var newEvaluation = new Evaluation() { 88 ExcessDemand = evaluation.ExcessDemand, 89 FlowCosts = evaluation.FlowCosts, 90 InstallationCosts = evaluation.InstallationCosts, 91 Slack = evaluation.Slack.ToArray() 92 }; 87 var excessDemand = evaluation.ExcessDemand; 88 var flowCosts = evaluation.FlowCosts; 89 var installationCosts = evaluation.InstallationCosts; 90 var slack = evaluation.Slack.ToArray(); 91 93 92 foreach (var kvp in move.NewAssignments) { 94 93 int equip = kvp.Key; … … 96 95 int oldLoc = assignment[equip]; 97 96 var equipDemand = problemInstance.Demands[equip]; 98 newEvaluation.InstallationCosts -= problemInstance.InstallationCosts[equip, oldLoc];99 newEvaluation.InstallationCosts += problemInstance.InstallationCosts[equip, newLoc];97 installationCosts -= problemInstance.InstallationCosts[equip, oldLoc]; 98 installationCosts += problemInstance.InstallationCosts[equip, newLoc]; 100 99 for (int j = 0; j < assignment.Length; j++) { 101 100 if (!move.NewAssignments.ContainsKey(j)) { 102 newEvaluation.FlowCosts += problemInstance.Weights[equip, j] * problemInstance.Distances[newLoc, assignment[j]];103 newEvaluation.FlowCosts -= problemInstance.Weights[equip, j] * problemInstance.Distances[oldLoc, assignment[j]];104 newEvaluation.FlowCosts += problemInstance.Weights[j, equip] * problemInstance.Distances[assignment[j], newLoc];105 newEvaluation.FlowCosts -= problemInstance.Weights[j, equip] * problemInstance.Distances[assignment[j], oldLoc];101 flowCosts += problemInstance.Weights[equip, j] * problemInstance.Distances[newLoc, assignment[j]]; 102 flowCosts -= problemInstance.Weights[equip, j] * problemInstance.Distances[oldLoc, assignment[j]]; 103 flowCosts += problemInstance.Weights[j, equip] * problemInstance.Distances[assignment[j], newLoc]; 104 flowCosts -= problemInstance.Weights[j, equip] * problemInstance.Distances[assignment[j], oldLoc]; 106 105 } else { 107 newEvaluation.FlowCosts += problemInstance.Weights[equip, j] * problemInstance.Distances[newLoc, move.NewAssignments[j]];108 newEvaluation.FlowCosts -= problemInstance.Weights[equip, j] * problemInstance.Distances[oldLoc, assignment[j]];106 flowCosts += problemInstance.Weights[equip, j] * problemInstance.Distances[newLoc, move.NewAssignments[j]]; 107 flowCosts -= problemInstance.Weights[equip, j] * problemInstance.Distances[oldLoc, assignment[j]]; 109 108 } 110 109 } 111 newEvaluation.Slack[oldLoc] += equipDemand;112 if ( newEvaluation.Slack[oldLoc] < equipDemand)113 newEvaluation.ExcessDemand -= Math.Min(equipDemand, equipDemand - newEvaluation.Slack[oldLoc]);114 newEvaluation.Slack[newLoc] -= equipDemand;115 if ( newEvaluation.Slack[newLoc] < 0)116 newEvaluation.ExcessDemand += Math.Min(equipDemand, -newEvaluation.Slack[newLoc]);110 slack[oldLoc] += equipDemand; 111 if (slack[oldLoc] < equipDemand) 112 excessDemand -= Math.Min(equipDemand, equipDemand - slack[oldLoc]); 113 slack[newLoc] -= equipDemand; 114 if (slack[newLoc] < 0) 115 excessDemand += Math.Min(equipDemand, -slack[newLoc]); 117 116 } 118 117 119 return new Evaluation;118 return new Evaluation(flowCosts, installationCosts, excessDemand, slack); 120 119 } 121 120 -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GQAP.cs
r15506 r15510 154 154 } 155 155 var archive = archiveResult.Value as GQAPAssignmentArchive; 156 if (archive == null) archive = new GQAPAssignmentArchive(ProblemInstance); 157 else archive.ProblemInstance = ProblemInstance; 156 if (archive == null) { 157 archive = new GQAPAssignmentArchive(ProblemInstance); 158 archiveResult.Value = archive; 159 } else archive.ProblemInstance = ProblemInstance; 158 160 159 161 var combinedArchive = solutions … … 401 403 402 404 private void InitializeOperators() { 403 Operators.Clear(); 405 Operators.RemoveAll(x => x is ISingleObjectiveMoveOperator); 406 Operators.RemoveAll(x => x is SingleObjectiveImprover); 404 407 Operators.AddRange(ApplicationManager.Manager.GetInstances<IGQAPOperator>()); 405 Operators.RemoveAll(x => x is ISingleObjectiveMoveEvaluator);406 408 Operators.AddRange(ApplicationManager.Manager.GetInstances<IGQAPMoveEvaluator>()); 407 409 Operators.Add(new HammingSimilarityCalculator() { SolutionVariableName = Encoding.Name, QualityVariableName = Evaluator.QualityParameter.ActualName }); -
branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GQAPInstance.cs
r15504 r15510 214 214 slack[assignI] -= demands[i]; 215 215 } 216 return new Evaluation() { 217 ExcessDemand = overbookedCapacity, 218 FlowCosts = flowDistanceQuality, 219 InstallationCosts = installationQuality, 220 Slack = slack 221 }; 216 return new Evaluation(flowDistanceQuality, installationQuality, overbookedCapacity, slack); 222 217 } 223 218
Note: See TracChangeset
for help on using the changeset viewer.