Free cookie consent management tool by TermsFeed Policy Generator

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/HeuristicLab.Problems.VehicleRouting/3.4
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • 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.