|
| 1 | +// codebeat:disable[SIMILARITY] |
| 2 | +package com.route4me.sdk.examples.balance; |
| 3 | + |
| 4 | +import com.route4me.sdk.exception.APIException; |
| 5 | +import com.route4me.sdk.services.routing.Constants.*; |
| 6 | +import com.route4me.sdk.services.routing.*; |
| 7 | +import com.route4me.sdk.services.routing.balance.Balance; |
| 8 | +import com.route4me.sdk.services.routing.balance.BalanceMode; |
| 9 | + |
| 10 | +import java.util.ArrayList; |
| 11 | +import java.util.List; |
| 12 | + |
| 13 | +/** |
| 14 | + * @author route4me |
| 15 | + */ |
| 16 | +public class BalancedRoute { |
| 17 | + |
| 18 | + public static void main(String[] args) { |
| 19 | + String apiKey = "11111111111111111111111111111111"; |
| 20 | + RoutingManager manager = new RoutingManager(apiKey); |
| 21 | + OptimizationParameters optParameters = new OptimizationParameters(); |
| 22 | + |
| 23 | + Parameters parameters = new Parameters(); |
| 24 | + parameters.setAlgorithmType(AlgorithmType.CVRP_TW_SD.getValue()); |
| 25 | + parameters.setStoreRoute(Boolean.FALSE); |
| 26 | + parameters.setShareRoute(Boolean.FALSE); |
| 27 | + parameters.setRouteTime(0); |
| 28 | + parameters.setParts(3); |
| 29 | + parameters.setBalance(new Balance(BalanceMode.DESTINATIONS_COUNT.toString())); |
| 30 | + parameters.setRouteMaxDuration(86400); |
| 31 | + parameters.setVehicleCapacity("9999"); |
| 32 | + parameters.setRouteName("Balanced Drivers"); |
| 33 | + parameters.setOptimize(Optimize.DISTANCE.toString()); |
| 34 | + parameters.setDistanceUnit(DistanceUnit.MI.toString()); |
| 35 | + parameters.setDeviceType(DeviceType.WEB.toString()); |
| 36 | + parameters.setTravelMode(TravelMode.DRIVING.toString()); |
| 37 | + optParameters.setParameters(parameters); |
| 38 | + |
| 39 | + List<Address> addresses = new ArrayList<>(); |
| 40 | + addresses.add(new Address("455 S 4th St, Louisville, KY 40202", true, 38.251698, -85.757308, 300, 28800, 29400)); |
| 41 | + addresses.add(new Address("1604 PARKRIDGE PKWY, Louisville, KY, 40214", 38.141598, -85.793846, 300, 29400, 30000)); |
| 42 | + addresses.add(new Address("1407 MCCOY, Louisville, KY, 40215", 38.202496, -85.786514, 300, 30000, 30600)); |
| 43 | + addresses.add(new Address("4805 BELLEVUE AVE, Louisville, KY, 40215", 38.178844, -85.774864, 300, 30600, 31200)); |
| 44 | + addresses.add(new Address("730 CECIL AVENUE, Louisville, KY, 40211", 38.248684, -85.821121, 300, 31200, 31800)); |
| 45 | + addresses.add(new Address("650 SOUTH 29TH ST UNIT 315, Louisville, KY, 40211", 38.251923, -85.800034, 300, 31800, 32400)); |
| 46 | + addresses.add(new Address("4629 HILLSIDE DRIVE, Louisville, KY, 40216", 38.176067, -85.824638, 300, 32400, 33000)); |
| 47 | + addresses.add(new Address("4738 BELLEVUE AVE, Louisville, KY, 40215", 38.179806, -85.775558, 300, 33000, 33600)); |
| 48 | + addresses.add(new Address("318 SO. 39TH STREET, Louisville, KY, 40212", 38.259335, -85.815094, 300, 33600, 34200)); |
| 49 | + addresses.add(new Address("1324 BLUEGRASS AVE, Louisville, KY, 40215", 38.179253, -85.785118, 300, 34200, 34800)); |
| 50 | + addresses.add(new Address("7305 ROYAL WOODS DR, Louisville, KY, 40214", 38.162472, -85.792854, 300, 34800, 35400)); |
| 51 | + addresses.add(new Address("1661 W HILL ST, Louisville, KY, 40210", 38.229584, -85.783966, 300, 35400, 36000)); |
| 52 | + addresses.add(new Address("3222 KINGSWOOD WAY, Louisville, KY, 40216", 38.210606, -85.822594, 300, 36000, 36600)); |
| 53 | + addresses.add(new Address("1922 PALATKA RD, Louisville, KY, 40214", 38.153767, -85.796783, 300, 36600, 37200)); |
| 54 | + addresses.add(new Address("1314 SOUTH 26TH STREET, Louisville, KY, 40210", 38.235847, -85.796852, 300, 37200, 37800)); |
| 55 | + addresses.add(new Address("2135 MCCLOSKEY AVENUE, Louisville, KY, 40210", 38.218662, -85.789032, 300, 37800, 38400)); |
| 56 | + addresses.add(new Address("1409 PHYLLIS AVE, Louisville, KY, 40215", 38.206154, -85.781387, 300, 38400, 39000)); |
| 57 | + addresses.add(new Address("4504 SUNFLOWER AVE, Louisville, KY, 40216", 38.187511, -85.839149, 300, 39000, 39600)); |
| 58 | + addresses.add(new Address("2512 GREENWOOD AVE, Louisville, KY, 40210", 38.241405, -85.795059, 300, 39600, 40200)); |
| 59 | + addresses.add(new Address("5500 WILKE FARM AVE, Louisville, KY, 40216", 38.166065, -85.863319, 300, 40200, 40800)); |
| 60 | + addresses.add(new Address("3640 LENTZ AVE, Louisville, KY, 40215", 38.193283, -85.786201, 300, 40800, 41400)); |
| 61 | + addresses.add(new Address("1020 BLUEGRASS AVE, Louisville, KY, 40215", 38.17952, -85.780037, 300, 41400, 42000)); |
| 62 | + addresses.add(new Address("123 NORTH 40TH ST, Louisville, KY, 40212", 38.26498, -85.814156, 300, 42000, 42600)); |
| 63 | + addresses.add(new Address("7315 ST ANDREWS WOODS CIRCLE UNIT 104, Louisville, KY, 40214", 38.151072, -85.802867, 300, 42600, 43200)); |
| 64 | + addresses.add(new Address("3210 POPLAR VIEW DR, Louisville, KY, 40216", 38.182594, -85.849937, 300, 43200, 43800)); |
| 65 | + addresses.add(new Address("4519 LOUANE WAY, Louisville, KY, 40216", 38.1754, -85.811447, 300, 43800, 44400)); |
| 66 | + addresses.add(new Address("6812 MANSLICK RD, Louisville, KY, 40214", 38.161839, -85.798279, 300, 44400, 45000)); |
| 67 | + addresses.add(new Address("1524 HUNTOON AVENUE, Louisville, KY, 40215", 38.172031, -85.788353, 300, 45000, 45600)); |
| 68 | + addresses.add(new Address("1307 LARCHMONT AVE, Louisville, KY, 40215", 38.209663, -85.779816, 300, 45600, 46200)); |
| 69 | + addresses.add(new Address("434 N 26TH STREET #2, Louisville, KY, 40212", 38.26844, -85.791962, 300, 46200, 46800)); |
| 70 | + addresses.add(new Address("678 WESTLAWN ST, Louisville, KY, 40211", 38.250397, -85.80629, 300, 46800, 47400)); |
| 71 | + addresses.add(new Address("2308 W BROADWAY, Louisville, KY, 40211", 38.248882, -85.790421, 300, 47400, 48000)); |
| 72 | + addresses.add(new Address("2332 WOODLAND AVE, Louisville, KY, 40210", 38.233579, -85.794257, 300, 48000, 48600)); |
| 73 | + addresses.add(new Address("1706 WEST ST. CATHERINE, Louisville, KY, 40210", 38.239697, -85.783928, 300, 48600, 49200)); |
| 74 | + addresses.add(new Address("1699 WATHEN LN, Louisville, KY, 40216", 38.216465, -85.792397, 300, 49200, 49800)); |
| 75 | + addresses.add(new Address("2416 SUNSHINE WAY, Louisville, KY, 40216", 38.186245, -85.831787, 300, 49800, 50400)); |
| 76 | + addresses.add(new Address("6925 MANSLICK RD, Louisville, KY, 40214", 38.158466, -85.798355, 300, 50400, 51000)); |
| 77 | + addresses.add(new Address("2707 7TH ST, Louisville, KY, 40215", 38.212438, -85.785082, 300, 51000, 51600)); |
| 78 | + addresses.add(new Address("2014 KENDALL LN, Louisville, KY, 40216", 38.179394, -85.826668, 300, 51600, 52200)); |
| 79 | + addresses.add(new Address("612 N 39TH ST, Louisville, KY, 40212", 38.273354, -85.812012, 300, 52200, 52800)); |
| 80 | + addresses.add(new Address("2215 ROWAN ST, Louisville, KY, 40212", 38.261703, -85.786781, 300, 52800, 53400)); |
| 81 | + addresses.add(new Address("1826 W. KENTUCKY ST, Louisville, KY, 40210", 38.241611, -85.78653, 300, 53400, 54000)); |
| 82 | + addresses.add(new Address("1810 GREGG AVE, Louisville, KY, 40210", 38.224716, -85.796211, 300, 54000, 54600)); |
| 83 | + addresses.add(new Address("4103 BURRRELL DRIVE, Louisville, KY, 40216", 38.191753, -85.825836, 300, 54600, 55200)); |
| 84 | + addresses.add(new Address("359 SOUTHWESTERN PKWY, Louisville, KY, 40212", 38.259903, -85.823463, 300, 55200, 55800)); |
| 85 | + addresses.add(new Address("2407 W CHESTNUT ST, Louisville, KY, 40211", 38.252781, -85.792109, 300, 55800, 56400)); |
| 86 | + addresses.add(new Address("225 S 22ND ST, Louisville, KY, 40212", 38.257616, -85.786658, 300, 56400, 57000)); |
| 87 | + addresses.add(new Address("1404 MCCOY AVE, Louisville, KY, 40215", 38.202122, -85.786072, 300, 57000, 57600)); |
| 88 | + addresses.add(new Address("117 FOUNT LANDING CT, Louisville, KY, 40212", 38.270061, -85.799438, 300, 57600, 58200)); |
| 89 | + addresses.add(new Address("5504 SHOREWOOD DRIVE, Louisville, KY, 40214", 38.145851, -85.7798, 300, 58200, 58800)); |
| 90 | + optParameters.setAddresses(addresses); |
| 91 | + |
| 92 | + try { |
| 93 | + DataObject responseObject = manager.runOptimization(optParameters); |
| 94 | + System.out.println("Optimization Problem ID:" + responseObject.getOptimizationProblemId()); |
| 95 | + System.out.println("State:" + OptimizationState.get(responseObject.getState().intValue())); |
| 96 | + if (responseObject.getAddresses() != null) { |
| 97 | + for (Address address : responseObject.getAddresses()) { |
| 98 | + System.out.println(address); |
| 99 | + } |
| 100 | + } |
| 101 | + } catch (APIException e) { |
| 102 | + //handle exception |
| 103 | + e.printStackTrace(); |
| 104 | + } |
| 105 | + } |
| 106 | +} |
| 107 | +// codebeat:enable[SIMILARITY] |
0 commit comments