Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4847 for trunk/sources


Ignore:
Timestamp:
11/19/10 11:12:40 (13 years ago)
Author:
svonolfe
Message:

Implemented review comments (#1236)

Location:
trunk/sources
Files:
2 added
6 edited

Legend:

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

    r4619 r4847  
    112112  <ItemGroup>
    113113    <Compile Include="HeuristicLabProblemsVehicleRoutingViewsPlugin.cs" />
     114    <Compile Include="VRPImportDialog.cs">
     115      <SubType>Form</SubType>
     116    </Compile>
     117    <Compile Include="VRPImportDialog.Designer.cs">
     118      <DependentUpon>VRPImportDialog.cs</DependentUpon>
     119    </Compile>
    114120    <Compile Include="VRPSolutionView.cs">
    115121      <SubType>UserControl</SubType>
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.Designer.cs

    r4619 r4847  
    2929      this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
    3030      this.tabPage2 = new System.Windows.Forms.TabPage();
    31       this.importButton2 = new System.Windows.Forms.Button();
    32       this.importButton3 = new System.Windows.Forms.Button();
    33       this.importBestButton = new System.Windows.Forms.Button();
    3431      this.vrpSolutionView = new HeuristicLab.Problems.VehicleRouting.Views.VRPSolutionView();
    3532      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     
    4643      // importButton
    4744      //
     45      this.importButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     46                  | System.Windows.Forms.AnchorStyles.Right)));
    4847      this.importButton.Location = new System.Drawing.Point(0, 55);
    4948      this.importButton.Name = "importButton";
    50       this.importButton.Size = new System.Drawing.Size(139, 23);
     49      this.importButton.Size = new System.Drawing.Size(490, 23);
    5150      this.importButton.TabIndex = 5;
    52       this.importButton.Text = "Import from Solomon";
     51      this.importButton.Text = "Import";
    5352      this.importButton.UseVisualStyleBackColor = true;
    5453      this.importButton.Click += new System.EventHandler(this.importButton_Click);
     
    6160      this.tabControl1.Controls.Add(this.tabPage1);
    6261      this.tabControl1.Controls.Add(this.tabPage2);
    63       this.tabControl1.Location = new System.Drawing.Point(0, 111);
     62      this.tabControl1.Location = new System.Drawing.Point(0, 84);
    6463      this.tabControl1.Name = "tabControl1";
    6564      this.tabControl1.SelectedIndex = 0;
    66       this.tabControl1.Size = new System.Drawing.Size(490, 255);
     65      this.tabControl1.Size = new System.Drawing.Size(490, 278);
    6766      this.tabControl1.TabIndex = 6;
    6867      //
     
    7372      this.tabPage1.Name = "tabPage1";
    7473      this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
    75       this.tabPage1.Size = new System.Drawing.Size(482, 229);
     74      this.tabPage1.Size = new System.Drawing.Size(482, 252);
    7675      this.tabPage1.TabIndex = 0;
    7776      this.tabPage1.Text = "Parameters";
     
    8887      this.parameterCollectionView.Name = "parameterCollectionView";
    8988      this.parameterCollectionView.ReadOnly = false;
    90       this.parameterCollectionView.Size = new System.Drawing.Size(476, 223);
     89      this.parameterCollectionView.Size = new System.Drawing.Size(476, 246);
    9190      this.parameterCollectionView.TabIndex = 1;
    9291      //
     
    101100      this.tabPage2.Text = "Visualization";
    102101      this.tabPage2.UseVisualStyleBackColor = true;
    103       //
    104       // importButton2
    105       //
    106       this.importButton2.Location = new System.Drawing.Point(145, 55);
    107       this.importButton2.Name = "importButton2";
    108       this.importButton2.Size = new System.Drawing.Size(126, 23);
    109       this.importButton2.TabIndex = 7;
    110       this.importButton2.Text = "Import from TSPLib";
    111       this.importButton2.UseVisualStyleBackColor = true;
    112       this.importButton2.Click += new System.EventHandler(this.importButton2_Click);
    113       //
    114       // importButton3
    115       //
    116       this.importButton3.Location = new System.Drawing.Point(277, 55);
    117       this.importButton3.Name = "importButton3";
    118       this.importButton3.Size = new System.Drawing.Size(131, 23);
    119       this.importButton3.TabIndex = 8;
    120       this.importButton3.Text = "Import from ORLib";
    121       this.importButton3.UseVisualStyleBackColor = true;
    122       this.importButton3.Click += new System.EventHandler(this.importButton3_Click);
    123       //
    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);
    133102      //
    134103      // vrpSolutionView
     
    146115      //
    147116      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    148       this.Controls.Add(this.importBestButton);
    149       this.Controls.Add(this.importButton3);
    150       this.Controls.Add(this.importButton2);
    151117      this.Controls.Add(this.importButton);
    152118      this.Controls.Add(this.tabControl1);
    153119      this.Name = "VehicleRoutingProblemView";
    154       this.Size = new System.Drawing.Size(490, 369);
     120      this.Size = new System.Drawing.Size(490, 365);
    155121      this.Controls.SetChildIndex(this.tabControl1, 0);
    156122      this.Controls.SetChildIndex(this.importButton, 0);
     
    159125      this.Controls.SetChildIndex(this.descriptionLabel, 0);
    160126      this.Controls.SetChildIndex(this.descriptionTextBox, 0);
    161       this.Controls.SetChildIndex(this.importButton2, 0);
    162       this.Controls.SetChildIndex(this.importButton3, 0);
    163       this.Controls.SetChildIndex(this.importBestButton, 0);
    164127      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    165128      this.tabControl1.ResumeLayout(false);
     
    179142    private Core.Views.ParameterCollectionView parameterCollectionView;
    180143    private VRPSolutionView vrpSolutionView;
    181     private System.Windows.Forms.Button importButton2;
    182     private System.Windows.Forms.Button importButton3;
    183     private System.Windows.Forms.Button importBestButton;
    184144  }
    185145}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.cs

    r4722 r4847  
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.Parameters;
     29using HeuristicLab.PluginInfrastructure;
    2930
    3031namespace HeuristicLab.Problems.VehicleRouting.Views {
     
    3233  [Content(typeof(VehicleRoutingProblem), true)]
    3334  public partial class VehicleRoutingProblemView : NamedItemView {
     35    private VRPImportDialog vrpImportDialog;
     36   
    3437    public new VehicleRoutingProblem Content {
    3538      get { return (VehicleRoutingProblem)base.Content; }
     
    6770      parameterCollectionView.Enabled = Content != null;
    6871      vrpSolutionView.Enabled = Content != null;
    69       importBestButton.Enabled = importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;
     72      importButton.Enabled = Content != null && !ReadOnly;
    7073    }
    7174
    7275    private void importButton_Click(object sender, EventArgs e) {
    73       OpenFileDialog dialog = new OpenFileDialog();
    74       dialog.Filter = "Solomon files (*.txt)|*.txt";
     76      if (vrpImportDialog == null) vrpImportDialog = new VRPImportDialog();
    7577
    76       if (dialog.ShowDialog() == DialogResult.OK) {
    77         Content.ImportFromSolomon(dialog.FileName);
     78      if (vrpImportDialog.ShowDialog(this) == DialogResult.OK) {
     79        try {
     80          switch (vrpImportDialog.Format) {
     81            case VRPFormat.TSPLib:
     82              Content.ImportFromTSPLib(vrpImportDialog.VRPFileName);
     83              break;
     84
     85            case VRPFormat.Solomon:
     86              Content.ImportFromSolomon(vrpImportDialog.VRPFileName);
     87              break;
     88
     89            case VRPFormat.ORLib:
     90              Content.ImportFromORLib(vrpImportDialog.VRPFileName);
     91              break;
     92          }
     93
     94          if(!string.IsNullOrEmpty(vrpImportDialog.TourFileName))
     95            Content.ImportSolution(vrpImportDialog.TourFileName);
     96         }
     97        catch (Exception ex) {
     98          ErrorHandling.ShowErrorDialog(this, ex);
     99        }
    78100      }
    79101    }
    80 
    81     private void importButton2_Click(object sender, EventArgs e) {
    82       OpenFileDialog dialog = new OpenFileDialog();
    83       dialog.Filter = "TSPLib files (*.vrp)|*.vrp";
    84 
    85       if (dialog.ShowDialog() == DialogResult.OK) {
    86         Content.ImportFromTSPLib(dialog.FileName);
    87       }
    88     }
    89 
    90     private void importBestButton_Click(object sender, EventArgs e) {
    91       OpenFileDialog dialog = new OpenFileDialog();
    92       dialog.Filter = "VRP solution files (*.opt)|*.opt";
    93 
    94       if (dialog.ShowDialog() == DialogResult.OK) {
    95         Content.ImportSolution(dialog.FileName);
    96       }
    97     }
    98 
    99     private void importButton3_Click(object sender, EventArgs e) {
    100       OpenFileDialog dialog = new OpenFileDialog();
    101       dialog.Filter = "ORLib files (*.txt)|*.txt";
    102 
    103       if (dialog.ShowDialog() == DialogResult.OK) {
    104         Content.ImportFromORLib(dialog.FileName);
    105       }
    106     } 
    107102
    108103    private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Evaluators/VRPEvaluator.cs

    r4722 r4847  
    116116      DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
    117117      DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor, DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
    118       DoubleMatrix coordinates, ILookupParameter<DoubleMatrix> distanceMatrix, BoolValue useDistanceMatrix) {
     118      DoubleMatrix coordinates, IParameter distanceMatrix, BoolValue useDistanceMatrix) {
    119119      TourEvaluation eval = new TourEvaluation();
    120120
     
    190190      DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
    191191      DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor, DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
    192       DoubleMatrix coordinates, ILookupParameter<DoubleMatrix> distanceMatrix, BoolValue useDistanceMatrix) {
     192      DoubleMatrix coordinates, IParameter distanceMatrix, BoolValue useDistanceMatrix) {
    193193      TourEvaluation sumEval = new TourEvaluation();
    194194      sumEval.Distance = 0;
     
    199199      sumEval.Tardiness = 0;
    200200
    201       foreach (Tour tour in solution.GetTours(distanceMatrix)) {
     201      foreach (Tour tour in solution.GetTours(distanceMatrix as ILookupParameter<DoubleMatrix>)) {
    202202        TourEvaluation eval = EvaluateTour(tour, dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
    203203          fleetUsageFactor, timeFactor, distanceFactor, overloadPenalty, tardinessPenalty,
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPUtilities.cs

    r4722 r4847  
    5757
    5858      if (useDistanceMatrix.Value) {
    59         if (distanceMatrix is IValueLookupParameter<DoubleMatrix>) {
    60           if ((distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value == null) {
    61             (distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value = CreateDistanceMatrix(coordinates);
     59        if (distanceMatrix is IValueParameter<DoubleMatrix>) {
     60          if ((distanceMatrix as IValueParameter<DoubleMatrix>).Value == null) {
     61            (distanceMatrix as IValueParameter<DoubleMatrix>).Value = CreateDistanceMatrix(coordinates);
    6262          }
    6363         
    64           distance = (distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value[start, end];
     64          distance = (distanceMatrix as IValueParameter<DoubleMatrix>).Value[start, end];
    6565        } else {
    6666          if (distanceMatrix.ActualValue == null) {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

    r4722 r4847  
    620620      this.Name = parser.ProblemName;
    621621
     622      BestKnownSolution = null;
    622623      Coordinates = new DoubleMatrix(parser.Coordinates);
    623624      Vehicles.Value = parser.Vehicles;
     
    636637
    637638      this.Name = parser.Name;
    638 
    639639      int problemSize = parser.Demands.Length;
    640640
     641      BestKnownSolution = null;
    641642      Coordinates = new DoubleMatrix(parser.Vertices);
    642643      if (parser.Vehicles != -1)
     
    661662
    662663      if (parser.Depot != 1)
    663         throw new Exception("Invalid depot specification");
     664        ErrorHandling.ShowErrorDialog(new Exception("Invalid depot specification"));
    664665
    665666      if (parser.WeightType != TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D)
    666         throw new Exception("Invalid weight type");
     667        ErrorHandling.ShowErrorDialog(new Exception("Invalid weight type"));
    667668
    668669      OnReset();
     
    672673      if (BestKnownSolution != null) {
    673674        //call evaluator
    674         IValueLookupParameter<DoubleMatrix> distMatrix = new ValueLookupParameter<DoubleMatrix>("DistMatrix",
     675        IValueParameter<DoubleMatrix> distMatrix = new ValueParameter<DoubleMatrix>("DistMatrix",
    675676          DistanceMatrix);
    676677
     
    716717
    717718      if (cities != Coordinates.Rows - 1)
    718         throw new Exception("Invalid solution");
    719 
    720       BestKnownSolutionParameter.Value = encoding;
     719        ErrorHandling.ShowErrorDialog(new Exception("Invalid solution"));
     720      else
     721        BestKnownSolutionParameter.Value = encoding;
    721722    }
    722723
     
    728729      int problemSize = parser.Demands.Length;
    729730
     731      BestKnownSolution = null;
    730732      Coordinates = new DoubleMatrix(parser.Vertices);
    731733      Vehicles.Value = problemSize - 1;
Note: See TracChangeset for help on using the changeset viewer.