Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/13 13:13:41 (11 years ago)
Author:
spimming
Message:

#1888:

  • Merged revisions from trunk
Location:
branches/OaaS
Files:
27 edited
5 copied

Legend:

Unmodified
Added
Removed
  • branches/OaaS

  • branches/OaaS/HeuristicLab.Problems.VehicleRouting

  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj

    r6866 r9363  
    330330  -->
    331331  <PropertyGroup>
    332     <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     332   <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    333333set ProjectDir=$(ProjectDir)
    334334set SolutionDir=$(SolutionDir)
     
    337337call PreBuildEvent.cmd
    338338</PreBuildEvent>
     339<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     340export ProjectDir=$(ProjectDir)
     341export SolutionDir=$(SolutionDir)
     342
     343$SolutionDir/PreBuildEvent.sh
     344</PreBuildEvent>
    339345  </PropertyGroup>
    340346</Project>
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.3/Plugin.cs.frame

    r7259 r9363  
    2626  /// Plugin class for HeuristicLab.Problems.VehicleRouting plugin
    2727  /// </summary>
    28   [Plugin("HeuristicLab.Problems.VehicleRouting", "3.3.6.$WCREV$")]
     28  [Plugin("HeuristicLab.Problems.VehicleRouting", "3.3.7.$WCREV$")]
    2929  [PluginFile("HeuristicLab.Problems.VehicleRouting-3.3.dll", PluginFileType.Assembly)]
    3030  [PluginDependency("HeuristicLab.Analysis", "3.3")]
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.3/Properties/AssemblyInfo.cs.frame

    r7259 r9363  
    5353// by using the '*' as shown below:
    5454[assembly: AssemblyVersion("3.3.0.0")]
    55 [assembly: AssemblyFileVersion("3.3.6.$WCREV$")]
     55[assembly: AssemblyFileVersion("3.3.7.$WCREV$")]
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/Capacitated/BestCapacitatedVRPSolutionAnalyzer.cs

    r8053 r9363  
    3030using HeuristicLab.Problems.VehicleRouting.Interfaces;
    3131using HeuristicLab.Problems.VehicleRouting.Variants;
     32using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting {
     
    8788
    8889    public override IOperation Apply() {
     90      IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue;
    8991      ItemArray<IVRPEncoding> solutions = VRPToursParameter.ActualValue;
    9092      ResultCollection results = ResultsParameter.ActualValue;
     
    100102          results.Add(new Result("Best VRP Solution Overload", new DoubleValue(overloads[i].Value)));
    101103        } else {
    102           if (qualities[i].Value <= solution.Quality.Value) {
     104          VRPEvaluation eval = problemInstance.Evaluate(solution.Solution);
     105          if (qualities[i].Value <= eval.Quality) {
    103106            (results["Best VRP Solution Overload"].Value as DoubleValue).Value = overloads[i].Value;
    104107          }
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/PickupAndDelivery/BestPickupAndDeliveryVRPSolutionAnalyzer.cs

    r8053 r9363  
    3030using HeuristicLab.Problems.VehicleRouting.Interfaces;
    3131using HeuristicLab.Problems.VehicleRouting.Variants;
     32using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting {
     
    8788
    8889    public override IOperation Apply() {
     90      IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue;
    8991      ItemArray<IVRPEncoding> solutions = VRPToursParameter.ActualValue;
    9092      ResultCollection results = ResultsParameter.ActualValue;
     
    101103          results.Add(new Result("Best VRP Solution PickupViolations", new DoubleValue(pickupViolations[i].Value)));
    102104        } else {
    103           if (qualities[i].Value <= solution.Quality.Value) {
     105          VRPEvaluation eval = problemInstance.Evaluate(solution.Solution);
     106          if (qualities[i].Value <= eval.Quality) {
    104107            (results["Best VRP Solution PickupViolations"].Value as DoubleValue).Value = pickupViolations[i].Value;
    105108          }
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/TimeWindowed/BestTimeWindowedVRPSolutionAnalyzer.cs

    r8053 r9363  
    3030using HeuristicLab.Problems.VehicleRouting.Interfaces;
    3131using HeuristicLab.Problems.VehicleRouting.Variants;
     32using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
    3233
    3334namespace HeuristicLab.Problems.VehicleRouting {
     
    9192
    9293    public override IOperation Apply() {
     94      IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue;
    9395      ItemArray<IVRPEncoding> solutions = VRPToursParameter.ActualValue;
    9496      ResultCollection results = ResultsParameter.ActualValue;
     
    106108          results.Add(new Result("Best VRP Solution TravelTime", new DoubleValue(travelTimes[i].Value)));
    107109        } else {
    108           if (qualities[i].Value <= solution.Quality.Value) {
     110          VRPEvaluation eval = problemInstance.Evaluate(solution.Solution);
     111          if (qualities[i].Value <= eval.Quality) {
    109112            (results["Best VRP Solution Tardiness"].Value as DoubleValue).Value = tardinesses[i].Value;
    110113            (results["Best VRP Solution TravelTime"].Value as DoubleValue).Value = travelTimes[i].Value;
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/Capacitated/CapacityRelaxationVRPAnalyzer.cs

    r8053 r9363  
    6060      get { return (IValueParameter<DoubleValue>)Parameters["MinPenaltyFactor"]; }
    6161    }
     62    public IValueParameter<DoubleValue> MaxPenaltyFactorParameter {
     63      get { return (IValueParameter<DoubleValue>)Parameters["MaxPenaltyFactor"]; }
     64    }
    6265
    6366    public ValueLookupParameter<ResultCollection> ResultsParameter {
     
    8083      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Overload", "The overloads of the VRP solutions which should be analyzed."));
    8184
    82       Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.04)));
    83       Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.01)));
     85      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     86      Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.5)));
    8487      Parameters.Add(new ValueParameter<DoubleValue>("MinPenaltyFactor", "The minimum penalty factor.", new DoubleValue(0.01)));
     88      Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
    8589
    8690      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best VRP solution should be stored."));
     
    9599    }
    96100
     101    [StorableHook(HookType.AfterDeserialization)]
     102    private void AfterDeserialization() {
     103      // BackwardsCompatibility3.3
     104      #region Backwards compatible code, remove with 3.4
     105      if (!Parameters.ContainsKey("MaxPenaltyFactor")) {
     106        Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
     107      }
     108      #endregion
     109    }
     110
    97111    public override IOperation Apply() {
    98112      ICapacitatedProblemInstance cvrp = ProblemInstanceParameter.ActualValue as ICapacitatedProblemInstance;
     
    105119      double phi = PhiParameter.Value.Value;
    106120      double minPenalty = MinPenaltyFactorParameter.Value.Value;
     121      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    107122
    108123      for (int j = 0; j < qualities.Length; j++) {
     
    124139      if (cvrp.OverloadPenalty.Value < minPenalty)
    125140        cvrp.OverloadPenalty.Value = minPenalty;
     141      if (cvrp.OverloadPenalty.Value > maxPenalty)
     142        cvrp.OverloadPenalty.Value = maxPenalty;
    126143
    127144      for (int j = 0; j < qualities.Length; j++) {
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/PickupAndDelivery/PickupViolationsRelaxationVRPAnalyzer.cs

    r8053 r9363  
    6060      get { return (IValueParameter<DoubleValue>)Parameters["MinPenaltyFactor"]; }
    6161    }
     62    public IValueParameter<DoubleValue> MaxPenaltyFactorParameter {
     63      get { return (IValueParameter<DoubleValue>)Parameters["MaxPenaltyFactor"]; }
     64    }
    6265
    6366    public ValueLookupParameter<ResultCollection> ResultsParameter {
     
    8083      Parameters.Add(new ScopeTreeLookupParameter<IntValue>("PickupViolations", "The pickup violation of the VRP solutions which should be analyzed."));
    8184
    82       Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.04)));
    83       Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.01)));
     85      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     86      Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.5)));
    8487      Parameters.Add(new ValueParameter<DoubleValue>("MinPenaltyFactor", "The minimum penalty factor.", new DoubleValue(0.01)));
     88      Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
    8589
    8690      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best VRP solution should be stored."));
     
    9599    }
    96100
     101    [StorableHook(HookType.AfterDeserialization)]
     102    private void AfterDeserialization() {
     103      // BackwardsCompatibility3.3
     104      #region Backwards compatible code, remove with 3.4
     105      if (!Parameters.ContainsKey("MaxPenaltyFactor")) {
     106        Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
     107      }
     108      #endregion
     109    }
     110
    97111    public override IOperation Apply() {
    98112      IPickupAndDeliveryProblemInstance pdp = ProblemInstanceParameter.ActualValue as IPickupAndDeliveryProblemInstance;
     
    105119      double phi = PhiParameter.Value.Value;
    106120      double minPenalty = MinPenaltyFactorParameter.Value.Value;
     121      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    107122
    108123      for (int j = 0; j < qualities.Length; j++) {
     
    124139      if (pdp.PickupViolationPenalty.Value < minPenalty)
    125140        pdp.PickupViolationPenalty.Value = minPenalty;
     141      if (pdp.PickupViolationPenalty.Value > maxPenalty)
     142        pdp.PickupViolationPenalty.Value = maxPenalty;
    126143
    127144      for (int j = 0; j < qualities.Length; j++) {
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/TimeWindowed/TimeWindowRelaxationVRPAnalyzer.cs

    r8053 r9363  
    6060      get { return (IValueParameter<DoubleValue>)Parameters["MinPenaltyFactor"]; }
    6161    }
     62    public IValueParameter<DoubleValue> MaxPenaltyFactorParameter {
     63      get { return (IValueParameter<DoubleValue>)Parameters["MaxPenaltyFactor"]; }
     64    }
    6265
    6366    public ValueLookupParameter<ResultCollection> ResultsParameter {
     
    8083      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Tardiness", "The tardiness of the VRP solutions which should be analyzed."));
    8184
    82       Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.04)));
    83       Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.01)));
     85      Parameters.Add(new ValueParameter<DoubleValue>("Sigma", "The sigma applied to the penalty factor.", new DoubleValue(0.5)));
     86      Parameters.Add(new ValueParameter<DoubleValue>("Phi", "The phi applied to the penalty factor.", new DoubleValue(0.5)));
    8487      Parameters.Add(new ValueParameter<DoubleValue>("MinPenaltyFactor", "The minimum penalty factor.", new DoubleValue(0.01)));
     88      Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
    8589
    8690      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best VRP solution should be stored."));
     
    9599    }
    96100
     101    [StorableHook(HookType.AfterDeserialization)]
     102    private void AfterDeserialization() {
     103      // BackwardsCompatibility3.3
     104      #region Backwards compatible code, remove with 3.4
     105      if (!Parameters.ContainsKey("MaxPenaltyFactor")) {
     106        Parameters.Add(new ValueParameter<DoubleValue>("MaxPenaltyFactor", "The maximum penalty factor.", new DoubleValue(100000)));
     107      }
     108      #endregion
     109    }
     110
    97111    public override IOperation Apply() {
    98112      ITimeWindowedProblemInstance vrptw = ProblemInstanceParameter.ActualValue as ITimeWindowedProblemInstance;
     
    105119      double phi = PhiParameter.Value.Value;
    106120      double minPenalty = MinPenaltyFactorParameter.Value.Value;
     121      double maxPenalty = MaxPenaltyFactorParameter.Value.Value;
    107122
    108123      for (int j = 0; j < qualities.Length; j++) {
     
    124139      if (vrptw.TardinessPenalty.Value < minPenalty)
    125140        vrptw.TardinessPenalty.Value = minPenalty;
     141      if (vrptw.TardinessPenalty.Value > maxPenalty)
     142        vrptw.TardinessPenalty.Value = maxPenalty;
    126143
    127144      for (int j = 0; j < qualities.Length; j++) {
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinCrossover.cs

    r8053 r9363  
    6363    }
    6464
    65     protected Tour FindRoute(PotvinEncoding solution, int city) {
     65    protected static Tour FindRoute(PotvinEncoding solution, int city) {
    6666      Tour found = null;
    6767
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinRouteBasedCrossover.cs

    r8053 r9363  
    2424using HeuristicLab.Encodings.PermutationEncoding;
    2525using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     26using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2627
    2728namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    4344    }
    4445
    45     protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
    46       bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
    47 
     46    public static PotvinEncoding Apply(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2, IVRPProblemInstance problemInstance, bool allowInfeasible) {
    4847      PotvinEncoding child = parent2.Clone() as PotvinEncoding;
    4948
     
    7574            child.Unrouted.Add(city);
    7675
    77         if (Repair(random, child, replacing, ProblemInstance, allowInfeasible) || allowInfeasible)
     76        if (Repair(random, child, replacing, problemInstance, allowInfeasible) || allowInfeasible)
    7877          return child;
    7978        else {
     
    8786      }
    8887    }
     88
     89    protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
     90      return Apply(random, parent1, parent2, ProblemInstance, AllowInfeasibleSolutions.Value.Value);
     91    }
    8992  }
    9093}
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinSequenceBasedCrossover.cs

    r8053 r9363  
    2323using HeuristicLab.Core;
    2424using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     25using HeuristicLab.Problems.VehicleRouting.Interfaces;
    2526
    2627namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
     
    4243    }
    4344
    44     protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
    45       bool allowInfeasible = AllowInfeasibleSolutions.Value.Value;
    46 
     45    public static PotvinEncoding Apply(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2, IVRPProblemInstance problemInstance, bool allowInfeasible) {
    4746      PotvinEncoding child = parent1.Clone() as PotvinEncoding;
    4847      Tour newTour = new Tour();
    4948
    50       int cities = ProblemInstance.Cities.Value;
     49      int cities = problemInstance.Cities.Value;
    5150
    5251      if (cities > 0) {
     
    7776            child.Unrouted.Add(city);
    7877
    79         if (Repair(random, child, newTour, ProblemInstance, allowInfeasible) || allowInfeasible) {
     78        if (Repair(random, child, newTour, problemInstance, allowInfeasible) || allowInfeasible) {
    8079          return child;
    8180        } else {
     
    8988      }
    9089    }
     90
     91    protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) {
     92      return Apply(random, parent1, parent2, ProblemInstance, AllowInfeasibleSolutions.Value.Value);
     93    }
    9194  }
    9295}
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinPairwiseOneLevelExchangeManipulator.cs

    r8053 r9363  
    2727
    2828namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
    29   [Item("PotvinPairwiseOneLevelExchangeMainpulator", "The 1M operator which manipulates a VRP representation.  It is implemented as described in Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172. It was adapted to the PDP formulation.")]
     29  [Item("PotvinPairwiseOneLevelExchangeMainpulator", "The 1M operator which manipulates a PDP representation. It has been adapted to pickup and delivery from Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172. It was adapted to the PDP formulation.")]
    3030  [StorableClass]
    3131  public sealed class PotvinPairwiseOneLevelExchangeMainpulator : PotvinManipulator {
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinPairwiseTwoLevelExchangeManipulator.cs

    r8053 r9363  
    2828
    2929namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin {
    30   [Item("PotvinPairwiseTwoLevelExchangeManipulator", "The 2M operator which manipulates a VRP representation.  It is implemented as described in Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172.  It was adapted to the PDP formulation.")]
     30  [Item("PotvinPairwiseTwoLevelExchangeManipulator", "The 2M operator which manipulates a VRP representation.   It has been adapted to pickup and delivery from Potvin, J.-Y. and Bengio, S. (1996). The Vehicle Routing Problem with Time Windows - Part II: Genetic Search. INFORMS Journal of Computing, 8:165–172.  It was adapted to the PDP formulation.")]
    3131  [StorableClass]
    3232  public sealed class PotvinPairwiseTwoLevelExchangeManipulator : PotvinManipulator {
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs

    r8053 r9363  
    6969      foreach (Tour tour in toBeRemoved) {
    7070        int index = Tours.IndexOf(tour);
     71        Tours.Remove(tour);
    7172        if (index < VehicleAssignment.Length) {
    7273          int vehicle = VehicleAssignment[index];
    73 
    74           Tours.Remove(tour);
    75           for (int i = index; i < VehicleAssignment.Length - 1; i++) {
     74          int max = System.Math.Min(VehicleAssignment.Length - 1, Tours.Count);
     75
     76          for (int i = index; i < max; i++) {
    7677            VehicleAssignment[i] = VehicleAssignment[i + 1];
    7778          }
    78           VehicleAssignment[VehicleAssignment.Length - 1] = vehicle;
     79          VehicleAssignment[max] = vehicle;
    7980        }
    8081      }
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj

    r7923 r9363  
    7272    <OutputPath>..\..\bin\</OutputPath>
    7373    <DefineConstants>TRACE</DefineConstants>
    74     <DocumentationFile>bin\x86\Release\HeuristicLab.Routing.TSP-3.3.xml</DocumentationFile>
     74    <DocumentationFile>
     75    </DocumentationFile>
    7576    <Optimize>true</Optimize>
    7677    <DebugType>pdbonly</DebugType>
     
    139140    <Compile Include="Encodings\Potvin\Moves\TwoOptStar\PotvinTwoOptStarMultiMoveGenerator.cs" />
    140141    <Compile Include="Encodings\Potvin\Moves\TwoOptStar\PotvinTwoOptStarSingleMoveGenerator.cs" />
     142    <Compile Include="Improver\VRPImprovementOperator.cs" />
     143    <Compile Include="Improver\VRPIntraRouteImprovementOperator.cs" />
    141144    <Compile Include="Interfaces\IVRPLocalSearchManipulator.cs" />
     145    <Compile Include="Interpreters\MDCVRPInterpreter.cs" />
     146    <Compile Include="Interpreters\VRPInterpreter.cs" />
    142147    <Compile Include="Interpreters\MDCVRPTWInterpreter.cs" />
    143148    <Compile Include="Interpreters\PDPTWInterpreter.cs" />
     
    145150    <Compile Include="Interpreters\CVRPInterpreter.cs" />
    146151    <Compile Include="Interpreters\IVRPDataInterpreter.cs" />
     152    <Compile Include="PathRelinkers\VRPPathRelinker.cs" />
    147153    <Compile Include="Properties\AssemblyInfo.cs" />
    148154    <Compile Include="Encodings\Alba\AlbaEncoding.cs" />
     
    336342    <Compile Include="ProblemInstances\SingleDepotVRP\CVRP\CVRPTW\CVRPPDTW\CVRPPDTWEvaluator.cs" />
    337343    <Compile Include="ProblemInstances\SingleDepotVRP\SingleDepotVRPEvaluator.cs" />
     344    <Compile Include="SimilarityCalculators\VRPSimilarityCalculator.cs" />
    338345    <Compile Include="SolutionParser.cs" />
    339346    <Compile Include="Variants\Capacitated\Heterogenous\IHeterogenousCapacitatedProblemInstance.cs" />
     
    468475  -->
    469476  <PropertyGroup>
    470     <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     477    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    471478set ProjectDir=$(ProjectDir)
    472479set SolutionDir=$(SolutionDir)
     
    474481
    475482call PreBuildEvent.cmd</PreBuildEvent>
     483    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     484export ProjectDir=$(ProjectDir)
     485export SolutionDir=$(SolutionDir)
     486
     487$SolutionDir/PreBuildEvent.sh
     488</PreBuildEvent>
    476489  </PropertyGroup>
    477490  <PropertyGroup>
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPProblemInstance.cs

    r8053 r9363  
    2727
    2828namespace HeuristicLab.Problems.VehicleRouting.Interfaces {
    29   public interface IVRPProblemInstance : IItem {
     29  public interface IVRPProblemInstance : IParameterizedNamedItem {
    3030    IVRPEvaluator SolutionEvaluator { get; set; }
    3131    IVRPEvaluator MoveEvaluator { get; }
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/CVRPInterpreter.cs

    r8053 r9363  
    2424using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin;
    2525using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
     26using HeuristicLab.Problems.VehicleRouting.Interfaces;
     27using System;
    2628
    2729namespace HeuristicLab.Problems.VehicleRouting.Interpreters {
    28   public class CVRPInterpreter : IVRPDataInterpreter<CVRPData> {
    29     public VRPInstanceDescription Interpret(IVRPData data) {
    30       CVRPData cvrpData = data as CVRPData;
     30  public class CVRPInterpreter : VRPInterpreter, IVRPDataInterpreter<CVRPData> {   
     31    protected override IVRPProblemInstance CreateProblemInstance() {
     32      return new CVRPProblemInstance();
     33    }
    3134
    32       VRPInstanceDescription result = new VRPInstanceDescription();
    33       result.Name = cvrpData.Name;
    34       result.Description = cvrpData.Description;
    35 
    36       CVRPProblemInstance problem = new CVRPProblemInstance();
     35    protected override void Interpret(IVRPData data, IVRPProblemInstance problemInstance) {
     36      CVRPData cvrpData = (CVRPData)data;
     37      CVRPProblemInstance problem = (CVRPProblemInstance)problemInstance;
     38     
    3739      if (cvrpData.Coordinates != null)
    3840        problem.Coordinates = new DoubleMatrix(cvrpData.Coordinates);
     
    4749        problem.DistanceMatrix = new DoubleMatrix(cvrpData.GetDistanceMatrix());
    4850      }
    49       result.ProblemInstance = problem;
    50 
    51       result.BestKnownQuality = cvrpData.BestKnownQuality;
    52       if (cvrpData.BestKnownTour != null) {
    53         PotvinEncoding solution = new PotvinEncoding(problem);
    54 
    55         for (int i = 0; i < cvrpData.BestKnownTour.GetLength(0); i++) {
    56           Tour tour = new Tour();
    57           solution.Tours.Add(tour);
    58 
    59           foreach (int stop in cvrpData.BestKnownTour[i]) {
    60             tour.Stops.Add(stop + 1);
    61           }
    62         }
    63 
    64         result.BestKnownSolution = solution;
    65       }
    66 
    67       return result;
    6851    }
    6952  }
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/CVRPTWInterpreter.cs

    r8053 r9363  
    2424using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin;
    2525using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
     26using HeuristicLab.Problems.VehicleRouting.Interfaces;
     27using System;
    2628
    2729namespace HeuristicLab.Problems.VehicleRouting.Interpreters {
    28   public class CVRPTWInterpreter : IVRPDataInterpreter<CVRPTWData> {
    29     public VRPInstanceDescription Interpret(IVRPData data) {
    30       CVRPTWData cvrpData = data as CVRPTWData;
     30  public class CVRPTWInterpreter: CVRPInterpreter, IVRPDataInterpreter<CVRPTWData> {   
     31    protected override IVRPProblemInstance CreateProblemInstance() {
     32      return new CVRPTWProblemInstance();
     33    }
    3134
    32       VRPInstanceDescription result = new VRPInstanceDescription();
    33       result.Name = cvrpData.Name;
    34       result.Description = cvrpData.Description;
     35    protected override void Interpret(IVRPData data, IVRPProblemInstance problemInstance) {
     36      base.Interpret(data, problemInstance);
    3537
    36       CVRPTWProblemInstance problem = new CVRPTWProblemInstance();
    37       if (cvrpData.Coordinates != null)
    38         problem.Coordinates = new DoubleMatrix(cvrpData.Coordinates);
    39       if (cvrpData.MaximumVehicles != null)
    40         problem.Vehicles.Value = (int)cvrpData.MaximumVehicles;
    41       else
    42         problem.Vehicles.Value = cvrpData.Dimension - 1;
    43       problem.Capacity.Value = cvrpData.Capacity;
    44       problem.Demand = new DoubleArray(cvrpData.Demands);
    45       if (cvrpData.DistanceMeasure != DistanceMeasure.Euclidean) {
    46         problem.UseDistanceMatrix.Value = true;
    47         problem.DistanceMatrix = new DoubleMatrix(cvrpData.GetDistanceMatrix());
    48       }
    49       problem.ReadyTime = new DoubleArray(cvrpData.ReadyTimes);
    50       problem.ServiceTime = new DoubleArray(cvrpData.ServiceTimes);
    51       problem.DueTime = new DoubleArray(cvrpData.DueTimes);
    52       result.ProblemInstance = problem;
     38      CVRPTWData cvrptwData = (CVRPTWData)data;
     39      CVRPTWProblemInstance problem = (CVRPTWProblemInstance)problemInstance;
    5340
    54       result.BestKnownQuality = cvrpData.BestKnownQuality;
    55       if (cvrpData.BestKnownTour != null) {
    56         PotvinEncoding solution = new PotvinEncoding(problem);
    57 
    58         for (int i = 0; i < cvrpData.BestKnownTour.GetLength(0); i++) {
    59           Tour tour = new Tour();
    60           solution.Tours.Add(tour);
    61 
    62           foreach (int stop in cvrpData.BestKnownTour[i]) {
    63             tour.Stops.Add(stop + 1);
    64           }
    65         }
    66 
    67         result.BestKnownSolution = solution;
    68       }
    69 
    70       return result;
     41      problem.ReadyTime = new DoubleArray(cvrptwData.ReadyTimes);
     42      problem.ServiceTime = new DoubleArray(cvrptwData.ServiceTimes);
     43      problem.DueTime = new DoubleArray(cvrptwData.DueTimes);
    7144    }
    7245  }
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/IVRPDataInterpreter.cs

    r8053 r9363  
    2222using HeuristicLab.Problems.Instances;
    2323using HeuristicLab.Problems.VehicleRouting.Interfaces;
     24using System;
    2425
    2526namespace HeuristicLab.Problems.VehicleRouting.Interpreters {
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/MDCVRPTWInterpreter.cs

    r8053 r9363  
    2424using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin;
    2525using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
     26using HeuristicLab.Problems.VehicleRouting.Interfaces;
     27using System;
    2628
    2729namespace HeuristicLab.Problems.VehicleRouting.Interpreters {
    28   public class MDCVRPTWInterpreter : IVRPDataInterpreter<MDCVRPTWData> {
    29     public VRPInstanceDescription Interpret(IVRPData data) {
    30       MDCVRPTWData cvrpData = data as MDCVRPTWData;
     30  public class MDCVRPTWInterpreter : MDCVRPInterpreter, IVRPDataInterpreter<MDCVRPTWData> {   
     31    protected override IVRPProblemInstance CreateProblemInstance() {
     32      return new MDCVRPTWProblemInstance();
     33    }
    3134
    32       VRPInstanceDescription result = new VRPInstanceDescription();
    33       result.Name = cvrpData.Name;
    34       result.Description = cvrpData.Description;
     35    protected override void Interpret(IVRPData data, IVRPProblemInstance problemInstance) {
     36      base.Interpret(data, problemInstance);
    3537
    36       MDCVRPTWProblemInstance problem = new MDCVRPTWProblemInstance();
    37       if (cvrpData.Coordinates != null)
    38         problem.Coordinates = new DoubleMatrix(cvrpData.Coordinates);
    39       if (cvrpData.MaximumVehicles != null)
    40         problem.Vehicles.Value = (int)cvrpData.MaximumVehicles;
    41       else
    42         problem.Vehicles.Value = cvrpData.Dimension - 1;
    43       problem.Capacity = new DoubleArray(cvrpData.Capacity);
    44       problem.Demand = new DoubleArray(cvrpData.Demands);
    45       if (cvrpData.DistanceMeasure != DistanceMeasure.Euclidean) {
    46         problem.UseDistanceMatrix.Value = true;
    47         problem.DistanceMatrix = new DoubleMatrix(cvrpData.GetDistanceMatrix());
    48       }
     38      MDCVRPTWData cvrptwData = (MDCVRPTWData)data;
     39      MDCVRPTWProblemInstance problem = (MDCVRPTWProblemInstance)problemInstance;
    4940
    50       problem.Depots.Value = cvrpData.Depots;
    51       problem.VehicleDepotAssignment = new IntArray(cvrpData.VehicleDepotAssignment);
    52 
    53       problem.ReadyTime = new DoubleArray(cvrpData.ReadyTimes);
    54       problem.ServiceTime = new DoubleArray(cvrpData.ServiceTimes);
    55       problem.DueTime = new DoubleArray(cvrpData.DueTimes);
    56       result.ProblemInstance = problem;
    57 
    58       result.BestKnownQuality = cvrpData.BestKnownQuality;
    59       if (cvrpData.BestKnownTour != null) {
    60         PotvinEncoding solution = new PotvinEncoding(problem);
    61 
    62         for (int i = 0; i < cvrpData.BestKnownTour.GetLength(0); i++) {
    63           Tour tour = new Tour();
    64           solution.Tours.Add(tour);
    65 
    66           foreach (int stop in cvrpData.BestKnownTour[i]) {
    67             tour.Stops.Add(stop + 1);
    68           }
    69         }
    70 
    71         result.BestKnownSolution = solution;
    72       }
    73 
    74       return result;
     41      problem.ReadyTime = new DoubleArray(cvrptwData.ReadyTimes);
     42      problem.ServiceTime = new DoubleArray(cvrptwData.ServiceTimes);
     43      problem.DueTime = new DoubleArray(cvrptwData.DueTimes);
    7544    }
    7645  }
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/PDPTWInterpreter.cs

    r8053 r9363  
    2424using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin;
    2525using HeuristicLab.Problems.VehicleRouting.ProblemInstances;
     26using HeuristicLab.Problems.VehicleRouting.Interfaces;
     27using System;
    2628
    2729namespace HeuristicLab.Problems.VehicleRouting.Interpreters {
    28   public class PDPTWInterpreter : IVRPDataInterpreter<PDPTWData> {
    29     public VRPInstanceDescription Interpret(IVRPData data) {
    30       PDPTWData cvrpData = data as PDPTWData;
     30  public class PDPTWInterpreter : CVRPTWInterpreter, IVRPDataInterpreter<PDPTWData> {   
     31    protected override IVRPProblemInstance CreateProblemInstance() {
     32      return new CVRPPDTWProblemInstance();
     33    }
    3134
    32       VRPInstanceDescription result = new VRPInstanceDescription();
    33       result.Name = cvrpData.Name;
    34       result.Description = cvrpData.Description;
     35    protected override void Interpret(IVRPData data, IVRPProblemInstance problemInstance) {
     36      base.Interpret(data, problemInstance);
    3537
    36       CVRPPDTWProblemInstance problem = new CVRPPDTWProblemInstance();
    37       if (cvrpData.Coordinates != null)
    38         problem.Coordinates = new DoubleMatrix(cvrpData.Coordinates);
    39       if (cvrpData.MaximumVehicles != null)
    40         problem.Vehicles.Value = (int)cvrpData.MaximumVehicles;
    41       else
    42         problem.Vehicles.Value = cvrpData.Dimension - 1;
    43       problem.Capacity.Value = cvrpData.Capacity;
    44       problem.Demand = new DoubleArray(cvrpData.Demands);
    45       if (cvrpData.DistanceMeasure != DistanceMeasure.Euclidean) {
    46         problem.UseDistanceMatrix.Value = true;
    47         problem.DistanceMatrix = new DoubleMatrix(cvrpData.GetDistanceMatrix());
    48       }
    49       problem.ReadyTime = new DoubleArray(cvrpData.ReadyTimes);
    50       problem.ServiceTime = new DoubleArray(cvrpData.ServiceTimes);
    51       problem.DueTime = new DoubleArray(cvrpData.DueTimes);
    52       problem.PickupDeliveryLocation = new IntArray(cvrpData.PickupDeliveryLocations);
    53       result.ProblemInstance = problem;
     38      PDPTWData pdpData = (PDPTWData)data;
     39      CVRPPDTWProblemInstance problem = (CVRPPDTWProblemInstance)problemInstance;
    5440
    55       result.BestKnownQuality = cvrpData.BestKnownQuality;
    56       if (cvrpData.BestKnownTour != null) {
    57         PotvinEncoding solution = new PotvinEncoding(problem);
    58 
    59         for (int i = 0; i < cvrpData.BestKnownTour.GetLength(0); i++) {
    60           Tour tour = new Tour();
    61           solution.Tours.Add(tour);
    62 
    63           foreach (int stop in cvrpData.BestKnownTour[i]) {
    64             tour.Stops.Add(stop + 1);
    65           }
    66         }
    67 
    68         result.BestKnownSolution = solution;
    69       }
    70 
    71       return result;
     41      problem.PickupDeliveryLocation = new IntArray(pdpData.PickupDeliveryLocations);
    7242    }
    7343  }
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPEvaluator.cs

    r8053 r9363  
    118118    }
    119119
    120     public VRPEvaluation Evaluate(IVRPProblemInstance instance, IVRPEncoding solution) {
     120    public virtual VRPEvaluation Evaluate(IVRPProblemInstance instance, IVRPEncoding solution) {
    121121      VRPEvaluation evaluation = CreateTourEvaluation();
    122122
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs

    r8053 r9363  
    3737    IVRPEvaluator moveEvaluator;
    3838
     39    private object locker = new object();
     40
    3941    public IVRPEvaluator MoveEvaluator {
    4042      get {
    41         if (evaluator == null)
    42           return null;
    43         else {
    44           if (moveEvaluator == null) {
    45             moveEvaluator = evaluator.Clone() as IVRPEvaluator;
    46 
    47             foreach (IParameter parameter in moveEvaluator.Parameters) {
    48               if (parameter is ILookupParameter
    49                 && parameter != moveEvaluator.ProblemInstanceParameter
    50                 && parameter != moveEvaluator.VRPToursParameter) {
    51                 (parameter as ILookupParameter).ActualName =
    52                   VRPMoveEvaluator.MovePrefix +
    53                   (parameter as ILookupParameter).ActualName;
     43        lock (locker) {
     44          if (evaluator == null)
     45            return null;
     46          else {
     47            if (moveEvaluator == null) {
     48              moveEvaluator = evaluator.Clone() as IVRPEvaluator;
     49
     50              foreach (IParameter parameter in moveEvaluator.Parameters) {
     51                if (parameter is ILookupParameter
     52                  && parameter != moveEvaluator.ProblemInstanceParameter
     53                  && parameter != moveEvaluator.VRPToursParameter) {
     54                  (parameter as ILookupParameter).ActualName =
     55                    VRPMoveEvaluator.MovePrefix +
     56                    (parameter as ILookupParameter).ActualName;
     57                }
    5458              }
    5559            }
     60
     61            return moveEvaluator;
    5662          }
    57 
    58           return moveEvaluator;
    5963        }
    6064      }
     
    176180
    177181      set {
    178         moveEvaluator = null;
    179         evaluator = value;
    180         EvalBestKnownSolution();
     182        lock (locker) {
     183          moveEvaluator = null;
     184          evaluator = value;
     185          EvalBestKnownSolution();
     186        }
    181187      }
    182188    }
    183189
    184190    public virtual double GetDistance(int start, int end, IVRPEncoding solution) {
    185       double distance = 0.0;
    186191      if (distanceMatrix == null && UseDistanceMatrix.Value) {
    187         distanceMatrix = DistanceMatrix = CreateDistanceMatrix();
    188       }
    189 
    190       if (distanceMatrix != null)
    191         distance = distanceMatrix[start, end];
    192       else
    193         distance = CalculateDistance(start, end);
    194 
    195       return distance;
     192        if (DistanceMatrix == null) DistanceMatrix = CreateDistanceMatrix();
     193        distanceMatrix = DistanceMatrix;
     194      }
     195
     196      if (distanceMatrix != null) return distanceMatrix[start, end];
     197      return CalculateDistance(start, end);
    196198    }
    197199
  • branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs

    r8121 r9363  
    2424using System.Drawing;
    2525using System.Linq;
     26using HeuristicLab.Analysis;
    2627using HeuristicLab.Common;
    2728using HeuristicLab.Core;
     
    3839
    3940namespace HeuristicLab.Problems.VehicleRouting {
     41  public interface IVRPInstanceConsumer : 
     42    IProblemInstanceConsumer<CVRPData>, IProblemInstanceConsumer<CVRPTWData>,
     43    IProblemInstanceConsumer<MDCVRPData>, IProblemInstanceConsumer<MDCVRPTWData>,
     44    IProblemInstanceConsumer<PDPTWData> {
     45  }
     46
    4047  [Item("Vehicle Routing Problem", "Represents a Vehicle Routing Problem.")]
    4148  [Creatable("Problems")]
    4249  [StorableClass]
    43   public sealed class VehicleRoutingProblem : Problem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IProblemInstanceConsumer<IVRPData> {
     50  public sealed class VehicleRoutingProblem : Problem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IVRPInstanceConsumer {
    4451    public string Filename { get; set; }
    4552
     
    111118      get { return SolutionCreatorParameter.Value; }
    112119      set { SolutionCreatorParameter.Value = value; }
     120    }
     121    private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer {
     122      get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); }
    113123    }
    114124    #endregion
     
    178188
    179189    private void AttachProblemInstanceEventHandlers() {
    180       var solutionCreatorParameter = SolutionCreatorParameter as ConstrainedValueParameter<IVRPCreator>;
    181       solutionCreatorParameter.ValidValues.Clear();
    182 
    183190      if (ProblemInstance != null) {
    184191        EvaluatorParameter.Value = ProblemInstance.SolutionEvaluator;
    185         IVRPCreator defaultCreator = null;
    186         foreach (IVRPCreator creator in Operators.Where(o => o is IVRPCreator)) {
    187           solutionCreatorParameter.ValidValues.Add(creator);
    188           if (creator is Encodings.Alba.RandomCreator)
    189             defaultCreator = creator;
    190         }
    191         if (defaultCreator != null)
    192           solutionCreatorParameter.Value = defaultCreator;
    193 
    194192        ProblemInstance.EvaluationChanged += new EventHandler(ProblemInstance_EvaluationChanged);
    195193      }
     
    246244
    247245    private void InitializeOperators() {
     246      var solutionCreatorParameter = SolutionCreatorParameter as ConstrainedValueParameter<IVRPCreator>;
     247      solutionCreatorParameter.ValidValues.Clear();
     248
    248249      Operators.Clear();
    249250
     
    252253        ProblemInstance.Operators.Concat(
    253254          ApplicationManager.Manager.GetInstances<IGeneralVRPOperator>().Cast<IOperator>()).OrderBy(op => op.Name));
     255        Operators.Add(new VRPSimilarityCalculator());
     256        Operators.Add(new SingleObjectivePopulationDiversityAnalyzer());
     257
     258        IVRPCreator defaultCreator = null;
     259        foreach (IVRPCreator creator in Operators.Where(o => o is IVRPCreator)) {
     260          solutionCreatorParameter.ValidValues.Add(creator);
     261          if (creator is Encodings.Alba.RandomCreator)
     262            defaultCreator = creator;
     263        }
     264        if (defaultCreator != null)
     265          solutionCreatorParameter.Value = defaultCreator;
    254266      }
    255267
     
    263275        }
    264276      }
    265     }
     277      if (ProblemInstance != null) {
     278        foreach (ISingleObjectiveImprovementOperator op in Operators.OfType<ISingleObjectiveImprovementOperator>()) {
     279          op.SolutionParameter.ActualName = SolutionCreator.VRPToursParameter.ActualName;
     280          op.SolutionParameter.Hidden = true;
     281        }
     282        foreach (ISingleObjectivePathRelinker op in Operators.OfType<ISingleObjectivePathRelinker>()) {
     283          op.ParentsParameter.ActualName = SolutionCreator.VRPToursParameter.ActualName;
     284          op.ParentsParameter.Hidden = true;
     285        }
     286        foreach (VRPSimilarityCalculator op in Operators.OfType<VRPSimilarityCalculator>()) {
     287          op.SolutionVariableName = SolutionCreator.VRPToursParameter.ActualName;
     288          op.QualityVariableName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName;
     289          op.ProblemInstance = ProblemInstance;
     290        }
     291        if (SingleObjectivePopulationDiversityAnalyzer != null) {
     292          SingleObjectivePopulationDiversityAnalyzer.MaximizationParameter.ActualName = MaximizationParameter.Name;
     293          SingleObjectivePopulationDiversityAnalyzer.QualityParameter.ActualName = ProblemInstance.SolutionEvaluator.QualityParameter.ActualName;
     294          SingleObjectivePopulationDiversityAnalyzer.ResultsParameter.ActualName = "Results";
     295          SingleObjectivePopulationDiversityAnalyzer.SimilarityCalculator = Operators.OfType<VRPSimilarityCalculator>().SingleOrDefault();
     296        }
     297      }
     298    }
     299
    266300    #endregion
    267301
     
    324358    }
    325359
    326     public void Load(IVRPData data) {
    327       Type interpreterType = typeof(IVRPDataInterpreter<>).MakeGenericType(data.GetType());
    328       var interpreters = ApplicationManager.Manager.GetInstances(interpreterType);
    329       if (interpreters.Count() > 0) {
    330         IVRPDataInterpreter interpreter = interpreters.First() as IVRPDataInterpreter;
    331         VRPInstanceDescription instance = interpreter.Interpret(data);
    332 
    333         Name = instance.Name;
    334         Description = instance.Description;
    335         if (ProblemInstance != null && instance.ProblemInstance != null &&
    336           instance.ProblemInstance.GetType() == ProblemInstance.GetType())
    337           SetProblemInstance(instance.ProblemInstance);
    338         else
    339           ProblemInstance = instance.ProblemInstance;
    340 
    341         OnReset();
    342         BestKnownQuality = null;
    343         BestKnownSolution = null;
    344 
    345         if (instance.BestKnownQuality != null) {
    346           BestKnownQuality = new DoubleValue((double)instance.BestKnownQuality);
    347         }
    348 
    349         if (instance.BestKnownSolution != null) {
    350           VRPSolution solution = new VRPSolution(ProblemInstance, instance.BestKnownSolution, new DoubleValue(0));
    351           BestKnownSolution = solution;
    352         }
    353       } else {
    354         throw new Exception("Cannot find an interpreter for " + data.GetType());
    355       }
    356     }
     360    #region Instance Consuming
     361    public void Load(IVRPData data, IVRPDataInterpreter interpreter) {
     362      VRPInstanceDescription instance = interpreter.Interpret(data);
     363
     364      Name = instance.Name;
     365      Description = instance.Description;
     366      if (ProblemInstance != null && instance.ProblemInstance != null &&
     367        instance.ProblemInstance.GetType() == ProblemInstance.GetType())
     368        SetProblemInstance(instance.ProblemInstance);
     369      else
     370        ProblemInstance = instance.ProblemInstance;
     371
     372      OnReset();
     373      BestKnownQuality = null;
     374      BestKnownSolution = null;
     375
     376      if (instance.BestKnownQuality != null) {
     377        BestKnownQuality = new DoubleValue((double)instance.BestKnownQuality);
     378      }
     379
     380      if (instance.BestKnownSolution != null) {
     381        VRPSolution solution = new VRPSolution(ProblemInstance, instance.BestKnownSolution, new DoubleValue(0));
     382        BestKnownSolution = solution;
     383      }
     384    }
     385
     386    public void Load(CVRPData data) {
     387      Load(data, new CVRPInterpreter());
     388    }
     389
     390    public void Load(CVRPTWData data) {
     391      Load(data, new CVRPTWInterpreter());
     392    }
     393
     394    public void Load(MDCVRPData data) {
     395      Load(data, new MDCVRPInterpreter());
     396    }
     397
     398    public void Load(MDCVRPTWData data) {
     399      Load(data, new MDCVRPTWInterpreter());
     400    }
     401
     402    public void Load(PDPTWData data) {
     403      Load(data, new PDPTWInterpreter());
     404    }
     405
     406    #endregion
    357407  }
    358408}
Note: See TracChangeset for help on using the changeset viewer.