Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLab.Problems.VehicleRouting.Views-3.4.csproj
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLab.Problems.VehicleRouting.Views-3.4.csproj (revision 4361)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLab.Problems.VehicleRouting.Views-3.4.csproj (revision 4362)
@@ -113,4 +113,10 @@
+
+ UserControl
+
+
+ VehicleRoutingProblemView.cs
+
@@ -180,7 +186,7 @@
HeuristicLab.PluginInfrastructure-3.3
-
- {6410BDA6-3641-42B2-BABA-AA626E2F6F71}
- HeuristicLab.Problems.VehicleRouting-3.3
+
+ {B94FFB82-43D4-40AB-9980-B03470ADF221}
+ HeuristicLab.Problems.VehicleRouting-3.4
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLabProblemsVehicleRoutingViewsPlugin.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLabProblemsVehicleRoutingViewsPlugin.cs (revision 4361)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLabProblemsVehicleRoutingViewsPlugin.cs (revision 4362)
@@ -26,5 +26,5 @@
/// Plugin class for HeuristicLab.Problems.VehicleRouting.Views plugin
///
- [Plugin("HeuristicLab.Problems.VehicleRouting.Views", "3.4.0.4359")]
+ [Plugin("HeuristicLab.Problems.VehicleRouting.Views", "3.4.0.4361")]
[PluginFile("HeuristicLab.Problems.VehicleRouting.Views-3.4.dll", PluginFileType.Assembly)]
[PluginDependency("HeuristicLab.Collections", "3.3")]
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.Designer.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.Designer.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.Designer.cs (revision 4362)
@@ -0,0 +1,111 @@
+namespace HeuristicLab.Problems.VehicleRouting.Views {
+ partial class VehicleRoutingProblemView {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing) {
+ if (disposing && (components != null)) {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent() {
+ this.importButton = new System.Windows.Forms.Button();
+ this.importButton2 = new System.Windows.Forms.Button();
+ this.importButton3 = new System.Windows.Forms.Button();
+ this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
+ ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+ this.SuspendLayout();
+ //
+ // nameTextBox
+ //
+ this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
+ this.errorProvider.SetIconPadding(this.nameTextBox, 2);
+ //
+ // importButton
+ //
+ this.importButton.Location = new System.Drawing.Point(0, 55);
+ this.importButton.Name = "importButton";
+ this.importButton.Size = new System.Drawing.Size(139, 23);
+ this.importButton.TabIndex = 5;
+ this.importButton.Text = "Import from Solomon";
+ this.importButton.UseVisualStyleBackColor = true;
+ this.importButton.Click += new System.EventHandler(this.importButton_Click);
+ //
+ // importButton2
+ //
+ this.importButton2.Location = new System.Drawing.Point(145, 55);
+ this.importButton2.Name = "importButton2";
+ this.importButton2.Size = new System.Drawing.Size(126, 23);
+ this.importButton2.TabIndex = 7;
+ this.importButton2.Text = "Import from TSPLib";
+ this.importButton2.UseVisualStyleBackColor = true;
+ this.importButton2.Click += new System.EventHandler(this.importButton2_Click);
+ //
+ // importButton3
+ //
+ this.importButton3.Location = new System.Drawing.Point(277, 55);
+ this.importButton3.Name = "importButton3";
+ this.importButton3.Size = new System.Drawing.Size(131, 23);
+ this.importButton3.TabIndex = 8;
+ this.importButton3.Text = "Import from ORLib";
+ this.importButton3.UseVisualStyleBackColor = true;
+ this.importButton3.Click += new System.EventHandler(this.importButton3_Click);
+ //
+ // parameterCollectionView
+ //
+ this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+ | System.Windows.Forms.AnchorStyles.Left)
+ | System.Windows.Forms.AnchorStyles.Right)));
+ this.parameterCollectionView.Caption = "ParameterCollection View";
+ this.parameterCollectionView.Content = null;
+ this.parameterCollectionView.Location = new System.Drawing.Point(0, 84);
+ this.parameterCollectionView.Name = "parameterCollectionView";
+ this.parameterCollectionView.ReadOnly = false;
+ this.parameterCollectionView.Size = new System.Drawing.Size(490, 268);
+ this.parameterCollectionView.TabIndex = 9;
+ //
+ // VehicleRoutingProblemView
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.Controls.Add(this.parameterCollectionView);
+ this.Controls.Add(this.importButton3);
+ this.Controls.Add(this.importButton2);
+ this.Controls.Add(this.importButton);
+ this.Name = "VehicleRoutingProblemView";
+ this.Size = new System.Drawing.Size(490, 352);
+ this.Controls.SetChildIndex(this.importButton, 0);
+ this.Controls.SetChildIndex(this.importButton2, 0);
+ this.Controls.SetChildIndex(this.importButton3, 0);
+ this.Controls.SetChildIndex(this.nameTextBox, 0);
+ this.Controls.SetChildIndex(this.nameLabel, 0);
+ this.Controls.SetChildIndex(this.descriptionLabel, 0);
+ this.Controls.SetChildIndex(this.descriptionTextBox, 0);
+ this.Controls.SetChildIndex(this.parameterCollectionView, 0);
+ ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Button importButton;
+ private System.Windows.Forms.Button importButton2;
+ private System.Windows.Forms.Button importButton3;
+ private Core.Views.ParameterCollectionView parameterCollectionView;
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.cs (revision 4362)
@@ -0,0 +1,91 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Windows.Forms;
+using HeuristicLab.MainForm;
+using HeuristicLab.Optimization.Views;
+using HeuristicLab.Core.Views;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.Problems.VehicleRouting.Views {
+ [View("VehicleRouting Problem View")]
+ [Content(typeof(VehicleRoutingProblem), true)]
+ public partial class VehicleRoutingProblemView : NamedItemView {
+ public new VehicleRoutingProblem Content {
+ get { return (VehicleRoutingProblem)base.Content; }
+ set { base.Content = value; }
+ }
+
+ public VehicleRoutingProblemView() {
+ InitializeComponent();
+ }
+
+ protected override void DeregisterContentEvents() {
+ base.DeregisterContentEvents();
+ }
+ protected override void RegisterContentEvents() {
+ base.RegisterContentEvents();
+ }
+
+ protected override void OnContentChanged() {
+ base.OnContentChanged();
+ if (Content == null) {
+ parameterCollectionView.Content = null;
+ } else {
+ parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
+ }
+ }
+
+ protected override void SetEnabledStateOfControls() {
+ base.SetEnabledStateOfControls();
+ parameterCollectionView.Enabled = Content != null;
+ importButton.Enabled = importButton2.Enabled = importButton3.Enabled = Content != null && !ReadOnly;
+ }
+
+ private void importButton_Click(object sender, EventArgs e) {
+ OpenFileDialog dialog = new OpenFileDialog();
+ dialog.Filter = "Solomon files (*.txt)|*.txt";
+
+ if (dialog.ShowDialog() == DialogResult.OK) {
+ Content.ImportFromSolomon(dialog.FileName);
+ }
+ }
+
+ private void importButton2_Click(object sender, EventArgs e) {
+ OpenFileDialog dialog = new OpenFileDialog();
+ dialog.Filter = "TSPLib files (*.vrp)|*.vrp";
+
+ if (dialog.ShowDialog() == DialogResult.OK) {
+ Content.ImportFromTSPLib(dialog.FileName);
+ }
+ }
+
+ private void importButton3_Click(object sender, EventArgs e) {
+ OpenFileDialog dialog = new OpenFileDialog();
+ dialog.Filter = "ORLib files (*.txt)|*.txt";
+
+ if (dialog.ShowDialog() == DialogResult.OK) {
+ Content.ImportFromORLib(dialog.FileName);
+ }
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/DomainModel/Tour.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/DomainModel/Tour.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/DomainModel/Tour.cs (revision 4362)
@@ -0,0 +1,47 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.Problems.VehicleRouting.DomainModel {
+ [StorableClass]
+ public class Tour : Item {
+ [Storable]
+ public List Stops { get; private set; }
+
+ public Tour() {
+ Stops = new List();
+ }
+
+ public override IDeepCloneable Clone(Cloner cloner) {
+ Tour clone = base.Clone(cloner) as Tour;
+ clone.Stops = new List(Stops);
+
+ return clone;
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/AlbaOperator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/AlbaOperator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/AlbaOperator.cs (revision 4362)
@@ -0,0 +1,45 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.VehicleRouting.Interfaces;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Parameters;
+using HeuristicLab.Operators;
+using HeuristicLab.Problems.VehicleRouting.Interfaces.Variants;
+
+namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
+ [Item("AlbaOperator", "Represents a VRP operator.")]
+ [StorableClass]
+ public abstract class AlbaOperator : VRPOperator,
+ ISingleDepotOperator, IHeterogenousCapacitatedOperator, ITimeWindowedOperator {
+ [StorableConstructor]
+ protected AlbaOperator(bool deserializing) : base(deserializing) { }
+
+ public AlbaOperator()
+ : base() {
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/AlbaCreator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/AlbaCreator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/AlbaCreator.cs (revision 4362)
@@ -0,0 +1,52 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Problems.VehicleRouting.Interfaces;
+
+namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
+ [Item("AlbaCreator", "A VRP creator.")]
+ [StorableClass]
+ public abstract class AlbaCreator : AlbaOperator, IVRPCreator {
+ public override bool CanChangeName {
+ get { return false; }
+ }
+
+ #region IVRPCreator Members
+ public ILookupParameter VRPToursParameter {
+ get { return (ILookupParameter)Parameters["VRPTours"]; }
+ }
+
+ [StorableConstructor]
+ protected AlbaCreator(bool deserializing) : base(deserializing) { }
+
+ public AlbaCreator()
+ : base() {
+ Parameters.Add(new LookupParameter("VRPTours", "The new VRP tours."));
+ }
+
+ #endregion
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/DefaultRepresentationCreator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/DefaultRepresentationCreator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/DefaultRepresentationCreator.cs (revision 4362)
@@ -0,0 +1,49 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using System.Collections.Generic;
+using HeuristicLab.Problems.VehicleRouting.Encodings;
+using HeuristicLab.Problems.VehicleRouting.Interfaces.Variants;
+
+namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
+ [Item("DefaultRepresentationCreator", "An operator which creates a VRP solution in the default representation.")]
+ [StorableClass]
+ public abstract class DefaultRepresentationCreator : AlbaCreator {
+ protected abstract List CreateSolution();
+
+ [StorableConstructor]
+ protected DefaultRepresentationCreator(bool deserializing) : base(deserializing) { }
+
+ public DefaultRepresentationCreator() : base() { }
+
+ public override IOperation Apply() {
+ //choose default encoding here
+ //VRPToursParameter.ActualValue = AlbaEncoding.ConvertFrom(CreateSolution());
+
+ return base.Apply();
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/RandomCreator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/RandomCreator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Alba/Creators/RandomCreator.cs (revision 4362)
@@ -0,0 +1,82 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.PermutationEncoding;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+
+namespace HeuristicLab.Problems.VehicleRouting.Encodings.Alba {
+ [Item("RandomCreator", "Creates a randomly initialized VRP solution.")]
+ [StorableClass]
+ public sealed class RandomCreator : DefaultRepresentationCreator, IStochasticOperator {
+ #region IStochasticOperator Members
+ public ILookupParameter RandomParameter {
+ get { return (LookupParameter)Parameters["Random"]; }
+ }
+ #endregion
+
+ [StorableConstructor]
+ private RandomCreator(bool deserializing) : base(deserializing) { }
+
+ public RandomCreator()
+ : base() {
+ Parameters.Add(new LookupParameter("Random", "The pseudo random number generator."));
+ }
+
+ protected override List CreateSolution() {
+ int cities = ProblemInstance.Cities.Value;
+ int vehicles = ProblemInstance.Vehicles.Value;
+
+ int[] perm = new int[cities + vehicles];
+ int[] sortingArray = new int[perm.Length - 2];
+ for (int i = 0; i < cities; i++)
+ perm[i] = i + 1;
+ for (int i = cities; i < cities + vehicles; i++)
+ perm[i] = 0;
+ for (int i = 0; i < perm.Length - 2; i++) {
+ sortingArray[i] = RandomParameter.ActualValue.Next(perm.Length * 2);
+ }
+ // shuffle perm from 1...n-1 by sorting sortingArray (perm[0] and perm[n] must stay 0)
+ bool done;
+ do {
+ done = true;
+ for (int i = 0; i < perm.Length - 3; i++) {
+ if (sortingArray[i] > sortingArray[i + 1]) {
+ int h = sortingArray[i];
+ sortingArray[i] = sortingArray[i + 1];
+ sortingArray[i + 1] = h;
+ h = perm[i + 1];
+ perm[i + 1] = perm[i + 2];
+ perm[i + 2] = h;
+ done = false;
+ }
+ }
+ } while (!done);
+
+ return new List(perm);
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/VRPEncoding.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/VRPEncoding.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/VRPEncoding.cs (revision 4362)
@@ -0,0 +1,44 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.VehicleRouting.Interfaces;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Problems.VehicleRouting.DomainModel;
+
+namespace HeuristicLab.Problems.VehicleRouting.Encodings {
+ [Item("VRPEncoding", "Represents a VRP encoding.")]
+ [StorableClass]
+ public abstract class VRPEncoding : Item, IVRPEncoding {
+ public abstract List GetTours();
+
+ [StorableConstructor]
+ protected VRPEncoding(bool deserializing) : base(deserializing) { }
+
+ public VRPEncoding()
+ : base() {
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/VRPOperator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/VRPOperator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/VRPOperator.cs (revision 4362)
@@ -0,0 +1,52 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.VehicleRouting.Interfaces;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Parameters;
+using HeuristicLab.Operators;
+
+namespace HeuristicLab.Problems.VehicleRouting.Encodings {
+ [Item("VRPOperator", "Represents a VRP operator.")]
+ [StorableClass]
+ public abstract class VRPOperator : SingleSuccessorOperator, IVRPOperator {
+ protected LookupParameter ProblemInstanceParameter {
+ get { return (LookupParameter)Parameters["ProblemInstance"]; }
+ }
+
+ protected IVRPProblemInstance ProblemInstance {
+ get { return ProblemInstanceParameter.ActualValue; }
+ }
+
+ [StorableConstructor]
+ protected VRPOperator(bool deserializing) : base(deserializing) { }
+
+ public VRPOperator()
+ : base() {
+ Parameters.Add(new LookupParameter("ProblemInstance", "The VRP problem instance"));
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj (revision 4361)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj (revision 4362)
@@ -106,10 +106,42 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
@@ -191,7 +223,5 @@
-
-
-
+
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLabProblemsVehicleRoutingPlugin.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLabProblemsVehicleRoutingPlugin.cs (revision 4361)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLabProblemsVehicleRoutingPlugin.cs (revision 4362)
@@ -26,5 +26,5 @@
/// Plugin class for HeuristicLab.Problems.VehicleRouting plugin
///
- [Plugin("HeuristicLab.Problems.VehicleRouting", "3.4.0.4360")]
+ [Plugin("HeuristicLab.Problems.VehicleRouting", "3.4.0.4361")]
[PluginFile("HeuristicLab.Problems.VehicleRouting-3.4.dll", PluginFileType.Assembly)]
[PluginDependency("HeuristicLab.Analysis", "3.3")]
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPCreator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPCreator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPCreator.cs (revision 4362)
@@ -0,0 +1,30 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces {
+ public interface IVRPCreator : IVRPOperator, ISolutionCreator {
+ ILookupParameter VRPToursParameter { get; }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPEncoding.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPEncoding.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPEncoding.cs (revision 4362)
@@ -0,0 +1,33 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Problems.VehicleRouting.DomainModel;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces {
+ public interface IVRPEncoding: IItem {
+ List GetTours();
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPEvaluator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPEvaluator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPEvaluator.cs (revision 4362)
@@ -0,0 +1,37 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Optimization;
+using HeuristicLab.Problems.VehicleRouting.DomainModel;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces {
+ public interface IVRPEvaluator: IVRPOperator, ISingleObjectiveEvaluator {
+ bool Feasible(IVRPProblemInstance instance, IVRPEncoding solution);
+ bool Feasible(IVRPProblemInstance instance, Tour tour);
+ double Evaluate(IVRPProblemInstance instance, IVRPEncoding solution);
+ double Evaluate(IVRPProblemInstance instance, Tour tour);
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPOperator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPOperator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPOperator.cs (revision 4362)
@@ -0,0 +1,31 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Core;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces {
+ public interface IVRPOperator: IItem {
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPProblemInstance.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPProblemInstance.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPProblemInstance.cs (revision 4362)
@@ -0,0 +1,53 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Optimization;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Problems.VehicleRouting.DomainModel;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces {
+ public interface IVRPProblemInstance: IItem {
+ IValueParameter EvaluatorParameter { get; }
+ IValueParameter SolutionCreatorParameter { get; }
+ IEnumerable Operators { get; }
+
+ DoubleMatrix Coordinates { get; }
+ DoubleMatrix DistanceMatrix { get; }
+ BoolValue UseDistanceMatrix { get; }
+ IntValue Vehicles { get; }
+ DoubleArray Demand { get; }
+ IntValue Cities { get; }
+
+ DoubleValue FleetUsageFactor { get; }
+ DoubleValue DistanceFactor { get; }
+
+ double GetDistance(int start, int end);
+ bool Feasible(IVRPEncoding solution);
+ bool Feasible(Tour tour);
+ double Evaluate(IVRPEncoding solution);
+ double Evaluate(Tour tour);
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Heterogenous/IHeterogenousCapacitatedEncoding.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Heterogenous/IHeterogenousCapacitatedEncoding.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Heterogenous/IHeterogenousCapacitatedEncoding.cs (revision 4362)
@@ -0,0 +1,31 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface IHeterogenousCapacitatedEncoding: ICapacitatedEncoding {
+ List GetVehicleAssignment();
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Heterogenous/IHeterogenousCapacitatedOperator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Heterogenous/IHeterogenousCapacitatedOperator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Heterogenous/IHeterogenousCapacitatedOperator.cs (revision 4362)
@@ -0,0 +1,30 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface IHeterogenousCapacitatedOperator: ICapacitatedOperator {
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Heterogenous/IHeterogenousCapacitatedProblemInstance.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Heterogenous/IHeterogenousCapacitatedProblemInstance.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Heterogenous/IHeterogenousCapacitatedProblemInstance.cs (revision 4362)
@@ -0,0 +1,30 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface IHeterogenousCapacitatedProblemInstance : ICapacitatedProblemInstance {
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Homogenous/ICapacitatedEncoding.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Homogenous/ICapacitatedEncoding.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Homogenous/ICapacitatedEncoding.cs (revision 4362)
@@ -0,0 +1,30 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface ICapacitatedEncoding: IVRPEncoding {
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Homogenous/ICapacitatedOperator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Homogenous/ICapacitatedOperator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Homogenous/ICapacitatedOperator.cs (revision 4362)
@@ -0,0 +1,30 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface ICapacitatedOperator: IVRPOperator {
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Homogenous/ICapacitatedProblemInstance.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Homogenous/ICapacitatedProblemInstance.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/Capacitated/Homogenous/ICapacitatedProblemInstance.cs (revision 4362)
@@ -0,0 +1,33 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Data;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface ICapacitatedProblemInstance: IVRPProblemInstance {
+ DoubleValue Capacity { get; }
+ DoubleValue OverloadPenalty { get; }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/SingleDepot/ISingleDepotEncoding.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/SingleDepot/ISingleDepotEncoding.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/SingleDepot/ISingleDepotEncoding.cs (revision 4362)
@@ -0,0 +1,30 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface ISingleDepotEncoding: IVRPEncoding {
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/SingleDepot/ISingleDepotOperator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/SingleDepot/ISingleDepotOperator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/SingleDepot/ISingleDepotOperator.cs (revision 4362)
@@ -0,0 +1,30 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface ISingleDepotOperator: IVRPOperator {
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/SingleDepot/ISingleDepotProblemInstance.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/SingleDepot/ISingleDepotProblemInstance.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/SingleDepot/ISingleDepotProblemInstance.cs (revision 4362)
@@ -0,0 +1,30 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface ISingleDepotProblemInstance: IVRPProblemInstance {
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/TimeWindowed/ITimeWindowedEncoding.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/TimeWindowed/ITimeWindowedEncoding.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/TimeWindowed/ITimeWindowedEncoding.cs (revision 4362)
@@ -0,0 +1,30 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface ITimeWindowedEncoding: IVRPEncoding {
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/TimeWindowed/ITimeWindowedOperator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/TimeWindowed/ITimeWindowedOperator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/TimeWindowed/ITimeWindowedOperator.cs (revision 4362)
@@ -0,0 +1,30 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface ITimeWindowedOperator: IVRPOperator {
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/TimeWindowed/ITimeWindowedProblemInstance.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/TimeWindowed/ITimeWindowedProblemInstance.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/Variants/TimeWindowed/ITimeWindowedProblemInstance.cs (revision 4362)
@@ -0,0 +1,36 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Data;
+
+namespace HeuristicLab.Problems.VehicleRouting.Interfaces.Variants {
+ public interface ITimeWindowedProblemInstance: IVRPProblemInstance {
+ DoubleArray ReadyTime { get; }
+ DoubleArray DueTime { get; }
+ DoubleArray ServiceTime { get; }
+ DoubleValue TimeFactor { get; }
+ DoubleValue TardinessPenalty { get; }
+ }
+}
Index: anches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ORLIBParser.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ORLIBParser.cs (revision 4361)
+++ (revision )
@@ -1,120 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.IO;
-using System.Globalization;
-
-namespace HeuristicLab.Problems.VehicleRouting {
- class ORLIBParser {
- private StreamReader source;
- CultureInfo culture = new CultureInfo("en-US");
-
- private string name;
- public string Name {
- get {
- return name;
- }
- }
-
- private double[,] vertices;
- public double[,] Vertices {
- get {
- return vertices;
- }
- }
-
- private double capacity;
- public double Capacity {
- get {
- return capacity;
- }
- }
-
- private double maxRouteTime;
- public double MaxRouteTime {
- get {
- return maxRouteTime;
- }
- }
-
- private double serviceTime;
- public double ServiceTime {
- get {
- return serviceTime;
- }
- }
-
- private double[] demands;
- public double[] Demands {
- get {
- return demands;
- }
- }
-
- public ORLIBParser(String path) {
- source = null;
-
- name = path;
- vertices = null;
- capacity = -1;
- maxRouteTime = -1;
- serviceTime = -1;
- demands = null;
- }
-
- public void Parse() {
- using (source = new StreamReader(name)) {
- //Read header
- string line = source.ReadLine();
- string[] tokens = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
-
- int customers = int.Parse(tokens[0]);
- demands = new double[customers + 1];
- demands[0] = 0;
- vertices = new double[customers + 1, 2];
-
- capacity = int.Parse(tokens[1]);
- maxRouteTime = int.Parse(tokens[2]);
- serviceTime = int.Parse(tokens[3]);
-
- //Read depot
- line = source.ReadLine();
- tokens = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
- vertices[0, 0] = double.Parse(tokens[0], culture.NumberFormat);
- vertices[0, 1] = double.Parse(tokens[1], culture.NumberFormat);
-
- for (int i = 0; i < customers; i++) {
- line = source.ReadLine();
- tokens = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
- vertices[i + 1, 0] = double.Parse(tokens[0], culture.NumberFormat);
- vertices[i + 1, 1] = double.Parse(tokens[1], culture.NumberFormat);
- demands[i + 1] = double.Parse(tokens[2], culture.NumberFormat);
- }
- }
-
- source = null;
- }
- }
-}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/ORLIBParser.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/ORLIBParser.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/ORLIBParser.cs (revision 4362)
@@ -0,0 +1,120 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO;
+using System.Globalization;
+
+namespace HeuristicLab.Problems.VehicleRouting.Parsers {
+ class ORLIBParser {
+ private StreamReader source;
+ CultureInfo culture = new CultureInfo("en-US");
+
+ private string name;
+ public string Name {
+ get {
+ return name;
+ }
+ }
+
+ private double[,] vertices;
+ public double[,] Vertices {
+ get {
+ return vertices;
+ }
+ }
+
+ private double capacity;
+ public double Capacity {
+ get {
+ return capacity;
+ }
+ }
+
+ private double maxRouteTime;
+ public double MaxRouteTime {
+ get {
+ return maxRouteTime;
+ }
+ }
+
+ private double serviceTime;
+ public double ServiceTime {
+ get {
+ return serviceTime;
+ }
+ }
+
+ private double[] demands;
+ public double[] Demands {
+ get {
+ return demands;
+ }
+ }
+
+ public ORLIBParser(String path) {
+ source = null;
+
+ name = path;
+ vertices = null;
+ capacity = -1;
+ maxRouteTime = -1;
+ serviceTime = -1;
+ demands = null;
+ }
+
+ public void Parse() {
+ using (source = new StreamReader(name)) {
+ //Read header
+ string line = source.ReadLine();
+ string[] tokens = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+
+ int customers = int.Parse(tokens[0]);
+ demands = new double[customers + 1];
+ demands[0] = 0;
+ vertices = new double[customers + 1, 2];
+
+ capacity = int.Parse(tokens[1]);
+ maxRouteTime = int.Parse(tokens[2]);
+ serviceTime = int.Parse(tokens[3]);
+
+ //Read depot
+ line = source.ReadLine();
+ tokens = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+ vertices[0, 0] = double.Parse(tokens[0], culture.NumberFormat);
+ vertices[0, 1] = double.Parse(tokens[1], culture.NumberFormat);
+
+ for (int i = 0; i < customers; i++) {
+ line = source.ReadLine();
+ tokens = line.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+ vertices[i + 1, 0] = double.Parse(tokens[0], culture.NumberFormat);
+ vertices[i + 1, 1] = double.Parse(tokens[1], culture.NumberFormat);
+ demands[i + 1] = double.Parse(tokens[2], culture.NumberFormat);
+ }
+ }
+
+ source = null;
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/SolomonParser.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/SolomonParser.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/SolomonParser.cs (revision 4362)
@@ -0,0 +1,156 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Text.RegularExpressions;
+
+namespace HeuristicLab.Problems.VehicleRouting.Parsers {
+ class SolomonParser {
+ private string file;
+ private string problemName;
+ private int cities;
+ private int vehicles;
+ private double capacity;
+ private List xCoord;
+ private List yCoord;
+ private List demand;
+ private List readyTime;
+ private List dueTime;
+ private List serviceTime;
+
+ public int Cities {
+ get {
+ return cities;
+ }
+ }
+
+ public int Vehicles {
+ get {
+ return vehicles;
+ }
+ }
+
+ public double Capacity {
+ get {
+ return capacity;
+ }
+ }
+
+ public double[,] Coordinates {
+ get {
+ double[] x = xCoord.ToArray();
+ double[] y = yCoord.ToArray();
+ double[,] coord = new double[x.Length, 2];
+ for (int i = 0; i < x.Length; i++) {
+ coord[i, 0] = x[i];
+ coord[i, 1] = y[i];
+ }
+ return coord;
+ }
+ }
+
+ public double[] Demands {
+ get {
+ return demand.ToArray();
+ }
+ }
+
+ public double[] Readytimes {
+ get {
+ return readyTime.ToArray();
+ }
+ }
+
+ public double[] Duetimes {
+ get {
+ return dueTime.ToArray();
+ }
+ }
+
+ public double[] Servicetimes {
+ get {
+ return serviceTime.ToArray();
+ }
+ }
+
+ public String ProblemName {
+ get {
+ return problemName;
+ }
+ }
+
+ public SolomonParser(string file) {
+ this.file = file;
+ xCoord = new List();
+ yCoord = new List();
+ demand = new List();
+ readyTime = new List();
+ dueTime = new List();
+ serviceTime = new List();
+ }
+
+ public void Parse() {
+ string line;
+ Regex reg = new Regex(@"-?\d+");
+ MatchCollection m;
+
+ StreamReader reader = new StreamReader(file);
+
+ problemName = reader.ReadLine();
+ for (int i = 0; i < 3; i++) {
+ reader.ReadLine();
+ }
+ line = reader.ReadLine();
+
+ m = reg.Matches(line);
+ if (m.Count != 2)
+ throw new InvalidDataException("File has wrong format!");
+
+ vehicles = int.Parse(m[0].Value);
+ capacity = double.Parse(m[1].Value);
+
+ for (int i = 0; i < 4; i++) {
+ reader.ReadLine();
+ }
+
+ line = reader.ReadLine();
+ while ((line != null) && (line.Length > 5)) {
+ m = reg.Matches(line);
+ if (m.Count != 7) { continue; }
+ xCoord.Add((double)int.Parse(m[1].Value));
+ yCoord.Add((double)int.Parse(m[2].Value));
+ demand.Add((double)int.Parse(m[3].Value));
+ readyTime.Add((double)int.Parse(m[4].Value));
+ double st = (double)int.Parse(m[6].Value);
+ dueTime.Add((double)int.Parse(m[5].Value));
+ serviceTime.Add(st);
+ line = reader.ReadLine();
+ }
+ cities = serviceTime.Count;
+ }
+
+ internal string OnReset() {
+ throw new NotImplementedException();
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/TSPLIBParser.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/TSPLIBParser.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Parsers/TSPLIBParser.cs (revision 4362)
@@ -0,0 +1,402 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Globalization;
+using System.IO;
+
+namespace HeuristicLab.Problems.VehicleRouting.Parsers {
+ ///
+ /// Parses a *.vrp file in TSPLIB format and extracts its information about a VRP.
+ ///
+ public class TSPLIBParser {
+ #region Inner Enum TSPLIBEdgeWeightType
+ public enum TSPLIBEdgeWeightType {
+ UNDEFINED,
+ EUC_2D,
+ GEO
+ }
+ #endregion
+
+ private const int EOF = 0;
+ private const int NAME = 1;
+ private const int TYPE = 2;
+ private const int COMMENT = 3;
+ private const int DIM = 4;
+ private const int WEIGHTTYPE = 5;
+ private const int WEIGHTFORMAT = 11;
+ private const int NODETYPE = 6;
+ private const int NODESECTION = 7;
+ private const int CAPACITY = 8;
+ private const int DISTANCE = 12;
+ private const int VEHICLES = 13;
+ private const int DEPOTSECTION = 9;
+ private const int DEMANDSECTION = 10;
+
+ private StreamReader source;
+ private bool alternateFormat;
+ CultureInfo culture = new CultureInfo("en-US");
+
+ private string name;
+ ///
+ /// Gets the name of the parsed VRP.
+ ///
+ public string Name {
+ get { return name; }
+ }
+ private string comment;
+ ///
+ /// Gets the comment of the parsed VRP.
+ ///
+ public string Comment {
+ get { return comment; }
+ }
+ private double[,] vertices;
+ ///
+ /// Gets the vertices of the parsed VRP.
+ ///
+ public double[,] Vertices {
+ get { return vertices; }
+ }
+ private TSPLIBEdgeWeightType weightType;
+ ///
+ /// Gets the weight format of the parsed VRP.
+ ///
+ public TSPLIBEdgeWeightType WeightType {
+ get { return weightType; }
+ }
+
+ private double capacity;
+ public double Capacity {
+ get {
+ return capacity;
+ }
+ }
+
+ private double distance;
+ public double Distance {
+ get {
+ return distance;
+ }
+ }
+
+ private int vehicles;
+ public int Vehicles {
+ get {
+ return vehicles;
+ }
+ }
+
+ private int depot;
+ public int Depot {
+ get {
+ return depot;
+ }
+ }
+
+ private double[] demands;
+ public double[] Demands {
+ get {
+ return demands;
+ }
+ }
+
+ ///
+ /// Initializes a new instance of with the given .
+ ///
+ /// Thrown if the input file is not a TSPLIB TSP file (*.vrp)
+ ///
+ /// The path where the VRP is stored.
+ public TSPLIBParser(String path) {
+ if (!path.EndsWith(".vrp"))
+ throw new ArgumentException("Input file has to be a TSPLIB CVRP file (*.vrp, *.txt).");
+
+ source = null;
+ name = path;
+ comment = string.Empty;
+ vertices = null;
+ weightType = TSPLIBEdgeWeightType.UNDEFINED;
+ capacity = -1;
+ distance = -1;
+ vehicles = -1;
+ depot = -1;
+ demands = null;
+ alternateFormat = false;
+ }
+
+ ///
+ /// Reads the TSPLIB VRP file and parses the elements.
+ ///
+ /// Thrown if the file has an invalid format or contains invalid data.
+ public void Parse() {
+ using (source = new StreamReader(name)) {
+ int section = -1;
+ string str = null;
+ bool typeIsChecked = false;
+ bool weightTypeIsChecked = false;
+ bool weightFormatIsChecked = false;
+
+ do {
+ str = source.ReadLine();
+ section = GetSection(str);
+
+ if (section != -1) {
+ switch (section) {
+ case NAME:
+ ReadName(str);
+ break;
+ case TYPE:
+ CheckType(str);
+ typeIsChecked = true;
+ break;
+ case COMMENT:
+ ReadComment(str);
+ break;
+ case DIM:
+ InitArrays(str);
+ break;
+ case WEIGHTTYPE:
+ ReadWeightType(str);
+ weightTypeIsChecked = true;
+ break;
+ case WEIGHTFORMAT:
+ ReadWeightFormat(str);
+ weightFormatIsChecked = true;
+ break;
+ case NODETYPE:
+ CheckNodeType(str);
+ break;
+ case NODESECTION:
+ ReadVertices();
+ break;
+ case CAPACITY:
+ ReadCapacity(str);
+ break;
+ case DISTANCE:
+ ReadDistance(str);
+ break;
+ case VEHICLES:
+ ReadVehicles(str);
+ break;
+ case DEPOTSECTION:
+ ReadDepot();
+ break;
+ case DEMANDSECTION:
+ ReadDemands();
+ break;
+ }
+ }
+ } while (!((section == EOF) || (str == null)));
+
+ if (!typeIsChecked || !weightTypeIsChecked ||
+ (alternateFormat && !weightFormatIsChecked) ||
+ weightType == TSPLIBEdgeWeightType.UNDEFINED)
+ throw new InvalidDataException("Input file does not contain format or edge weight format information.");
+ }
+ source = null;
+ }
+
+ private int GetSection(string str) {
+ if (str == null)
+ return EOF;
+
+ string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
+ if (tokens.Length == 0)
+ return -1;
+
+ string token = tokens[0].Trim();
+ if (token.Equals("eof", StringComparison.OrdinalIgnoreCase))
+ return EOF;
+ if (token.Equals("name", StringComparison.OrdinalIgnoreCase))
+ return NAME;
+ if (token.Equals("type", StringComparison.OrdinalIgnoreCase))
+ return TYPE;
+ if (token.Equals("comment", StringComparison.OrdinalIgnoreCase))
+ return COMMENT;
+ if (token.Equals("dimension", StringComparison.OrdinalIgnoreCase))
+ return DIM;
+ if (token.Equals("edge_weight_type", StringComparison.OrdinalIgnoreCase))
+ return WEIGHTTYPE;
+ if (token.Equals("edge_weight_format", StringComparison.OrdinalIgnoreCase))
+ return WEIGHTFORMAT;
+ if (token.Equals("node_coord_type", StringComparison.OrdinalIgnoreCase))
+ return NODETYPE;
+ if (token.Equals("node_coord_section", StringComparison.OrdinalIgnoreCase))
+ return NODESECTION;
+ if (token.Equals("capacity", StringComparison.OrdinalIgnoreCase))
+ return CAPACITY;
+ if (token.Equals("distance", StringComparison.OrdinalIgnoreCase))
+ return DISTANCE;
+ if (token.Equals("vehicles", StringComparison.OrdinalIgnoreCase))
+ return VEHICLES;
+ if (token.Equals("depot_section", StringComparison.OrdinalIgnoreCase))
+ return DEPOTSECTION;
+ if (token.Equals("demand_section", StringComparison.OrdinalIgnoreCase))
+ return DEMANDSECTION;
+
+ return -1;
+ }
+
+ private void ReadName(string str) {
+ string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
+ name = tokens[tokens.Length - 1].Trim();
+ }
+
+ private void CheckType(string str) {
+ string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
+
+ string type = tokens[tokens.Length - 1].Trim();
+ if (!type.Equals("cvrp", StringComparison.OrdinalIgnoreCase))
+ throw new InvalidDataException("Input file format is not \"CVRP\"");
+ }
+
+ private void ReadComment(string str) {
+ string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
+ comment = tokens[tokens.Length - 1].Trim();
+ }
+
+ private void InitArrays(string str) {
+ string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
+ string dimension = tokens[tokens.Length - 1].Trim();
+
+ int dim = Int32.Parse(dimension);
+ vertices = new double[dim, 2];
+ demands = new double[dim];
+ }
+
+ private void ReadWeightType(string str) {
+ string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
+ string type = tokens[tokens.Length - 1].Trim();
+
+ if (type.Equals("euc_2d", StringComparison.OrdinalIgnoreCase))
+ weightType = TSPLIBEdgeWeightType.EUC_2D;
+ else if (type.Equals("geo", StringComparison.OrdinalIgnoreCase))
+ weightType = TSPLIBEdgeWeightType.GEO;
+ else if (type.Equals("function", StringComparison.OrdinalIgnoreCase)) {
+ weightType = TSPLIBEdgeWeightType.UNDEFINED;
+ alternateFormat = true;
+ } else
+ throw new InvalidDataException("Input file contains an unsupported edge weight format (only \"EUC_2D\" and \"GEO\" are supported).");
+ }
+
+ private void ReadWeightFormat(string str) {
+ string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
+ string format = tokens[tokens.Length - 1].Trim();
+
+ if (alternateFormat && format.Equals("euc_2d", StringComparison.OrdinalIgnoreCase))
+ weightType = TSPLIBEdgeWeightType.EUC_2D;
+ else if (format.Equals("geo", StringComparison.OrdinalIgnoreCase))
+ weightType = TSPLIBEdgeWeightType.GEO;
+ else
+ throw new InvalidDataException("Input file contains an unsupported edge weight format.");
+ }
+
+ private void CheckNodeType(string str) {
+ string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
+ string type = tokens[tokens.Length - 1].Trim();
+
+ if (!type.Equals("twod_coords", StringComparison.OrdinalIgnoreCase))
+ throw new InvalidDataException("Input file contains an unsupported node coordinates format (only \"TWOD_COORDS\" is supported).");
+ }
+
+ private void ReadVertices() {
+ if (vertices == null)
+ throw new InvalidDataException("Input file does not contain dimension information.");
+
+ for (int i = 0; i < (vertices.Length / 2); i++) {
+ if (!(alternateFormat && i == 0)) {
+ string str = source.ReadLine();
+ string[] tokens = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+
+ if (tokens.Length != 3)
+ throw new InvalidDataException("Input file contains invalid node coordinates.");
+
+ vertices[i, 0] = double.Parse(tokens[1], culture.NumberFormat);
+ vertices[i, 1] = double.Parse(tokens[2], culture.NumberFormat);
+ }
+ }
+ }
+
+ private void ReadCapacity(string str) {
+ string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
+ capacity = double.Parse(tokens[tokens.Length - 1].Trim(), culture.NumberFormat);
+ }
+
+ private void ReadDistance(string str) {
+ string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
+ distance = double.Parse(tokens[tokens.Length - 1].Trim(), culture.NumberFormat);
+ }
+
+ private void ReadVehicles(string str) {
+ string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
+ vehicles = int.Parse(tokens[tokens.Length - 1].Trim());
+ }
+
+ private void ReadDepot() {
+ if (alternateFormat) {
+ string[] tokens;
+ do {
+ string str = source.ReadLine();
+ tokens = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+
+ if (tokens.Length == 2) {
+ vertices[0, 0] = double.Parse(tokens[0], culture.NumberFormat);
+ vertices[0, 1] = double.Parse(tokens[1], culture.NumberFormat);
+ depot = 1;
+ }
+ } while(tokens.Length == 2);
+ } else {
+ int read;
+ do {
+ string str = source.ReadLine();
+ read = int.Parse(str);
+ if (read != -1)
+ depot = read;
+ } while (read != -1);
+ }
+ }
+
+ private void ReadDemands() {
+ if (demands == null)
+ throw new InvalidDataException("Input file does not contain dimension information.");
+
+ for (int i = 0; i < demands.Length; i++) {
+ if (!(alternateFormat && i == 0)) {
+ string str = source.ReadLine();
+ string[] tokens = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
+
+ if (tokens.Length != 2)
+ throw new InvalidDataException("Input file contains invalid demands.");
+
+ int index = int.Parse(tokens[0]);
+ double value = double.Parse(tokens[1]);
+
+ if (alternateFormat)
+ demands[index] = value;
+ else
+ demands[index - 1] = value;
+ } else {
+ demands[0] = 0;
+ }
+ }
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/CVRPProblemInstance.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/CVRPProblemInstance.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/CVRPProblemInstance.cs (revision 4362)
@@ -0,0 +1,70 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.VehicleRouting.Interfaces;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Parameters;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.VehicleRouting.Interfaces.Variants;
+
+namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
+ [Item("CVRPProblemInstance", "Represents a single depot CVRP instance.")]
+ [StorableClass]
+ public class CVRPProblemInstance: SingleDepotVRPProblemInstance, ICapacitatedProblemInstance {
+ protected ValueParameter CapacityParameter {
+ get { return (ValueParameter)Parameters["Capacity"]; }
+ }
+ public IValueParameter OverloadPenaltyParameter {
+ get { return (IValueParameter)Parameters["EvalOverloadPenalty"]; }
+ }
+
+ public DoubleValue Capacity {
+ get { return CapacityParameter.Value; }
+ set { CapacityParameter.Value = value; }
+ }
+ public DoubleValue OverloadPenalty {
+ get { return OverloadPenaltyParameter.Value; }
+ set { OverloadPenaltyParameter.Value = value; }
+ }
+
+ public override IEnumerable Operators {
+ get {
+ return base.Operators
+ .Where(o => o is ICapacitatedOperator).Cast();
+ }
+ }
+
+ [StorableConstructor]
+ protected CVRPProblemInstance(bool deserializing) : base(deserializing) { }
+
+ public CVRPProblemInstance() {
+ Parameters.Add(new ValueParameter("Capacity", "The capacity of each vehicle.", new DoubleValue(0)));
+ Parameters.Add(new ValueParameter("EvalOverloadPenalty", "The overload penalty considered in the evaluation.", new DoubleValue(100)));
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/CVRPTWProblemInstance.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/CVRPTWProblemInstance.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/CVRPTWProblemInstance.cs (revision 4362)
@@ -0,0 +1,96 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.VehicleRouting.Interfaces;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Parameters;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.VehicleRouting.Interfaces.Variants;
+
+namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
+ [Item("CVRPTWProblemInstance", "Represents a single depot CVRPTW instance.")]
+ [StorableClass]
+ public class CVRPTWProblemInstance: CVRPProblemInstance, ITimeWindowedProblemInstance {
+ protected ValueParameter ReadyTimeParameter {
+ get { return (ValueParameter)Parameters["ReadyTime"]; }
+ }
+ protected ValueParameter DueTimeParameter {
+ get { return (ValueParameter)Parameters["DueTime"]; }
+ }
+ protected ValueParameter ServiceTimeParameter {
+ get { return (ValueParameter)Parameters["ServiceTime"]; }
+ }
+
+ protected IValueParameter TimeFactorParameter {
+ get { return (IValueParameter)Parameters["EvalTimeFactor"]; }
+ }
+ public IValueParameter TardinessPenaltyParameter {
+ get { return (IValueParameter)Parameters["EvalTardinessPenalty"]; }
+ }
+
+ public DoubleArray ReadyTime {
+ get { return ReadyTimeParameter.Value; }
+ set { ReadyTimeParameter.Value = value; }
+ }
+ public DoubleArray DueTime {
+ get { return DueTimeParameter.Value; }
+ set { DueTimeParameter.Value = value; }
+ }
+ public DoubleArray ServiceTime {
+ get { return ServiceTimeParameter.Value; }
+ set { ServiceTimeParameter.Value = value; }
+ }
+ public DoubleValue TimeFactor {
+ get { return TimeFactorParameter.Value; }
+ set { TimeFactorParameter.Value = value; }
+ }
+ public DoubleValue TardinessPenalty {
+ get { return TardinessPenaltyParameter.Value; }
+ set { TardinessPenaltyParameter.Value = value; }
+ }
+
+ public override IEnumerable Operators {
+ get {
+ return base.Operators
+ .Where(o => o is ITimeWindowedOperator).Cast();
+ }
+ }
+
+ [StorableConstructor]
+ protected CVRPTWProblemInstance(bool deserializing) : base(deserializing) { }
+
+ public CVRPTWProblemInstance() {
+ Parameters.Add(new ValueParameter("ReadyTime", "The ready time of each customer.", new DoubleArray()));
+ Parameters.Add(new ValueParameter("DueTime", "The due time of each customer.", new DoubleArray()));
+ Parameters.Add(new ValueParameter("ServiceTime", "The service time of each customer.", new DoubleArray()));
+
+ Parameters.Add(new ValueParameter("EvalTimeFactor", "The time factor considered in the evaluation.", new DoubleValue(0)));
+ Parameters.Add(new ValueParameter("EvalTardinessPenalty", "The tardiness penalty considered in the evaluation.", new DoubleValue(100)));
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/CVRPEvaluation.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/CVRPEvaluation.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/CVRPEvaluation.cs (revision 4362)
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances.Evaluation {
+ public class CVRPEvaluation: VRPEvaluation {
+ public double Overload { get; set; }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/CVRPTWEvaluation.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/CVRPTWEvaluation.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/CVRPTWEvaluation.cs (revision 4362)
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances.Evaluation {
+ public class CVRPTWEvaluation: CVRPEvaluation {
+ public double Tardiness { get; set; }
+ public double TravelTime { get; set; }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/Evaluators/SingleDepotVRPEvaluator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/Evaluators/SingleDepotVRPEvaluator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/Evaluators/SingleDepotVRPEvaluator.cs (revision 4362)
@@ -0,0 +1,51 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.VehicleRouting.Interfaces;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Parameters;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.VehicleRouting.Interfaces.Variants;
+using HeuristicLab.Problems.VehicleRouting.Encodings;
+using HeuristicLab.Problems.VehicleRouting.DomainModel;
+
+namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances.Evaluation {
+ [Item("SingleDepotVRPEvaluator", "Represents a single depot VRP evaluator.")]
+ [StorableClass]
+ public class SingleDepotVRPEvaluator: VRPEvaluator {
+ protected override void EvaluateTour(VRPEvaluation eval, IVRPProblemInstance instance, Tour tour) {
+
+ }
+
+ [StorableConstructor]
+ protected SingleDepotVRPEvaluator(bool deserializing) : base(deserializing) { }
+
+ public SingleDepotVRPEvaluator() {
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/Evaluators/VRPEvaluator.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/Evaluators/VRPEvaluator.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/Evaluators/VRPEvaluator.cs (revision 4362)
@@ -0,0 +1,152 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.VehicleRouting.Interfaces;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Parameters;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.VehicleRouting.Interfaces.Variants;
+using HeuristicLab.Problems.VehicleRouting.Encodings;
+using HeuristicLab.Problems.VehicleRouting.DomainModel;
+
+namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances.Evaluation {
+ [Item("VRPEvaluator", "Represents a VRP evaluator.")]
+ [StorableClass]
+ public abstract class VRPEvaluator: VRPOperator, IVRPEvaluator {
+ public ILookupParameter VRPToursParameter {
+ get { return (ILookupParameter)Parameters["VRPTours"]; }
+ }
+
+ #region ISingleObjectiveEvaluator Members
+
+ public ILookupParameter QualityParameter {
+ get { return (ILookupParameter)Parameters["Quality"]; }
+ }
+
+ public ILookupParameter DistanceParameter {
+ get { return (ILookupParameter)Parameters["Distance"]; }
+ }
+ public ILookupParameter VehcilesUtilizedParameter {
+ get { return (ILookupParameter)Parameters["VehiclesUtilized"]; }
+ }
+
+ public ILookupParameter FleetUsageFactor {
+ get { return (ILookupParameter)Parameters["EvalFleetUsageFactor"]; }
+ }
+ public ILookupParameter DistanceFactor {
+ get { return (ILookupParameter)Parameters["EvalDistanceFactor"]; }
+ }
+
+ #endregion
+
+ [StorableConstructor]
+ protected VRPEvaluator(bool deserializing) : base(deserializing) { }
+
+ public VRPEvaluator() {
+ Parameters.Add(new LookupParameter("VRPTours", "The VRP tours which should be evaluated."));
+
+ Parameters.Add(new LookupParameter("EvalFleetUsageFactor", "The fleet usage factor considered in the evaluation."));
+ Parameters.Add(new LookupParameter("EvalDistanceFactor", "The distance factor considered in the evaluation."));
+
+ Parameters.Add(new LookupParameter("Quality", "The evaluated quality of the VRP solution."));
+ Parameters.Add(new LookupParameter("Distance", "The distance."));
+ Parameters.Add(new LookupParameter("VehiclesUtilized", "The number of vehicles utilized."));
+ }
+
+ protected virtual VRPEvaluation CreateTourEvaluation() {
+ return new VRPEvaluation();
+ }
+
+ protected abstract void EvaluateTour(VRPEvaluation eval, IVRPProblemInstance instance, Tour tour);
+
+ protected VRPEvaluation EvaluateTour(IVRPProblemInstance instance, Tour tour) {
+ VRPEvaluation evaluation = CreateTourEvaluation();
+ EvaluateTour(evaluation, instance, tour);
+ return evaluation;
+ }
+
+ protected virtual void InitResultParameters() {
+ QualityParameter.ActualValue = new DoubleValue(0);
+ VehcilesUtilizedParameter.ActualValue = new DoubleValue(0);
+ DistanceParameter.ActualValue = new DoubleValue(0);
+ }
+
+ protected virtual void UpdateResultParameters(VRPEvaluation tourEvaluation) {
+ QualityParameter.ActualValue.Value += tourEvaluation.Quality;
+ VehcilesUtilizedParameter.ActualValue.Value += tourEvaluation.VehicleUtilization;
+ DistanceParameter.ActualValue.Value += tourEvaluation.Distance;
+ }
+
+ #region IVRPEvaluator Members
+
+ public bool Feasible(IVRPProblemInstance instance, IVRPEncoding solution) {
+ bool feasible = true;
+
+ foreach (Tour tour in solution.GetTours()) {
+ if (!Feasible(instance, tour)) {
+ feasible = false;
+ break;
+ }
+ }
+
+ return feasible;
+ }
+
+ public bool Feasible(IVRPProblemInstance instance, Tour tour) {
+ return EvaluateTour(instance, tour).Penalty == 0;
+ }
+
+ public double Evaluate(IVRPProblemInstance instance, IVRPEncoding solution) {
+ double quality = 0;
+
+ foreach (Tour tour in solution.GetTours()) {
+ quality += Evaluate(instance, tour);
+ }
+
+ return quality;
+ }
+
+ public double Evaluate(IVRPProblemInstance instance, Tour tour) {
+ return EvaluateTour(instance, tour).Quality;
+ }
+
+ public override IOperation Apply() {
+ InitResultParameters();
+
+ foreach (Tour tour in VRPToursParameter.ActualValue.GetTours()) {
+ VRPEvaluation tourEvaluation = EvaluateTour(ProblemInstance, tour);
+
+ UpdateResultParameters(tourEvaluation);
+ }
+
+ return base.Apply();
+ }
+
+ #endregion
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/VRPEvaluation.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/VRPEvaluation.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/Evaluation/VRPEvaluation.cs (revision 4362)
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances.Evaluation {
+ public class VRPEvaluation {
+ public double Quality { get; set; }
+ public double Distance { get; set; }
+ public int VehicleUtilization { get; set; }
+
+ public double Penalty { get; set; }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRPProblemInstance.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRPProblemInstance.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/SingleDepotVRPProblemInstance.cs (revision 4362)
@@ -0,0 +1,64 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.VehicleRouting.Interfaces;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Parameters;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.VehicleRouting.Interfaces.Variants;
+using HeuristicLab.Problems.VehicleRouting.ProblemInstances.Evaluation;
+
+namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
+ [Item("SingleDepotVRPProblemInstance", "Represents a single depot VRP instance.")]
+ [StorableClass]
+ public class SingleDepotVRPProblemInstance: VRPProblemInstance, ISingleDepotProblemInstance {
+ public override IEnumerable Operators {
+ get {
+ return ApplicationManager.Manager.GetInstances().Cast();
+ }
+ }
+
+ protected override IVRPEvaluator Evaluator {
+ get {
+ return new SingleDepotVRPEvaluator();
+ }
+ }
+
+ protected override IVRPCreator Creator {
+ get {
+ return new HeuristicLab.Problems.VehicleRouting.Encodings.Alba.RandomCreator();
+ }
+ }
+
+ [StorableConstructor]
+ protected SingleDepotVRPProblemInstance(bool deserializing) : base(deserializing) { }
+
+ public SingleDepotVRPProblemInstance() {
+ }
+ }
+}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs (revision 4362)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs (revision 4362)
@@ -0,0 +1,188 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see .
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Problems.VehicleRouting.Interfaces;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Core;
+using HeuristicLab.Parameters;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.VehicleRouting.DomainModel;
+
+namespace HeuristicLab.Problems.VehicleRouting.ProblemInstances {
+ [Item("VRPProblemInstance", "Represents a VRP instance.")]
+ [StorableClass]
+ public abstract class VRPProblemInstance: ParameterizedNamedItem, IVRPProblemInstance {
+ public IValueParameter EvaluatorParameter {
+ get { return (ValueParameter)Parameters["Evaluator"]; }
+ }
+
+ public IValueParameter SolutionCreatorParameter {
+ get { return (ValueParameter)Parameters["SolutionCreator"]; }
+ }
+
+ public abstract IEnumerable Operators { get; }
+
+ protected ValueParameter CoordinatesParameter {
+ get { return (ValueParameter)Parameters["Coordinates"]; }
+ }
+ protected OptionalValueParameter DistanceMatrixParameter {
+ get { return (OptionalValueParameter)Parameters["DistanceMatrix"]; }
+ }
+ protected ValueParameter UseDistanceMatrixParameter {
+ get { return (ValueParameter)Parameters["UseDistanceMatrix"]; }
+ }
+ protected ValueParameter VehiclesParameter {
+ get { return (ValueParameter)Parameters["Vehicles"]; }
+ }
+ protected ValueParameter DemandParameter {
+ get { return (ValueParameter)Parameters["Demand"]; }
+ }
+
+ protected IValueParameter FleetUsageFactorParameter {
+ get { return (IValueParameter)Parameters["EvalFleetUsageFactor"]; }
+ }
+ protected IValueParameter DistanceFactorParameter {
+ get { return (IValueParameter)Parameters["EvalDistanceFactor"]; }
+ }
+
+ public DoubleMatrix Coordinates {
+ get { return CoordinatesParameter.Value; }
+ set { CoordinatesParameter.Value = value; }
+ }
+ public DoubleMatrix DistanceMatrix {
+ get { return DistanceMatrixParameter.Value; }
+ set { DistanceMatrixParameter.Value = value; }
+ }
+ public BoolValue UseDistanceMatrix {
+ get { return UseDistanceMatrixParameter.Value; }
+ set { UseDistanceMatrixParameter.Value = value; }
+ }
+ public IntValue Vehicles {
+ get { return VehiclesParameter.Value; }
+ set { VehiclesParameter.Value = value; }
+ }
+ public DoubleArray Demand {
+ get { return DemandParameter.Value; }
+ set { DemandParameter.Value = value; }
+ }
+ public IntValue Cities {
+ get { return new IntValue(Demand.Length); }
+ }
+
+ public DoubleValue FleetUsageFactor {
+ get { return FleetUsageFactorParameter.Value; }
+ set { FleetUsageFactorParameter.Value = value; }
+ }
+ public DoubleValue DistanceFactor {
+ get { return DistanceFactorParameter.Value; }
+ set { DistanceFactorParameter.Value = value; }
+ }
+
+ private double CalculateDistance(int start, int end) {
+ double distance = 0.0;
+
+ distance =
+ Math.Sqrt(
+ Math.Pow(Coordinates[start, 0] - Coordinates[end, 0], 2) +
+ Math.Pow(Coordinates[start, 1] - Coordinates[end, 1], 2));
+
+ return distance;
+ }
+
+ private DoubleMatrix CreateDistanceMatrix() {
+ DoubleMatrix distanceMatrix = new DoubleMatrix(Coordinates.Rows, Coordinates.Rows);
+
+ for (int i = 0; i < distanceMatrix.Rows; i++) {
+ for (int j = i; j < distanceMatrix.Columns; j++) {
+ double distance = CalculateDistance(i, j);
+
+ distanceMatrix[i, j] = distance;
+ distanceMatrix[j, i] = distance;
+ }
+ }
+
+ return distanceMatrix;
+ }
+
+ public double GetDistance(int start, int end) {
+ double distance = 0.0;
+
+ if (UseDistanceMatrix.Value) {
+ if (DistanceMatrixParameter.Value != null) {
+ distance = DistanceMatrixParameter.Value[start, end];
+ } else {
+ if (DistanceMatrixParameter.ActualValue == null) {
+ DistanceMatrixParameter.ActualValue = CreateDistanceMatrix();
+ }
+
+ distance = DistanceMatrix[start, end];
+ }
+ } else {
+ distance = CalculateDistance(start, end);
+ }
+
+ return distance;
+ }
+
+ public bool Feasible(IVRPEncoding solution) {
+ return EvaluatorParameter.Value.Feasible(this, solution);
+ }
+
+ public bool Feasible(Tour tour) {
+ return EvaluatorParameter.Value.Feasible(this, tour);
+ }
+
+ public double Evaluate(IVRPEncoding solution) {
+ return EvaluatorParameter.Value.Evaluate(this, solution);
+ }
+
+ public double Evaluate(Tour tour) {
+ return EvaluatorParameter.Value.Evaluate(this, tour);
+ }
+
+ protected abstract IVRPEvaluator Evaluator { get; }
+ protected abstract IVRPCreator Creator { get; }
+
+ [StorableConstructor]
+ protected VRPProblemInstance(bool deserializing) : base(deserializing) { }
+
+ public VRPProblemInstance()
+ : base() {
+ Parameters.Add(new ValueParameter("Coordinates", "The x- and y-Coordinates of the cities.", new DoubleMatrix()));
+ Parameters.Add(new OptionalValueParameter("DistanceMatrix", "The matrix which contains the distances between the cities."));
+ Parameters.Add(new ValueParameter("UseDistanceMatrix", "True if a distance matrix should be calculated and used for evaluation, otherwise false.", new BoolValue(true)));
+ Parameters.Add(new ValueParameter("Vehicles", "The number of vehicles.", new IntValue(0)));
+ Parameters.Add(new ValueParameter("Demand", "The demand of each customer.", new DoubleArray()));
+
+ Parameters.Add(new ValueParameter("EvalFleetUsageFactor", "The fleet usage factor considered in the evaluation.", new DoubleValue(100)));
+ Parameters.Add(new ValueParameter("EvalDistanceFactor", "The distance factor considered in the evaluation.", new DoubleValue(1)));
+
+ Parameters.Add(new ValueParameter("SolutionCreator", "The operator which should be used to create new VRP solutions.", Creator));
+ Parameters.Add(new ValueParameter("Evaluator", "The operator which should be used to evaluate VRP solutions.", Evaluator));
+ }
+ }
+}
Index: anches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/SolomonParser.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/SolomonParser.cs (revision 4361)
+++ (revision )
@@ -1,156 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text.RegularExpressions;
-
-namespace HeuristicLab.Problems.VehicleRouting {
- class SolomonParser {
- private string file;
- private string problemName;
- private int cities;
- private int vehicles;
- private double capacity;
- private List xCoord;
- private List yCoord;
- private List demand;
- private List readyTime;
- private List dueTime;
- private List serviceTime;
-
- public int Cities {
- get {
- return cities;
- }
- }
-
- public int Vehicles {
- get {
- return vehicles;
- }
- }
-
- public double Capacity {
- get {
- return capacity;
- }
- }
-
- public double[,] Coordinates {
- get {
- double[] x = xCoord.ToArray();
- double[] y = yCoord.ToArray();
- double[,] coord = new double[x.Length, 2];
- for (int i = 0; i < x.Length; i++) {
- coord[i, 0] = x[i];
- coord[i, 1] = y[i];
- }
- return coord;
- }
- }
-
- public double[] Demands {
- get {
- return demand.ToArray();
- }
- }
-
- public double[] Readytimes {
- get {
- return readyTime.ToArray();
- }
- }
-
- public double[] Duetimes {
- get {
- return dueTime.ToArray();
- }
- }
-
- public double[] Servicetimes {
- get {
- return serviceTime.ToArray();
- }
- }
-
- public String ProblemName {
- get {
- return problemName;
- }
- }
-
- public SolomonParser(string file) {
- this.file = file;
- xCoord = new List();
- yCoord = new List();
- demand = new List();
- readyTime = new List();
- dueTime = new List();
- serviceTime = new List();
- }
-
- public void Parse() {
- string line;
- Regex reg = new Regex(@"-?\d+");
- MatchCollection m;
-
- StreamReader reader = new StreamReader(file);
-
- problemName = reader.ReadLine();
- for (int i = 0; i < 3; i++) {
- reader.ReadLine();
- }
- line = reader.ReadLine();
-
- m = reg.Matches(line);
- if (m.Count != 2)
- throw new InvalidDataException("File has wrong format!");
-
- vehicles = int.Parse(m[0].Value);
- capacity = double.Parse(m[1].Value);
-
- for (int i = 0; i < 4; i++) {
- reader.ReadLine();
- }
-
- line = reader.ReadLine();
- while ((line != null) && (line.Length > 5)) {
- m = reg.Matches(line);
- if (m.Count != 7) { continue; }
- xCoord.Add((double)int.Parse(m[1].Value));
- yCoord.Add((double)int.Parse(m[2].Value));
- demand.Add((double)int.Parse(m[3].Value));
- readyTime.Add((double)int.Parse(m[4].Value));
- double st = (double)int.Parse(m[6].Value);
- dueTime.Add((double)int.Parse(m[5].Value));
- serviceTime.Add(st);
- line = reader.ReadLine();
- }
- cities = serviceTime.Count;
- }
-
- internal string OnReset() {
- throw new NotImplementedException();
- }
- }
-}
Index: anches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/TSPLIBParser.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/TSPLIBParser.cs (revision 4361)
+++ (revision )
@@ -1,402 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using System;
-using System.Globalization;
-using System.IO;
-
-namespace HeuristicLab.Problems.VehicleRouting {
- ///
- /// Parses a *.vrp file in TSPLIB format and extracts its information about a VRP.
- ///
- public class TSPLIBParser {
- #region Inner Enum TSPLIBEdgeWeightType
- public enum TSPLIBEdgeWeightType {
- UNDEFINED,
- EUC_2D,
- GEO
- }
- #endregion
-
- private const int EOF = 0;
- private const int NAME = 1;
- private const int TYPE = 2;
- private const int COMMENT = 3;
- private const int DIM = 4;
- private const int WEIGHTTYPE = 5;
- private const int WEIGHTFORMAT = 11;
- private const int NODETYPE = 6;
- private const int NODESECTION = 7;
- private const int CAPACITY = 8;
- private const int DISTANCE = 12;
- private const int VEHICLES = 13;
- private const int DEPOTSECTION = 9;
- private const int DEMANDSECTION = 10;
-
- private StreamReader source;
- private bool alternateFormat;
- CultureInfo culture = new CultureInfo("en-US");
-
- private string name;
- ///
- /// Gets the name of the parsed VRP.
- ///
- public string Name {
- get { return name; }
- }
- private string comment;
- ///
- /// Gets the comment of the parsed VRP.
- ///
- public string Comment {
- get { return comment; }
- }
- private double[,] vertices;
- ///
- /// Gets the vertices of the parsed VRP.
- ///
- public double[,] Vertices {
- get { return vertices; }
- }
- private TSPLIBEdgeWeightType weightType;
- ///
- /// Gets the weight format of the parsed VRP.
- ///
- public TSPLIBEdgeWeightType WeightType {
- get { return weightType; }
- }
-
- private double capacity;
- public double Capacity {
- get {
- return capacity;
- }
- }
-
- private double distance;
- public double Distance {
- get {
- return distance;
- }
- }
-
- private int vehicles;
- public int Vehicles {
- get {
- return vehicles;
- }
- }
-
- private int depot;
- public int Depot {
- get {
- return depot;
- }
- }
-
- private double[] demands;
- public double[] Demands {
- get {
- return demands;
- }
- }
-
- ///
- /// Initializes a new instance of with the given .
- ///
- /// Thrown if the input file is not a TSPLIB TSP file (*.vrp)
- ///
- /// The path where the VRP is stored.
- public TSPLIBParser(String path) {
- if (!path.EndsWith(".vrp"))
- throw new ArgumentException("Input file has to be a TSPLIB CVRP file (*.vrp, *.txt).");
-
- source = null;
- name = path;
- comment = string.Empty;
- vertices = null;
- weightType = TSPLIBEdgeWeightType.UNDEFINED;
- capacity = -1;
- distance = -1;
- vehicles = -1;
- depot = -1;
- demands = null;
- alternateFormat = false;
- }
-
- ///
- /// Reads the TSPLIB VRP file and parses the elements.
- ///
- /// Thrown if the file has an invalid format or contains invalid data.
- public void Parse() {
- using (source = new StreamReader(name)) {
- int section = -1;
- string str = null;
- bool typeIsChecked = false;
- bool weightTypeIsChecked = false;
- bool weightFormatIsChecked = false;
-
- do {
- str = source.ReadLine();
- section = GetSection(str);
-
- if (section != -1) {
- switch (section) {
- case NAME:
- ReadName(str);
- break;
- case TYPE:
- CheckType(str);
- typeIsChecked = true;
- break;
- case COMMENT:
- ReadComment(str);
- break;
- case DIM:
- InitArrays(str);
- break;
- case WEIGHTTYPE:
- ReadWeightType(str);
- weightTypeIsChecked = true;
- break;
- case WEIGHTFORMAT:
- ReadWeightFormat(str);
- weightFormatIsChecked = true;
- break;
- case NODETYPE:
- CheckNodeType(str);
- break;
- case NODESECTION:
- ReadVertices();
- break;
- case CAPACITY:
- ReadCapacity(str);
- break;
- case DISTANCE:
- ReadDistance(str);
- break;
- case VEHICLES:
- ReadVehicles(str);
- break;
- case DEPOTSECTION:
- ReadDepot();
- break;
- case DEMANDSECTION:
- ReadDemands();
- break;
- }
- }
- } while (!((section == EOF) || (str == null)));
-
- if (!typeIsChecked || !weightTypeIsChecked ||
- (alternateFormat && !weightFormatIsChecked) ||
- weightType == TSPLIBEdgeWeightType.UNDEFINED)
- throw new InvalidDataException("Input file does not contain format or edge weight format information.");
- }
- source = null;
- }
-
- private int GetSection(string str) {
- if (str == null)
- return EOF;
-
- string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
- if (tokens.Length == 0)
- return -1;
-
- string token = tokens[0].Trim();
- if (token.Equals("eof", StringComparison.OrdinalIgnoreCase))
- return EOF;
- if (token.Equals("name", StringComparison.OrdinalIgnoreCase))
- return NAME;
- if (token.Equals("type", StringComparison.OrdinalIgnoreCase))
- return TYPE;
- if (token.Equals("comment", StringComparison.OrdinalIgnoreCase))
- return COMMENT;
- if (token.Equals("dimension", StringComparison.OrdinalIgnoreCase))
- return DIM;
- if (token.Equals("edge_weight_type", StringComparison.OrdinalIgnoreCase))
- return WEIGHTTYPE;
- if (token.Equals("edge_weight_format", StringComparison.OrdinalIgnoreCase))
- return WEIGHTFORMAT;
- if (token.Equals("node_coord_type", StringComparison.OrdinalIgnoreCase))
- return NODETYPE;
- if (token.Equals("node_coord_section", StringComparison.OrdinalIgnoreCase))
- return NODESECTION;
- if (token.Equals("capacity", StringComparison.OrdinalIgnoreCase))
- return CAPACITY;
- if (token.Equals("distance", StringComparison.OrdinalIgnoreCase))
- return DISTANCE;
- if (token.Equals("vehicles", StringComparison.OrdinalIgnoreCase))
- return VEHICLES;
- if (token.Equals("depot_section", StringComparison.OrdinalIgnoreCase))
- return DEPOTSECTION;
- if (token.Equals("demand_section", StringComparison.OrdinalIgnoreCase))
- return DEMANDSECTION;
-
- return -1;
- }
-
- private void ReadName(string str) {
- string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
- name = tokens[tokens.Length - 1].Trim();
- }
-
- private void CheckType(string str) {
- string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
-
- string type = tokens[tokens.Length - 1].Trim();
- if (!type.Equals("cvrp", StringComparison.OrdinalIgnoreCase))
- throw new InvalidDataException("Input file format is not \"CVRP\"");
- }
-
- private void ReadComment(string str) {
- string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
- comment = tokens[tokens.Length - 1].Trim();
- }
-
- private void InitArrays(string str) {
- string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
- string dimension = tokens[tokens.Length - 1].Trim();
-
- int dim = Int32.Parse(dimension);
- vertices = new double[dim, 2];
- demands = new double[dim];
- }
-
- private void ReadWeightType(string str) {
- string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
- string type = tokens[tokens.Length - 1].Trim();
-
- if (type.Equals("euc_2d", StringComparison.OrdinalIgnoreCase))
- weightType = TSPLIBEdgeWeightType.EUC_2D;
- else if (type.Equals("geo", StringComparison.OrdinalIgnoreCase))
- weightType = TSPLIBEdgeWeightType.GEO;
- else if (type.Equals("function", StringComparison.OrdinalIgnoreCase)) {
- weightType = TSPLIBEdgeWeightType.UNDEFINED;
- alternateFormat = true;
- } else
- throw new InvalidDataException("Input file contains an unsupported edge weight format (only \"EUC_2D\" and \"GEO\" are supported).");
- }
-
- private void ReadWeightFormat(string str) {
- string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
- string format = tokens[tokens.Length - 1].Trim();
-
- if (alternateFormat && format.Equals("euc_2d", StringComparison.OrdinalIgnoreCase))
- weightType = TSPLIBEdgeWeightType.EUC_2D;
- else if (format.Equals("geo", StringComparison.OrdinalIgnoreCase))
- weightType = TSPLIBEdgeWeightType.GEO;
- else
- throw new InvalidDataException("Input file contains an unsupported edge weight format.");
- }
-
- private void CheckNodeType(string str) {
- string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
- string type = tokens[tokens.Length - 1].Trim();
-
- if (!type.Equals("twod_coords", StringComparison.OrdinalIgnoreCase))
- throw new InvalidDataException("Input file contains an unsupported node coordinates format (only \"TWOD_COORDS\" is supported).");
- }
-
- private void ReadVertices() {
- if (vertices == null)
- throw new InvalidDataException("Input file does not contain dimension information.");
-
- for (int i = 0; i < (vertices.Length / 2); i++) {
- if (!(alternateFormat && i == 0)) {
- string str = source.ReadLine();
- string[] tokens = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
-
- if (tokens.Length != 3)
- throw new InvalidDataException("Input file contains invalid node coordinates.");
-
- vertices[i, 0] = double.Parse(tokens[1], culture.NumberFormat);
- vertices[i, 1] = double.Parse(tokens[2], culture.NumberFormat);
- }
- }
- }
-
- private void ReadCapacity(string str) {
- string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
- capacity = double.Parse(tokens[tokens.Length - 1].Trim(), culture.NumberFormat);
- }
-
- private void ReadDistance(string str) {
- string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
- distance = double.Parse(tokens[tokens.Length - 1].Trim(), culture.NumberFormat);
- }
-
- private void ReadVehicles(string str) {
- string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
- vehicles = int.Parse(tokens[tokens.Length - 1].Trim());
- }
-
- private void ReadDepot() {
- if (alternateFormat) {
- string[] tokens;
- do {
- string str = source.ReadLine();
- tokens = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
-
- if (tokens.Length == 2) {
- vertices[0, 0] = double.Parse(tokens[0], culture.NumberFormat);
- vertices[0, 1] = double.Parse(tokens[1], culture.NumberFormat);
- depot = 1;
- }
- } while(tokens.Length == 2);
- } else {
- int read;
- do {
- string str = source.ReadLine();
- read = int.Parse(str);
- if (read != -1)
- depot = read;
- } while (read != -1);
- }
- }
-
- private void ReadDemands() {
- if (demands == null)
- throw new InvalidDataException("Input file does not contain dimension information.");
-
- for (int i = 0; i < demands.Length; i++) {
- if (!(alternateFormat && i == 0)) {
- string str = source.ReadLine();
- string[] tokens = str.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
-
- if (tokens.Length != 2)
- throw new InvalidDataException("Input file contains invalid demands.");
-
- int index = int.Parse(tokens[0]);
- double value = double.Parse(tokens[1]);
-
- if (alternateFormat)
- demands[index] = value;
- else
- demands[index - 1] = value;
- } else {
- demands[0] = 0;
- }
- }
- }
- }
-}
Index: anches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VRPUtilities.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VRPUtilities.cs (revision 4361)
+++ (revision )
@@ -1,92 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see .
- */
-#endregion
-
-using System;
-using System.Drawing;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
-
-namespace HeuristicLab.Problems.VehicleRouting {
- public sealed class VRPUtilities {
- public static double CalculateDistance(int start, int end, DoubleMatrix coordinates) {
- double distance = 0.0;
-
- distance =
- Math.Sqrt(
- Math.Pow(coordinates[start, 0] - coordinates[end, 0], 2) +
- Math.Pow(coordinates[start, 1] - coordinates[end, 1], 2));
-
- return distance;
- }
-
- private static DoubleMatrix CreateDistanceMatrix(DoubleMatrix coordinates) {
- DoubleMatrix distanceMatrix = new DoubleMatrix(coordinates.Rows, coordinates.Rows);
-
- for (int i = 0; i < distanceMatrix.Rows; i++) {
- for (int j = i; j < distanceMatrix.Columns; j++) {
- double distance = CalculateDistance(i, j, coordinates);
-
- distanceMatrix[i, j] = distance;
- distanceMatrix[j, i] = distance;
- }
- }
-
- return distanceMatrix;
- }
-
- public static double GetDistance(int start, int end,
- DoubleMatrix coordinates, ILookupParameter distanceMatrix, BoolValue useDistanceMatrix) {
- double distance = 0.0;
-
- if (useDistanceMatrix.Value) {
- if (distanceMatrix is IValueLookupParameter &&
- (distanceMatrix as IValueLookupParameter).Value != null) {
- distance = (distanceMatrix as IValueLookupParameter).Value[start, end];
- } else {
- if (distanceMatrix.ActualValue == null) {
- distanceMatrix.ActualValue = CreateDistanceMatrix(coordinates);
- }
-
- distance = distanceMatrix.ActualValue[start, end];
- }
- } else {
- distance = CalculateDistance(start, end, coordinates);
- }
-
- return distance;
- }
-
- public static double GetDistance(int start, int end,
- DoubleMatrix coordinates, DoubleMatrix distanceMatrix, BoolValue useDistanceMatrix) {
- double distance = 0.0;
-
- if (useDistanceMatrix.Value) {
- distance = distanceMatrix[start, end];
- } else {
- distance = CalculateDistance(start, end, coordinates);
- }
-
- return distance;
- }
- }
-}
Index: /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
===================================================================
--- /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs (revision 4361)
+++ /branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs (revision 4362)
@@ -32,4 +32,7 @@
using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Problems.VehicleRouting.Interfaces;
+using HeuristicLab.Problems.VehicleRouting.Parsers;
+using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
namespace HeuristicLab.Problems.VehicleRouting {
@@ -42,37 +45,4 @@
}
- #region ISingleObjectiveProblem Members
- public IParameter BestKnownQualityParameter {
- get { throw new NotImplementedException(); }
- }
-
- public ISingleObjectiveEvaluator Evaluator {
- get { throw new NotImplementedException(); }
- }
-
- #endregion
-
- #region IProblem Members
- public IParameter SolutionCreatorParameter {
- get { throw new NotImplementedException(); }
- }
-
- public ISolutionCreator SolutionCreator {
- get { throw new NotImplementedException(); }
- }
-
- public IParameter EvaluatorParameter {
- get { throw new NotImplementedException(); }
- }
-
- IEvaluator IProblem.Evaluator {
- get { throw new NotImplementedException(); }
- }
-
- public IEnumerable Operators {
- get { throw new NotImplementedException(); }
- }
- #endregion
-
#region Parameter Properties
public ValueParameter MaximizationParameter {
@@ -82,12 +52,68 @@
get { return MaximizationParameter; }
}
+ public ValueParameter ProblemInstanceParameter {
+ get { return (ValueParameter)Parameters["ProblemInstance"]; }
+ }
+ public OptionalValueParameter BestKnownQualityParameter {
+ get { return (OptionalValueParameter)Parameters["BestKnownQuality"]; }
+ }
+ IParameter ISingleObjectiveProblem.BestKnownQualityParameter {
+ get { return BestKnownQualityParameter; }
+ }
+ public IParameter SolutionCreatorParameter {
+ get {
+ if (ProblemInstance != null)
+ return ProblemInstance.SolutionCreatorParameter;
+ else
+ return null;
+ }
+ }
+ public IParameter EvaluatorParameter {
+ get {
+ if (ProblemInstance != null)
+ return ProblemInstance.EvaluatorParameter;
+ else
+ return null;
+ }
+ }
#endregion
#region Properties
-
+ public IVRPProblemInstance ProblemInstance {
+ get { return ProblemInstanceParameter.Value; }
+ set { ProblemInstanceParameter.Value = value; }
+ }
+
+ public ISingleObjectiveEvaluator Evaluator {
+ get {
+ if (ProblemInstance != null)
+ return ProblemInstance.EvaluatorParameter.Value;
+ else
+ return null;
+ }
+ }
+
+ IEvaluator IProblem.Evaluator {
+ get { return this.Evaluator; }
+ }
+
+ public ISolutionCreator SolutionCreator {
+ get {
+ if (ProblemInstance != null)
+ return ProblemInstance.SolutionCreatorParameter.Value;
+ else
+ return null;
+ }
+ }
+
+ public IEnumerable Operators {
+ get {
+ if (ProblemInstance != null)
+ return ProblemInstance.Operators.OrderBy(op => op.Name);
+ else
+ return null;
+ }
+ }
#endregion
-
- [Storable]
- private List operators;
[StorableConstructor]
@@ -96,17 +122,15 @@
: base() {
Parameters.Add(new ValueParameter("Maximization", "Set to false as the Vehicle Routing Problem is a minimization problem.", new BoolValue(false)));
-
+ Parameters.Add(new ValueParameter("ProblemInstance", "The VRP problem instance"));
+ Parameters.Add(new OptionalValueParameter("BestKnownQuality", "The quality of the best known solution of this VRP instance."));
+
InitializeRandomVRPInstance();
- ParameterizeSolutionCreator();
- ParameterizeEvaluator();
-
- InitializeOperators();
AttachEventHandlers();
+ AttachProblemInstanceEventHandlers();
}
public override IDeepCloneable Clone(Cloner cloner) {
VehicleRoutingProblem clone = (VehicleRoutingProblem)base.Clone(cloner);
- clone.operators = operators.Select(x => (IOperator)cloner.Clone(x)).ToList();
clone.AttachEventHandlers();
return clone;
@@ -140,38 +164,27 @@
private void AfterDeserializationHook() {
AttachEventHandlers();
+ AttachProblemInstanceEventHandlers();
}
private void AttachEventHandlers() {
-
- }
- private void InitializeOperators() {
- operators = new List();
- ParameterizeAnalyzer();
- //operators.AddRange(ApplicationManager.Manager.GetInstances().Cast().OrderBy(op => op.Name));
- ParameterizeOperators();
- UpdateMoveEvaluators();
- InitializeMoveGenerators();
- }
- private void InitializeMoveGenerators() {
-
- }
- private void UpdateMoveEvaluators() {
- ParameterizeOperators();
- OnOperatorsChanged();
- }
- private void ParameterizeSolutionCreator() {
-
- }
- private void ParameterizeEvaluator() {
-
- }
- private void ParameterizeAnalyzer() {
-
- }
- private void ParameterizeOperators() {
-
- }
- private void ClearDistanceMatrix() {
-
+ ProblemInstanceParameter.ValueChanged += new EventHandler(ProblemInstanceParameter_ValueChanged);
+ }
+
+ private void AttachProblemInstanceEventHandlers() {
+ if (ProblemInstance != null) {
+ ProblemInstance.SolutionCreatorParameter.ValueChanged += new EventHandler(SolutionCreatorParameter_ValueChanged);
+ ProblemInstance.EvaluatorParameter.ValueChanged += new EventHandler(EvaluatorParameter_ValueChanged);
+ }
+ }
+
+ void ProblemInstanceParameter_ValueChanged(object sender, EventArgs e) {
+ AttachProblemInstanceEventHandlers();
+ }
+
+ private void SolutionCreatorParameter_ValueChanged(object sender, EventArgs e) {
+ OnSolutionCreatorChanged();
+ }
+ private void EvaluatorParameter_ValueChanged(object sender, EventArgs e) {
+ OnEvaluatorChanged();
}
#endregion
@@ -182,4 +195,15 @@
this.Name = parser.ProblemName;
+ CVRPTWProblemInstance problem = new CVRPTWProblemInstance();
+
+ problem.Coordinates = new DoubleMatrix(parser.Coordinates);
+ problem.Vehicles.Value = parser.Vehicles;
+ problem.Capacity.Value = parser.Capacity;
+ problem.Demand = new DoubleArray(parser.Demands);
+ problem.ReadyTime = new DoubleArray(parser.Readytimes);
+ problem.DueTime = new DoubleArray(parser.Duetimes);
+ problem.ServiceTime = new DoubleArray(parser.Servicetimes);
+
+ this.ProblemInstance = problem;
OnReset();
@@ -199,4 +223,28 @@
throw new Exception("Invalid weight type");
+ CVRPTWProblemInstance problem = new CVRPTWProblemInstance();
+ problem.Coordinates = new DoubleMatrix(parser.Vertices);
+ if (parser.Vehicles != -1)
+ problem.Vehicles.Value = parser.Vehicles;
+ else
+ problem.Vehicles.Value = problemSize - 1;
+ problem.Capacity.Value = parser.Capacity;
+ problem.Demand = new DoubleArray(parser.Demands);
+ problem.ReadyTime = new DoubleArray(problemSize);
+ problem.DueTime = new DoubleArray(problemSize);
+ problem.ServiceTime = new DoubleArray(problemSize);
+
+ for (int i = 0; i < problemSize; i++) {
+ problem.ReadyTime[i] = 0;
+ problem.DueTime[i] = int.MaxValue;
+ problem.ServiceTime[i] = 0;
+ }
+
+ if (parser.Distance != -1) {
+ problem.DueTime[0] = parser.Distance;
+ }
+
+ this.ProblemInstance = problem;
+
OnReset();
}
@@ -209,4 +257,13 @@
int problemSize = parser.Demands.Length;
+ CVRPProblemInstance problem = new CVRPProblemInstance();
+
+ problem.Coordinates = new DoubleMatrix(parser.Vertices);
+ problem.Vehicles.Value = problemSize - 1;
+ problem.Capacity.Value = parser.Capacity;
+ problem.Demand = new DoubleArray(parser.Demands);
+
+ this.ProblemInstance = problem;
+
OnReset();
}
@@ -215,5 +272,34 @@
System.Random rand = new System.Random();
+ CVRPTWProblemInstance problem = new CVRPTWProblemInstance();
int cities = 100;
+
+ problem.Coordinates = new DoubleMatrix(cities + 1, 2);
+ problem.Demand = new DoubleArray(cities + 1);
+ problem.DueTime = new DoubleArray(cities + 1);
+ problem.ReadyTime = new DoubleArray(cities + 1);
+ problem.ServiceTime = new DoubleArray(cities + 1);
+
+ problem.Vehicles.Value = 100;
+ problem.Capacity.Value = 200;
+
+ for (int i = 0; i <= cities; i++) {
+ problem.Coordinates[i, 0] = rand.Next(0, 100);
+ problem.Coordinates[i, 1] = rand.Next(0, 100);
+
+ if (i == 0) {
+ problem.Demand[i] = 0;
+ problem.DueTime[i] = Int16.MaxValue;
+ problem.ReadyTime[i] = 0;
+ problem.ServiceTime[i] = 0;
+ } else {
+ problem.Demand[i] = rand.Next(10, 50);
+ problem.DueTime[i] = rand.Next((int)Math.Ceiling(problem.GetDistance(0, i)), 1200);
+ problem.ReadyTime[i] = problem.DueTime[i] - rand.Next(0, 100);
+ problem.ServiceTime[i] = 90;
+ }
+ }
+
+ this.ProblemInstance = problem;
}
}