@@ -44,21 +44,21 @@ discard block |
||
44 | 44 | $locationsFieldsMapping['monthly_nth_what'] = 17; |
45 | 45 | |
46 | 46 | if (($handle = fopen("$source_file", "r"))!==FALSE) { |
47 | - $oAbook = new AddressBookLocation(); |
|
47 | + $oAbook = new AddressBookLocation(); |
|
48 | 48 | |
49 | - $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); |
|
49 | + $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping); |
|
50 | 50 | |
51 | - echo "Errors: <br><br>"; |
|
51 | + echo "Errors: <br><br>"; |
|
52 | 52 | |
53 | - foreach ($results['fail'] as $evalue) { |
|
54 | - echo $evalue."<br>"; |
|
55 | - } |
|
53 | + foreach ($results['fail'] as $evalue) { |
|
54 | + echo $evalue."<br>"; |
|
55 | + } |
|
56 | 56 | |
57 | - echo "Successes: <br><br>"; |
|
57 | + echo "Successes: <br><br>"; |
|
58 | 58 | |
59 | - foreach ($results['success'] as $svalue) { |
|
60 | - echo $svalue."<br>"; |
|
61 | - } |
|
59 | + foreach ($results['success'] as $svalue) { |
|
60 | + echo $svalue."<br>"; |
|
61 | + } |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /* Add orders with schedules from a CSV file */ |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | $ordersFieldsMapping['day_scheduled_for_YYMMDD'] = 8; |
79 | 79 | |
80 | 80 | if (($handle = fopen("$orders_file", "r"))!==FALSE) { |
81 | - $order = new Order(); |
|
82 | - $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping); |
|
81 | + $order = new Order(); |
|
82 | + $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping); |
|
83 | 83 | |
84 | - echo "Errors: <br><br>"; |
|
84 | + echo "Errors: <br><br>"; |
|
85 | 85 | |
86 | - foreach ($results['fail'] as $evalue) { |
|
87 | - echo $evalue."<br>"; |
|
88 | - } |
|
86 | + foreach ($results['fail'] as $evalue) { |
|
87 | + echo $evalue."<br>"; |
|
88 | + } |
|
89 | 89 | |
90 | - echo "Successes: <br><br>"; |
|
90 | + echo "Successes: <br><br>"; |
|
91 | 91 | |
92 | - foreach ($results['success'] as $svalue) { |
|
93 | - echo $svalue."<br>"; |
|
94 | - } |
|
92 | + foreach ($results['success'] as $svalue) { |
|
93 | + echo $svalue."<br>"; |
|
94 | + } |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /* Get Hybrid Optimization */ |
@@ -100,63 +100,63 @@ discard block |
||
100 | 100 | $sched_date = date("Y-m-d", $ep); |
101 | 101 | |
102 | 102 | $hybridParams = array( |
103 | - "target_date_string" => $sched_date, |
|
104 | - "timezone_offset_minutes" => 480 |
|
103 | + "target_date_string" => $sched_date, |
|
104 | + "timezone_offset_minutes" => 480 |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 | $optimization = new OptimizationProblem(); |
108 | 108 | $hybridOptimization = $optimization->getHybridOptimization($hybridParams); |
109 | 109 | |
110 | 110 | if ($hybridOptimization!=null) { |
111 | - if (isset($hybridOptimization['optimization_problem_id'])) { |
|
112 | - $optid = $hybridOptimization['optimization_problem_id']; |
|
111 | + if (isset($hybridOptimization['optimization_problem_id'])) { |
|
112 | + $optid = $hybridOptimization['optimization_problem_id']; |
|
113 | 113 | |
114 | - echo "Hibrid optimization with optimization_problem_id = $optid <br><br>"; |
|
114 | + echo "Hibrid optimization with optimization_problem_id = $optid <br><br>"; |
|
115 | 115 | |
116 | - /* Add depots to the Hybrid Optimization */ |
|
117 | - $depotfile = "depots.csv"; |
|
116 | + /* Add depots to the Hybrid Optimization */ |
|
117 | + $depotfile = "depots.csv"; |
|
118 | 118 | |
119 | - if (($handle = fopen("$depotfile", "r"))!==FALSE) { |
|
120 | - $columns = fgetcsv($handle, $max_line_length, $delimiter); |
|
119 | + if (($handle = fopen("$depotfile", "r"))!==FALSE) { |
|
120 | + $columns = fgetcsv($handle, $max_line_length, $delimiter); |
|
121 | 121 | |
122 | - if (empty($columns)) { |
|
123 | - $error['message'] = 'Empty'; |
|
124 | - return ($error); |
|
125 | - } |
|
122 | + if (empty($columns)) { |
|
123 | + $error['message'] = 'Empty'; |
|
124 | + return ($error); |
|
125 | + } |
|
126 | 126 | |
127 | - $depotsParams = array( |
|
128 | - 'optimization_problem_id' => $optid, |
|
129 | - 'delete_old_depots' => true, |
|
130 | - ); |
|
127 | + $depotsParams = array( |
|
128 | + 'optimization_problem_id' => $optid, |
|
129 | + 'delete_old_depots' => true, |
|
130 | + ); |
|
131 | 131 | |
132 | - $iRow = 1; |
|
133 | - $depotAddresses = array(); |
|
132 | + $iRow = 1; |
|
133 | + $depotAddresses = array(); |
|
134 | 134 | |
135 | - while (($rows = fgetcsv($handle, $max_line_length, $delimiter))!==false) { |
|
136 | - if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) { |
|
137 | - $depotAddress['lat'] = $rows[0]; |
|
138 | - $depotAddress['lng'] = $rows[1]; |
|
139 | - $depotAddress['address'] = $rows[3]; |
|
140 | - array_push($depotAddresses, $depotAddress); |
|
141 | - } |
|
142 | - } |
|
135 | + while (($rows = fgetcsv($handle, $max_line_length, $delimiter))!==false) { |
|
136 | + if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) { |
|
137 | + $depotAddress['lat'] = $rows[0]; |
|
138 | + $depotAddress['lng'] = $rows[1]; |
|
139 | + $depotAddress['address'] = $rows[3]; |
|
140 | + array_push($depotAddresses, $depotAddress); |
|
141 | + } |
|
142 | + } |
|
143 | 143 | |
144 | - $depotsParams['new_depots'] = $depotAddresses; |
|
144 | + $depotsParams['new_depots'] = $depotAddresses; |
|
145 | 145 | |
146 | - $optProblem = new OptimizationProblem(); |
|
146 | + $optProblem = new OptimizationProblem(); |
|
147 | 147 | |
148 | - $resultDepots = $optProblem->addDepotsToHybrid($depotsParams); |
|
148 | + $resultDepots = $optProblem->addDepotsToHybrid($depotsParams); |
|
149 | 149 | |
150 | - /* Reoptimize hybrid optimization */ |
|
150 | + /* Reoptimize hybrid optimization */ |
|
151 | 151 | |
152 | - if ($resultDepots!=null) { |
|
153 | - $problemParams = array( |
|
154 | - 'optimization_problem_id' => $optid |
|
155 | - ); |
|
156 | - $problem = OptimizationProblem::reoptimize($problemParams); |
|
152 | + if ($resultDepots!=null) { |
|
153 | + $problemParams = array( |
|
154 | + 'optimization_problem_id' => $optid |
|
155 | + ); |
|
156 | + $problem = OptimizationProblem::reoptimize($problemParams); |
|
157 | 157 | |
158 | - Route4Me::simplePrint($problem); |
|
159 | - } |
|
160 | - } |
|
161 | - } |
|
158 | + Route4Me::simplePrint($problem); |
|
159 | + } |
|
160 | + } |
|
161 | + } |
|
162 | 162 | } |