Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/19/10 13:22:55 (14 years ago)
Author:
svonolfe
Message:

Add best known solution import for the VRP (TSPLib format) #1236

Location:
trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/HeuristicLab.Problems.VehicleRouting.Views-3.3.csproj

    r4065 r4619  
    172172      <Name>HeuristicLab.MainForm-3.3</Name>
    173173    </ProjectReference>
     174    <ProjectReference Include="..\..\HeuristicLab.Operators\3.3\HeuristicLab.Operators-3.3.csproj">
     175      <Project>{23DA7FF4-D5B8-41B6-AA96-F0561D24F3EE}</Project>
     176      <Name>HeuristicLab.Operators-3.3</Name>
     177    </ProjectReference>
    174178    <ProjectReference Include="..\..\HeuristicLab.Optimization.Views\3.3\HeuristicLab.Optimization.Views-3.3.csproj">
    175179      <Project>{662B4B15-8F4D-4AE5-B3EB-D91C215F5AF2}</Project>
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/HeuristicLabProblemsVehicleRoutingViewsPlugin.cs.frame

    r4497 r4619  
    3838  [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
    3939  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     40  [PluginDependency("HeuristicLab.Operators", "3.3")]
    4041  [PluginDependency("HeuristicLab.Optimization.Views", "3.3")]
    4142  [PluginDependency("HeuristicLab.Parameters", "3.3")]
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VRPSolutionView.Designer.cs

    r4352 r4619  
    123123      this.tourGridView.Location = new System.Drawing.Point(3, 16);
    124124      this.tourGridView.Name = "tourGridView";
     125      this.tourGridView.ReadOnly = true;
    125126      this.tourGridView.Size = new System.Drawing.Size(403, 507);
    126127      this.tourGridView.TabIndex = 0;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.Designer.cs

    r4352 r4619  
    3131      this.importButton2 = new System.Windows.Forms.Button();
    3232      this.importButton3 = new System.Windows.Forms.Button();
     33      this.importBestButton = new System.Windows.Forms.Button();
    3334      this.vrpSolutionView = new HeuristicLab.Problems.VehicleRouting.Views.VRPSolutionView();
    3435      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     
    6061      this.tabControl1.Controls.Add(this.tabPage1);
    6162      this.tabControl1.Controls.Add(this.tabPage2);
    62       this.tabControl1.Location = new System.Drawing.Point(0, 84);
     63      this.tabControl1.Location = new System.Drawing.Point(0, 111);
    6364      this.tabControl1.Name = "tabControl1";
    6465      this.tabControl1.SelectedIndex = 0;
    65       this.tabControl1.Size = new System.Drawing.Size(490, 265);
     66      this.tabControl1.Size = new System.Drawing.Size(490, 255);
    6667      this.tabControl1.TabIndex = 6;
    6768      //
     
    7273      this.tabPage1.Name = "tabPage1";
    7374      this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
    74       this.tabPage1.Size = new System.Drawing.Size(482, 239);
     75      this.tabPage1.Size = new System.Drawing.Size(482, 229);
    7576      this.tabPage1.TabIndex = 0;
    7677      this.tabPage1.Text = "Parameters";
     
    7980      // parameterCollectionView
    8081      //
     82      this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     83                  | System.Windows.Forms.AnchorStyles.Left)
     84                  | System.Windows.Forms.AnchorStyles.Right)));
    8185      this.parameterCollectionView.Caption = "ParameterCollection View";
    8286      this.parameterCollectionView.Content = null;
    83       this.parameterCollectionView.Dock = System.Windows.Forms.DockStyle.Fill;
    8487      this.parameterCollectionView.Location = new System.Drawing.Point(3, 3);
    8588      this.parameterCollectionView.Name = "parameterCollectionView";
    8689      this.parameterCollectionView.ReadOnly = false;
    87       this.parameterCollectionView.Size = new System.Drawing.Size(476, 233);
     90      this.parameterCollectionView.Size = new System.Drawing.Size(476, 223);
    8891      this.parameterCollectionView.TabIndex = 1;
    8992      //
     
    9497      this.tabPage2.Name = "tabPage2";
    9598      this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
    96       this.tabPage2.Size = new System.Drawing.Size(482, 239);
     99      this.tabPage2.Size = new System.Drawing.Size(482, 229);
    97100      this.tabPage2.TabIndex = 1;
    98101      this.tabPage2.Text = "Visualization";
     
    119122      this.importButton3.Click += new System.EventHandler(this.importButton3_Click);
    120123      //
     124      // importBestButton
     125      //
     126      this.importBestButton.Location = new System.Drawing.Point(0, 82);
     127      this.importBestButton.Name = "importBestButton";
     128      this.importBestButton.Size = new System.Drawing.Size(139, 23);
     129      this.importBestButton.TabIndex = 9;
     130      this.importBestButton.Text = "Import solution";
     131      this.importBestButton.UseVisualStyleBackColor = true;
     132      this.importBestButton.Click += new System.EventHandler(this.importBestButton_Click);
     133      //
    121134      // vrpSolutionView
    122135      //
     
    127140      this.vrpSolutionView.Name = "vrpSolutionView";
    128141      this.vrpSolutionView.ReadOnly = false;
    129       this.vrpSolutionView.Size = new System.Drawing.Size(476, 233);
     142      this.vrpSolutionView.Size = new System.Drawing.Size(476, 223);
    130143      this.vrpSolutionView.TabIndex = 0;
    131144      //
     
    133146      //
    134147      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     148      this.Controls.Add(this.importBestButton);
    135149      this.Controls.Add(this.importButton3);
    136150      this.Controls.Add(this.importButton2);
     
    138152      this.Controls.Add(this.tabControl1);
    139153      this.Name = "VehicleRoutingProblemView";
    140       this.Size = new System.Drawing.Size(490, 352);
     154      this.Size = new System.Drawing.Size(490, 369);
    141155      this.Controls.SetChildIndex(this.tabControl1, 0);
    142156      this.Controls.SetChildIndex(this.importButton, 0);
     
    147161      this.Controls.SetChildIndex(this.importButton2, 0);
    148162      this.Controls.SetChildIndex(this.importButton3, 0);
     163      this.Controls.SetChildIndex(this.importBestButton, 0);
    149164      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    150165      this.tabControl1.ResumeLayout(false);
     
    166181    private System.Windows.Forms.Button importButton2;
    167182    private System.Windows.Forms.Button importButton3;
     183    private System.Windows.Forms.Button importBestButton;
    168184  }
    169185}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.cs

    r4352 r4619  
    2626using HeuristicLab.Core.Views;
    2727using HeuristicLab.Core;
     28using HeuristicLab.Data;
     29using HeuristicLab.Parameters;
    2830
    2931namespace HeuristicLab.Problems.VehicleRouting.Views {
     
    4244    protected override void DeregisterContentEvents() {
    4345      Content.CoordinatesParameter.ValueChanged -= new EventHandler(CoordinatesParameter_ValueChanged);
     46      Content.BestKnownQualityParameter.ValueChanged -= new EventHandler(BestKnownQualityParameter_ValueChanged);
    4447      base.DeregisterContentEvents();
    4548    }
     
    4750      base.RegisterContentEvents();
    4851      Content.CoordinatesParameter.ValueChanged += new EventHandler(CoordinatesParameter_ValueChanged);
     52      Content.BestKnownQualityParameter.ValueChanged += new EventHandler(BestKnownQualityParameter_ValueChanged);
    4953    }
    5054
     
    5660      } else {
    5761        parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
    58         vrpSolutionView.Content = new VRPSolution(Content.Coordinates);
     62        UpdateSolution();
    5963      }
    6064    }
     
    6468      parameterCollectionView.Enabled = Content != null;
    6569      vrpSolutionView.Enabled = Content != null;
    66       importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;
     70      importBestButton.Enabled = importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;
    6771    }
    6872
     
    8589    }
    8690
     91    private void importBestButton_Click(object sender, EventArgs e) {
     92      OpenFileDialog dialog = new OpenFileDialog();
     93      dialog.Filter = "VRP solution files (*.opt)|*.opt";
     94
     95      if (dialog.ShowDialog() == DialogResult.OK) {
     96        Content.ImportSolution(dialog.FileName);
     97      }
     98    }
     99
    87100    private void importButton3_Click(object sender, EventArgs e) {
    88101      OpenFileDialog dialog = new OpenFileDialog();
     
    96109    private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
    97110      vrpSolutionView.Content.Coordinates = Content.Coordinates;
    98     } 
     111    }
     112
     113    private void UpdateSolution() {
     114      if (Content.BestKnownSolution == null)
     115        vrpSolutionView.Content = new VRPSolution(Content.Coordinates);
     116      else {
     117        //call evaluator
     118        IValueLookupParameter<DoubleMatrix> distMatrix = new ValueLookupParameter<DoubleMatrix>("DistMatrix",
     119          Content.DistanceMatrix);
     120
     121        TourEvaluation eval = VRPEvaluator.Evaluate(
     122          Content.BestKnownSolution,
     123          Content.Vehicles,
     124          Content.DueTime,
     125          Content.ServiceTime,
     126          Content.ReadyTime,
     127          Content.Demand,
     128          Content.Capacity,
     129          Content.FleetUsageFactorParameter.Value,
     130          Content.TimeFactorParameter.Value,
     131          Content.DistanceFactorParameter.Value,
     132          Content.OverloadPenaltyParameter.Value,
     133          Content.TardinessPenaltyParameter.Value,
     134          Content.Coordinates,
     135          distMatrix,
     136          Content.UseDistanceMatrix);
     137
     138        Content.DistanceMatrix = distMatrix.Value;
     139
     140        vrpSolutionView.Content = new VRPSolution(Content.Coordinates,
     141          Content.BestKnownSolution,
     142          new DoubleValue(eval.Quality),
     143          new DoubleValue(eval.Distance),
     144          new DoubleValue(eval.Overload),
     145          new DoubleValue(eval.Tardiness),
     146          new DoubleValue(eval.TravelTime),
     147          new DoubleValue(eval.VehcilesUtilized),
     148          Content.DistanceMatrix,
     149          Content.UseDistanceMatrix,
     150          Content.ReadyTime,
     151          Content.DueTime,
     152          Content.ServiceTime);
     153      }
     154    }
     155
     156   void BestKnownQualityParameter_ValueChanged(object sender, EventArgs e) {
     157      UpdateSolution();
     158    }
    99159  }
    100160}
Note: See TracChangeset for help on using the changeset viewer.