Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7871


Ignore:
Timestamp:
05/22/12 17:37:33 (12 years ago)
Author:
svonolfe
Message:

Added support for included TSPLib CVRP instances (#1177)

Location:
branches/VRP
Files:
3 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/HeuristicLab.Problems.VehicleRouting.Views-3.4.csproj

    r7090 r7871  
    163163      <Private>False</Private>
    164164    </Reference>
     165    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    165166    <Reference Include="System" />
    166167    <Reference Include="System.Core">
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/Plugin.cs.frame

    r7088 r7871  
    4141  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4242  [PluginDependency("HeuristicLab.Problems.VehicleRouting", "3.4")]
     43  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    4344  public class HeuristicLabProblemsVehicleRoutingViewsPlugin : PluginBase {
    4445  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.Designer.cs

    r5867 r7871  
    11namespace HeuristicLab.Problems.VehicleRouting.Views {
    22  partial class VehicleRoutingProblemView {
    3     /// <summary>
     3    /// <summary> 
    44    /// Required designer variable.
    55    /// </summary>
    66    private System.ComponentModel.IContainer components = null;
    77
    8     /// <summary>
     8    /// <summary> 
    99    /// Clean up any resources being used.
    1010    /// </summary>
     
    1717    }
    1818
    19     #region Windows Form Designer generated code
     19    #region Component Designer generated code
    2020
    21     /// <summary>
    22     /// Required method for Designer support - do not modify
     21    /// <summary> 
     22    /// Required method for Designer support - do not modify 
    2323    /// the contents of this method with the code editor.
    2424    /// </summary>
    2525    private void InitializeComponent() {
    26       this.importButton = new System.Windows.Forms.Button();
    27       this.parameterCollectionView = new HeuristicLab.Core.Views.ParameterCollectionView();
    28       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    29       this.SuspendLayout();
    30       //
    31       // nameTextBox
    32       //
    33       this.errorProvider.SetIconAlignment(this.nameTextBox, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
    34       this.errorProvider.SetIconPadding(this.nameTextBox, 2);
    35       this.nameTextBox.Location = new System.Drawing.Point(60, 0);
    36       this.nameTextBox.Size = new System.Drawing.Size(405, 20);
    37       //
    38       // infoLabel
    39       //
    40       this.infoLabel.Location = new System.Drawing.Point(471, 3);
    41       //
    42       // importButton
    43       //
    44       this.importButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    45                   | System.Windows.Forms.AnchorStyles.Right)));
    46       this.importButton.Location = new System.Drawing.Point(0, 26);
    47       this.importButton.Name = "importButton";
    48       this.importButton.Size = new System.Drawing.Size(490, 23);
    49       this.importButton.TabIndex = 5;
    50       this.importButton.Text = "Import";
    51       this.importButton.UseVisualStyleBackColor = true;
    52       this.importButton.Click += new System.EventHandler(this.importButton_Click);
    53       //
    54       // parameterCollectionView
    55       //
    56       this.parameterCollectionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    57                   | System.Windows.Forms.AnchorStyles.Left)
    58                   | System.Windows.Forms.AnchorStyles.Right)));
    59       this.parameterCollectionView.Caption = "ParameterCollection View";
    60       this.parameterCollectionView.Content = null;
    61       this.parameterCollectionView.Location = new System.Drawing.Point(0, 55);
    62       this.parameterCollectionView.Name = "parameterCollectionView";
    63       this.parameterCollectionView.ReadOnly = false;
    64       this.parameterCollectionView.Size = new System.Drawing.Size(490, 210);
    65       this.parameterCollectionView.TabIndex = 9;
    66       //
    67       // VehicleRoutingProblemView
    68       //
    69       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    70       this.Controls.Add(this.parameterCollectionView);
    71       this.Controls.Add(this.importButton);
    72       this.Name = "VehicleRoutingProblemView";
    73       this.Size = new System.Drawing.Size(490, 275);
    74       this.Controls.SetChildIndex(this.importButton, 0);
    75       this.Controls.SetChildIndex(this.parameterCollectionView, 0);
    76       this.Controls.SetChildIndex(this.nameTextBox, 0);
    77       this.Controls.SetChildIndex(this.nameLabel, 0);
    78       ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    79       this.ResumeLayout(false);
    80       this.PerformLayout();
    81 
     26      components = new System.ComponentModel.Container();
     27      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    8228    }
    8329
    8430    #endregion
    85 
    86     private System.Windows.Forms.Button importButton;
    87     private Core.Views.ParameterCollectionView parameterCollectionView;
    8831  }
    8932}
  • branches/VRP/HeuristicLab.Problems.VehicleRouting.Views/3.4/VehicleRoutingProblemView.cs

    r6851 r7871  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.ComponentModel;
     25using System.Drawing;
     26using System.Data;
     27using System.Linq;
     28using System.Text;
    2329using System.Windows.Forms;
     30using HeuristicLab.Optimization.Views;
    2431using HeuristicLab.MainForm;
    25 using HeuristicLab.Optimization.Views;
    26 using HeuristicLab.Core.Views;
    27 using HeuristicLab.Core;
    28 using HeuristicLab.PluginInfrastructure;
    2932
    3033namespace HeuristicLab.Problems.VehicleRouting.Views {
    31   [View("VehicleRouting Problem View")]
    32   [Content(typeof(VehicleRoutingProblem), true)]
    33   public partial class VehicleRoutingProblemView : NamedItemView {
    34     private VRPImportDialog vrpImportDialog;
    35 
    36     public new VehicleRoutingProblem Content {
    37       get { return (VehicleRoutingProblem)base.Content; }
    38       set { base.Content = value; }
    39     }
    40 
     34  [View("Vehicle Routing Problem View")]
     35  [Content(typeof(VehicleRoutingProblem), IsDefaultView = true)]
     36  public partial class VehicleRoutingProblemView : ProblemView {
    4137    public VehicleRoutingProblemView() {
    4238      InitializeComponent();
    4339    }
    44 
    45     protected override void DeregisterContentEvents() {
    46       base.DeregisterContentEvents();
    47     }
    48     protected override void RegisterContentEvents() {
    49       base.RegisterContentEvents();
    50     }
    51 
    52     protected override void OnContentChanged() {
    53       base.OnContentChanged();
    54       if (Content == null) {
    55         parameterCollectionView.Content = null;
    56       } else {
    57         parameterCollectionView.Content = ((IParameterizedNamedItem)Content).Parameters;
    58       }
    59     }
    60 
    61     protected override void SetEnabledStateOfControls() {
    62       base.SetEnabledStateOfControls();
    63       parameterCollectionView.Enabled = Content != null;
    64       importButton.Enabled = Content != null && !ReadOnly;
    65     }
    66 
    67     private void importButton_Click(object sender, EventArgs e) {
    68       if (vrpImportDialog == null) vrpImportDialog = new VRPImportDialog();
    69 
    70       if (vrpImportDialog.ShowDialog(this) == DialogResult.OK) {
    71         try {
    72           switch (vrpImportDialog.Format) {
    73             case VRPFormat.TSPLib:
    74               Content.ImportFromTSPLib(vrpImportDialog.VRPFileName);
    75               break;
    76 
    77             case VRPFormat.Solomon:
    78               Content.ImportFromSolomon(vrpImportDialog.VRPFileName);
    79               break;
    80 
    81             case VRPFormat.ORLib:
    82               Content.ImportFromORLib(vrpImportDialog.VRPFileName);
    83               break;
    84 
    85             case VRPFormat.LiLim:
    86               Content.ImportFromLiLim(vrpImportDialog.VRPFileName);
    87               break;
    88 
    89             case VRPFormat.Cordeau:
    90               Content.ImportFromCordeau(vrpImportDialog.VRPFileName);
    91               break;
    92           }
    93 
    94           if (!string.IsNullOrEmpty(vrpImportDialog.TourFileName))
    95             Content.ImportSolution(vrpImportDialog.TourFileName);
    96         }
    97         catch (Exception ex) {
    98           ErrorHandling.ShowErrorDialog(this, ex);
    99         }
    100       }
    101     } 
    10240  }
    10341}
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj

    r7865 r7871  
    150150      <Private>False</Private>
    151151    </Reference>
     152    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
    152153    <Reference Include="System" />
    153154    <Reference Include="System.Core">
     
    191192    <Compile Include="Encodings\Potvin\Moves\TwoOptStar\PotvinTwoOptStarSingleMoveGenerator.cs" />
    192193    <Compile Include="Interfaces\IVRPLocalSearchManipulator.cs" />
     194    <Compile Include="Interpreters\CVRPInterpreter.cs" />
     195    <Compile Include="Interpreters\IVRPDataInterpreter.cs" />
    193196    <Compile Include="Properties\AssemblyInfo.cs" />
    194197    <Compile Include="Encodings\Alba\AlbaEncoding.cs" />
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/Plugin.cs.frame

    r7088 r7871  
    4040  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4141  [PluginDependency("HeuristicLab.Persistence", "3.3")]
     42  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    4243  public class HeuristicLabProblemsVehicleRoutingPlugin : PluginBase {
    4344  }
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r7861 r7871  
    3636using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3737using HeuristicLab.Problems.VehicleRouting.Variants;
     38using HeuristicLab.Problems.Instances;
     39using System.Reflection;
     40using HeuristicLab.Problems.VehicleRouting.Interpreters;
    3841
    3942namespace HeuristicLab.Problems.VehicleRouting {
     
    4144  [Creatable("Problems")]
    4245  [StorableClass]
    43   public sealed class VehicleRoutingProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent {
     46  public sealed class VehicleRoutingProblem : ParameterizedNamedItem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IProblemInstanceConsumer<IVRPData> {
    4447    public string Filename { get; set; }
    4548
     
    466469      }
    467470    }
     471
     472    public void Load(IVRPData data) {
     473      Type interpreterType = typeof(IVRPDataInterpreter<>).MakeGenericType(data.GetType());
     474      var interpreters = ApplicationManager.Manager.GetInstances(interpreterType);
     475      if (interpreters.Count() > 0) {
     476        IVRPDataInterpreter interpreter = interpreters.First() as IVRPDataInterpreter;
     477        VRPInstanceDescription instance = interpreter.Interpret(data);
     478
     479        Name = instance.Name;
     480        Description = instance.Description;
     481        ProblemInstance = instance.ProblemInstance;
     482
     483        OnReset();
     484
     485        if (instance.BestKnownQuality != null) {
     486          BestKnownQuality = new DoubleValue((double)instance.BestKnownQuality);
     487        }
     488
     489        if (instance.BestKnownSolution != null) {
     490          VRPSolution solution = new VRPSolution(ProblemInstance, instance.BestKnownSolution, new DoubleValue(0));
     491          BestKnownSolutionParameter.Value = solution;
     492        }
     493      } else {
     494        throw new Exception("Cannot find an interpreter for " + data.GetType());
     495      }   
     496    }
    468497  }
    469498}
Note: See TracChangeset for help on using the changeset viewer.