Changeset 4352


Ignore:
Timestamp:
09/01/10 11:13:46 (12 years ago)
Author:
svonolfe
Message:

Merged r4351 of the VRP feature branch into trunk (#1039)

Location:
trunk/sources
Files:
35 deleted
31 edited
80 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.VehicleRouting

  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views

  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VRPSolutionView.Designer.cs

    r4185 r4352  
    5050      this.valueTabPage = new System.Windows.Forms.TabPage();
    5151      this.tourGroupBox = new System.Windows.Forms.GroupBox();
    52       this.tourViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     52      this.tourGridView = new System.Windows.Forms.DataGridView();
    5353      this.tabControl.SuspendLayout();
    5454      this.visualizationTabPage.SuspendLayout();
     
    5656      this.valueTabPage.SuspendLayout();
    5757      this.tourGroupBox.SuspendLayout();
     58      ((System.ComponentModel.ISupportInitialize)(this.tourGridView)).BeginInit();
    5859      this.SuspendLayout();
    5960      //
     
    100101      this.valueTabPage.Name = "valueTabPage";
    101102      this.valueTabPage.Padding = new System.Windows.Forms.Padding(3);
    102       this.valueTabPage.Size = new System.Drawing.Size(415, 398);
     103      this.valueTabPage.Size = new System.Drawing.Size(415, 532);
    103104      this.valueTabPage.TabIndex = 1;
    104105      this.valueTabPage.Text = "Value";
     
    107108      // tourGroupBox
    108109      //
    109       this.tourGroupBox.Controls.Add(this.tourViewHost);
     110      this.tourGroupBox.Controls.Add(this.tourGridView);
    110111      this.tourGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
    111112      this.tourGroupBox.Location = new System.Drawing.Point(3, 3);
    112113      this.tourGroupBox.Name = "tourGroupBox";
    113       this.tourGroupBox.Size = new System.Drawing.Size(409, 392);
     114      this.tourGroupBox.Size = new System.Drawing.Size(409, 526);
    114115      this.tourGroupBox.TabIndex = 0;
    115116      this.tourGroupBox.TabStop = false;
    116117      this.tourGroupBox.Text = "Tour";
    117118      //
    118       // tourViewHost
     119      // tourGridView
    119120      //
    120       this.tourViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    121                   | System.Windows.Forms.AnchorStyles.Left)
    122                   | System.Windows.Forms.AnchorStyles.Right)));
    123       this.tourViewHost.Caption = "View";
    124       this.tourViewHost.Content = null;
    125       this.tourViewHost.Location = new System.Drawing.Point(6, 19);
    126       this.tourViewHost.Name = "tourViewHost";
    127       this.tourViewHost.ReadOnly = false;
    128       this.tourViewHost.Size = new System.Drawing.Size(397, 367);
    129       this.tourViewHost.TabIndex = 0;
    130       this.tourViewHost.ViewType = null;
     121      this.tourGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
     122      this.tourGridView.Dock = System.Windows.Forms.DockStyle.Fill;
     123      this.tourGridView.Location = new System.Drawing.Point(3, 16);
     124      this.tourGridView.Name = "tourGridView";
     125      this.tourGridView.Size = new System.Drawing.Size(403, 507);
     126      this.tourGridView.TabIndex = 0;
    131127      //
    132128      // VRPSolutionView
     
    142138      this.valueTabPage.ResumeLayout(false);
    143139      this.tourGroupBox.ResumeLayout(false);
     140      ((System.ComponentModel.ISupportInitialize)(this.tourGridView)).EndInit();
    144141      this.ResumeLayout(false);
    145142
     
    153150    private System.Windows.Forms.TabPage valueTabPage;
    154151    private System.Windows.Forms.GroupBox tourGroupBox;
    155     private MainForm.WindowsForms.ViewHost tourViewHost;
     152    private System.Windows.Forms.DataGridView tourGridView;
    156153
    157154
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VRPSolutionView.cs

    r4185 r4352  
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.Problems.VehicleRouting.Encodings;
     29using HeuristicLab.Parameters;
     30using System.Linq;
    2931
    3032namespace HeuristicLab.Problems.VehicleRouting.Views {
     
    6769      } else {
    6870        GenerateImage();
    69         tourViewHost.Content = Content.Solution;
     71        UpdateTourView();
    7072      }
    7173    }
     
    8082      pictureBox.Enabled = Content != null;
    8183      tourGroupBox.Enabled = Content != null;
     84    }
     85
     86    private void UpdateTourView() {
     87      tourGridView.Rows.Clear();
     88      tourGridView.ColumnCount = Content.Coordinates.Rows - 1;
     89
     90      if (Content != null && Content.Solution != null) {
     91        foreach (Tour tour in Content.Solution.GetTours(new ValueLookupParameter<DoubleMatrix>("DistanceMatrix", Content.DistanceMatrix))) {
     92          int row = tourGridView.Rows.Add();
     93          int cell = 0;
     94          foreach (int city in tour.Cities) {
     95            tourGridView.Rows[row].Cells[cell].Value = city;
     96            cell++;
     97          }
     98        }
     99      }
    82100    }
    83101
     
    119137              if (Content.Solution != null) {
    120138                int currentTour = 0;
    121                 foreach (Tour tour in Content.Solution.Tours) {
     139                foreach (Tour tour in Content.Solution.GetTours(new ValueLookupParameter<DoubleMatrix>("DistanceMatrix", distanceMatrix))) {
    122140                  double t = 0.0;
    123141                  Point[] tourPoints = new Point[tour.Cities.Count + 2];
     
    202220      else {
    203221        GenerateImage();
    204         tourViewHost.Content = Content.Solution;
     222        UpdateTourView();
    205223      }
    206224    }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.Designer.cs

    r4185 r4352  
    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();
    3133      this.vrpSolutionView = new HeuristicLab.Problems.VehicleRouting.Views.VRPSolutionView();
    3234      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
     
    4345      // importButton
    4446      //
    45       this.importButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    46                   | System.Windows.Forms.AnchorStyles.Right)));
    4747      this.importButton.Location = new System.Drawing.Point(0, 55);
    4848      this.importButton.Name = "importButton";
    49       this.importButton.Size = new System.Drawing.Size(490, 23);
     49      this.importButton.Size = new System.Drawing.Size(139, 23);
    5050      this.importButton.TabIndex = 5;
    5151      this.importButton.Text = "Import from Solomon";
     
    6363      this.tabControl1.Name = "tabControl1";
    6464      this.tabControl1.SelectedIndex = 0;
    65       this.tabControl1.Size = new System.Drawing.Size(490, 338);
     65      this.tabControl1.Size = new System.Drawing.Size(490, 265);
    6666      this.tabControl1.TabIndex = 6;
    6767      //
     
    7272      this.tabPage1.Name = "tabPage1";
    7373      this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
    74       this.tabPage1.Size = new System.Drawing.Size(482, 312);
     74      this.tabPage1.Size = new System.Drawing.Size(482, 239);
    7575      this.tabPage1.TabIndex = 0;
    7676      this.tabPage1.Text = "Parameters";
     
    8585      this.parameterCollectionView.Name = "parameterCollectionView";
    8686      this.parameterCollectionView.ReadOnly = false;
    87       this.parameterCollectionView.Size = new System.Drawing.Size(476, 306);
     87      this.parameterCollectionView.Size = new System.Drawing.Size(476, 233);
    8888      this.parameterCollectionView.TabIndex = 1;
    8989      //
     
    9494      this.tabPage2.Name = "tabPage2";
    9595      this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
    96       this.tabPage2.Size = new System.Drawing.Size(482, 312);
     96      this.tabPage2.Size = new System.Drawing.Size(482, 239);
    9797      this.tabPage2.TabIndex = 1;
    9898      this.tabPage2.Text = "Visualization";
    9999      this.tabPage2.UseVisualStyleBackColor = true;
     100      //
     101      // importButton2
     102      //
     103      this.importButton2.Location = new System.Drawing.Point(145, 55);
     104      this.importButton2.Name = "importButton2";
     105      this.importButton2.Size = new System.Drawing.Size(126, 23);
     106      this.importButton2.TabIndex = 7;
     107      this.importButton2.Text = "Import from TSPLib";
     108      this.importButton2.UseVisualStyleBackColor = true;
     109      this.importButton2.Click += new System.EventHandler(this.importButton2_Click);
     110      //
     111      // importButton3
     112      //
     113      this.importButton3.Location = new System.Drawing.Point(277, 55);
     114      this.importButton3.Name = "importButton3";
     115      this.importButton3.Size = new System.Drawing.Size(131, 23);
     116      this.importButton3.TabIndex = 8;
     117      this.importButton3.Text = "Import from ORLib";
     118      this.importButton3.UseVisualStyleBackColor = true;
     119      this.importButton3.Click += new System.EventHandler(this.importButton3_Click);
    100120      //
    101121      // vrpSolutionView
     
    107127      this.vrpSolutionView.Name = "vrpSolutionView";
    108128      this.vrpSolutionView.ReadOnly = false;
    109       this.vrpSolutionView.Size = new System.Drawing.Size(476, 306);
     129      this.vrpSolutionView.Size = new System.Drawing.Size(476, 233);
    110130      this.vrpSolutionView.TabIndex = 0;
    111131      //
     
    113133      //
    114134      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     135      this.Controls.Add(this.importButton3);
     136      this.Controls.Add(this.importButton2);
    115137      this.Controls.Add(this.importButton);
    116138      this.Controls.Add(this.tabControl1);
    117139      this.Name = "VehicleRoutingProblemView";
    118       this.Size = new System.Drawing.Size(490, 422);
     140      this.Size = new System.Drawing.Size(490, 352);
    119141      this.Controls.SetChildIndex(this.tabControl1, 0);
    120142      this.Controls.SetChildIndex(this.importButton, 0);
     
    123145      this.Controls.SetChildIndex(this.descriptionLabel, 0);
    124146      this.Controls.SetChildIndex(this.descriptionTextBox, 0);
     147      this.Controls.SetChildIndex(this.importButton2, 0);
     148      this.Controls.SetChildIndex(this.importButton3, 0);
    125149      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    126150      this.tabControl1.ResumeLayout(false);
     
    140164    private Core.Views.ParameterCollectionView parameterCollectionView;
    141165    private VRPSolutionView vrpSolutionView;
     166    private System.Windows.Forms.Button importButton2;
     167    private System.Windows.Forms.Button importButton3;
    142168  }
    143169}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting.Views/3.3/VehicleRoutingProblemView.cs

    r4185 r4352  
    6464      parameterCollectionView.Enabled = Content != null;
    6565      vrpSolutionView.Enabled = Content != null;
    66       importButton.Enabled = Content != null && !ReadOnly;
     66      importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;
    6767    }
    6868
    6969    private void importButton_Click(object sender, EventArgs e) {
    7070      OpenFileDialog dialog = new OpenFileDialog();
    71       dialog.DefaultExt = "txt";
     71      dialog.Filter = "Solomon files (*.txt)|*.txt";
    7272
    7373      if (dialog.ShowDialog() == DialogResult.OK) {
     
    7676    }
    7777
     78    private void importButton2_Click(object sender, EventArgs e) {
     79      OpenFileDialog dialog = new OpenFileDialog();
     80      dialog.Filter = "TSPLib files (*.vrp)|*.vrp";
     81
     82      if (dialog.ShowDialog() == DialogResult.OK) {
     83        Content.ImportFromTSPLib(dialog.FileName);
     84      }
     85    }
     86
     87    private void importButton3_Click(object sender, EventArgs e) {
     88      OpenFileDialog dialog = new OpenFileDialog();
     89      dialog.Filter = "ORLib files (*.txt)|*.txt";
     90
     91      if (dialog.ShowDialog() == DialogResult.OK) {
     92        Content.ImportFromORLib(dialog.FileName);
     93      }
     94    } 
     95
    7896    private void CoordinatesParameter_ValueChanged(object sender, EventArgs e) {
    7997      vrpSolutionView.Content.Coordinates = Content.Coordinates;
    80     }
     98    } 
    8199  }
    82100}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Analyzers/BestVRPSolutionAnalyzer.cs

    r4185 r4352  
    128128        results.Add(new Result("Best VRP Solution", solution));
    129129
    130         results.Add(new Result("Best TravelTime", new DoubleValue(travelTimes[i].Value)));
    131         results.Add(new Result("Best Distance",  new DoubleValue(distances[i].Value)));
    132         results.Add(new Result("Best VehicleUtilization", new DoubleValue(vehiclesUtilizations[i].Value)));
    133         results.Add(new Result("Best Overload",  new DoubleValue(overloads[i].Value)));
    134         results.Add(new Result("Best Tardiness",  new DoubleValue(tardinesses[i].Value)));
     130        results.Add(new Result("Best VRP Solution TravelTime", new DoubleValue(travelTimes[i].Value)));
     131        results.Add(new Result("Best VRP Solution Distance", new DoubleValue(distances[i].Value)));
     132        results.Add(new Result("Best VRP Solution VehicleUtilization", new DoubleValue(vehiclesUtilizations[i].Value)));
     133        results.Add(new Result("Best VRP Solution Overload", new DoubleValue(overloads[i].Value)));
     134        results.Add(new Result("Best VRP Solution Tardiness", new DoubleValue(tardinesses[i].Value)));
     135
    135136      } else {
    136         if (solution.Quality.Value > qualities[i].Value) {
     137        if (qualities[i].Value <= solution.Quality.Value) {
    137138          solution.Coordinates = coordinates;
    138139          solution.Solution = best.Clone() as IVRPEncoding;
    139140          solution.Quality.Value = qualities[i].Value;
    140           solution.Distance.Value = (results["Best Distance"].Value as DoubleValue).Value = distances[i].Value;
    141           solution.Overload.Value = (results["Best Overload"].Value as DoubleValue).Value = overloads[i].Value;
    142           solution.Tardiness.Value = (results["Best Tardiness"].Value as DoubleValue).Value = tardinesses[i].Value;
    143           solution.TravelTime.Value = (results["Best TravelTime"].Value as DoubleValue).Value = travelTimes[i].Value;
    144           solution.VehicleUtilization.Value = (results["Best VehicleUtilization"].Value as DoubleValue).Value = vehiclesUtilizations[i].Value;
     141          solution.Distance.Value = (results["Best VRP Solution Distance"].Value as DoubleValue).Value = distances[i].Value;
     142          solution.Overload.Value = (results["Best VRP Solution Overload"].Value as DoubleValue).Value = overloads[i].Value;
     143          solution.Tardiness.Value = (results["Best VRP Solution Tardiness"].Value as DoubleValue).Value = tardinesses[i].Value;
     144          solution.TravelTime.Value = (results["Best VRP Solution TravelTime"].Value as DoubleValue).Value = travelTimes[i].Value;
     145          solution.VehicleUtilization.Value = (results["Best VRP Solution VehicleUtilization"].Value as DoubleValue).Value = vehiclesUtilizations[i].Value;
    145146          solution.DistanceMatrix = DistanceMatrixParameter.ActualValue;
    146147          solution.UseDistanceMatrix = UseDistanceMatrixParameter.ActualValue;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/AlbaEncoding.cs

    r4204 r4352  
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2727using System.Collections.Generic;
     28using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    2829
    2930namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
    3031  [Item("AlbaEncoding", "Represents an Alba encoding of VRP solutions. It is implemented as described in Alba, E. and Dorronsoro, B. (2004). Solving the Vehicle Routing Problem by Using Cellular Genetic Algorithms.")]
    3132  [StorableClass]
    32   public class AlbaEncoding : Permutation, IVRPEncoding {
     33  public class AlbaEncoding : PermutationEncoding {
    3334    [Storable]
    3435    private int cities;
    3536   
    3637    #region IVRPEncoding Members
    37     public ItemList<Tour> Tours {
    38       get {
    39         ItemList<Tour> result = new ItemList<Tour>();
    40        
    41         Tour tour = new Tour();
    42         for (int i = 0; i < this.array.Length; i++) {
    43           if (this.array[i] >= cities) {
    44             if (tour.Cities.Count > 0) {
    45               result.Add(tour);
     38    public override List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix = null, int maxVehicles = int.MaxValue) {
     39      List<Tour> result = new List<Tour>();
    4640
    47               tour = new Tour();
    48             }
    49           } else {
    50             tour.Cities.Add(this.array[i] + 1);
     41      Tour tour = new Tour();
     42      for (int i = 0; i < this.array.Length; i++) {
     43        if (this.array[i] >= cities) {
     44          if (tour.Cities.Count > 0) {
     45            result.Add(tour);
     46
     47            tour = new Tour();
    5148          }
     49        } else {
     50          tour.Cities.Add(this.array[i] + 1);
    5251        }
     52      }
    5353
    54         if (tour.Cities.Count > 0) {
    55           result.Add(tour);
    56         }
     54      if (tour.Cities.Count > 0) {
     55        result.Add(tour);
     56      }
    5757
    58         return result;
    59       }
     58      return result;
    6059    }
    6160
     
    6564
    6665    public int MaxVehicles {
    67       get { return Length - Cities;  }
     66      get { return Length - Cities + 1;  }
    6867    }
    6968
     
    7978
    8079    public AlbaEncoding(Permutation permutation, int cities)
    81       : base(PermutationTypes.RelativeUndirected) {
    82       this.array = new int[permutation.Length];
    83       for (int i = 0; i < array.Length; i++)
    84         this.array[i] = permutation[i];
    85 
     80      : base(permutation) {
    8681      this.cities = cities;
    8782    }
     
    8984    [StorableConstructor]
    9085    private AlbaEncoding(bool serializing)
    91       : base() {
     86      : base(serializing) {
    9287    }
    9388
    94     public static AlbaEncoding ConvertFrom(IVRPEncoding encoding, int vehicles) {
    95       ItemList<Tour> tours = encoding.Tours;
     89    public static AlbaEncoding ConvertFrom(IVRPEncoding encoding, int vehicles, ILookupParameter<DoubleMatrix> distanceMatrix) {
     90      List<Tour> tours = encoding.GetTours(distanceMatrix, vehicles);
    9691
    9792      int cities = 0;
     
    132127    public static AlbaEncoding ConvertFrom(List<int> routeParam) {
    133128      List<int> route = new List<int>(routeParam);
     129      route.RemoveAt(routeParam.Count - 1);
    134130     
    135131      int cities = 0;
     
    156152
    157153    internal static void RemoveUnusedParameters(ParameterCollection parameters) {
    158       parameters.Remove("DistanceMatrix");
    159154      parameters.Remove("UseDistanceMatrix");
    160155      parameters.Remove("Capacity");
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Crossovers/AlbaCrossover.cs

    r4206 r4352  
    5353
    5454        if (!(solution is AlbaEncoding)) {
    55           parents[i] = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
     55          parents[i] = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value,
     56            DistanceMatrixParameter);
    5657        } else {
    5758          parents[i] = solution;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Manipulators/AlbaManipulator.cs

    r4206 r4352  
    6262      IVRPEncoding solution = VRPToursParameter.ActualValue;
    6363      if (!(solution is AlbaEncoding)) {
    64         VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
     64        VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value, DistanceMatrixParameter);
    6565      }
    6666
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveMaker.cs

    r4208 r4352  
    2626
    2727namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
    28   [Item("PermutationTranslocationMoveMaker", "An operator which makes translocation moves for the Alba representation.")]
     28  [Item("AlbaTranslocationMoveMaker", "An operator which makes translocation moves for the Alba representation.")]
    2929  [StorableClass]
    3030  public abstract class AlbaMoveMaker : AlbaMoveOperator {
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/AlbaMoveOperator.cs

    r4204 r4352  
    4141      IVRPEncoding solution = VRPToursParameter.ActualValue;
    4242      if (!(solution is AlbaEncoding)) {
    43         VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value);
     43        VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(solution, VehiclesParameter.ActualValue.Value,
     44          DistanceMatrixParameter);
    4445      }
    4546
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/Interfaces/IAlbaIntraRouteInversionMoveOperator.cs

    r4206 r4352  
    2626namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
    2727  public interface IAlbaIntraRouteInversionMoveOperator : IVRPMoveOperator {
    28     ILookupParameter<IntraRouteInversionMove> IntraRouteInversionMoveParameter { get; }
     28    ILookupParameter<AlbaIntraRouteInversionMove> IntraRouteInversionMoveParameter { get; }
    2929  }
    3030}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Alba/Moves/Interfaces/IAlbaLambdaInterchangeMoveOperator.cs

    r4204 r4352  
    2626namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
    2727  public interface IAlbaLambdaInterchangeMoveOperator : IVRPMoveOperator {
    28     ILookupParameter<LambdaInterchangeMove> LambdaInterchangeMoveParameter { get; }
     28    ILookupParameter<AlbaLambdaInterchangeMove> LambdaInterchangeMoveParameter { get; }
    2929  }
    3030}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Creators/PushForwardInsertionCreator.cs

    r4183 r4352  
    225225      int customer = -1;
    226226      int subTourCount = 1;
    227       List<int> route = new List<int>(CitiesParameter.ActualValue.Value + VehiclesParameter.ActualValue.Value - 1);
     227      List<int> route = new List<int>(Cities + VehiclesParameter.ActualValue.Value - 1);
    228228      minimumCost = double.MaxValue;
    229229      indexOfMinimumCost = -1;
     
    271271        customer = -1;
    272272      } while (unroutedList.Count > 0);
    273       while (route.Count < CitiesParameter.ActualValue.Value + VehiclesParameter.ActualValue.Value - 1)
     273      while (route.Count < Cities + VehiclesParameter.ActualValue.Value - 1)
    274274        route.Add(0);
    275275
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/Interfaces/IVRPMove.cs

    r4205 r4352  
    2727namespace HeuristicLab.Problems.VehicleRouting.Encodings.General {
    2828  public interface IVRPMove : IItem {
    29     TourEvaluation GetMoveQuality(IVRPEncoding individual,
     29    TourEvaluation GetMoveQuality(IntValue vehicles,
    3030        DoubleArray dueTimeArray, DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray,
    3131        DoubleValue capacity,DoubleMatrix coordinates,
     
    3434      ILookupParameter<DoubleMatrix> distanceMatrix, BoolValue useDistanceMatrix);
    3535
    36     void MakeMove(IRandom random, IVRPEncoding individual);
     36    IVRPEncoding MakeMove();
    3737  }
    3838}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveEvaluator.cs

    r4205 r4352  
    4646
    4747      return move.GetMoveQuality(
    48         VRPToursParameter.ActualValue,
     48        VehiclesParameter.ActualValue,
    4949        DueTimeParameter.ActualValue,
    5050        ServiceTimeParameter.ActualValue,
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveGenerator.cs

    r4205 r4352  
    118118      Parameters.Add(new LookupParameter<IVRPMove>("VRPMove", "The generated moves."));
    119119
    120       foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(IMultiVRPMoveGenerator))) {
     120      foreach (Type type in ApplicationManager.Manager.GetTypes(typeof(IMultiVRPMoveGenerator)).OrderBy(op => op.Name)) {
    121121        if (!typeof(MultiOperator<IMultiVRPMoveGenerator>).IsAssignableFrom(type))
    122122          Operators.Add((IMultiVRPMoveGenerator)Activator.CreateInstance(type), true);
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/General/Moves/MultiVRPMoveOperator/MultiVRPMoveMaker.cs

    r4205 r4352  
    114114     
    115115      //perform move
    116       move.MakeMove(RandomParameter.ActualValue, VRPToursParameter.ActualValue);
     116      VRPToursParameter.ActualValue = move.MakeMove();
    117117
    118118      quality.Value = moveQuality.Value;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Crossovers/PotvinCrossover.cs

    r4206 r4352  
    129129
    130130        if (!(solution is PotvinEncoding)) {
    131           parents[i] = PotvinEncoding.ConvertFrom(solution);
     131          parents[i] = PotvinEncoding.ConvertFrom(solution, DistanceMatrixParameter);
    132132        } else {
    133133          parents[i] = solution;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/Manipulators/PotvinManipulator.cs

    r4206 r4352  
    8282      IVRPEncoding solution = VRPToursParameter.ActualValue;
    8383      if (!(solution is PotvinEncoding)) {
    84         VRPToursParameter.ActualValue = PotvinEncoding.ConvertFrom(solution);
     84        VRPToursParameter.ActualValue = PotvinEncoding.ConvertFrom(solution, DistanceMatrixParameter);
    8585      }
    8686     
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/Potvin/PotvinEncoding.cs

    r4177 r4352  
    2727using System.Drawing;
    2828using System.Collections.Generic;
     29using HeuristicLab.Problems.VehicleRouting.Encodings.General;
    2930
    3031namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
    3132  [Item("PotvinEncoding", "Represents a potvin encoding of VRP solutions. It is implemented as described in Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172.")]
    3233  [StorableClass]
    33   public class PotvinEncoding : Item, IVRPEncoding {
    34     public override Image ItemImage {
    35       get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Class; }
    36     }
    37    
    38     #region IVRPEncoding Members
    39     [Storable]
    40     public ItemList<Tour> Tours { get; set; }
    41 
    42     public int Cities {
    43       get
    44       {
    45         int cities = 0;
    46 
    47         foreach (Tour tour in Tours) {
    48           cities += tour.Cities.Count;
    49         }
    50 
    51         return cities;
    52       }
    53     }
    54     #endregion
    55 
     34  public class PotvinEncoding : TourEncoding {   
    5635    [Storable]
    5736    public List<int> Unrouted { get; set; }
     
    6544    }
    6645
    67     public PotvinEncoding() {
    68       Tours = new ItemList<Tour>();
     46    public PotvinEncoding(): base() {
    6947      Unrouted = new List<int>();
    7048    }
     49
     50    [StorableConstructor]
     51    private PotvinEncoding(bool serializing)
     52      : base() {
     53    }
    7154   
    72     public static PotvinEncoding ConvertFrom(IVRPEncoding encoding) {
     55    public static PotvinEncoding ConvertFrom(IVRPEncoding encoding, ILookupParameter<DoubleMatrix> distanceMatrix) {
    7356      PotvinEncoding solution = new PotvinEncoding();
    7457
    75       solution.Tours.AddRange(
    76         encoding.Tours);
     58      TourEncoding.ConvertFrom(encoding, solution, distanceMatrix);
    7759
    7860      return solution;
     
    8264      PotvinEncoding solution = new PotvinEncoding();
    8365
    84       Tour tour = new Tour();
    85       for (int i = 0; i < route.Count; i++) {
    86         if (route[i] == 0) {
    87           if (tour.Cities.Count > 0) {
    88             solution.Tours.Add(tour);
    89             tour = new Tour();
    90           }
    91         } else {
    92           tour.Cities.Add(route[i]);
    93         }
    94       }
     66      TourEncoding.ConvertFrom(route, solution);
    9567
    9668      return solution;
     
    11587            if (Tours[tour].Feasible(dueTimeArray, serviceTimeArray, readyTimeArray, demandArray,
    11688              capacity, coordinates, distanceMatrix, useDistanceMatrix)) {
    117               double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
     89                double newLength = Tours[tour].GetLength(coordinates, distanceMatrix, useDistanceMatrix);
    11890
    11991              double detour = newLength - length;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Encodings/VRPCreator.cs

    r4179 r4352  
    3939    }
    4040   
    41     public IValueLookupParameter<IntValue> CitiesParameter {
    42       get { return (IValueLookupParameter<IntValue>)Parameters["Cities"]; }
    43     }
    44 
    4541    [StorableConstructor]
    4642    protected VRPCreator(bool deserializing) : base(deserializing) { }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Evaluators/VRPEvaluator.cs

    r4179 r4352  
    101101      IVRPEncoding vrpSolution = VRPToursParameter.ActualValue;
    102102
    103       return vrpSolution.Tours.Count;
     103      return vrpSolution.GetTours(DistanceMatrixParameter, VehiclesParameter.ActualValue.Value).Count;
    104104    }
    105105
     
    178178    }
    179179
    180     public static TourEvaluation Evaluate(IVRPEncoding solution, DoubleArray dueTimeArray,
     180    public static TourEvaluation Evaluate(IVRPEncoding solution, IntValue vehicles, DoubleArray dueTimeArray,
    181181      DoubleArray serviceTimeArray, DoubleArray readyTimeArray, DoubleArray demandArray, DoubleValue capacity,
    182182      DoubleValue fleetUsageFactor, DoubleValue timeFactor, DoubleValue distanceFactor, DoubleValue overloadPenalty, DoubleValue tardinessPenalty,
     
    190190      sumEval.Tardiness = 0;
    191191
    192       foreach (Tour tour in solution.Tours) {
     192      foreach (Tour tour in solution.GetTours(distanceMatrix)) {
    193193        TourEvaluation eval = EvaluateTour(tour, dueTimeArray, serviceTimeArray, readyTimeArray, demandArray, capacity,
    194194          fleetUsageFactor, timeFactor, distanceFactor, overloadPenalty, tardinessPenalty,
     
    208208      IVRPEncoding solution = VRPToursParameter.ActualValue;
    209209
    210       TourEvaluation sumEval = Evaluate(solution, DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
     210      TourEvaluation sumEval = Evaluate(solution, VehiclesParameter.ActualValue, DueTimeParameter.ActualValue, ServiceTimeParameter.ActualValue, ReadyTimeParameter.ActualValue,
    211211        DemandParameter.ActualValue, CapacityParameter.ActualValue,
    212212        FleetUsageFactor.ActualValue, TimeFactor.ActualValue, DistanceFactor.ActualValue, OverloadPenalty.ActualValue, TardinessPenalty.ActualValue,
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj

    r4210 r4352  
    106106  </ItemGroup>
    107107  <ItemGroup>
     108    <Compile Include="Analyzers\BestAverageWorstVRPToursAnalyzer.cs" />
     109    <Compile Include="Analyzers\BestAverageWorstVRPToursCalculator.cs" />
     110    <Compile Include="Analyzers\BestVRPToursMemorizer.cs" />
    108111    <Compile Include="Analyzers\BestVRPSolutionAnalyzer.cs" />
    109     <Compile Include="Encodings\Alba\Crossovers\PermutationCrossover.cs" />
    110     <Compile Include="Encodings\Alba\Manipulators\IntraRouteInversionManipulator.cs" />
    111     <Compile Include="Encodings\Alba\Manipulators\LambdaInterchangeManipulator.cs" />
     112    <Compile Include="Encodings\Alba\Crossovers\AlbaPermutationCrossover.cs" />
     113    <Compile Include="Encodings\Alba\Manipulators\AlbaIntraRouteInversionManipulator.cs" />
     114    <Compile Include="Encodings\Alba\Manipulators\AlbaLambdaInterchangeManipulator.cs" />
    112115    <Compile Include="Encodings\Alba\Moves\Interfaces\IAlbaLambdaInterchangeMoveOperator.cs" />
    113116    <Compile Include="Encodings\Alba\Moves\Interfaces\IAlbaIntraRouteInversionMoveOperator.cs" />
    114     <Compile Include="Encodings\Alba\Manipulators\CustomerInversionManipulator.cs" />
    115     <Compile Include="Encodings\Alba\Manipulators\CustomerSwapManipulator.cs" />
    116     <Compile Include="Encodings\Alba\Manipulators\CustomerInsertionManipulator.cs" />
    117     <Compile Include="Encodings\Alba\Manipulators\PermutationManipulator.cs" />
    118     <Compile Include="Encodings\Alba\Moves\LambdaInterchange\ExhaustiveLambdaInterchangeMoveGenerator.cs" />
    119     <Compile Include="Encodings\Alba\Moves\LambdaInterchange\LambdaInterchangeMove.cs" />
    120     <Compile Include="Encodings\Alba\Moves\LambdaInterchange\LambdaInterchangeMoveGenerator.cs" />
    121     <Compile Include="Encodings\Alba\Moves\LambdaInterchange\LambdaInterchangeMoveEvaluator.cs" />
    122     <Compile Include="Encodings\Alba\Moves\LambdaInterchange\LambdaInterchangeMoveMaker.cs" />
    123     <Compile Include="Encodings\Alba\Moves\LambdaInterchange\StochasticLambdaInterchangeSingleMoveGenerator.cs" />
    124     <Compile Include="Encodings\Alba\Moves\LambdaInterchange\StochasticLambdaInterchangeMutliMoveGenerator.cs" />
    125     <Compile Include="Encodings\Alba\Moves\PermutationMoveOperator.cs" />
    126     <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\StochasticIntraRouteInversionMutliMoveGenerator.cs" />
    127     <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\StochasticIntraRouteInversionSingleMoveGenerator.cs" />
    128     <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\IntraRouteInversionMoveGenerator.cs" />
    129     <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\IntraRouteInversionEvaluator.cs" />
    130     <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\ExhaustiveIntraRouteInversionMoveGenerator.cs" />
    131     <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\IntraRouteInversionMoveMaker.cs" />
    132     <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\IntraRouteInversionMove.cs" />
    133     <Compile Include="Encodings\General\Crossovers\MultiVRPManipulator.cs" />
    134     <Compile Include="Encodings\General\Crossovers\MultiVRPCrossover.cs" />
     117    <Compile Include="Encodings\Alba\Manipulators\AlbaCustomerInversionManipulator.cs" />
     118    <Compile Include="Encodings\Alba\Manipulators\AlbaCustomerSwapManipulator.cs" />
     119    <Compile Include="Encodings\Alba\Manipulators\AlbaCustomerInsertionManipulator.cs" />
     120    <Compile Include="Encodings\Alba\Manipulators\AlbaPermutationManipulator.cs" />
     121    <Compile Include="Encodings\Alba\Moves\LambdaInterchange\AlbaExhaustiveLambdaInterchangeMoveGenerator.cs" />
     122    <Compile Include="Encodings\Alba\Moves\LambdaInterchange\AlbaLambdaInterchangeMove.cs" />
     123    <Compile Include="Encodings\Alba\Moves\LambdaInterchange\AlbaLambdaInterchangeMoveGenerator.cs" />
     124    <Compile Include="Encodings\Alba\Moves\LambdaInterchange\AlbaLambdaInterchangeMoveEvaluator.cs" />
     125    <Compile Include="Encodings\Alba\Moves\LambdaInterchange\AlbaLambdaInterchangeMoveMaker.cs" />
     126    <Compile Include="Encodings\Alba\Moves\LambdaInterchange\AlbaStochasticLambdaInterchangeSingleMoveGenerator.cs" />
     127    <Compile Include="Encodings\Alba\Moves\LambdaInterchange\AlbaStochasticLambdaInterchangeMutliMoveGenerator.cs" />
     128    <Compile Include="Encodings\Alba\Moves\AlbaPermutationMoveOperator.cs" />
     129    <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\AlbaStochasticIntraRouteInversionMutliMoveGenerator.cs" />
     130    <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\AlbaStochasticIntraRouteInversionSingleMoveGenerator.cs" />
     131    <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\AlbaIntraRouteInversionMoveGenerator.cs" />
     132    <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\AlbaIntraRouteInversionEvaluator.cs" />
     133    <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\AlbaExhaustiveIntraRouteInversionMoveGenerator.cs" />
     134    <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\AlbaIntraRouteInversionMoveMaker.cs" />
     135    <Compile Include="Encodings\Alba\Moves\IntraRouteInversion\AlbaIntraRouteInversionMove.cs" />
     136    <Compile Include="Encodings\General\Crossovers\RandomParentCloneCrossover.cs" />
     137    <Compile Include="Encodings\General\PermutationEncoding.cs" />
     138    <Compile Include="Encodings\General\Creators\MultiVRPSolutionCreator.cs" />
     139    <Compile Include="Encodings\General\Manipulators\MultiVRPSolutionManipulator.cs" />
     140    <Compile Include="Encodings\General\Crossovers\MultiVRPSolutionCrossover.cs" />
    135141    <Compile Include="Encodings\General\Creators\RandomCreator.cs" />
    136142    <Compile Include="Encodings\General\Moves\Interfaces\IMultiVRPMoveGenerator.cs" />
     
    140146    <Compile Include="Encodings\General\Moves\MultiVRPMoveOperator\MultiVRPMoveMaker.cs" />
    141147    <Compile Include="Encodings\General\Moves\MultiVRPMoveOperator\MultiVRPMoveGenerator.cs" />
    142     <Compile Include="Encodings\Potvin\Crossovers\RouteBasedCrossover.cs" />
    143     <Compile Include="Encodings\Potvin\Crossovers\SequenceBasedCrossover.cs" />
     148    <Compile Include="Encodings\General\TourEncoding.cs" />
     149    <Compile Include="Encodings\GVR\Crossovers\GVRCrossover.cs" />
     150    <Compile Include="Encodings\GVR\GVREncoding.cs" />
     151    <Compile Include="Encodings\GVR\Manipulators\GVRDisplacementManipulator.cs" />
     152    <Compile Include="Encodings\GVR\Manipulators\GVRInsertionManipulator.cs" />
     153    <Compile Include="Encodings\GVR\Manipulators\GVRInversionManipulator.cs" />
     154    <Compile Include="Encodings\GVR\Manipulators\GVRSwapManipulator.cs" />
     155    <Compile Include="Encodings\GVR\Manipulators\GVRManipulator.cs" />
     156    <Compile Include="Encodings\Potvin\Crossovers\PotvinRouteBasedCrossover.cs" />
     157    <Compile Include="Encodings\Potvin\Crossovers\PotvinSequenceBasedCrossover.cs" />
    144158    <Compile Include="Encodings\Potvin\Crossovers\PotvinCrossover.cs" />
    145     <Compile Include="Encodings\Potvin\Manipulators\LocalSearchManipulator.cs" />
    146     <Compile Include="Encodings\Potvin\Manipulators\TwoLevelExchangeManipulator.cs" />
    147     <Compile Include="Encodings\Potvin\Manipulators\OneLevelExchangeManipulator.cs" />
     159    <Compile Include="Encodings\Potvin\Manipulators\PotvinLocalSearchManipulator.cs" />
     160    <Compile Include="Encodings\Potvin\Manipulators\PotvinTwoLevelExchangeManipulator.cs" />
     161    <Compile Include="Encodings\Potvin\Manipulators\PotvinOneLevelExchangeManipulator.cs" />
    148162    <Compile Include="Encodings\Potvin\Manipulators\PotvinManipulator.cs" />
     163    <Compile Include="Encodings\Prins\Crossovers\PrinsCrossover.cs" />
     164    <Compile Include="Encodings\Prins\Crossovers\PrinsPermutationCrossover.cs" />
     165    <Compile Include="Encodings\Prins\Interfaces\IPrinsOperator.cs" />
     166    <Compile Include="Encodings\Prins\Manipulators\PrinsStochasticLSManipulator.cs" />
     167    <Compile Include="Encodings\Prins\Manipulators\PrinsExhaustiveLSManipulator.cs" />
     168    <Compile Include="Encodings\Prins\Manipulators\PrinsLSManipulator.cs" />
     169    <Compile Include="Encodings\Prins\Manipulators\PrinsManipulator.cs" />
     170    <Compile Include="Encodings\Prins\Manipulators\PrinsPermutationManipulator.cs" />
     171    <Compile Include="Encodings\Prins\PrinsEncoding.cs" />
     172    <Compile Include="Encodings\Zhu\Crossovers\ZhuMergeCrossover2.cs" />
     173    <Compile Include="Encodings\Zhu\Crossovers\ZhuMergeCrossover1.cs" />
     174    <Compile Include="Encodings\Zhu\Crossovers\ZhuHeuristicCrossover2.cs" />
     175    <Compile Include="Encodings\Zhu\Crossovers\ZhuHeuristicCrossover1.cs" />
     176    <Compile Include="Encodings\Zhu\Crossovers\ZhuCrossover.cs" />
     177    <Compile Include="Encodings\Zhu\Crossovers\ZhuPermutationCrossover.cs" />
     178    <Compile Include="Encodings\Zhu\Manipulators\ZhuPermutationManipulator.cs" />
     179    <Compile Include="Encodings\Zhu\Manipulators\ZhuManipulator.cs" />
     180    <Compile Include="Encodings\Zhu\ZhuEncoding.cs" />
    149181    <Compile Include="Interfaces\IVRPMoveMaker.cs" />
     182    <Compile Include="ORLIBParser.cs" />
     183    <Compile Include="TSPLIBParser.cs" />
    150184    <Compile Include="VRPUtilities.cs" />
    151185    <Compile Include="VRPOperator.cs" />
     
    157191    <Compile Include="Encodings\Alba\Moves\AlbaMoveOperator.cs" />
    158192    <Compile Include="Encodings\Alba\Moves\AlbaMoveMaker.cs" />
    159     <Compile Include="Encodings\Alba\Moves\ThreeOpt\PermutationTranslocationMoveGenerator.cs" />
    160     <Compile Include="Encodings\Alba\Moves\ThreeOpt\PermutationTranslocationMoveMaker.cs" />
    161     <Compile Include="Encodings\Alba\Moves\ThreeOpt\PermutationTranslocationMoveTabuMaker.cs" />
    162     <Compile Include="Encodings\Alba\Moves\ThreeOpt\PermutationTranslocationMoveSoftTabuCriterion.cs" />
    163     <Compile Include="Encodings\Alba\Moves\ThreeOpt\PermutationTranslocationMoveHardTabuCriterion.cs" />
     193    <Compile Include="Encodings\Alba\Moves\ThreeOpt\AlbaTranslocationMoveGenerator.cs" />
     194    <Compile Include="Encodings\Alba\Moves\ThreeOpt\AlbaTranslocationMoveMaker.cs" />
     195    <Compile Include="Encodings\Alba\Moves\ThreeOpt\AlbaTranslocationMoveTabuMaker.cs" />
     196    <Compile Include="Encodings\Alba\Moves\ThreeOpt\AlbaTranslocationMoveSoftTabuCriterion.cs" />
     197    <Compile Include="Encodings\Alba\Moves\ThreeOpt\AlbaTranslocationMoveHardTabuCriterion.cs" />
    164198    <Compile Include="Encodings\Potvin\PotvinEncoding.cs" />
    165199    <Compile Include="Encodings\VRPMoveOperator.cs" />
     
    179213    <Compile Include="Interfaces\IVRPCreator.cs" />
    180214    <Compile Include="Interfaces\IVRPOperator.cs" />
    181     <Compile Include="Encodings\Alba\Moves\ThreeOpt\PermutationTranslocationMoveEvaluator.cs" />
     215    <Compile Include="Encodings\Alba\Moves\ThreeOpt\AlbaTranslocationMoveEvaluator.cs" />
    182216    <Compile Include="MoveEvaluators\VRPMoveEvaluator.cs" />
    183217    <Compile Include="VRPSolution.cs" />
     
    187221  </ItemGroup>
    188222  <ItemGroup>
     223    <ProjectReference Include="..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
     224      <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
     225      <Name>HeuristicLab.Analysis-3.3</Name>
     226    </ProjectReference>
    189227    <ProjectReference Include="..\..\HeuristicLab.Collections\3.3\HeuristicLab.Collections-3.3.csproj">
    190228      <Project>{958B43BC-CC5C-4FA2-8628-2B3B01D890B6}</Project>
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLabProblemsVehicleRoutingPlugin.cs.frame

    r3938 r4352  
    2828  [Plugin("HeuristicLab.Problems.VehicleRouting", "3.3.0.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.VehicleRouting-3.3.dll", PluginFileType.Assembly)]
     30  [PluginDependency("HeuristicLab.Analysis", "3.3")]
    3031  [PluginDependency("HeuristicLab.Collections", "3.3")]
    3132  [PluginDependency("HeuristicLab.Common", "3.3")]
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Interfaces/IVRPCreator.cs

    r4179 r4352  
    2626namespace HeuristicLab.Problems.VehicleRouting {
    2727  public interface IVRPCreator : IVRPOperator, ISolutionCreator {
    28     IValueLookupParameter<IntValue> CitiesParameter { get; }
    2928    ILookupParameter<IVRPEncoding> VRPToursParameter { get; }
    3029  }
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/Interfaces/IVRPEncoding.cs

    r4154 r4352  
    2222using HeuristicLab.Core;
    2323using HeuristicLab.Problems.VehicleRouting.Encodings;
     24using System.Collections.Generic;
     25using HeuristicLab.Data;
    2426
    2527namespace HeuristicLab.Problems.VehicleRouting {
    2628  public interface IVRPEncoding : IItem {
    27     ItemList<Tour> Tours {
    28       get;
    29     }
     29    List<Tour> GetTours(ILookupParameter<DoubleMatrix> distanceMatrix, int maxVehicles = int.MaxValue);
    3030  }
    3131}
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPOperator.cs

    r4186 r4352  
    113113    public VRPOperator()
    114114      : base() {
    115       Parameters.Add(new ValueLookupParameter<IntValue>("Cities", "The city count."));
    116115      Parameters.Add(new LookupParameter<DoubleMatrix>("Coordinates", "The coordinates of the cities."));
    117116      Parameters.Add(new LookupParameter<DoubleMatrix>("DistanceMatrix", "The matrix which contains the distances between the cities."));
     
    140139      bool feasible = true;
    141140
    142       foreach (Tour tour in solution.Tours) {
     141      foreach (Tour tour in solution.GetTours(DistanceMatrixParameter)) {
    143142        if (!Feasible(tour)) {
    144143          feasible = false;
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VRPUtilities.cs

    r4154 r4352  
    6060
    6161      if (useDistanceMatrix.Value) {
    62         if (distanceMatrix.ActualValue == null) {
    63           distanceMatrix.ActualValue = CreateDistanceMatrix(coordinates);
    64         }
     62        if (distanceMatrix is IValueLookupParameter<DoubleMatrix> &&
     63          (distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value != null) {
     64            distance = (distanceMatrix as IValueLookupParameter<DoubleMatrix>).Value[start, end];
     65        } else {
     66          if (distanceMatrix.ActualValue == null) {
     67            distanceMatrix.ActualValue = CreateDistanceMatrix(coordinates);
     68          }
    6569
    66         distance = distanceMatrix.ActualValue[start, end];
     70          distance = distanceMatrix.ActualValue[start, end];
     71        }       
    6772      } else {
    6873        distance = CalculateDistance(start, end, coordinates);
  • trunk/sources/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

    r4179 r4352  
    3434using HeuristicLab.Problems.VehicleRouting.Encodings.Alba;
    3535using HeuristicLab.Problems.VehicleRouting.Encodings.General;
     36using HeuristicLab.Problems.VehicleRouting.Encodings.Prins;
    3637
    3738namespace HeuristicLab.Problems.VehicleRouting {
     
    176177    private BestVRPSolutionAnalyzer BestVRPSolutionAnalyzer {
    177178      get { return operators.OfType<BestVRPSolutionAnalyzer>().FirstOrDefault(); }
     179    }
     180    private BestAverageWorstVRPToursAnalyzer BestAverageWorstVRPToursAnalyzer {
     181      get { return operators.OfType<BestAverageWorstVRPToursAnalyzer>().FirstOrDefault(); }
    178182    }
    179183    #endregion
     
    314318      operators = new List<IOperator>();
    315319      operators.Add(new BestVRPSolutionAnalyzer());
     320      operators.Add(new BestAverageWorstVRPToursAnalyzer());
    316321      ParameterizeAnalyzer();
    317       operators.AddRange(ApplicationManager.Manager.GetInstances<IVRPOperator>().Cast<IOperator>());
     322      operators.AddRange(ApplicationManager.Manager.GetInstances<IVRPOperator>().Cast<IOperator>().OrderBy(op => op.Name));
    318323      ParameterizeOperators();
    319324      UpdateMoveEvaluators();
     
    333338    }
    334339    private void ParameterizeSolutionCreator() {
    335       SolutionCreator.CitiesParameter.Value = new IntValue(Coordinates.Rows - 1);
    336340      SolutionCreator.VehiclesParameter.ActualName = VehiclesParameter.Name;
    337341      SolutionCreator.CoordinatesParameter.ActualName = CoordinatesParameter.Name;
     
    367371      BestVRPSolutionAnalyzer.OverloadParameter.ActualName = Evaluator.OverloadParameter.ActualName;
    368372      BestVRPSolutionAnalyzer.TardinessParameter.ActualName = Evaluator.TardinessParameter.ActualName;
     373      BestVRPSolutionAnalyzer.TravelTimeParameter.ActualName = Evaluator.TravelTimeParameter.ActualName;
     374      BestVRPSolutionAnalyzer.VehiclesUtilizedParameter.ActualName = Evaluator.VehcilesUtilizedParameter.ActualName;
    369375      BestVRPSolutionAnalyzer.VRPToursParameter.ActualName = SolutionCreator.VRPToursParameter.ActualName;
    370376      BestVRPSolutionAnalyzer.ResultsParameter.ActualName = "Results";
     377
     378      BestAverageWorstVRPToursAnalyzer.DistanceParameter.ActualName = Evaluator.DistanceParameter.ActualName;
     379      BestAverageWorstVRPToursAnalyzer.OverloadParameter.ActualName = Evaluator.OverloadParameter.ActualName;
     380      BestAverageWorstVRPToursAnalyzer.TardinessParameter.ActualName = Evaluator.TardinessParameter.ActualName;
     381      BestAverageWorstVRPToursAnalyzer.TravelTimeParameter.ActualName = Evaluator.TravelTimeParameter.ActualName;
     382      BestAverageWorstVRPToursAnalyzer.VehiclesUtilizedParameter.ActualName = Evaluator.VehcilesUtilizedParameter.ActualName;
     383      BestAverageWorstVRPToursAnalyzer.ResultsParameter.ActualName = "Results";
    371384    }
    372385    private void ParameterizeOperators() {
     
    387400      }
    388401
     402      foreach (IPrinsOperator op in Operators.OfType<IPrinsOperator>()) {
     403        op.FleetUsageFactor.ActualName = FleetUsageFactor.Name;
     404        op.TimeFactor.ActualName = TimeFactor.Name;
     405        op.DistanceFactor.ActualName = DistanceFactor.Name;
     406        op.OverloadPenalty.ActualName = OverloadPenalty.Name;
     407        op.TardinessPenalty.ActualName = TardinessPenalty.Name;
     408      }
     409
    389410      foreach (IVRPMoveEvaluator op in Operators.OfType<IVRPMoveEvaluator>()) {
    390411        op.FleetUsageFactor.ActualName = FleetUsageFactor.Name;
     
    427448      DueTime = new DoubleArray(parser.Duetimes);
    428449      ServiceTime = new DoubleArray(parser.Servicetimes);
     450
     451      OnReset();
     452    }
     453
     454    public void ImportFromTSPLib(string tspFileName) {
     455      TSPLIBParser parser = new TSPLIBParser(tspFileName);
     456      parser.Parse();
     457
     458      this.Name = parser.Name;
     459
     460      int problemSize = parser.Demands.Length;
     461
     462      Coordinates = new DoubleMatrix(parser.Vertices);
     463      if (parser.Vehicles != -1)
     464        Vehicles.Value = parser.Vehicles;
     465      else
     466        Vehicles.Value = problemSize - 1;
     467      Capacity.Value = parser.Capacity;
     468      Demand = new DoubleArray(parser.Demands);
     469      ReadyTime = new DoubleArray(problemSize);
     470      DueTime = new DoubleArray(problemSize);
     471      ServiceTime = new DoubleArray(problemSize);
     472
     473      for (int i = 0; i < problemSize; i++) {
     474        ReadyTime[i] = 0;
     475        DueTime[i] = int.MaxValue;
     476        ServiceTime[i] = 0;
     477      }
     478
     479      if (parser.Distance != -1) {
     480        DueTime[0] = parser.Distance;
     481      }
     482
     483      if (parser.Depot != 1)
     484        throw new Exception("Invalid depot specification");
     485
     486      if (parser.WeightType != TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D)
     487        throw new Exception("Invalid weight type");
     488
     489      OnReset();
     490    }
     491
     492    public void ImportFromORLib(string orFileName) {
     493      ORLIBParser parser = new ORLIBParser(orFileName);
     494      parser.Parse();
     495
     496      this.Name = parser.Name;
     497      int problemSize = parser.Demands.Length;
     498
     499      Coordinates = new DoubleMatrix(parser.Vertices);
     500      Vehicles.Value = problemSize - 1;
     501      Capacity.Value = parser.Capacity;
     502      Demand = new DoubleArray(parser.Demands);
     503      ReadyTime = new DoubleArray(problemSize);
     504      DueTime = new DoubleArray(problemSize);
     505      ServiceTime = new DoubleArray(problemSize);
     506
     507      ReadyTime[0] = 0;
     508      DueTime[0] = parser.MaxRouteTime;
     509      ServiceTime[0] = 0;
     510
     511      for (int i = 1; i < problemSize; i++) {
     512        ReadyTime[i] = 0;
     513        DueTime[i] = int.MaxValue;
     514        ServiceTime[i] = parser.ServiceTime;
     515      }
    429516
    430517      OnReset();
Note: See TracChangeset for help on using the changeset viewer.