Free cookie consent management tool by TermsFeed Policy Generator

Changeset 4232


Ignore:
Timestamp:
08/16/10 17:05:23 (14 years ago)
Author:
svonolfe
Message:

Added TSPLIBParser (#1039)

Location:
branches/VRP
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.Designer.cs

    r4185 r4232  
    3030      this.tabPage2 = new System.Windows.Forms.TabPage();
    3131      this.vrpSolutionView = new HeuristicLab.Problems.VehicleRouting.Views.VRPSolutionView();
     32      this.importButton2 = new System.Windows.Forms.Button();
    3233      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    3334      this.tabControl1.SuspendLayout();
     
    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, 109);
    6364      this.tabControl1.Name = "tabControl1";
    6465      this.tabControl1.SelectedIndex = 0;
    65       this.tabControl1.Size = new System.Drawing.Size(490, 338);
     66      this.tabControl1.Size = new System.Drawing.Size(490, 313);
    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, 312);
     75      this.tabPage1.Size = new System.Drawing.Size(482, 287);
    7576      this.tabPage1.TabIndex = 0;
    7677      this.tabPage1.Text = "Parameters";
     
    8586      this.parameterCollectionView.Name = "parameterCollectionView";
    8687      this.parameterCollectionView.ReadOnly = false;
    87       this.parameterCollectionView.Size = new System.Drawing.Size(476, 306);
     88      this.parameterCollectionView.Size = new System.Drawing.Size(476, 281);
    8889      this.parameterCollectionView.TabIndex = 1;
    8990      //
     
    9495      this.tabPage2.Name = "tabPage2";
    9596      this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
    96       this.tabPage2.Size = new System.Drawing.Size(482, 312);
     97      this.tabPage2.Size = new System.Drawing.Size(482, 287);
    9798      this.tabPage2.TabIndex = 1;
    9899      this.tabPage2.Text = "Visualization";
     
    110111      this.vrpSolutionView.TabIndex = 0;
    111112      //
     113      // importButton2
     114      //
     115      this.importButton2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     116                  | System.Windows.Forms.AnchorStyles.Right)));
     117      this.importButton2.Location = new System.Drawing.Point(0, 81);
     118      this.importButton2.Name = "importButton2";
     119      this.importButton2.Size = new System.Drawing.Size(490, 23);
     120      this.importButton2.TabIndex = 7;
     121      this.importButton2.Text = "Import from TSPLib";
     122      this.importButton2.UseVisualStyleBackColor = true;
     123      this.importButton2.Click += new System.EventHandler(this.importButton2_Click);
     124      //
    112125      // VehicleRoutingProblemView
    113126      //
    114127      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     128      this.Controls.Add(this.importButton2);
    115129      this.Controls.Add(this.importButton);
    116130      this.Controls.Add(this.tabControl1);
     
    123137      this.Controls.SetChildIndex(this.descriptionLabel, 0);
    124138      this.Controls.SetChildIndex(this.descriptionTextBox, 0);
     139      this.Controls.SetChildIndex(this.importButton2, 0);
    125140      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    126141      this.tabControl1.ResumeLayout(false);
     
    140155    private Core.Views.ParameterCollectionView parameterCollectionView;
    141156    private VRPSolutionView vrpSolutionView;
     157    private System.Windows.Forms.Button importButton2;
    142158  }
    143159}
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.cs

    r4185 r4232  
    6464      parameterCollectionView.Enabled = Content != null;
    6565      vrpSolutionView.Enabled = Content != null;
    66       importButton.Enabled = Content != null && !ReadOnly;
     66      importButton.Enabled = importButton2.Enabled = Content != null && !ReadOnly;
    6767    }
    6868
     
    7676    }
    7777
     78    private void importButton2_Click(object sender, EventArgs e) {
     79      OpenFileDialog dialog = new OpenFileDialog();
     80      dialog.DefaultExt = "vrp";
     81
     82      if (dialog.ShowDialog() == DialogResult.OK) {
     83        Content.ImportFromTSPLib(dialog.FileName);
     84      }
     85    }
     86
    7887    private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
    7988      vrpSolutionView.Content.Coordinates = Content.Coordinates;
    80     }
     89    }   
    8190  }
    8291}
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj

    r4230 r4232  
    156156    <Compile Include="Encodings\Potvin\Manipulators\PotvinManipulator.cs" />
    157157    <Compile Include="Interfaces\IVRPMoveMaker.cs" />
     158    <Compile Include="TSPLIBParser.cs" />
    158159    <Compile Include="VRPUtilities.cs" />
    159160    <Compile Include="VRPOperator.cs" />
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

    r4179 r4232  
    431431    }
    432432
     433    public void ImportFromTSPLib(string tspFileName) {
     434      TSPLIBParser parser = new TSPLIBParser(tspFileName);
     435      parser.Parse();
     436
     437      this.Name = parser.Name;
     438
     439      int problemSize = parser.Demands.Length;
     440
     441      Coordinates = new DoubleMatrix(parser.Vertices);
     442      Vehicles.Value = problemSize - 1;
     443      Capacity.Value = parser.Capacity;
     444      Demand = new DoubleArray(parser.Demands);
     445      ReadyTime = new DoubleArray(problemSize);
     446      DueTime = new DoubleArray(problemSize);
     447      ServiceTime = new DoubleArray(problemSize);
     448
     449      for (int i = 0; i < problemSize; i++) {
     450        ReadyTime[i] = 0;
     451        DueTime[i] = int.MaxValue;
     452        ServiceTime[i] = 0;
     453      }
     454
     455      if (parser.Depot != 1)
     456        throw new Exception("Invalid depot specification");
     457
     458      if (parser.WeightType != TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D)
     459        throw new Exception("Invalid weight type");
     460
     461      OnReset();
     462    }
     463
    433464    private void InitializeRandomVRPInstance() {
    434465      System.Random rand = new System.Random();
Note: See TracChangeset for help on using the changeset viewer.