@@ -4,15 +4,15 @@ |
||
| 4 | 4 | |
| 5 | 5 | class AlgorithmType |
| 6 | 6 | { |
| 7 | - const STATE_NEW = 0; |
|
| 8 | - const TSP = 1; |
|
| 9 | - const VRP = 2; |
|
| 10 | - const CVRP_TW_SD = 3; |
|
| 11 | - const CVRP_TW_MD = 4; |
|
| 12 | - const TSP_TW = 5; |
|
| 13 | - const TSP_TW_CR = 6; |
|
| 14 | - const OPTIMIZATION_STATE_IN_QUEUE = 7; |
|
| 15 | - const ADVANCED_CVRP_TW = 9; |
|
| 16 | - const ALG_NONE = 100; |
|
| 17 | - const ALG_LEGACY_DISTRIBUTED = 101; |
|
| 7 | + const STATE_NEW = 0; |
|
| 8 | + const TSP = 1; |
|
| 9 | + const VRP = 2; |
|
| 10 | + const CVRP_TW_SD = 3; |
|
| 11 | + const CVRP_TW_MD = 4; |
|
| 12 | + const TSP_TW = 5; |
|
| 13 | + const TSP_TW_CR = 6; |
|
| 14 | + const OPTIMIZATION_STATE_IN_QUEUE = 7; |
|
| 15 | + const ADVANCED_CVRP_TW = 9; |
|
| 16 | + const ALG_NONE = 100; |
|
| 17 | + const ALG_LEGACY_DISTRIBUTED = 101; |
|
| 18 | 18 | } |
@@ -4,9 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Metric |
| 6 | 6 | { |
| 7 | - const EUCLIDEAN = 1; //measures point to point distance as a straight line |
|
| 8 | - const MANHATTAN = 2; //measures point to point distance as taxicab geometry line |
|
| 9 | - const GEODESIC = 3; //measures point to point distance approximating curvature of the earth |
|
| 10 | - const MATRIX = 4; //measures point to point distance by traversing the actual road network |
|
| 11 | - const EXACT_2D = 5; //measures point to point distance using 2d rectilinear distance |
|
| 7 | + const EUCLIDEAN = 1; //measures point to point distance as a straight line |
|
| 8 | + const MANHATTAN = 2; //measures point to point distance as taxicab geometry line |
|
| 9 | + const GEODESIC = 3; //measures point to point distance approximating curvature of the earth |
|
| 10 | + const MATRIX = 4; //measures point to point distance by traversing the actual road network |
|
| 11 | + const EXACT_2D = 5; //measures point to point distance using 2d rectilinear distance |
|
| 12 | 12 | } |
@@ -4,9 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | class DeviceType |
| 6 | 6 | { |
| 7 | - const WEB = 'web'; |
|
| 8 | - const IPHONE = 'iphone'; |
|
| 9 | - const IPAD = 'ipad'; |
|
| 10 | - const ANDROID_PHONE = 'android_phone'; |
|
| 11 | - const ANDROID_TABLET = 'android_tablet'; |
|
| 7 | + const WEB = 'web'; |
|
| 8 | + const IPHONE = 'iphone'; |
|
| 9 | + const IPAD = 'ipad'; |
|
| 10 | + const ANDROID_PHONE = 'android_phone'; |
|
| 11 | + const ANDROID_TABLET = 'android_tablet'; |
|
| 12 | 12 | } |
@@ -4,9 +4,9 @@ |
||
| 4 | 4 | |
| 5 | 5 | class TravelMode |
| 6 | 6 | { |
| 7 | - const DRIVING = 'Driving'; |
|
| 8 | - const WALKING = 'Walking'; |
|
| 9 | - const TRUCKING = 'Trucking'; |
|
| 10 | - const CYCLING = 'Cycling'; |
|
| 11 | - const TRANSIT = 'Transit'; |
|
| 7 | + const DRIVING = 'Driving'; |
|
| 8 | + const WALKING = 'Walking'; |
|
| 9 | + const TRUCKING = 'Trucking'; |
|
| 10 | + const CYCLING = 'Cycling'; |
|
| 11 | + const TRANSIT = 'Transit'; |
|
| 12 | 12 | } |
@@ -23,25 +23,25 @@ discard block |
||
| 23 | 23 | //********************************************************************** |
| 24 | 24 | // General Route Parameters |
| 25 | 25 | $parameters = RouteParameters::fromArray([ |
| 26 | - 'rt' => false, |
|
| 27 | - 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
| 28 | - 'route_name' => 'Persistent Location - Single Depot - Multiple Driver '.date('Y-m-d H:i:s', time()), |
|
| 29 | - 'route_time' => 25200, |
|
| 30 | - 'distance_unit' => DistanceUnit::MILES, |
|
| 31 | - 'device_type' => DeviceType::WEB, |
|
| 32 | - 'optimize' => OptimizationType::DISTANCE, |
|
| 33 | - 'travel_mode' => TravelMode::DRIVING, |
|
| 34 | - 'advanced_constraints' => [] |
|
| 26 | + 'rt' => false, |
|
| 27 | + 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
| 28 | + 'route_name' => 'Persistent Location - Single Depot - Multiple Driver '.date('Y-m-d H:i:s', time()), |
|
| 29 | + 'route_time' => 25200, |
|
| 30 | + 'distance_unit' => DistanceUnit::MILES, |
|
| 31 | + 'device_type' => DeviceType::WEB, |
|
| 32 | + 'optimize' => OptimizationType::DISTANCE, |
|
| 33 | + 'travel_mode' => TravelMode::DRIVING, |
|
| 34 | + 'advanced_constraints' => [] |
|
| 35 | 35 | ]); |
| 36 | 36 | |
| 37 | 37 | //********************************************************************** |
| 38 | 38 | // Persistent Location |
| 39 | 39 | $persistent_location = [ |
| 40 | - 'alias' => 'DEPOT END LOCATION', |
|
| 41 | - 'address' => '4738 BELLEVUE AVE, Louisville, KY, 40215', |
|
| 42 | - 'lat' => 38.179806, |
|
| 43 | - 'lng' => -85.775558, |
|
| 44 | - 'time' => 300 |
|
| 40 | + 'alias' => 'DEPOT END LOCATION', |
|
| 41 | + 'address' => '4738 BELLEVUE AVE, Louisville, KY, 40215', |
|
| 42 | + 'lat' => 38.179806, |
|
| 43 | + 'lng' => -85.775558, |
|
| 44 | + 'time' => 300 |
|
| 45 | 45 | ]; |
| 46 | 46 | |
| 47 | 47 | //********************************************************************** |
@@ -50,22 +50,22 @@ discard block |
||
| 50 | 50 | // Time Window Start: 2:00 am EST |
| 51 | 51 | // Time Window End: 15:50 am EST |
| 52 | 52 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
| 53 | - 'max_cargo_volume' => 0.0, |
|
| 54 | - 'max_capacity' => 200, |
|
| 55 | - 'members_count' => 10, |
|
| 56 | - 'available_time_windows' => [[25200, 75000]], |
|
| 57 | - 'location_sequence_pattern' => ['', $persistent_location] |
|
| 53 | + 'max_cargo_volume' => 0.0, |
|
| 54 | + 'max_capacity' => 200, |
|
| 55 | + 'members_count' => 10, |
|
| 56 | + 'available_time_windows' => [[25200, 75000]], |
|
| 57 | + 'location_sequence_pattern' => ['', $persistent_location] |
|
| 58 | 58 | ]); |
| 59 | 59 | |
| 60 | 60 | // Schedule 2 |
| 61 | 61 | // Time Window Start: 7:33 am EST |
| 62 | 62 | // Time Window End: 21:23 am EST |
| 63 | 63 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
| 64 | - 'max_cargo_volume' => 0.0, |
|
| 65 | - 'max_capacity' => 200, |
|
| 66 | - 'members_count' => 10, |
|
| 67 | - 'available_time_windows' => [[45200, 95000]], |
|
| 68 | - 'location_sequence_pattern' => ['', $persistent_location] |
|
| 64 | + 'max_cargo_volume' => 0.0, |
|
| 65 | + 'max_capacity' => 200, |
|
| 66 | + 'members_count' => 10, |
|
| 67 | + 'available_time_windows' => [[45200, 95000]], |
|
| 68 | + 'location_sequence_pattern' => ['', $persistent_location] |
|
| 69 | 69 | ]); |
| 70 | 70 | |
| 71 | 71 | //********************************************************************** |
@@ -74,25 +74,25 @@ discard block |
||
| 74 | 74 | |
| 75 | 75 | // Depot |
| 76 | 76 | $addresses[] = Address::fromArray([ |
| 77 | - 'address' => '1604 PARKRIDGE PKWY, Louisville, KY, 40214', |
|
| 78 | - 'is_depot' => true, |
|
| 79 | - 'lat' => 38.141598, |
|
| 80 | - 'lng' => -85.793846, |
|
| 81 | - 'time' => 0 |
|
| 77 | + 'address' => '1604 PARKRIDGE PKWY, Louisville, KY, 40214', |
|
| 78 | + 'is_depot' => true, |
|
| 79 | + 'lat' => 38.141598, |
|
| 80 | + 'lng' => -85.793846, |
|
| 81 | + 'time' => 0 |
|
| 82 | 82 | ]); |
| 83 | 83 | |
| 84 | 84 | // Stops |
| 85 | 85 | foreach ($json as $address) { |
| 86 | 86 | |
| 87 | - // skip persistent |
|
| 88 | - if($address['address'] == '4738 BELLEVUE AVE, Louisville, KY, 40215') continue; |
|
| 87 | + // skip persistent |
|
| 88 | + if($address['address'] == '4738 BELLEVUE AVE, Louisville, KY, 40215') continue; |
|
| 89 | 89 | |
| 90 | - $addresses[] = Address::fromArray([ |
|
| 91 | - 'address' => $address['address'], |
|
| 92 | - 'lat' => $address['lat'], |
|
| 93 | - 'lng' => $address['lng'], |
|
| 94 | - 'time' => $address['time'] |
|
| 95 | - ]); |
|
| 90 | + $addresses[] = Address::fromArray([ |
|
| 91 | + 'address' => $address['address'], |
|
| 92 | + 'lat' => $address['lat'], |
|
| 93 | + 'lng' => $address['lng'], |
|
| 94 | + 'time' => $address['time'] |
|
| 95 | + ]); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | $optimizationParams = new OptimizationProblemParams(); |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | echo "Routes:" . PHP_EOL; |
| 108 | 108 | foreach($problem->routes as $route) |
| 109 | 109 | { |
| 110 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
| 111 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
| 112 | - echo "\tAddresses:" . PHP_EOL; |
|
| 110 | + echo "\tID: " . $route->route_id . PHP_EOL; |
|
| 111 | + echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
| 112 | + echo "\tAddresses:" . PHP_EOL; |
|
| 113 | 113 | |
| 114 | - foreach($route->addresses as $address) echo "\t\t" . $address->address . PHP_EOL; |
|
| 114 | + foreach($route->addresses as $address) echo "\t\t" . $address->address . PHP_EOL; |
|
| 115 | 115 | } |
@@ -18,70 +18,70 @@ |
||
| 18 | 18 | Route4Me::setApiKey(Constants::API_KEY); |
| 19 | 19 | |
| 20 | 20 | try { |
| 21 | - // get route_id and member_id |
|
| 22 | - $route = new Route; |
|
| 23 | - $routes = $route->getRoutes([ |
|
| 24 | - 'limit' => 1, |
|
| 25 | - 'offset' => 0 |
|
| 26 | - ]); |
|
| 27 | - |
|
| 28 | - $route_id = null; |
|
| 29 | - $member_id = null; |
|
| 30 | - if (is_array($routes) && isset($routes[0])) { |
|
| 31 | - $route_id = $routes[0]->route_id; |
|
| 32 | - $member_id = $routes[0]->member_id; |
|
| 33 | - } |
|
| 34 | - $route = null; |
|
| 35 | - |
|
| 36 | - if ($route_id === null) { |
|
| 37 | - throw new ApiError('There is no any route.'); |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - // get vehicle_id |
|
| 41 | - $vehicle = new Vehicle(); |
|
| 42 | - $vehicles = $vehicle->getVehiclesPaginatedList([ |
|
| 43 | - 'with_pagination' => true, |
|
| 44 | - 'page' => 1, |
|
| 45 | - 'perPage' => 1 |
|
| 46 | - ]); |
|
| 47 | - |
|
| 48 | - $vehicle_id = null; |
|
| 49 | - if (is_array($vehicles) && isset($vehicles[0]) && is_array($vehicles[0]) && isset($vehicles[0]['vehicle_id'])) { |
|
| 50 | - $vehicle_id = $vehicles[0]['vehicle_id']; |
|
| 51 | - } |
|
| 52 | - $vehicle = null; |
|
| 53 | - |
|
| 54 | - if ($vehicle_id === null) { |
|
| 55 | - throw new ApiError('There is no any vehicle.'); |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - // create Schedule |
|
| 59 | - $schedules = new Schedules; |
|
| 60 | - |
|
| 61 | - $schedule = $schedules->createSchedule([ |
|
| 62 | - 'name' => 'The bestest schedule', |
|
| 63 | - 'schedule_blacklist' => [], |
|
| 64 | - 'schedule' => null, |
|
| 65 | - 'timezone' => 'UTC' |
|
| 66 | - ]); |
|
| 67 | - |
|
| 68 | - // work with RouteSchedule |
|
| 69 | - $route_schedule = $schedules->createRouteSchedule([ |
|
| 70 | - 'route_id' => $route_id, |
|
| 71 | - 'schedule_uid' => $schedule->schedule_uid |
|
| 72 | - ]); |
|
| 73 | - |
|
| 74 | - $route_schedule = $schedules->updateRouteSchedule($route_id, [ |
|
| 75 | - 'schedule_uid' => $schedule->schedule_uid, |
|
| 76 | - 'member_id' => $member_id, |
|
| 77 | - 'vehicle_id' => $vehicle_id |
|
| 78 | - ]); |
|
| 79 | - |
|
| 80 | - $route_schedule = $schedules->getRouteSchedule($route_id); |
|
| 81 | - |
|
| 82 | - $schedules->deleteRouteSchedule($route_id); |
|
| 83 | - |
|
| 84 | - print_r($route_schedule); |
|
| 21 | + // get route_id and member_id |
|
| 22 | + $route = new Route; |
|
| 23 | + $routes = $route->getRoutes([ |
|
| 24 | + 'limit' => 1, |
|
| 25 | + 'offset' => 0 |
|
| 26 | + ]); |
|
| 27 | + |
|
| 28 | + $route_id = null; |
|
| 29 | + $member_id = null; |
|
| 30 | + if (is_array($routes) && isset($routes[0])) { |
|
| 31 | + $route_id = $routes[0]->route_id; |
|
| 32 | + $member_id = $routes[0]->member_id; |
|
| 33 | + } |
|
| 34 | + $route = null; |
|
| 35 | + |
|
| 36 | + if ($route_id === null) { |
|
| 37 | + throw new ApiError('There is no any route.'); |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + // get vehicle_id |
|
| 41 | + $vehicle = new Vehicle(); |
|
| 42 | + $vehicles = $vehicle->getVehiclesPaginatedList([ |
|
| 43 | + 'with_pagination' => true, |
|
| 44 | + 'page' => 1, |
|
| 45 | + 'perPage' => 1 |
|
| 46 | + ]); |
|
| 47 | + |
|
| 48 | + $vehicle_id = null; |
|
| 49 | + if (is_array($vehicles) && isset($vehicles[0]) && is_array($vehicles[0]) && isset($vehicles[0]['vehicle_id'])) { |
|
| 50 | + $vehicle_id = $vehicles[0]['vehicle_id']; |
|
| 51 | + } |
|
| 52 | + $vehicle = null; |
|
| 53 | + |
|
| 54 | + if ($vehicle_id === null) { |
|
| 55 | + throw new ApiError('There is no any vehicle.'); |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + // create Schedule |
|
| 59 | + $schedules = new Schedules; |
|
| 60 | + |
|
| 61 | + $schedule = $schedules->createSchedule([ |
|
| 62 | + 'name' => 'The bestest schedule', |
|
| 63 | + 'schedule_blacklist' => [], |
|
| 64 | + 'schedule' => null, |
|
| 65 | + 'timezone' => 'UTC' |
|
| 66 | + ]); |
|
| 67 | + |
|
| 68 | + // work with RouteSchedule |
|
| 69 | + $route_schedule = $schedules->createRouteSchedule([ |
|
| 70 | + 'route_id' => $route_id, |
|
| 71 | + 'schedule_uid' => $schedule->schedule_uid |
|
| 72 | + ]); |
|
| 73 | + |
|
| 74 | + $route_schedule = $schedules->updateRouteSchedule($route_id, [ |
|
| 75 | + 'schedule_uid' => $schedule->schedule_uid, |
|
| 76 | + 'member_id' => $member_id, |
|
| 77 | + 'vehicle_id' => $vehicle_id |
|
| 78 | + ]); |
|
| 79 | + |
|
| 80 | + $route_schedule = $schedules->getRouteSchedule($route_id); |
|
| 81 | + |
|
| 82 | + $schedules->deleteRouteSchedule($route_id); |
|
| 83 | + |
|
| 84 | + print_r($route_schedule); |
|
| 85 | 85 | } catch (\Exception $e) { |
| 86 | - echo $e->getMessage() . PHP_EOL; |
|
| 86 | + echo $e->getMessage() . PHP_EOL; |
|
| 87 | 87 | } |
@@ -15,16 +15,16 @@ |
||
| 15 | 15 | Route4Me::setApiKey(Constants::API_KEY); |
| 16 | 16 | |
| 17 | 17 | try { |
| 18 | - $route_schedules = new Schedules; |
|
| 18 | + $route_schedules = new Schedules; |
|
| 19 | 19 | |
| 20 | - $params = [ |
|
| 21 | - 'route_id' => '66C2AC4A323053FF0A40FEB6918ACF5E', |
|
| 22 | - 'schedule_uid' => '1515E9A65DD2DEF79CAD7A7E68D91515' |
|
| 23 | - ]; |
|
| 20 | + $params = [ |
|
| 21 | + 'route_id' => '66C2AC4A323053FF0A40FEB6918ACF5E', |
|
| 22 | + 'schedule_uid' => '1515E9A65DD2DEF79CAD7A7E68D91515' |
|
| 23 | + ]; |
|
| 24 | 24 | |
| 25 | - $schedule = $route_schedules->createRouteSchedule($params); |
|
| 25 | + $schedule = $route_schedules->createRouteSchedule($params); |
|
| 26 | 26 | |
| 27 | - print_r($schedule); |
|
| 27 | + print_r($schedule); |
|
| 28 | 28 | } catch (\Exception $e) { |
| 29 | - echo $e->getMessage() . PHP_EOL; |
|
| 29 | + echo $e->getMessage() . PHP_EOL; |
|
| 30 | 30 | } |
@@ -15,20 +15,20 @@ |
||
| 15 | 15 | Route4Me::setApiKey(Constants::API_KEY); |
| 16 | 16 | |
| 17 | 17 | try { |
| 18 | - $schedules = new Schedules; |
|
| 18 | + $schedules = new Schedules; |
|
| 19 | 19 | |
| 20 | - $params = [ |
|
| 21 | - 'schedule_uid' => '1515E9A65DD2DEF79CAD7A7E68D91515', |
|
| 22 | - 'root_member_id' => 15, |
|
| 23 | - 'name' => 'The bestest schedule 1', |
|
| 24 | - 'schedule_blacklist' => [], |
|
| 25 | - 'schedule' => null, |
|
| 26 | - 'timezone' => 'UTC' |
|
| 27 | - ]; |
|
| 20 | + $params = [ |
|
| 21 | + 'schedule_uid' => '1515E9A65DD2DEF79CAD7A7E68D91515', |
|
| 22 | + 'root_member_id' => 15, |
|
| 23 | + 'name' => 'The bestest schedule 1', |
|
| 24 | + 'schedule_blacklist' => [], |
|
| 25 | + 'schedule' => null, |
|
| 26 | + 'timezone' => 'UTC' |
|
| 27 | + ]; |
|
| 28 | 28 | |
| 29 | - $schedule = $schedules->createSchedule($params); |
|
| 29 | + $schedule = $schedules->createSchedule($params); |
|
| 30 | 30 | |
| 31 | - print_r($schedule); |
|
| 31 | + print_r($schedule); |
|
| 32 | 32 | } catch (\Exception $e) { |
| 33 | - echo $e->getMessage() . PHP_EOL; |
|
| 33 | + echo $e->getMessage() . PHP_EOL; |
|
| 34 | 34 | } |
@@ -15,10 +15,10 @@ |
||
| 15 | 15 | Route4Me::setApiKey(Constants::API_KEY); |
| 16 | 16 | |
| 17 | 17 | try { |
| 18 | - $schedules = new Schedules(); |
|
| 18 | + $schedules = new Schedules(); |
|
| 19 | 19 | |
| 20 | - $schedule = $schedules->getSchedule('1515E9A65DD2DEF79CAD7A7E68D91515'); |
|
| 21 | - print_r($schedule); |
|
| 20 | + $schedule = $schedules->getSchedule('1515E9A65DD2DEF79CAD7A7E68D91515'); |
|
| 21 | + print_r($schedule); |
|
| 22 | 22 | } catch (\Exception $e) { |
| 23 | - echo $e->getMessage() . PHP_EOL; |
|
| 23 | + echo $e->getMessage() . PHP_EOL; |
|
| 24 | 24 | } |