@@ -25,28 +25,28 @@ discard block |
||
25 | 25 | |
26 | 26 | // Depot |
27 | 27 | $depots = [ |
28 | - Address::fromArray([ |
|
29 | - 'alias' => 'Start Depot', |
|
30 | - 'address' => '1604 PARKRIDGE PKWY, Louisville, KY, 40214', |
|
31 | - 'lat' => 38.141598, |
|
32 | - 'lng' => -80.190211 |
|
33 | - ]) |
|
28 | + Address::fromArray([ |
|
29 | + 'alias' => 'Start Depot', |
|
30 | + 'address' => '1604 PARKRIDGE PKWY, Louisville, KY, 40214', |
|
31 | + 'lat' => 38.141598, |
|
32 | + 'lng' => -80.190211 |
|
33 | + ]) |
|
34 | 34 | ]; |
35 | 35 | |
36 | 36 | //********************************************************************** |
37 | 37 | // General Route Parameters |
38 | 38 | $parameters = RouteParameters::fromArray([ |
39 | - 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
40 | - 'route_name' => 'Drivers Different Working Time Example - Single Depot, Multiple Driver '.date('Y-m-d H:i:s', time()), |
|
41 | - 'route_date' => time() + 24 * 60 * 60, |
|
42 | - 'route_time' => 6 * 3600, |
|
43 | - 'distance_unit' => DistanceUnit::MILES, |
|
44 | - 'device_type' => DeviceType::WEB, |
|
45 | - 'optimize' => OptimizationType::DISTANCE, |
|
46 | - 'travel_mode' => TravelMode::DRIVING, |
|
47 | - 'route_max_duration' => 8 * 60 * 60, |
|
48 | - 'parts' => 6, |
|
49 | - 'advanced_constraints' => [] |
|
39 | + 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
40 | + 'route_name' => 'Drivers Different Working Time Example - Single Depot, Multiple Driver '.date('Y-m-d H:i:s', time()), |
|
41 | + 'route_date' => time() + 24 * 60 * 60, |
|
42 | + 'route_time' => 6 * 3600, |
|
43 | + 'distance_unit' => DistanceUnit::MILES, |
|
44 | + 'device_type' => DeviceType::WEB, |
|
45 | + 'optimize' => OptimizationType::DISTANCE, |
|
46 | + 'travel_mode' => TravelMode::DRIVING, |
|
47 | + 'route_max_duration' => 8 * 60 * 60, |
|
48 | + 'parts' => 6, |
|
49 | + 'advanced_constraints' => [] |
|
50 | 50 | ]); |
51 | 51 | |
52 | 52 | //********************************************************************** |
@@ -55,18 +55,18 @@ discard block |
||
55 | 55 | // Time Window Start: 7:00 am EST |
56 | 56 | // Time Window End: 11:00 am EST |
57 | 57 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
58 | - 'max_cargo_volume' => 0.0, |
|
59 | - 'members_count' => 4, |
|
60 | - 'available_time_windows' => [[(7 + 5) * 3600 , (11 + 5) * 3600]] |
|
58 | + 'max_cargo_volume' => 0.0, |
|
59 | + 'members_count' => 4, |
|
60 | + 'available_time_windows' => [[(7 + 5) * 3600 , (11 + 5) * 3600]] |
|
61 | 61 | ]); |
62 | 62 | |
63 | 63 | // Schedule full time |
64 | 64 | // Time Window Start: 7:00 am EST |
65 | 65 | // Time Window End: 15:00 am EST |
66 | 66 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
67 | - 'max_cargo_volume' => 0.0, |
|
68 | - 'members_count' => 2, |
|
69 | - 'available_time_windows' => [[(7 + 5) * 3600 , (15 + 5) * 3600]] |
|
67 | + 'max_cargo_volume' => 0.0, |
|
68 | + 'members_count' => 2, |
|
69 | + 'available_time_windows' => [[(7 + 5) * 3600 , (15 + 5) * 3600]] |
|
70 | 70 | ]); |
71 | 71 | |
72 | 72 | //********************************************************************** |
@@ -75,12 +75,12 @@ discard block |
||
75 | 75 | $addresses = []; |
76 | 76 | |
77 | 77 | foreach ($json as $address) { |
78 | - $addresses[] = Address::fromArray([ |
|
79 | - 'address' => $address['address'], |
|
80 | - 'lat' => $address['lat'], |
|
81 | - 'lng' => $address['lng'], |
|
82 | - 'time' => $address['time'] |
|
83 | - ]); |
|
78 | + $addresses[] = Address::fromArray([ |
|
79 | + 'address' => $address['address'], |
|
80 | + 'lat' => $address['lat'], |
|
81 | + 'lng' => $address['lng'], |
|
82 | + 'time' => $address['time'] |
|
83 | + ]); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | $optimizationParams = new OptimizationProblemParams(); |
@@ -99,9 +99,9 @@ discard block |
||
99 | 99 | echo "Routes:" . PHP_EOL; |
100 | 100 | foreach($problem->routes as $route) |
101 | 101 | { |
102 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
103 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
104 | - echo "\tAddresses:" . PHP_EOL; |
|
102 | + echo "\tID: " . $route->route_id . PHP_EOL; |
|
103 | + echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
104 | + echo "\tAddresses:" . PHP_EOL; |
|
105 | 105 | |
106 | - foreach($route->addresses as $address) echo "\t\t" . $address->address . PHP_EOL; |
|
106 | + foreach($route->addresses as $address) echo "\t\t" . $address->address . PHP_EOL; |
|
107 | 107 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
58 | 58 | 'max_cargo_volume' => 0.0, |
59 | 59 | 'members_count' => 4, |
60 | - 'available_time_windows' => [[(7 + 5) * 3600 , (11 + 5) * 3600]] |
|
60 | + 'available_time_windows' => [[(7 + 5) * 3600, (11 + 5) * 3600]] |
|
61 | 61 | ]); |
62 | 62 | |
63 | 63 | // Schedule full time |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
67 | 67 | 'max_cargo_volume' => 0.0, |
68 | 68 | 'members_count' => 2, |
69 | - 'available_time_windows' => [[(7 + 5) * 3600 , (15 + 5) * 3600]] |
|
69 | + 'available_time_windows' => [[(7 + 5) * 3600, (15 + 5) * 3600]] |
|
70 | 70 | ]); |
71 | 71 | |
72 | 72 | //********************************************************************** |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | |
91 | 91 | $problem = OptimizationProblem::optimize($optimizationParams); |
92 | 92 | |
93 | -echo "Optimization Problem ID: " . $problem->optimization_problem_id . PHP_EOL; |
|
94 | -echo "State: " . OptimizationStates::getName($problem->state) . " (" . $problem->state . ")" . PHP_EOL; |
|
93 | +echo "Optimization Problem ID: ".$problem->optimization_problem_id.PHP_EOL; |
|
94 | +echo "State: ".OptimizationStates::getName($problem->state)." (".$problem->state.")".PHP_EOL; |
|
95 | 95 | |
96 | -echo "Optimization Problem ID: " . $problem->optimization_problem_id . PHP_EOL; |
|
97 | -echo "State: " . OptimizationStates::getName($problem->state) . " (" . $problem->state . ")" . PHP_EOL; |
|
96 | +echo "Optimization Problem ID: ".$problem->optimization_problem_id.PHP_EOL; |
|
97 | +echo "State: ".OptimizationStates::getName($problem->state)." (".$problem->state.")".PHP_EOL; |
|
98 | 98 | |
99 | -echo "Routes:" . PHP_EOL; |
|
100 | -foreach($problem->routes as $route) |
|
99 | +echo "Routes:".PHP_EOL; |
|
100 | +foreach ($problem->routes as $route) |
|
101 | 101 | { |
102 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
103 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
104 | - echo "\tAddresses:" . PHP_EOL; |
|
102 | + echo "\tID: ".$route->route_id.PHP_EOL; |
|
103 | + echo "\tDistance: ".$route->trip_distance.PHP_EOL; |
|
104 | + echo "\tAddresses:".PHP_EOL; |
|
105 | 105 | |
106 | - foreach($route->addresses as $address) echo "\t\t" . $address->address . PHP_EOL; |
|
106 | + foreach ($route->addresses as $address) echo "\t\t".$address->address.PHP_EOL; |
|
107 | 107 | } |
@@ -103,5 +103,7 @@ |
||
103 | 103 | echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
104 | 104 | echo "\tAddresses:" . PHP_EOL; |
105 | 105 | |
106 | - foreach($route->addresses as $address) echo "\t\t" . $address->address . PHP_EOL; |
|
107 | -} |
|
106 | + foreach($route->addresses as $address) { |
|
107 | + echo "\t\t" . $address->address . PHP_EOL; |
|
108 | + } |
|
109 | + } |
@@ -24,42 +24,42 @@ discard block |
||
24 | 24 | Route4Me::setApiKey(Constants::API_KEY); |
25 | 25 | |
26 | 26 | $depots = [ |
27 | - Address::fromArray([ |
|
28 | - 'address' => 'DEPOT', |
|
29 | - 'lat' => 25.694341, |
|
30 | - 'lng' => -80.166036 |
|
31 | - ]) |
|
27 | + Address::fromArray([ |
|
28 | + 'address' => 'DEPOT', |
|
29 | + 'lat' => 25.694341, |
|
30 | + 'lng' => -80.166036 |
|
31 | + ]) |
|
32 | 32 | ]; |
33 | 33 | |
34 | 34 | //********************************************************************** |
35 | 35 | // General Route Parameters |
36 | 36 | $parameters = RouteParameters::fromArray([ |
37 | - 'rt' => true, |
|
38 | - 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
39 | - 'route_name' => '10 Drivers Schedules '.date('Y-m-d H:i:s', time()), |
|
40 | - 'distance_unit' => DistanceUnit::MILES, |
|
41 | - 'device_type' => DeviceType::WEB, |
|
42 | - 'optimize' => OptimizationType::DISTANCE, |
|
43 | - 'travel_mode' => TravelMode::DRIVING, |
|
44 | - 'parts' => 10, |
|
45 | - 'advanced_constraints' => [] |
|
37 | + 'rt' => true, |
|
38 | + 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
39 | + 'route_name' => '10 Drivers Schedules '.date('Y-m-d H:i:s', time()), |
|
40 | + 'distance_unit' => DistanceUnit::MILES, |
|
41 | + 'device_type' => DeviceType::WEB, |
|
42 | + 'optimize' => OptimizationType::DISTANCE, |
|
43 | + 'travel_mode' => TravelMode::DRIVING, |
|
44 | + 'parts' => 10, |
|
45 | + 'advanced_constraints' => [] |
|
46 | 46 | ]); |
47 | 47 | |
48 | 48 | //********************************************************************** |
49 | 49 | // Schedules |
50 | 50 | // Time: 9:00 am EST => (9 + 5) * 3600 => 50400 |
51 | 51 | $available_time_windows = [ |
52 | - [50400, 64800], [54000, 75600], [57600, 72000], [57600, 75600], [54000, 68400], |
|
53 | - [54000, 75600], [54000, 68400], [57600, 79200], [43200, 57600], [57600, 79200] |
|
52 | + [50400, 64800], [54000, 75600], [57600, 72000], [57600, 75600], [54000, 68400], |
|
53 | + [54000, 75600], [54000, 68400], [57600, 79200], [43200, 57600], [57600, 79200] |
|
54 | 54 | ]; |
55 | 55 | |
56 | 56 | for($i = 0; $i < 10; ++$i) |
57 | 57 | { |
58 | - $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
|
59 | - 'max_cargo_volume' => 0.0, |
|
60 | - 'members_count' => 1, |
|
61 | - 'available_time_windows' => [$available_time_windows[$i]] |
|
62 | - ]); |
|
58 | + $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
|
59 | + 'max_cargo_volume' => 0.0, |
|
60 | + 'members_count' => 1, |
|
61 | + 'available_time_windows' => [$available_time_windows[$i]] |
|
62 | + ]); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | //********************************************************************** |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | $addresses = []; |
69 | 69 | |
70 | 70 | foreach ($json as $address) { |
71 | - $addresses[] = Address::fromArray([ |
|
72 | - 'alias' => $address['alias'], |
|
73 | - 'address' => $address['address'], |
|
74 | - 'lat' => $address['lat'], |
|
75 | - 'lng' => $address['lng'] |
|
76 | - ]); |
|
71 | + $addresses[] = Address::fromArray([ |
|
72 | + 'alias' => $address['alias'], |
|
73 | + 'address' => $address['address'], |
|
74 | + 'lat' => $address['lat'], |
|
75 | + 'lng' => $address['lng'] |
|
76 | + ]); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $optimizationParams = new OptimizationProblemParams(); |
@@ -89,6 +89,6 @@ discard block |
||
89 | 89 | echo "Routes:" . PHP_EOL; |
90 | 90 | foreach($problem->routes as $route) |
91 | 91 | { |
92 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
93 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
92 | + echo "\tID: " . $route->route_id . PHP_EOL; |
|
93 | + echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
94 | 94 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | [54000, 75600], [54000, 68400], [57600, 79200], [43200, 57600], [57600, 79200] |
54 | 54 | ]; |
55 | 55 | |
56 | -for($i = 0; $i < 10; ++$i) |
|
56 | +for ($i = 0; $i<10; ++$i) |
|
57 | 57 | { |
58 | 58 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
59 | 59 | 'max_cargo_volume' => 0.0, |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | |
84 | 84 | $problem = OptimizationProblem::optimize($optimizationParams); |
85 | 85 | |
86 | -echo "Optimization Problem ID: " . $problem->optimization_problem_id . PHP_EOL; |
|
87 | -echo "State: " . OptimizationStates::getName($problem->state) . " (" . $problem->state . ")" . PHP_EOL; |
|
86 | +echo "Optimization Problem ID: ".$problem->optimization_problem_id.PHP_EOL; |
|
87 | +echo "State: ".OptimizationStates::getName($problem->state)." (".$problem->state.")".PHP_EOL; |
|
88 | 88 | |
89 | -echo "Routes:" . PHP_EOL; |
|
90 | -foreach($problem->routes as $route) |
|
89 | +echo "Routes:".PHP_EOL; |
|
90 | +foreach ($problem->routes as $route) |
|
91 | 91 | { |
92 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
93 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
92 | + echo "\tID: ".$route->route_id.PHP_EOL; |
|
93 | + echo "\tDistance: ".$route->trip_distance.PHP_EOL; |
|
94 | 94 | } |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | //********************************************************************** |
27 | 27 | // General Route Parameters |
28 | 28 | $parameters = RouteParameters::fromArray([ |
29 | - 'rt' => true, |
|
30 | - 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
31 | - 'route_name' => 'Drivers Schedules - 3 Territories '.date('Y-m-d H:i:s', time()), |
|
32 | - 'distance_unit' => DistanceUnit::MILES, |
|
33 | - 'device_type' => DeviceType::WEB, |
|
34 | - 'optimize' => OptimizationType::DISTANCE, |
|
35 | - 'travel_mode' => TravelMode::DRIVING, |
|
36 | - 'parts' => 9, |
|
37 | - 'advanced_constraints' => [] |
|
29 | + 'rt' => true, |
|
30 | + 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
31 | + 'route_name' => 'Drivers Schedules - 3 Territories '.date('Y-m-d H:i:s', time()), |
|
32 | + 'distance_unit' => DistanceUnit::MILES, |
|
33 | + 'device_type' => DeviceType::WEB, |
|
34 | + 'optimize' => OptimizationType::DISTANCE, |
|
35 | + 'travel_mode' => TravelMode::DRIVING, |
|
36 | + 'parts' => 9, |
|
37 | + 'advanced_constraints' => [] |
|
38 | 38 | ]); |
39 | 39 | |
40 | 40 | //********************************************************************** |
@@ -45,18 +45,18 @@ discard block |
||
45 | 45 | // Schedules |
46 | 46 | // Time: 9:00 am EST => (9 + 5) * 3600 => 50400 |
47 | 47 | $available_time_windows = [ |
48 | - [50400, 64800], [54000, 75600], [57600, 72000], [57600, 75600], [54000, 68400], |
|
49 | - [54000, 75600], [54000, 68400], [57600, 79200], [43200, 57600] |
|
48 | + [50400, 64800], [54000, 75600], [57600, 72000], [57600, 75600], [54000, 68400], |
|
49 | + [54000, 75600], [54000, 68400], [57600, 79200], [43200, 57600] |
|
50 | 50 | ]; |
51 | 51 | |
52 | 52 | for($i = 0; $i < 9; ++$i) |
53 | 53 | { |
54 | - $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
|
55 | - 'max_cargo_volume' => 0.0, |
|
56 | - 'members_count' => 1, |
|
57 | - 'available_time_windows' => [$available_time_windows[$i]], |
|
58 | - 'tags' => $zones[$i % 3] |
|
59 | - ]); |
|
54 | + $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
|
55 | + 'max_cargo_volume' => 0.0, |
|
56 | + 'members_count' => 1, |
|
57 | + 'available_time_windows' => [$available_time_windows[$i]], |
|
58 | + 'tags' => $zones[$i % 3] |
|
59 | + ]); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | //********************************************************************** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $addresses = []; |
66 | 66 | |
67 | 67 | foreach ($json as $address) { |
68 | - $addresses[] = Address::fromArray($address); |
|
68 | + $addresses[] = Address::fromArray($address); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $optimizationParams = new OptimizationProblemParams(); |
@@ -80,6 +80,6 @@ discard block |
||
80 | 80 | echo "Routes:" . PHP_EOL; |
81 | 81 | foreach($problem->routes as $route) |
82 | 82 | { |
83 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
84 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
83 | + echo "\tID: " . $route->route_id . PHP_EOL; |
|
84 | + echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
85 | 85 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | [54000, 75600], [54000, 68400], [57600, 79200], [43200, 57600] |
50 | 50 | ]; |
51 | 51 | |
52 | -for($i = 0; $i < 9; ++$i) |
|
52 | +for ($i = 0; $i<9; ++$i) |
|
53 | 53 | { |
54 | 54 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
55 | 55 | 'max_cargo_volume' => 0.0, |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | |
75 | 75 | $problem = OptimizationProblem::optimize($optimizationParams); |
76 | 76 | |
77 | -echo "Optimization Problem ID: " . $problem->optimization_problem_id . PHP_EOL; |
|
78 | -echo "State: " . OptimizationStates::getName($problem->state) . " (" . $problem->state . ")" . PHP_EOL; |
|
77 | +echo "Optimization Problem ID: ".$problem->optimization_problem_id.PHP_EOL; |
|
78 | +echo "State: ".OptimizationStates::getName($problem->state)." (".$problem->state.")".PHP_EOL; |
|
79 | 79 | |
80 | -echo "Routes:" . PHP_EOL; |
|
81 | -foreach($problem->routes as $route) |
|
80 | +echo "Routes:".PHP_EOL; |
|
81 | +foreach ($problem->routes as $route) |
|
82 | 82 | { |
83 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
84 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
83 | + echo "\tID: ".$route->route_id.PHP_EOL; |
|
84 | + echo "\tDistance: ".$route->trip_distance.PHP_EOL; |
|
85 | 85 | } |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | //********************************************************************** |
30 | 30 | // General Route Parameters |
31 | 31 | $parameters = RouteParameters::fromArray([ |
32 | - 'rt' => true, |
|
33 | - 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
34 | - 'route_name' => 'Drivers Different Working Time Example - Territories '.date('Y-m-d H:i:s', time()), |
|
35 | - 'distance_unit' => DistanceUnit::MILES, |
|
36 | - 'device_type' => DeviceType::WEB, |
|
37 | - 'optimize' => OptimizationType::DISTANCE, |
|
38 | - 'travel_mode' => TravelMode::DRIVING, |
|
39 | - 'parts' => 10, |
|
40 | - 'advanced_constraints'=> [] |
|
32 | + 'rt' => true, |
|
33 | + 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
34 | + 'route_name' => 'Drivers Different Working Time Example - Territories '.date('Y-m-d H:i:s', time()), |
|
35 | + 'distance_unit' => DistanceUnit::MILES, |
|
36 | + 'device_type' => DeviceType::WEB, |
|
37 | + 'optimize' => OptimizationType::DISTANCE, |
|
38 | + 'travel_mode' => TravelMode::DRIVING, |
|
39 | + 'parts' => 10, |
|
40 | + 'advanced_constraints'=> [] |
|
41 | 41 | ]); |
42 | 42 | |
43 | 43 | //********************************************************************** |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | // Full Time Window End: 15:00 am EST |
52 | 52 | for($i = 0; $i < 6; ++$i) |
53 | 53 | { |
54 | - $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
|
55 | - 'max_cargo_volume' => 0.0, |
|
56 | - 'members_count' => 100, |
|
57 | - 'available_time_windows' => [[(7 + 5) * 3600, ($i % 2 == 0 ? (11 + 5) : (15 + 5)) * 3600]], |
|
58 | - 'tags' => $zones[intdiv($i, 2) % 3] |
|
59 | - ]); |
|
54 | + $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
|
55 | + 'max_cargo_volume' => 0.0, |
|
56 | + 'members_count' => 100, |
|
57 | + 'available_time_windows' => [[(7 + 5) * 3600, ($i % 2 == 0 ? (11 + 5) : (15 + 5)) * 3600]], |
|
58 | + 'tags' => $zones[intdiv($i, 2) % 3] |
|
59 | + ]); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | //********************************************************************** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $addresses = []; |
66 | 66 | |
67 | 67 | foreach ($json as $address) { |
68 | - $addresses[] = Address::fromArray($address); |
|
68 | + $addresses[] = Address::fromArray($address); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $optimizationParams = new OptimizationProblemParams(); |
@@ -83,6 +83,6 @@ discard block |
||
83 | 83 | echo "Routes:" . PHP_EOL; |
84 | 84 | foreach($problem->routes as $route) |
85 | 85 | { |
86 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
87 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
86 | + echo "\tID: " . $route->route_id . PHP_EOL; |
|
87 | + echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
88 | 88 | } |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | // Time Window Start: 7:00 am EST |
50 | 50 | // Part Time Window End: 11:00 am EST |
51 | 51 | // Full Time Window End: 15:00 am EST |
52 | -for($i = 0; $i < 6; ++$i) |
|
52 | +for ($i = 0; $i<6; ++$i) |
|
53 | 53 | { |
54 | 54 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
55 | 55 | 'max_cargo_volume' => 0.0, |
56 | 56 | 'members_count' => 100, |
57 | - 'available_time_windows' => [[(7 + 5) * 3600, ($i % 2 == 0 ? (11 + 5) : (15 + 5)) * 3600]], |
|
57 | + 'available_time_windows' => [[(7 + 5) * 3600, ($i % 2==0 ? (11 + 5) : (15 + 5)) * 3600]], |
|
58 | 58 | 'tags' => $zones[intdiv($i, 2) % 3] |
59 | 59 | ]); |
60 | 60 | } |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | |
75 | 75 | $problem = OptimizationProblem::optimize($optimizationParams); |
76 | 76 | |
77 | -echo "Optimization Problem ID: " . $problem->optimization_problem_id . PHP_EOL; |
|
78 | -echo "State: " . OptimizationStates::getName($problem->state) . " (" . $problem->state . ")" . PHP_EOL; |
|
77 | +echo "Optimization Problem ID: ".$problem->optimization_problem_id.PHP_EOL; |
|
78 | +echo "State: ".OptimizationStates::getName($problem->state)." (".$problem->state.")".PHP_EOL; |
|
79 | 79 | |
80 | -echo "Optimization Problem ID: " . $problem->optimization_problem_id . PHP_EOL; |
|
81 | -echo "State: " . OptimizationStates::getName($problem->state) . " (" . $problem->state . ")" . PHP_EOL; |
|
80 | +echo "Optimization Problem ID: ".$problem->optimization_problem_id.PHP_EOL; |
|
81 | +echo "State: ".OptimizationStates::getName($problem->state)." (".$problem->state.")".PHP_EOL; |
|
82 | 82 | |
83 | -echo "Routes:" . PHP_EOL; |
|
84 | -foreach($problem->routes as $route) |
|
83 | +echo "Routes:".PHP_EOL; |
|
84 | +foreach ($problem->routes as $route) |
|
85 | 85 | { |
86 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
87 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
86 | + echo "\tID: ".$route->route_id.PHP_EOL; |
|
87 | + echo "\tDistance: ".$route->trip_distance.PHP_EOL; |
|
88 | 88 | } |
@@ -23,19 +23,19 @@ discard block |
||
23 | 23 | //********************************************************************** |
24 | 24 | // General Route Parameters |
25 | 25 | $parameters = RouteParameters::fromArray([ |
26 | - 'rt' => true, |
|
27 | - 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
28 | - 'route_name' => 'Driver Shift Example - SDMD '.date('Y-m-d H:i:s', time()), |
|
29 | - 'route_time' => 0, |
|
30 | - 'distance_unit' => DistanceUnit::MILES, |
|
31 | - 'device_type' => DeviceType::WEB, |
|
32 | - 'optimize' => OptimizationType::DISTANCE, |
|
33 | - 'travel_mode' => TravelMode::DRIVING, |
|
34 | - 'vehicle_capacity' => 100, |
|
35 | - 'vehicle_max_distance_mi' => 10000, |
|
36 | - 'route_max_duration' => 86400, |
|
37 | - 'parts' => 20, |
|
38 | - 'advanced_constraints' => [] |
|
26 | + 'rt' => true, |
|
27 | + 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
28 | + 'route_name' => 'Driver Shift Example - SDMD '.date('Y-m-d H:i:s', time()), |
|
29 | + 'route_time' => 0, |
|
30 | + 'distance_unit' => DistanceUnit::MILES, |
|
31 | + 'device_type' => DeviceType::WEB, |
|
32 | + 'optimize' => OptimizationType::DISTANCE, |
|
33 | + 'travel_mode' => TravelMode::DRIVING, |
|
34 | + 'vehicle_capacity' => 100, |
|
35 | + 'vehicle_max_distance_mi' => 10000, |
|
36 | + 'route_max_duration' => 86400, |
|
37 | + 'parts' => 20, |
|
38 | + 'advanced_constraints' => [] |
|
39 | 39 | ]); |
40 | 40 | |
41 | 41 | //********************************************************************** |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | // Time Window Start: 2:00 am EST |
45 | 45 | // Time Window End: 15:50 am EST |
46 | 46 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
47 | - 'max_cargo_volume' => 0.0, |
|
48 | - 'max_capacity' => 200, |
|
49 | - 'members_count' => 10, |
|
50 | - 'available_time_windows' => [[25200, 75000]], |
|
51 | - 'tags' => ['TAG001', 'TAG002'] |
|
47 | + 'max_cargo_volume' => 0.0, |
|
48 | + 'max_capacity' => 200, |
|
49 | + 'members_count' => 10, |
|
50 | + 'available_time_windows' => [[25200, 75000]], |
|
51 | + 'tags' => ['TAG001', 'TAG002'] |
|
52 | 52 | ]); |
53 | 53 | |
54 | 54 | // Schedule 2 |
@@ -57,11 +57,11 @@ discard block |
||
57 | 57 | // Time Window Start: 12:13 am EST |
58 | 58 | // Time Window End: 18:36 am EST |
59 | 59 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
60 | - 'max_cargo_volume' => 0.0, |
|
61 | - 'max_capacity' => 500, |
|
62 | - 'members_count' => 6, |
|
63 | - 'available_time_windows' => [[45200, 55000], [62000, 85000]], |
|
64 | - 'tags' => ['TAG003'] |
|
60 | + 'max_cargo_volume' => 0.0, |
|
61 | + 'max_capacity' => 500, |
|
62 | + 'members_count' => 6, |
|
63 | + 'available_time_windows' => [[45200, 55000], [62000, 85000]], |
|
64 | + 'tags' => ['TAG003'] |
|
65 | 65 | ]); |
66 | 66 | |
67 | 67 | //********************************************************************** |
@@ -70,31 +70,31 @@ discard block |
||
70 | 70 | |
71 | 71 | // Depot |
72 | 72 | $addresses[] = Address::fromArray([ |
73 | - 'address' => '1604 PARKRIDGE PKWY, Louisville, KY, 40214', |
|
74 | - 'is_depot' => true, |
|
75 | - 'lat' => 38.141598, |
|
76 | - 'lng' => -85.793846, |
|
77 | - 'time' => 300 |
|
73 | + 'address' => '1604 PARKRIDGE PKWY, Louisville, KY, 40214', |
|
74 | + 'is_depot' => true, |
|
75 | + 'lat' => 38.141598, |
|
76 | + 'lng' => -85.793846, |
|
77 | + 'time' => 300 |
|
78 | 78 | ]); |
79 | 79 | |
80 | 80 | // Stops |
81 | 81 | $n = 0; |
82 | 82 | foreach ($json as $address) { |
83 | - $addr_obj = Address::fromArray([ |
|
84 | - 'address' => $address['address'], |
|
85 | - 'lat' => $address['lat'], |
|
86 | - 'lng' => $address['lng'], |
|
87 | - 'time' => $address['time'], |
|
88 | - 'tags' => ($n < 4 ? ['TAG001', 'TAG002'] : ['TAG003']) |
|
89 | - ]); |
|
90 | - |
|
91 | - if($n >= 4) |
|
92 | - { |
|
93 | - $addr_obj->time_window_start = $address['time_window_start']; |
|
94 | - $addr_obj->time_window_end = $address['time_window_end']; |
|
95 | - } |
|
96 | - $addresses[] = $addr_obj; |
|
97 | - ++$n; |
|
83 | + $addr_obj = Address::fromArray([ |
|
84 | + 'address' => $address['address'], |
|
85 | + 'lat' => $address['lat'], |
|
86 | + 'lng' => $address['lng'], |
|
87 | + 'time' => $address['time'], |
|
88 | + 'tags' => ($n < 4 ? ['TAG001', 'TAG002'] : ['TAG003']) |
|
89 | + ]); |
|
90 | + |
|
91 | + if($n >= 4) |
|
92 | + { |
|
93 | + $addr_obj->time_window_start = $address['time_window_start']; |
|
94 | + $addr_obj->time_window_end = $address['time_window_end']; |
|
95 | + } |
|
96 | + $addresses[] = $addr_obj; |
|
97 | + ++$n; |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | $optimizationParams = new OptimizationProblemParams(); |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | echo "Routes:" . PHP_EOL; |
110 | 110 | foreach($problem->routes as $route) |
111 | 111 | { |
112 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
113 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
114 | - echo "\tAddresses:" . PHP_EOL; |
|
112 | + echo "\tID: " . $route->route_id . PHP_EOL; |
|
113 | + echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
114 | + echo "\tAddresses:" . PHP_EOL; |
|
115 | 115 | |
116 | - foreach($route->addresses as $address) echo "\t\t" . $address->address . PHP_EOL; |
|
116 | + foreach($route->addresses as $address) echo "\t\t" . $address->address . PHP_EOL; |
|
117 | 117 | } |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | 'lat' => $address['lat'], |
86 | 86 | 'lng' => $address['lng'], |
87 | 87 | 'time' => $address['time'], |
88 | - 'tags' => ($n < 4 ? ['TAG001', 'TAG002'] : ['TAG003']) |
|
88 | + 'tags' => ($n<4 ? ['TAG001', 'TAG002'] : ['TAG003']) |
|
89 | 89 | ]); |
90 | 90 | |
91 | - if($n >= 4) |
|
91 | + if ($n>=4) |
|
92 | 92 | { |
93 | 93 | $addr_obj->time_window_start = $address['time_window_start']; |
94 | 94 | $addr_obj->time_window_end = $address['time_window_end']; |
@@ -103,15 +103,15 @@ discard block |
||
103 | 103 | |
104 | 104 | $problem = OptimizationProblem::optimize($optimizationParams); |
105 | 105 | |
106 | -echo "Optimization Problem ID: " . $problem->optimization_problem_id . PHP_EOL; |
|
107 | -echo "State: " . OptimizationStates::getName($problem->state) . " (" . $problem->state . ")" . PHP_EOL; |
|
106 | +echo "Optimization Problem ID: ".$problem->optimization_problem_id.PHP_EOL; |
|
107 | +echo "State: ".OptimizationStates::getName($problem->state)." (".$problem->state.")".PHP_EOL; |
|
108 | 108 | |
109 | -echo "Routes:" . PHP_EOL; |
|
110 | -foreach($problem->routes as $route) |
|
109 | +echo "Routes:".PHP_EOL; |
|
110 | +foreach ($problem->routes as $route) |
|
111 | 111 | { |
112 | - echo "\tID: " . $route->route_id . PHP_EOL; |
|
113 | - echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
|
114 | - echo "\tAddresses:" . PHP_EOL; |
|
112 | + echo "\tID: ".$route->route_id.PHP_EOL; |
|
113 | + echo "\tDistance: ".$route->trip_distance.PHP_EOL; |
|
114 | + echo "\tAddresses:".PHP_EOL; |
|
115 | 115 | |
116 | - foreach($route->addresses as $address) echo "\t\t" . $address->address . PHP_EOL; |
|
116 | + foreach ($route->addresses as $address) echo "\t\t".$address->address.PHP_EOL; |
|
117 | 117 | } |
@@ -113,5 +113,7 @@ |
||
113 | 113 | echo "\tDistance: " . $route->trip_distance . PHP_EOL; |
114 | 114 | echo "\tAddresses:" . PHP_EOL; |
115 | 115 | |
116 | - foreach($route->addresses as $address) echo "\t\t" . $address->address . PHP_EOL; |
|
117 | -} |
|
116 | + foreach($route->addresses as $address) { |
|
117 | + echo "\t\t" . $address->address . PHP_EOL; |
|
118 | + } |
|
119 | + } |
@@ -24,15 +24,15 @@ discard block |
||
24 | 24 | //********************************************************************** |
25 | 25 | // General Route Parameters |
26 | 26 | $parameters = RouteParameters::fromArray([ |
27 | - 'rt' => true, |
|
28 | - 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
29 | - 'route_name' => 'Single Depot, Multiple Driver - 3 Territories IDs '.date('Y-m-d H:i:s', time()), |
|
30 | - 'route_time' => 46800, |
|
31 | - 'distance_unit' => DistanceUnit::MILES, |
|
32 | - 'device_type' => DeviceType::WEB, |
|
33 | - 'optimize' => OptimizationType::DISTANCE, |
|
34 | - 'travel_mode' => TravelMode::DRIVING, |
|
35 | - 'advanced_constraints' => [] |
|
27 | + 'rt' => true, |
|
28 | + 'algorithm_type' => Algorithmtype::ADVANCED_CVRP_TW, |
|
29 | + 'route_name' => 'Single Depot, Multiple Driver - 3 Territories IDs '.date('Y-m-d H:i:s', time()), |
|
30 | + 'route_time' => 46800, |
|
31 | + 'distance_unit' => DistanceUnit::MILES, |
|
32 | + 'device_type' => DeviceType::WEB, |
|
33 | + 'optimize' => OptimizationType::DISTANCE, |
|
34 | + 'travel_mode' => TravelMode::DRIVING, |
|
35 | + 'advanced_constraints' => [] |
|
36 | 36 | ]); |
37 | 37 | |
38 | 38 | //********************************************************************** |
@@ -41,30 +41,30 @@ discard block |
||
41 | 41 | // Time Window Start: 8:00 am EST |
42 | 42 | // Time Window End: 11:00 am EST |
43 | 43 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
44 | - 'max_cargo_volume' => 0.0, |
|
45 | - 'members_count' => 3, |
|
46 | - 'available_time_windows' => [[46800, 57600]], |
|
47 | - 'tags' => ['A34BA30C717D1194FC0230252DF0C45C'] |
|
44 | + 'max_cargo_volume' => 0.0, |
|
45 | + 'members_count' => 3, |
|
46 | + 'available_time_windows' => [[46800, 57600]], |
|
47 | + 'tags' => ['A34BA30C717D1194FC0230252DF0C45C'] |
|
48 | 48 | ]); |
49 | 49 | |
50 | 50 | // Schedule 2 |
51 | 51 | // Time Window Start: 8:00 am EST |
52 | 52 | // Time Window End: 12:00 am EST |
53 | 53 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
54 | - 'max_cargo_volume' => 0.0, |
|
55 | - 'members_count' => 4, |
|
56 | - 'available_time_windows' => [[46800, 61200]], |
|
57 | - 'tags' => ['DA6A8F10313CCFEC843978FC065F235B'] |
|
54 | + 'max_cargo_volume' => 0.0, |
|
55 | + 'members_count' => 4, |
|
56 | + 'available_time_windows' => [[46800, 61200]], |
|
57 | + 'tags' => ['DA6A8F10313CCFEC843978FC065F235B'] |
|
58 | 58 | ]); |
59 | 59 | |
60 | 60 | // Schedule 3 |
61 | 61 | // Time Window Start: 8:00 am EST |
62 | 62 | // Time Window End: 13:00 am EST |
63 | 63 | $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([ |
64 | - 'max_cargo_volume' => 0.0, |
|
65 | - 'members_count' => 3, |
|
66 | - 'available_time_windows' => [[46800, 64800]], |
|
67 | - 'tags' => ['8142ABF2D693336987726ECDB5ED2D6D'] |
|
64 | + 'max_cargo_volume' => 0.0, |
|
65 | + 'members_count' => 3, |
|
66 | + 'available_time_windows' => [[46800, 64800]], |
|
67 | + 'tags' => ['8142ABF2D693336987726ECDB5ED2D6D'] |
|
68 | 68 | ]); |
69 | 69 | |
70 | 70 | //********************************************************************** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $addresses = []; |
74 | 74 | |
75 | 75 | foreach ($json as $address) { |
76 | - $addresses[] = Address::fromArray($address); |
|
76 | + $addresses[] = Address::fromArray($address); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | $optimizationParams = new OptimizationProblemParams(); |
@@ -82,5 +82,5 @@ |
||
82 | 82 | |
83 | 83 | $problem = OptimizationProblem::optimize($optimizationParams); |
84 | 84 | |
85 | -echo "Optimization Problem ID: " . $problem->optimization_problem_id . PHP_EOL; |
|
86 | -echo "State: " . OptimizationStates::getName($problem->state) . " (" . $problem->state . ")" . PHP_EOL; |
|
85 | +echo "Optimization Problem ID: ".$problem->optimization_problem_id.PHP_EOL; |
|
86 | +echo "State: ".OptimizationStates::getName($problem->state)." (".$problem->state.")".PHP_EOL; |
@@ -4,25 +4,25 @@ |
||
4 | 4 | |
5 | 5 | class StatusUpdateType |
6 | 6 | { |
7 | - const PICKUP = 'pickup'; |
|
8 | - const DROPOFF = 'dropoff'; |
|
9 | - const NOANSWER = 'noanswer'; |
|
10 | - const NOTFOUND = 'notfound'; |
|
11 | - const NOTPAID = 'notpaid'; |
|
12 | - const PAID = 'paid'; |
|
13 | - const WRONGDELIVERY = 'wrongdelivery'; |
|
14 | - const WRONGADDRESSRECIPIENT = 'wrongaddressrecipient'; |
|
15 | - const NOTPRESENT = 'notpresent'; |
|
16 | - const PARTS_MISSING = 'parts_missing'; |
|
17 | - const SERVICE_RENDERED = 'service_rendered'; |
|
18 | - const FOLLOW_UP = 'follow_up'; |
|
19 | - const LEFT_INFORMATION = 'left_information'; |
|
20 | - const SPOKE_WITH_DECISION_MAKER = 'spoke_with_decision_maker'; |
|
21 | - const SPOKE_WITH_DECISION_INFLUENCER = 'spoke_with_decision_influencer'; |
|
22 | - const COMPETITIVE_ACCOUNT = 'competitive_account'; |
|
23 | - const SCHEDULED_FOLLOW_UP_MEETING = 'scheduled_follow_up_meeting'; |
|
24 | - const SCHEDULED_LUNCH = 'scheduled_lunch'; |
|
25 | - const SCHEDULED_PRODUCT_DEMO = 'scheduled_product_demo'; |
|
26 | - const SCHEDULED_CLINICAL_DEMO = 'scheduled_clinical_demo'; |
|
27 | - const NO_OPPORTUNITY = 'no_opportunity'; |
|
7 | + const PICKUP = 'pickup'; |
|
8 | + const DROPOFF = 'dropoff'; |
|
9 | + const NOANSWER = 'noanswer'; |
|
10 | + const NOTFOUND = 'notfound'; |
|
11 | + const NOTPAID = 'notpaid'; |
|
12 | + const PAID = 'paid'; |
|
13 | + const WRONGDELIVERY = 'wrongdelivery'; |
|
14 | + const WRONGADDRESSRECIPIENT = 'wrongaddressrecipient'; |
|
15 | + const NOTPRESENT = 'notpresent'; |
|
16 | + const PARTS_MISSING = 'parts_missing'; |
|
17 | + const SERVICE_RENDERED = 'service_rendered'; |
|
18 | + const FOLLOW_UP = 'follow_up'; |
|
19 | + const LEFT_INFORMATION = 'left_information'; |
|
20 | + const SPOKE_WITH_DECISION_MAKER = 'spoke_with_decision_maker'; |
|
21 | + const SPOKE_WITH_DECISION_INFLUENCER = 'spoke_with_decision_influencer'; |
|
22 | + const COMPETITIVE_ACCOUNT = 'competitive_account'; |
|
23 | + const SCHEDULED_FOLLOW_UP_MEETING = 'scheduled_follow_up_meeting'; |
|
24 | + const SCHEDULED_LUNCH = 'scheduled_lunch'; |
|
25 | + const SCHEDULED_PRODUCT_DEMO = 'scheduled_product_demo'; |
|
26 | + const SCHEDULED_CLINICAL_DEMO = 'scheduled_clinical_demo'; |
|
27 | + const NO_OPPORTUNITY = 'no_opportunity'; |
|
28 | 28 | } |
@@ -6,22 +6,22 @@ |
||
6 | 6 | |
7 | 7 | class OptimizationStates |
8 | 8 | { |
9 | - const NEW = 0; |
|
10 | - const INITIAL = 1; |
|
11 | - const MATRIX_PROCESSING = 2; |
|
12 | - const OPTIMIZING = 3; |
|
13 | - const OPTIMIZED = 4; |
|
14 | - const ERROR = 5; |
|
15 | - const COMPUTING_DIRECTIONS = 6; |
|
16 | - const IN_QUEUE = 7; |
|
9 | + const NEW = 0; |
|
10 | + const INITIAL = 1; |
|
11 | + const MATRIX_PROCESSING = 2; |
|
12 | + const OPTIMIZING = 3; |
|
13 | + const OPTIMIZED = 4; |
|
14 | + const ERROR = 5; |
|
15 | + const COMPUTING_DIRECTIONS = 6; |
|
16 | + const IN_QUEUE = 7; |
|
17 | 17 | |
18 | - public static function getName(int $state) : string |
|
19 | - { |
|
20 | - $refl = new ReflectionClass(__CLASS__); |
|
21 | - foreach($refl->getConstants() AS $key => $val) |
|
22 | - { |
|
23 | - if($val == $state) return $key; |
|
24 | - } |
|
25 | - return 'UNKNOWN'; |
|
26 | - } |
|
18 | + public static function getName(int $state) : string |
|
19 | + { |
|
20 | + $refl = new ReflectionClass(__CLASS__); |
|
21 | + foreach($refl->getConstants() AS $key => $val) |
|
22 | + { |
|
23 | + if($val == $state) return $key; |
|
24 | + } |
|
25 | + return 'UNKNOWN'; |
|
26 | + } |
|
27 | 27 | } |
@@ -18,9 +18,9 @@ |
||
18 | 18 | public static function getName(int $state) : string |
19 | 19 | { |
20 | 20 | $refl = new ReflectionClass(__CLASS__); |
21 | - foreach($refl->getConstants() AS $key => $val) |
|
21 | + foreach ($refl->getConstants() AS $key => $val) |
|
22 | 22 | { |
23 | - if($val == $state) return $key; |
|
23 | + if ($val==$state) return $key; |
|
24 | 24 | } |
25 | 25 | return 'UNKNOWN'; |
26 | 26 | } |
@@ -20,7 +20,9 @@ |
||
20 | 20 | $refl = new ReflectionClass(__CLASS__); |
21 | 21 | foreach($refl->getConstants() AS $key => $val) |
22 | 22 | { |
23 | - if($val == $state) return $key; |
|
23 | + if($val == $state) { |
|
24 | + return $key; |
|
25 | + } |
|
24 | 26 | } |
25 | 27 | return 'UNKNOWN'; |
26 | 28 | } |
@@ -7,227 +7,227 @@ |
||
7 | 7 | |
8 | 8 | class Address extends Common |
9 | 9 | { |
10 | - public $route_destination_id; |
|
11 | - public $alias; |
|
12 | - public $member_id; |
|
13 | - public $address; |
|
14 | - public $addressUpdate; |
|
15 | - public $is_depot = false; |
|
16 | - public $lat; |
|
17 | - public $lng; |
|
18 | - public $route_id; |
|
19 | - public $original_route_id; |
|
20 | - public $optimization_problem_id; |
|
21 | - public $sequence_no; |
|
22 | - public $geocoded; |
|
23 | - public $preferred_geocoding; |
|
24 | - public $failed_geocoding; |
|
25 | - public $geocodings = []; |
|
26 | - public $contact_id; |
|
27 | - public $is_visited; |
|
28 | - public $customer_po; |
|
29 | - public $invoice_no; |
|
30 | - public $reference_no; |
|
31 | - public $order_no; |
|
32 | - public $weight; |
|
33 | - public $cost; |
|
34 | - public $revenue; |
|
35 | - public $cube; |
|
36 | - public $pieces; |
|
37 | - public $email; |
|
38 | - public $phone; |
|
39 | - public $tracking_number; |
|
40 | - public $destination_note_count; |
|
41 | - public $drive_time_to_next_destination; |
|
42 | - public $distance_to_next_destination; |
|
43 | - public $generated_time_window_start; |
|
44 | - public $generated_time_window_end; |
|
45 | - public $time_window_start; |
|
46 | - public $time_window_end; |
|
47 | - public $time; |
|
48 | - public $notes; |
|
49 | - public $timestamp_last_visited; |
|
50 | - public $custom_fields = []; |
|
51 | - public $manifest = []; |
|
52 | - |
|
53 | - public $first_name; |
|
54 | - public $last_name; |
|
55 | - public $is_departed; |
|
56 | - public $timestamp_last_departed; |
|
57 | - public $order_id; |
|
58 | - public $priority; |
|
59 | - public $curbside_lat; |
|
60 | - public $curbside_lng; |
|
61 | - public $time_window_start_2; |
|
62 | - public $time_window_end_2; |
|
63 | - |
|
64 | - public $timeframe_violation_state; |
|
65 | - public $timeframe_violation_time; |
|
66 | - public $timeframe_violation_rate; |
|
67 | - public $route_name; |
|
68 | - public $address_stop_type; |
|
69 | - public $visited_lat; |
|
70 | - public $visited_lng; |
|
71 | - public $departed_lat; |
|
72 | - public $departed_lng; |
|
73 | - public $group; |
|
74 | - public $abnormal_traffic_time_to_next_destination; |
|
75 | - public $uncongested_time_to_next_destination; |
|
76 | - public $traffic_time_to_next_destination; |
|
77 | - public $channel_name; |
|
78 | - public $pickup; |
|
79 | - public $dropoff; |
|
80 | - public $joint; |
|
81 | - public $geofence_detected_visited_timestamp; |
|
82 | - public $geofence_detected_departed_timestamp; |
|
83 | - public $geofence_detected_service_time; |
|
84 | - public $geofence_detected_visited_lat; |
|
85 | - public $geofence_detected_visited_lng; |
|
86 | - public $geofence_detected_departed_lat; |
|
87 | - public $geofence_detected_departed_lng; |
|
88 | - public $custom_fields_str_json; |
|
89 | - public $custom_fields_config; |
|
90 | - public $custom_fields_config_str_json; |
|
91 | - public $bundle_count; |
|
92 | - public $bundle_items; |
|
93 | - public $order_inventory; |
|
94 | - public $required_skills; |
|
95 | - public $udu_distance_to_next_destination; |
|
96 | - public $wait_time_to_next_destination; |
|
97 | - public $path_to_next = []; |
|
98 | - public $additional_status; |
|
99 | - public $tags = []; |
|
100 | - |
|
101 | - public function __construct() |
|
102 | - { |
|
103 | - Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
104 | - } |
|
105 | - |
|
106 | - public static function fromArray(array $params) |
|
107 | - { |
|
108 | - $address = new self(); |
|
109 | - |
|
110 | - foreach ($params as $key => $value) { |
|
111 | - if (property_exists($address, $key)) { |
|
112 | - $address->{$key} = $value; |
|
113 | - } else { |
|
114 | - throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key"); |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - return $address; |
|
119 | - } |
|
120 | - |
|
121 | - public static function getAddress($routeId, $addressId) |
|
122 | - { |
|
123 | - $address = Route4Me::makeRequst([ |
|
124 | - 'url' => Endpoint::ADDRESS_V4, |
|
125 | - 'method' => 'GET', |
|
126 | - 'query' => [ |
|
127 | - 'route_id' => $routeId, |
|
128 | - 'route_destination_id' => $addressId, |
|
129 | - ], |
|
130 | - ]); |
|
131 | - |
|
132 | - return self::fromArray($address); |
|
133 | - } |
|
134 | - |
|
135 | - public function update() |
|
136 | - { |
|
137 | - $addressUpdate = Route4Me::makeRequst([ |
|
138 | - 'url' => Endpoint::ADDRESS_V4, |
|
139 | - 'method' => 'PUT', |
|
140 | - 'body' => $this->toArray(), |
|
141 | - 'query' => [ |
|
142 | - 'route_id' => $this->route_id, |
|
143 | - 'route_destination_id' => $this->route_destination_id, |
|
144 | - ], |
|
145 | - ]); |
|
146 | - |
|
147 | - return self::fromArray($addressUpdate); |
|
148 | - } |
|
149 | - |
|
150 | - /* |
|
10 | + public $route_destination_id; |
|
11 | + public $alias; |
|
12 | + public $member_id; |
|
13 | + public $address; |
|
14 | + public $addressUpdate; |
|
15 | + public $is_depot = false; |
|
16 | + public $lat; |
|
17 | + public $lng; |
|
18 | + public $route_id; |
|
19 | + public $original_route_id; |
|
20 | + public $optimization_problem_id; |
|
21 | + public $sequence_no; |
|
22 | + public $geocoded; |
|
23 | + public $preferred_geocoding; |
|
24 | + public $failed_geocoding; |
|
25 | + public $geocodings = []; |
|
26 | + public $contact_id; |
|
27 | + public $is_visited; |
|
28 | + public $customer_po; |
|
29 | + public $invoice_no; |
|
30 | + public $reference_no; |
|
31 | + public $order_no; |
|
32 | + public $weight; |
|
33 | + public $cost; |
|
34 | + public $revenue; |
|
35 | + public $cube; |
|
36 | + public $pieces; |
|
37 | + public $email; |
|
38 | + public $phone; |
|
39 | + public $tracking_number; |
|
40 | + public $destination_note_count; |
|
41 | + public $drive_time_to_next_destination; |
|
42 | + public $distance_to_next_destination; |
|
43 | + public $generated_time_window_start; |
|
44 | + public $generated_time_window_end; |
|
45 | + public $time_window_start; |
|
46 | + public $time_window_end; |
|
47 | + public $time; |
|
48 | + public $notes; |
|
49 | + public $timestamp_last_visited; |
|
50 | + public $custom_fields = []; |
|
51 | + public $manifest = []; |
|
52 | + |
|
53 | + public $first_name; |
|
54 | + public $last_name; |
|
55 | + public $is_departed; |
|
56 | + public $timestamp_last_departed; |
|
57 | + public $order_id; |
|
58 | + public $priority; |
|
59 | + public $curbside_lat; |
|
60 | + public $curbside_lng; |
|
61 | + public $time_window_start_2; |
|
62 | + public $time_window_end_2; |
|
63 | + |
|
64 | + public $timeframe_violation_state; |
|
65 | + public $timeframe_violation_time; |
|
66 | + public $timeframe_violation_rate; |
|
67 | + public $route_name; |
|
68 | + public $address_stop_type; |
|
69 | + public $visited_lat; |
|
70 | + public $visited_lng; |
|
71 | + public $departed_lat; |
|
72 | + public $departed_lng; |
|
73 | + public $group; |
|
74 | + public $abnormal_traffic_time_to_next_destination; |
|
75 | + public $uncongested_time_to_next_destination; |
|
76 | + public $traffic_time_to_next_destination; |
|
77 | + public $channel_name; |
|
78 | + public $pickup; |
|
79 | + public $dropoff; |
|
80 | + public $joint; |
|
81 | + public $geofence_detected_visited_timestamp; |
|
82 | + public $geofence_detected_departed_timestamp; |
|
83 | + public $geofence_detected_service_time; |
|
84 | + public $geofence_detected_visited_lat; |
|
85 | + public $geofence_detected_visited_lng; |
|
86 | + public $geofence_detected_departed_lat; |
|
87 | + public $geofence_detected_departed_lng; |
|
88 | + public $custom_fields_str_json; |
|
89 | + public $custom_fields_config; |
|
90 | + public $custom_fields_config_str_json; |
|
91 | + public $bundle_count; |
|
92 | + public $bundle_items; |
|
93 | + public $order_inventory; |
|
94 | + public $required_skills; |
|
95 | + public $udu_distance_to_next_destination; |
|
96 | + public $wait_time_to_next_destination; |
|
97 | + public $path_to_next = []; |
|
98 | + public $additional_status; |
|
99 | + public $tags = []; |
|
100 | + |
|
101 | + public function __construct() |
|
102 | + { |
|
103 | + Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
104 | + } |
|
105 | + |
|
106 | + public static function fromArray(array $params) |
|
107 | + { |
|
108 | + $address = new self(); |
|
109 | + |
|
110 | + foreach ($params as $key => $value) { |
|
111 | + if (property_exists($address, $key)) { |
|
112 | + $address->{$key} = $value; |
|
113 | + } else { |
|
114 | + throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key"); |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + return $address; |
|
119 | + } |
|
120 | + |
|
121 | + public static function getAddress($routeId, $addressId) |
|
122 | + { |
|
123 | + $address = Route4Me::makeRequst([ |
|
124 | + 'url' => Endpoint::ADDRESS_V4, |
|
125 | + 'method' => 'GET', |
|
126 | + 'query' => [ |
|
127 | + 'route_id' => $routeId, |
|
128 | + 'route_destination_id' => $addressId, |
|
129 | + ], |
|
130 | + ]); |
|
131 | + |
|
132 | + return self::fromArray($address); |
|
133 | + } |
|
134 | + |
|
135 | + public function update() |
|
136 | + { |
|
137 | + $addressUpdate = Route4Me::makeRequst([ |
|
138 | + 'url' => Endpoint::ADDRESS_V4, |
|
139 | + 'method' => 'PUT', |
|
140 | + 'body' => $this->toArray(), |
|
141 | + 'query' => [ |
|
142 | + 'route_id' => $this->route_id, |
|
143 | + 'route_destination_id' => $this->route_destination_id, |
|
144 | + ], |
|
145 | + ]); |
|
146 | + |
|
147 | + return self::fromArray($addressUpdate); |
|
148 | + } |
|
149 | + |
|
150 | + /* |
|
151 | 151 | * Marks an address as marked as visited/as departed |
152 | 152 | * depending on which parameter is specified: 'is_visited' or 'is_departed'. |
153 | 153 | */ |
154 | - public function markAddress($params) |
|
155 | - { |
|
156 | - $allQueryFields = ['route_id', 'route_destination_id']; |
|
157 | - $allBodyFields = ['is_visited', 'is_departed']; |
|
158 | - |
|
159 | - $result = Route4Me::makeRequst([ |
|
160 | - 'url' => Endpoint::ADDRESS_V4, |
|
161 | - 'method' => 'PUT', |
|
162 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
163 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
164 | - ]); |
|
165 | - |
|
166 | - return $result; |
|
167 | - } |
|
168 | - |
|
169 | - /* |
|
154 | + public function markAddress($params) |
|
155 | + { |
|
156 | + $allQueryFields = ['route_id', 'route_destination_id']; |
|
157 | + $allBodyFields = ['is_visited', 'is_departed']; |
|
158 | + |
|
159 | + $result = Route4Me::makeRequst([ |
|
160 | + 'url' => Endpoint::ADDRESS_V4, |
|
161 | + 'method' => 'PUT', |
|
162 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
163 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
164 | + ]); |
|
165 | + |
|
166 | + return $result; |
|
167 | + } |
|
168 | + |
|
169 | + /* |
|
170 | 170 | * Marks an address as departed. |
171 | 171 | */ |
172 | - public function markAsDeparted($params) |
|
173 | - { |
|
174 | - $allQueryFields = ['route_id', 'address_id', 'is_departed', 'member_id']; |
|
172 | + public function markAsDeparted($params) |
|
173 | + { |
|
174 | + $allQueryFields = ['route_id', 'address_id', 'is_departed', 'member_id']; |
|
175 | 175 | |
176 | - $address = Route4Me::makeRequst([ |
|
177 | - 'url' => Endpoint::MARK_ADDRESS_DEPARTED, |
|
178 | - 'method' => 'PUT', |
|
179 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
180 | - ]); |
|
176 | + $address = Route4Me::makeRequst([ |
|
177 | + 'url' => Endpoint::MARK_ADDRESS_DEPARTED, |
|
178 | + 'method' => 'PUT', |
|
179 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
180 | + ]); |
|
181 | 181 | |
182 | - return $address; |
|
183 | - } |
|
182 | + return $address; |
|
183 | + } |
|
184 | 184 | |
185 | - /* |
|
185 | + /* |
|
186 | 186 | * Marks an address as visited. |
187 | 187 | */ |
188 | - public function markAsVisited($params) |
|
189 | - { |
|
190 | - $allQueryFields = ['route_id', 'address_id', 'is_visited', 'member_id']; |
|
191 | - |
|
192 | - $address = Route4Me::makeRequst([ |
|
193 | - 'url' => Endpoint::UPDATE_ADDRESS_VISITED, |
|
194 | - 'method' => 'PUT', |
|
195 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
196 | - ]); |
|
197 | - |
|
198 | - return $address; |
|
199 | - } |
|
200 | - |
|
201 | - public function deleteAddress() |
|
202 | - { |
|
203 | - $address = Route4Me::makeRequst([ |
|
204 | - 'url' => Endpoint::ADDRESS_V4, |
|
205 | - 'method' => 'DELETE', |
|
206 | - 'query' => [ |
|
207 | - 'route_id' => $this->route_id, |
|
208 | - 'route_destination_id' => $this->route_destination_id, |
|
209 | - ], |
|
210 | - ]); |
|
211 | - |
|
212 | - return (bool) $address['deleted']; |
|
213 | - } |
|
214 | - |
|
215 | - public function moveDestinationToRoute($params) |
|
216 | - { |
|
217 | - $allBodyFields = ['to_route_id', 'route_destination_id', 'after_destination_id']; |
|
218 | - |
|
219 | - $result = Route4Me::makeRequst([ |
|
220 | - 'url' => Endpoint::MOVE_ROUTE_DESTINATION, |
|
221 | - 'method' => 'POST', |
|
222 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
223 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
224 | - ]); |
|
225 | - |
|
226 | - return $result; |
|
227 | - } |
|
228 | - |
|
229 | - public function getAddressId() |
|
230 | - { |
|
231 | - return $this->route_destination_id; |
|
232 | - } |
|
188 | + public function markAsVisited($params) |
|
189 | + { |
|
190 | + $allQueryFields = ['route_id', 'address_id', 'is_visited', 'member_id']; |
|
191 | + |
|
192 | + $address = Route4Me::makeRequst([ |
|
193 | + 'url' => Endpoint::UPDATE_ADDRESS_VISITED, |
|
194 | + 'method' => 'PUT', |
|
195 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
196 | + ]); |
|
197 | + |
|
198 | + return $address; |
|
199 | + } |
|
200 | + |
|
201 | + public function deleteAddress() |
|
202 | + { |
|
203 | + $address = Route4Me::makeRequst([ |
|
204 | + 'url' => Endpoint::ADDRESS_V4, |
|
205 | + 'method' => 'DELETE', |
|
206 | + 'query' => [ |
|
207 | + 'route_id' => $this->route_id, |
|
208 | + 'route_destination_id' => $this->route_destination_id, |
|
209 | + ], |
|
210 | + ]); |
|
211 | + |
|
212 | + return (bool) $address['deleted']; |
|
213 | + } |
|
214 | + |
|
215 | + public function moveDestinationToRoute($params) |
|
216 | + { |
|
217 | + $allBodyFields = ['to_route_id', 'route_destination_id', 'after_destination_id']; |
|
218 | + |
|
219 | + $result = Route4Me::makeRequst([ |
|
220 | + 'url' => Endpoint::MOVE_ROUTE_DESTINATION, |
|
221 | + 'method' => 'POST', |
|
222 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
223 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
224 | + ]); |
|
225 | + |
|
226 | + return $result; |
|
227 | + } |
|
228 | + |
|
229 | + public function getAddressId() |
|
230 | + { |
|
231 | + return $this->route_destination_id; |
|
232 | + } |
|
233 | 233 | } |