Changeset 9363 for branches/OaaS/HeuristicLab.Problems.VehicleRouting
- Timestamp:
- 04/16/13 13:13:41 (11 years ago)
- Location:
- branches/OaaS
- Files:
-
- 27 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS
- Property svn:ignore
-
old new 21 21 protoc.exe 22 22 _ReSharper.HeuristicLab 3.3 Tests 23 Google.ProtocolBuffers-2.4.1.473.dll 23 24 packages
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/OaaS/HeuristicLab.Problems.VehicleRouting
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.VehicleRouting (added) merged: 8231,8246,8346,8455,8497,8600,8649,8651-8653,8720,8763,8894,8899,8905,8922,9010,9321
- Property svn:mergeinfo changed
-
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj
r6866 r9363 330 330 --> 331 331 <PropertyGroup> 332 <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)332 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 333 333 set ProjectDir=$(ProjectDir) 334 334 set SolutionDir=$(SolutionDir) … … 337 337 call PreBuildEvent.cmd 338 338 </PreBuildEvent> 339 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 340 export ProjectDir=$(ProjectDir) 341 export SolutionDir=$(SolutionDir) 342 343 $SolutionDir/PreBuildEvent.sh 344 </PreBuildEvent> 339 345 </PropertyGroup> 340 346 </Project> -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.3/Plugin.cs.frame
r7259 r9363 26 26 /// Plugin class for HeuristicLab.Problems.VehicleRouting plugin 27 27 /// </summary> 28 [Plugin("HeuristicLab.Problems.VehicleRouting", "3.3. 6.$WCREV$")]28 [Plugin("HeuristicLab.Problems.VehicleRouting", "3.3.7.$WCREV$")] 29 29 [PluginFile("HeuristicLab.Problems.VehicleRouting-3.3.dll", PluginFileType.Assembly)] 30 30 [PluginDependency("HeuristicLab.Analysis", "3.3")] -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.3/Properties/AssemblyInfo.cs.frame
r7259 r9363 53 53 // by using the '*' as shown below: 54 54 [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 30 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 31 31 using HeuristicLab.Problems.VehicleRouting.Variants; 32 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 32 33 33 34 namespace HeuristicLab.Problems.VehicleRouting { … … 87 88 88 89 public override IOperation Apply() { 90 IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue; 89 91 ItemArray<IVRPEncoding> solutions = VRPToursParameter.ActualValue; 90 92 ResultCollection results = ResultsParameter.ActualValue; … … 100 102 results.Add(new Result("Best VRP Solution Overload", new DoubleValue(overloads[i].Value))); 101 103 } else { 102 if (qualities[i].Value <= solution.Quality.Value) { 104 VRPEvaluation eval = problemInstance.Evaluate(solution.Solution); 105 if (qualities[i].Value <= eval.Quality) { 103 106 (results["Best VRP Solution Overload"].Value as DoubleValue).Value = overloads[i].Value; 104 107 } -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/PickupAndDelivery/BestPickupAndDeliveryVRPSolutionAnalyzer.cs
r8053 r9363 30 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 31 31 using HeuristicLab.Problems.VehicleRouting.Variants; 32 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 32 33 33 34 namespace HeuristicLab.Problems.VehicleRouting { … … 87 88 88 89 public override IOperation Apply() { 90 IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue; 89 91 ItemArray<IVRPEncoding> solutions = VRPToursParameter.ActualValue; 90 92 ResultCollection results = ResultsParameter.ActualValue; … … 101 103 results.Add(new Result("Best VRP Solution PickupViolations", new DoubleValue(pickupViolations[i].Value))); 102 104 } else { 103 if (qualities[i].Value <= solution.Quality.Value) { 105 VRPEvaluation eval = problemInstance.Evaluate(solution.Solution); 106 if (qualities[i].Value <= eval.Quality) { 104 107 (results["Best VRP Solution PickupViolations"].Value as DoubleValue).Value = pickupViolations[i].Value; 105 108 } -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/BestSolution/TimeWindowed/BestTimeWindowedVRPSolutionAnalyzer.cs
r8053 r9363 30 30 using HeuristicLab.Problems.VehicleRouting.Interfaces; 31 31 using HeuristicLab.Problems.VehicleRouting.Variants; 32 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 32 33 33 34 namespace HeuristicLab.Problems.VehicleRouting { … … 91 92 92 93 public override IOperation Apply() { 94 IVRPProblemInstance problemInstance = ProblemInstanceParameter.ActualValue; 93 95 ItemArray<IVRPEncoding> solutions = VRPToursParameter.ActualValue; 94 96 ResultCollection results = ResultsParameter.ActualValue; … … 106 108 results.Add(new Result("Best VRP Solution TravelTime", new DoubleValue(travelTimes[i].Value))); 107 109 } else { 108 if (qualities[i].Value <= solution.Quality.Value) { 110 VRPEvaluation eval = problemInstance.Evaluate(solution.Solution); 111 if (qualities[i].Value <= eval.Quality) { 109 112 (results["Best VRP Solution Tardiness"].Value as DoubleValue).Value = tardinesses[i].Value; 110 113 (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 60 60 get { return (IValueParameter<DoubleValue>)Parameters["MinPenaltyFactor"]; } 61 61 } 62 public IValueParameter<DoubleValue> MaxPenaltyFactorParameter { 63 get { return (IValueParameter<DoubleValue>)Parameters["MaxPenaltyFactor"]; } 64 } 62 65 63 66 public ValueLookupParameter<ResultCollection> ResultsParameter { … … 80 83 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Overload", "The overloads of the VRP solutions which should be analyzed.")); 81 84 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))); 84 87 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))); 85 89 86 90 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best VRP solution should be stored.")); … … 95 99 } 96 100 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 97 111 public override IOperation Apply() { 98 112 ICapacitatedProblemInstance cvrp = ProblemInstanceParameter.ActualValue as ICapacitatedProblemInstance; … … 105 119 double phi = PhiParameter.Value.Value; 106 120 double minPenalty = MinPenaltyFactorParameter.Value.Value; 121 double maxPenalty = MaxPenaltyFactorParameter.Value.Value; 107 122 108 123 for (int j = 0; j < qualities.Length; j++) { … … 124 139 if (cvrp.OverloadPenalty.Value < minPenalty) 125 140 cvrp.OverloadPenalty.Value = minPenalty; 141 if (cvrp.OverloadPenalty.Value > maxPenalty) 142 cvrp.OverloadPenalty.Value = maxPenalty; 126 143 127 144 for (int j = 0; j < qualities.Length; j++) { -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/PickupAndDelivery/PickupViolationsRelaxationVRPAnalyzer.cs
r8053 r9363 60 60 get { return (IValueParameter<DoubleValue>)Parameters["MinPenaltyFactor"]; } 61 61 } 62 public IValueParameter<DoubleValue> MaxPenaltyFactorParameter { 63 get { return (IValueParameter<DoubleValue>)Parameters["MaxPenaltyFactor"]; } 64 } 62 65 63 66 public ValueLookupParameter<ResultCollection> ResultsParameter { … … 80 83 Parameters.Add(new ScopeTreeLookupParameter<IntValue>("PickupViolations", "The pickup violation of the VRP solutions which should be analyzed.")); 81 84 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))); 84 87 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))); 85 89 86 90 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best VRP solution should be stored.")); … … 95 99 } 96 100 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 97 111 public override IOperation Apply() { 98 112 IPickupAndDeliveryProblemInstance pdp = ProblemInstanceParameter.ActualValue as IPickupAndDeliveryProblemInstance; … … 105 119 double phi = PhiParameter.Value.Value; 106 120 double minPenalty = MinPenaltyFactorParameter.Value.Value; 121 double maxPenalty = MaxPenaltyFactorParameter.Value.Value; 107 122 108 123 for (int j = 0; j < qualities.Length; j++) { … … 124 139 if (pdp.PickupViolationPenalty.Value < minPenalty) 125 140 pdp.PickupViolationPenalty.Value = minPenalty; 141 if (pdp.PickupViolationPenalty.Value > maxPenalty) 142 pdp.PickupViolationPenalty.Value = maxPenalty; 126 143 127 144 for (int j = 0; j < qualities.Length; j++) { -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Analyzer/ConstraintRelaxation/TimeWindowed/TimeWindowRelaxationVRPAnalyzer.cs
r8053 r9363 60 60 get { return (IValueParameter<DoubleValue>)Parameters["MinPenaltyFactor"]; } 61 61 } 62 public IValueParameter<DoubleValue> MaxPenaltyFactorParameter { 63 get { return (IValueParameter<DoubleValue>)Parameters["MaxPenaltyFactor"]; } 64 } 62 65 63 66 public ValueLookupParameter<ResultCollection> ResultsParameter { … … 80 83 Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Tardiness", "The tardiness of the VRP solutions which should be analyzed.")); 81 84 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))); 84 87 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))); 85 89 86 90 Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The result collection where the best VRP solution should be stored.")); … … 95 99 } 96 100 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 97 111 public override IOperation Apply() { 98 112 ITimeWindowedProblemInstance vrptw = ProblemInstanceParameter.ActualValue as ITimeWindowedProblemInstance; … … 105 119 double phi = PhiParameter.Value.Value; 106 120 double minPenalty = MinPenaltyFactorParameter.Value.Value; 121 double maxPenalty = MaxPenaltyFactorParameter.Value.Value; 107 122 108 123 for (int j = 0; j < qualities.Length; j++) { … … 124 139 if (vrptw.TardinessPenalty.Value < minPenalty) 125 140 vrptw.TardinessPenalty.Value = minPenalty; 141 if (vrptw.TardinessPenalty.Value > maxPenalty) 142 vrptw.TardinessPenalty.Value = maxPenalty; 126 143 127 144 for (int j = 0; j < qualities.Length; j++) { -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinCrossover.cs
r8053 r9363 63 63 } 64 64 65 protected Tour FindRoute(PotvinEncoding solution, int city) {65 protected static Tour FindRoute(PotvinEncoding solution, int city) { 66 66 Tour found = null; 67 67 -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinRouteBasedCrossover.cs
r8053 r9363 24 24 using HeuristicLab.Encodings.PermutationEncoding; 25 25 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 26 using HeuristicLab.Problems.VehicleRouting.Interfaces; 26 27 27 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 43 44 } 44 45 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) { 48 47 PotvinEncoding child = parent2.Clone() as PotvinEncoding; 49 48 … … 75 74 child.Unrouted.Add(city); 76 75 77 if (Repair(random, child, replacing, ProblemInstance, allowInfeasible) || allowInfeasible)76 if (Repair(random, child, replacing, problemInstance, allowInfeasible) || allowInfeasible) 78 77 return child; 79 78 else { … … 87 86 } 88 87 } 88 89 protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) { 90 return Apply(random, parent1, parent2, ProblemInstance, AllowInfeasibleSolutions.Value.Value); 91 } 89 92 } 90 93 } -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Crossovers/PotvinSequenceBasedCrossover.cs
r8053 r9363 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 25 using HeuristicLab.Problems.VehicleRouting.Interfaces; 25 26 26 27 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { … … 42 43 } 43 44 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) { 47 46 PotvinEncoding child = parent1.Clone() as PotvinEncoding; 48 47 Tour newTour = new Tour(); 49 48 50 int cities = ProblemInstance.Cities.Value;49 int cities = problemInstance.Cities.Value; 51 50 52 51 if (cities > 0) { … … 77 76 child.Unrouted.Add(city); 78 77 79 if (Repair(random, child, newTour, ProblemInstance, allowInfeasible) || allowInfeasible) {78 if (Repair(random, child, newTour, problemInstance, allowInfeasible) || allowInfeasible) { 80 79 return child; 81 80 } else { … … 89 88 } 90 89 } 90 91 protected override PotvinEncoding Crossover(IRandom random, PotvinEncoding parent1, PotvinEncoding parent2) { 92 return Apply(random, parent1, parent2, ProblemInstance, AllowInfeasibleSolutions.Value.Value); 93 } 91 94 } 92 95 } -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinPairwiseOneLevelExchangeManipulator.cs
r8053 r9363 27 27 28 28 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { 29 [Item("PotvinPairwiseOneLevelExchangeMainpulator", "The 1M operator which manipulates a VRP representation. It is implemented as described inPotvin, 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.")] 30 30 [StorableClass] 31 31 public sealed class PotvinPairwiseOneLevelExchangeMainpulator : PotvinManipulator { -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/Manipulators/PotvinPairwiseTwoLevelExchangeManipulator.cs
r8053 r9363 28 28 29 29 namespace HeuristicLab.Problems.VehicleRouting.Encodings.Potvin { 30 [Item("PotvinPairwiseTwoLevelExchangeManipulator", "The 2M operator which manipulates a VRP representation. It is implemented as described inPotvin, 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.")] 31 31 [StorableClass] 32 32 public sealed class PotvinPairwiseTwoLevelExchangeManipulator : PotvinManipulator { -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Encodings/Potvin/PotvinEncoding.cs
r8053 r9363 69 69 foreach (Tour tour in toBeRemoved) { 70 70 int index = Tours.IndexOf(tour); 71 Tours.Remove(tour); 71 72 if (index < VehicleAssignment.Length) { 72 73 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++) { 76 77 VehicleAssignment[i] = VehicleAssignment[i + 1]; 77 78 } 78 VehicleAssignment[ VehicleAssignment.Length - 1] = vehicle;79 VehicleAssignment[max] = vehicle; 79 80 } 80 81 } -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/HeuristicLab.Problems.VehicleRouting-3.4.csproj
r7923 r9363 72 72 <OutputPath>..\..\bin\</OutputPath> 73 73 <DefineConstants>TRACE</DefineConstants> 74 <DocumentationFile>bin\x86\Release\HeuristicLab.Routing.TSP-3.3.xml</DocumentationFile> 74 <DocumentationFile> 75 </DocumentationFile> 75 76 <Optimize>true</Optimize> 76 77 <DebugType>pdbonly</DebugType> … … 139 140 <Compile Include="Encodings\Potvin\Moves\TwoOptStar\PotvinTwoOptStarMultiMoveGenerator.cs" /> 140 141 <Compile Include="Encodings\Potvin\Moves\TwoOptStar\PotvinTwoOptStarSingleMoveGenerator.cs" /> 142 <Compile Include="Improver\VRPImprovementOperator.cs" /> 143 <Compile Include="Improver\VRPIntraRouteImprovementOperator.cs" /> 141 144 <Compile Include="Interfaces\IVRPLocalSearchManipulator.cs" /> 145 <Compile Include="Interpreters\MDCVRPInterpreter.cs" /> 146 <Compile Include="Interpreters\VRPInterpreter.cs" /> 142 147 <Compile Include="Interpreters\MDCVRPTWInterpreter.cs" /> 143 148 <Compile Include="Interpreters\PDPTWInterpreter.cs" /> … … 145 150 <Compile Include="Interpreters\CVRPInterpreter.cs" /> 146 151 <Compile Include="Interpreters\IVRPDataInterpreter.cs" /> 152 <Compile Include="PathRelinkers\VRPPathRelinker.cs" /> 147 153 <Compile Include="Properties\AssemblyInfo.cs" /> 148 154 <Compile Include="Encodings\Alba\AlbaEncoding.cs" /> … … 336 342 <Compile Include="ProblemInstances\SingleDepotVRP\CVRP\CVRPTW\CVRPPDTW\CVRPPDTWEvaluator.cs" /> 337 343 <Compile Include="ProblemInstances\SingleDepotVRP\SingleDepotVRPEvaluator.cs" /> 344 <Compile Include="SimilarityCalculators\VRPSimilarityCalculator.cs" /> 338 345 <Compile Include="SolutionParser.cs" /> 339 346 <Compile Include="Variants\Capacitated\Heterogenous\IHeterogenousCapacitatedProblemInstance.cs" /> … … 468 475 --> 469 476 <PropertyGroup> 470 <PreBuildEvent >set Path=%25Path%25;$(ProjectDir);$(SolutionDir)477 <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir) 471 478 set ProjectDir=$(ProjectDir) 472 479 set SolutionDir=$(SolutionDir) … … 474 481 475 482 call PreBuildEvent.cmd</PreBuildEvent> 483 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' "> 484 export ProjectDir=$(ProjectDir) 485 export SolutionDir=$(SolutionDir) 486 487 $SolutionDir/PreBuildEvent.sh 488 </PreBuildEvent> 476 489 </PropertyGroup> 477 490 <PropertyGroup> -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interfaces/IVRPProblemInstance.cs
r8053 r9363 27 27 28 28 namespace HeuristicLab.Problems.VehicleRouting.Interfaces { 29 public interface IVRPProblemInstance : I Item {29 public interface IVRPProblemInstance : IParameterizedNamedItem { 30 30 IVRPEvaluator SolutionEvaluator { get; set; } 31 31 IVRPEvaluator MoveEvaluator { get; } -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/CVRPInterpreter.cs
r8053 r9363 24 24 using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin; 25 25 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 26 using HeuristicLab.Problems.VehicleRouting.Interfaces; 27 using System; 26 28 27 29 namespace 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 } 31 34 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 37 39 if (cvrpData.Coordinates != null) 38 40 problem.Coordinates = new DoubleMatrix(cvrpData.Coordinates); … … 47 49 problem.DistanceMatrix = new DoubleMatrix(cvrpData.GetDistanceMatrix()); 48 50 } 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;68 51 } 69 52 } -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/CVRPTWInterpreter.cs
r8053 r9363 24 24 using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin; 25 25 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 26 using HeuristicLab.Problems.VehicleRouting.Interfaces; 27 using System; 26 28 27 29 namespace 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 } 31 34 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); 35 37 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; 53 40 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); 71 44 } 72 45 } -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/IVRPDataInterpreter.cs
r8053 r9363 22 22 using HeuristicLab.Problems.Instances; 23 23 using HeuristicLab.Problems.VehicleRouting.Interfaces; 24 using System; 24 25 25 26 namespace HeuristicLab.Problems.VehicleRouting.Interpreters { -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/MDCVRPTWInterpreter.cs
r8053 r9363 24 24 using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin; 25 25 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 26 using HeuristicLab.Problems.VehicleRouting.Interfaces; 27 using System; 26 28 27 29 namespace 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 } 31 34 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); 35 37 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; 49 40 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); 75 44 } 76 45 } -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/Interpreters/PDPTWInterpreter.cs
r8053 r9363 24 24 using HeuristicLab.Problems.VehicleRouting.Encodings.Potvin; 25 25 using HeuristicLab.Problems.VehicleRouting.ProblemInstances; 26 using HeuristicLab.Problems.VehicleRouting.Interfaces; 27 using System; 26 28 27 29 namespace 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 } 31 34 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); 35 37 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; 54 40 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); 72 42 } 73 43 } -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPEvaluator.cs
r8053 r9363 118 118 } 119 119 120 public VRPEvaluation Evaluate(IVRPProblemInstance instance, IVRPEncoding solution) {120 public virtual VRPEvaluation Evaluate(IVRPProblemInstance instance, IVRPEncoding solution) { 121 121 VRPEvaluation evaluation = CreateTourEvaluation(); 122 122 -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/ProblemInstances/VRPProblemInstance.cs
r8053 r9363 37 37 IVRPEvaluator moveEvaluator; 38 38 39 private object locker = new object(); 40 39 41 public IVRPEvaluator MoveEvaluator { 40 42 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 } 54 58 } 55 59 } 60 61 return moveEvaluator; 56 62 } 57 58 return moveEvaluator;59 63 } 60 64 } … … 176 180 177 181 set { 178 moveEvaluator = null; 179 evaluator = value; 180 EvalBestKnownSolution(); 182 lock (locker) { 183 moveEvaluator = null; 184 evaluator = value; 185 EvalBestKnownSolution(); 186 } 181 187 } 182 188 } 183 189 184 190 public virtual double GetDistance(int start, int end, IVRPEncoding solution) { 185 double distance = 0.0;186 191 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); 196 198 } 197 199 -
branches/OaaS/HeuristicLab.Problems.VehicleRouting/3.4/VehicleRoutingProblem.cs
r8121 r9363 24 24 using System.Drawing; 25 25 using System.Linq; 26 using HeuristicLab.Analysis; 26 27 using HeuristicLab.Common; 27 28 using HeuristicLab.Core; … … 38 39 39 40 namespace HeuristicLab.Problems.VehicleRouting { 41 public interface IVRPInstanceConsumer : 42 IProblemInstanceConsumer<CVRPData>, IProblemInstanceConsumer<CVRPTWData>, 43 IProblemInstanceConsumer<MDCVRPData>, IProblemInstanceConsumer<MDCVRPTWData>, 44 IProblemInstanceConsumer<PDPTWData> { 45 } 46 40 47 [Item("Vehicle Routing Problem", "Represents a Vehicle Routing Problem.")] 41 48 [Creatable("Problems")] 42 49 [StorableClass] 43 public sealed class VehicleRoutingProblem : Problem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, I ProblemInstanceConsumer<IVRPData>{50 public sealed class VehicleRoutingProblem : Problem, ISingleObjectiveHeuristicOptimizationProblem, IStorableContent, IVRPInstanceConsumer { 44 51 public string Filename { get; set; } 45 52 … … 111 118 get { return SolutionCreatorParameter.Value; } 112 119 set { SolutionCreatorParameter.Value = value; } 120 } 121 private SingleObjectivePopulationDiversityAnalyzer SingleObjectivePopulationDiversityAnalyzer { 122 get { return Operators.OfType<SingleObjectivePopulationDiversityAnalyzer>().FirstOrDefault(); } 113 123 } 114 124 #endregion … … 178 188 179 189 private void AttachProblemInstanceEventHandlers() { 180 var solutionCreatorParameter = SolutionCreatorParameter as ConstrainedValueParameter<IVRPCreator>;181 solutionCreatorParameter.ValidValues.Clear();182 183 190 if (ProblemInstance != null) { 184 191 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 194 192 ProblemInstance.EvaluationChanged += new EventHandler(ProblemInstance_EvaluationChanged); 195 193 } … … 246 244 247 245 private void InitializeOperators() { 246 var solutionCreatorParameter = SolutionCreatorParameter as ConstrainedValueParameter<IVRPCreator>; 247 solutionCreatorParameter.ValidValues.Clear(); 248 248 249 Operators.Clear(); 249 250 … … 252 253 ProblemInstance.Operators.Concat( 253 254 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; 254 266 } 255 267 … … 263 275 } 264 276 } 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 266 300 #endregion 267 301 … … 324 358 } 325 359 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 357 407 } 358 408 }
Note: See TracChangeset
for help on using the changeset viewer.