Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7471


Ignore:
Timestamp:
02/15/12 19:24:54 (12 years ago)
Author:
abeham
Message:

#1614

  • Added a button to recalculate the quality
Location:
branches/GeneralizedQAP
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentView.Designer.cs

    r7470 r7471  
    4949      this.qualityLabel = new System.Windows.Forms.Label();
    5050      this.assignmentGroupBox = new System.Windows.Forms.GroupBox();
     51      this.assignmentSplitContainer = new System.Windows.Forms.SplitContainer();
     52      this.assignmentView = new HeuristicLab.Data.Views.StringConvertibleArrayView();
    5153      this.characteristicsGroupBox = new System.Windows.Forms.GroupBox();
    5254      this.label7 = new System.Windows.Forms.Label();
     
    5658      this.label3 = new System.Windows.Forms.Label();
    5759      this.flowDistanceQualityLabel = new System.Windows.Forms.Label();
    58       this.assignmentSplitContainer = new System.Windows.Forms.SplitContainer();
    59       this.assignmentView = new HeuristicLab.Data.Views.StringConvertibleArrayView();
     60      this.recalculateButton = new System.Windows.Forms.Button();
    6061      this.assignmentGroupBox.SuspendLayout();
    61       this.characteristicsGroupBox.SuspendLayout();
    6262      ((System.ComponentModel.ISupportInitialize)(this.assignmentSplitContainer)).BeginInit();
    6363      this.assignmentSplitContainer.Panel1.SuspendLayout();
    6464      this.assignmentSplitContainer.Panel2.SuspendLayout();
    6565      this.assignmentSplitContainer.SuspendLayout();
     66      this.characteristicsGroupBox.SuspendLayout();
    6667      this.SuspendLayout();
    6768      //
     
    110111      this.assignmentGroupBox.Text = "Assignment";
    111112      //
     113      // assignmentSplitContainer
     114      //
     115      this.assignmentSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
     116      this.assignmentSplitContainer.Location = new System.Drawing.Point(3, 16);
     117      this.assignmentSplitContainer.Name = "assignmentSplitContainer";
     118      //
     119      // assignmentSplitContainer.Panel1
     120      //
     121      this.assignmentSplitContainer.Panel1.Controls.Add(this.assignmentTreeView);
     122      //
     123      // assignmentSplitContainer.Panel2
     124      //
     125      this.assignmentSplitContainer.Panel2.Controls.Add(this.assignmentView);
     126      this.assignmentSplitContainer.Size = new System.Drawing.Size(234, 337);
     127      this.assignmentSplitContainer.SplitterDistance = 78;
     128      this.assignmentSplitContainer.TabIndex = 4;
     129      //
     130      // assignmentView
     131      //
     132      this.assignmentView.Caption = "StringConvertibleArray View";
     133      this.assignmentView.Content = null;
     134      this.assignmentView.Dock = System.Windows.Forms.DockStyle.Fill;
     135      this.assignmentView.Location = new System.Drawing.Point(0, 0);
     136      this.assignmentView.Name = "assignmentView";
     137      this.assignmentView.ReadOnly = false;
     138      this.assignmentView.Size = new System.Drawing.Size(152, 337);
     139      this.assignmentView.TabIndex = 0;
     140      //
    112141      // characteristicsGroupBox
    113142      //
    114143      this.characteristicsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    115144            | System.Windows.Forms.AnchorStyles.Left)));
     145      this.characteristicsGroupBox.Controls.Add(this.recalculateButton);
    116146      this.characteristicsGroupBox.Controls.Add(this.label7);
    117147      this.characteristicsGroupBox.Controls.Add(this.overbookedCapacityLabel);
     
    189219      this.flowDistanceQualityLabel.Text = "-";
    190220      //
    191       // assignmentSplitContainer
    192       //
    193       this.assignmentSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
    194       this.assignmentSplitContainer.Location = new System.Drawing.Point(3, 16);
    195       this.assignmentSplitContainer.Name = "assignmentSplitContainer";
    196       //
    197       // assignmentSplitContainer.Panel1
    198       //
    199       this.assignmentSplitContainer.Panel1.Controls.Add(this.assignmentTreeView);
    200       //
    201       // assignmentSplitContainer.Panel2
    202       //
    203       this.assignmentSplitContainer.Panel2.Controls.Add(this.assignmentView);
    204       this.assignmentSplitContainer.Size = new System.Drawing.Size(234, 337);
    205       this.assignmentSplitContainer.SplitterDistance = 78;
    206       this.assignmentSplitContainer.TabIndex = 4;
    207       //
    208       // assignmentView
    209       //
    210       this.assignmentView.Caption = "StringConvertibleArray View";
    211       this.assignmentView.Content = null;
    212       this.assignmentView.Dock = System.Windows.Forms.DockStyle.Fill;
    213       this.assignmentView.Location = new System.Drawing.Point(0, 0);
    214       this.assignmentView.Name = "assignmentView";
    215       this.assignmentView.ReadOnly = false;
    216       this.assignmentView.Size = new System.Drawing.Size(152, 337);
    217       this.assignmentView.TabIndex = 0;
     221      // recalculateButton
     222      //
     223      this.recalculateButton.Location = new System.Drawing.Point(9, 95);
     224      this.recalculateButton.Name = "recalculateButton";
     225      this.recalculateButton.Size = new System.Drawing.Size(193, 23);
     226      this.recalculateButton.TabIndex = 5;
     227      this.recalculateButton.Text = "Recalculate";
     228      this.recalculateButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
     229      this.recalculateButton.UseVisualStyleBackColor = true;
     230      this.recalculateButton.Click += new System.EventHandler(this.recalculateButton_Click);
    218231      //
    219232      // GQAPAssignmentView
     
    226239      this.Size = new System.Drawing.Size(460, 362);
    227240      this.assignmentGroupBox.ResumeLayout(false);
    228       this.characteristicsGroupBox.ResumeLayout(false);
    229       this.characteristicsGroupBox.PerformLayout();
    230241      this.assignmentSplitContainer.Panel1.ResumeLayout(false);
    231242      this.assignmentSplitContainer.Panel2.ResumeLayout(false);
    232243      ((System.ComponentModel.ISupportInitialize)(this.assignmentSplitContainer)).EndInit();
    233244      this.assignmentSplitContainer.ResumeLayout(false);
     245      this.characteristicsGroupBox.ResumeLayout(false);
     246      this.characteristicsGroupBox.PerformLayout();
    234247      this.ResumeLayout(false);
    235248
     
    251264    private System.Windows.Forms.SplitContainer assignmentSplitContainer;
    252265    private Data.Views.StringConvertibleArrayView assignmentView;
     266    private System.Windows.Forms.Button recalculateButton;
    253267  }
    254268}
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment.Views/3.3/GQAPAssignmentView.cs

    r7470 r7471  
    2626using System.Linq;
    2727using System.Windows.Forms;
     28using HeuristicLab.Common.Resources;
    2829using HeuristicLab.Core.Views;
     30using HeuristicLab.Data;
    2931using HeuristicLab.Encodings.IntegerVectorEncoding;
    3032using HeuristicLab.MainForm;
     
    4446    public GQAPAssignmentView() {
    4547      InitializeComponent();
     48      recalculateButton.Image = VSImageLibrary.Refresh;
    4649    }
    4750
     
    307310    }
    308311    #endregion
     312
     313    private void recalculateButton_Click(object sender, EventArgs e) {
     314      double fdq, iq, oc;
     315      GQAPEvaluator.Evaluate(Content.Assignment, Content.Weights,
     316        Content.Distances, Content.InstallationCosts, Content.Demands,
     317        Content.Capacities, out fdq, out iq, out oc);
     318      Content.FlowDistanceQuality = new DoubleValue(fdq);
     319      Content.InstallationQuality = new DoubleValue(iq);
     320      Content.OverbookedCapacity = new DoubleValue(oc);
     321      Content.Quality = new DoubleValue(
     322        GQAPEvaluator.GetCombinedQuality(fdq, iq, oc,
     323        Content.TransportationCosts.Value, Content.OverbookedCapacityPenalty.Value));
     324    }
    309325  }
    310326}
  • branches/GeneralizedQAP/HeuristicLab.Problems.GeneralizedQuadraticAssignment/3.3/GeneralizedQuadraticAssignmentProblem.cs

    r7470 r7471  
    175175      DistancesParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
    176176      InstallationCostsParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
     177      DemandsParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
     178      CapacitiesParameter.ReactOnValueToStringChangedAndValueItemImageChanged = false;
    177179
    178180      Weights = new DoubleMatrix(5, 5);
     
    330332
    331333    private void EvaluateAndLoadAssignment(int[] vector) {
    332       var assignment = new IntegerVector(vector);
     334      EvaluateAndLoadAssignment(new IntegerVector(vector));
     335    }
     336    private void EvaluateAndLoadAssignment(IntegerVector assignment) {
     337      if (!IsConfigurationValid()) return;
    333338      double flowDistanceQuality, installationQuality, overbookedCapacity;
    334339      GQAPEvaluator.Evaluate(assignment, Weights, Distances, InstallationCosts, Demands, Capacities,
    335340        out flowDistanceQuality, out installationQuality, out overbookedCapacity);
    336341      double quality = GQAPEvaluator.GetCombinedQuality(flowDistanceQuality, installationQuality, overbookedCapacity, TransportationCosts.Value, OverbookedCapacityPenalty.Value);
    337       BestKnownSolution = new GQAPAssignment(assignment, new DoubleValue(quality),
     342      BestKnownSolution = new GQAPAssignment((IntegerVector)assignment.Clone(), new DoubleValue(quality),
    338343        new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality),
    339344        new DoubleValue(overbookedCapacity), EquipmentNames, LocationNames, Distances, Weights, InstallationCosts,
     
    341346      BestKnownQuality = new DoubleValue(quality);
    342347      BestKnownSolutions = new GQAPAssignmentArchive(EquipmentNames, LocationNames, Distances, Weights, InstallationCosts, Demands, Capacities, TransportationCosts, OverbookedCapacityPenalty);
    343       BestKnownSolutions.Solutions.Add(BestKnownSolution);
     348      BestKnownSolutions.Solutions.Add(new GQAPSolution((IntegerVector)assignment.Clone(), new DoubleValue(quality), new DoubleValue(flowDistanceQuality), new DoubleValue(installationQuality), new DoubleValue(overbookedCapacity)));
    344349    }
    345350
     
    480485    }
    481486    #endregion
     487
     488    private bool IsConfigurationValid() {
     489      return Weights != null && Distances != null && Demands != null && Capacities != null && InstallationCosts != null
     490        && Weights.Rows == Weights.Columns && Weights.Rows == InstallationCosts.Rows
     491        && Distances.Rows == Distances.Columns && Distances.Rows == InstallationCosts.Columns
     492        && Demands.Length == Weights.Rows && Capacities.Length == Distances.Rows;
     493    }
    482494  }
    483495}
Note: See TracChangeset for help on using the changeset viewer.