Changeset 14649 for branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting
- Timestamp:
- 02/07/17 10:43:13 (8 years ago)
- Location:
- branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/HeuristicLab.Networks.IntegratedOptimization.LocationRouting-3.3.csproj
r14632 r14649 83 83 <Private>False</Private> 84 84 </Reference> 85 <Reference Include="HeuristicLab.Analysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 86 <SpecificVersion>False</SpecificVersion> 87 <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Analysis-3.3.dll</HintPath> 88 <Private>False</Private> 89 </Reference> 85 90 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 86 91 <SpecificVersion>False</SpecificVersion> … … 177 182 <Compile Include="LrpNetwork.cs" /> 178 183 <Compile Include="LrpNetwork2.cs" /> 184 <Compile Include="LrpNetwork3.cs" /> 179 185 <Compile Include="LrpOrchestratorNode.cs" /> 180 186 <Compile Include="LrpOrchestratorNode2.cs" /> 187 <Compile Include="LrpOrchestratorNode3.cs" /> 181 188 <Compile Include="LrpUtils.cs" /> 182 189 <Compile Include="LrpNetwork1.cs" /> -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpNetwork1.cs
r14628 r14649 53 53 var vp = new MinimizationVariegationProblem<RealVectorEncoding>(); 54 54 cmaes.Problem = vp; 55 var cmaAnalyzer = cmaes.Analyzer.Operators.OfType<CMAAnalyzer>().Single(); 56 cmaes.Analyzer.Operators.SetItemCheckedState(cmaAnalyzer, true); 55 57 cmaes.MaximumGenerations = 80; 56 58 MetaSolver.Algorithm = cmaes; -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpNetwork2.cs
r14628 r14649 53 53 var vp = new MinimizationVariegationProblem<RealVectorEncoding>(); 54 54 cmaes.Problem = vp; 55 var cmaAnalyzer = cmaes.Analyzer.Operators.OfType<CMAAnalyzer>().Single(); 56 cmaes.Analyzer.Operators.SetItemCheckedState(cmaAnalyzer, true); 55 57 cmaes.MaximumGenerations = 80; 56 58 MetaSolver.Algorithm = cmaes; -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode.cs
r14628 r14649 31 31 using HeuristicLab.Encodings.RealVectorEncoding; 32 32 using HeuristicLab.Operators; 33 using HeuristicLab.Optimization;34 33 using HeuristicLab.Parameters; 35 34 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; … … 183 182 } 184 183 185 pr ivatevoid InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) {184 protected virtual void InstanceParameter_Value_ToStringChanged(object sender, EventArgs e) { 186 185 string filePath = InstanceParameter.Value.Value; 187 186 LrpUtils.Import(filePath, out nrOfDepots, out nrOfCustomers, -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode1.cs
r14628 r14649 97 97 var vrp = (VehicleRoutingProblem)VrpParameter.Value.Clone(); 98 98 var vrpInstance = (CVRPProblemInstance)vrp.ProblemInstance; 99 var coordinates = LrpUtils.GetVrpCoordinates(depotCoordinates, customerCoordinates, depotIdx, customers);99 var coordinates = LrpUtils.GetVrpCoordinates(depotCoordinates, customerCoordinates, new[] { depotIdx }, customers); 100 100 var distances = LrpUtils.GetVrpDistances(coordinates, distanceType); 101 101 vrpInstance.Coordinates = new DoubleMatrix(coordinates); … … 111 111 112 112 var vrpResults = (ResultCollection)vrpMsg["Results"]; 113 var bestVrpSolution = (VRPSolution)vrpResults["Best valid VRP Solution"].Value.Clone(); 113 IResult bestVrpSolutionResult; 114 if (!vrpResults.TryGetValue("Best valid VRP Solution", out bestVrpSolutionResult) 115 && !vrpResults.TryGetValue("Best VRP Solution", out bestVrpSolutionResult)) { 116 // no best solution found ... throw? 117 } 118 var bestVrpSolution = (VRPSolution)bestVrpSolutionResult.Value.Clone(); 114 119 vrpSolutions.Add(new Result("Depot " + depot.Key, bestVrpSolution)); 115 120 } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpOrchestratorNode2.cs
r14628 r14649 97 97 var vrp = (VehicleRoutingProblem)VrpParameter.Value.Clone(); 98 98 var vrpInstance = (CVRPProblemInstance)vrp.ProblemInstance; 99 var coordinates = LrpUtils.GetVrpCoordinates(depotCoordinates, customerCoordinates, depotIdx, customers);99 var coordinates = LrpUtils.GetVrpCoordinates(depotCoordinates, customerCoordinates, new[] { depotIdx }, customers); 100 100 var distances = LrpUtils.GetVrpDistances(coordinates, distanceType); 101 101 vrpInstance.Coordinates = new DoubleMatrix(coordinates); … … 111 111 112 112 var vrpResults = (ResultCollection)vrpMsg["Results"]; 113 var bestVrpSolution = (VRPSolution)vrpResults["Best valid VRP Solution"].Value.Clone(); 113 IResult bestVrpSolutionResult; 114 if (!vrpResults.TryGetValue("Best valid VRP Solution", out bestVrpSolutionResult) 115 && !vrpResults.TryGetValue("Best VRP Solution", out bestVrpSolutionResult)) { 116 // no best solution found ... throw? 117 } 118 var bestVrpSolution = (VRPSolution)bestVrpSolutionResult.Value.Clone(); 114 119 vrpSolutions.Add(new Result("Depot " + depot.Key, bestVrpSolution)); 115 120 } -
branches/OptimizationNetworks/HeuristicLab.Networks.IntegratedOptimization.LocationRouting/3.3/LrpUtils.cs
r14604 r14649 19 19 DistanceFuncs = new Dictionary<DistanceType, Func<double[,], int, double[,], int, double>>(); 20 20 DistanceFuncs.Add(DistanceType.EUC_2D, (d, i, c, j) => Math.Sqrt(Math.Pow(d[i, 0] - c[j, 0], 2.0) + Math.Pow(d[i, 1] - c[j, 1], 2.0))); 21 DistanceFuncs.Add(DistanceType.CEIL_2D, (d, i, c, j) => Math.Ceiling(DistanceFuncs[DistanceType.EUC_2D](d, i, c, j) ) * 100);21 DistanceFuncs.Add(DistanceType.CEIL_2D, (d, i, c, j) => Math.Ceiling(DistanceFuncs[DistanceType.EUC_2D](d, i, c, j) * 100)); 22 22 } 23 23 … … 135 135 } 136 136 137 public static double[,] GetVrpCoordinates(double[,] depotCoordinates, double[,] customerCoordinates, int depotIdx, int[] customers) {138 var coordinates = new double[ customers.Length + 1, 2];137 public static double[,] GetVrpCoordinates(double[,] depotCoordinates, double[,] customerCoordinates, int[] depots, int[] customers) { 138 var coordinates = new double[depots.Length + customers.Length, 2]; 139 139 140 coordinates[0, 0] = depotCoordinates[depotIdx, 0]; 141 coordinates[0, 1] = depotCoordinates[depotIdx, 1]; 140 for (int i = 0; i < depots.Length; i++) { 141 coordinates[i, 0] = depotCoordinates[depots[i], 0]; 142 coordinates[i, 1] = depotCoordinates[depots[i], 1]; 143 } 142 144 for (int i = 0; i < customers.Length; i++) { 143 coordinates[i + 1, 0] = customerCoordinates[customers[i], 0];144 coordinates[i + 1, 1] = customerCoordinates[customers[i], 1];145 coordinates[i + depots.Length, 0] = customerCoordinates[customers[i], 0]; 146 coordinates[i + depots.Length, 1] = customerCoordinates[customers[i], 1]; 145 147 } 146 148 … … 148 150 } 149 151 150 public static double[,] GetVrpDistances(double[,] depotCoordinates, double[,] customerCoordinates, int depotIdx, int[] customers, DistanceType distanceType) {151 var coordinates = GetVrpCoordinates(depotCoordinates, customerCoordinates, depot Idx, customers);152 public static double[,] GetVrpDistances(double[,] depotCoordinates, double[,] customerCoordinates, int[] depots, int[] customers, DistanceType distanceType) { 153 var coordinates = GetVrpCoordinates(depotCoordinates, customerCoordinates, depots, customers); 152 154 return GetVrpDistances(coordinates, distanceType); 153 155 }
Note: See TracChangeset
for help on using the changeset viewer.