diff --git a/src/Controller/AnalyticsController.php b/src/Controller/AnalyticsController.php index 6efd2eae..ccd654ae 100644 --- a/src/Controller/AnalyticsController.php +++ b/src/Controller/AnalyticsController.php @@ -46,7 +46,7 @@ class AnalyticsController extends Controller ['Sun - Fri', 6, 0, 1, 2, 3, 4], // Sun - Fri ]; - protected $hour_shifts = [ + //protected $hour_shifts = [ /* ['00:00 - 09:00', 0, 1, 2, 3, 4, 5, 6, 7, 8], ['01:00 - 10:00', 1, 2, 3, 4, 5, 6, 7, 8, 9], @@ -56,8 +56,8 @@ class AnalyticsController extends Controller ['05:00 - 14:00', 5, 6, 7, 8, 9, 10, 11, 12, 13], ['06:00 - 15:00', 6, 7, 8, 9, 10, 11, 12, 13, 14], */ - ['07:00 - 16:00', 7, 8, 9, 10, 11, 12, 13, 14, 15], - ['08:00 - 17:00', 8, 9, 10, 11, 12, 13, 14, 15, 16], + //['07:00 - 16:00', 7, 8, 9, 10, 11, 12, 13, 14, 15], + //['08:00 - 17:00', 8, 9, 10, 11, 12, 13, 14, 15, 16], /* ['09:00 - 18:00', 9, 10, 11, 12, 13, 14, 15, 16, 17], ['10:00 - 19:00', 10, 11, 12, 13, 14, 15, 16, 17, 18], @@ -75,7 +75,7 @@ class AnalyticsController extends Controller ['22:00 - 07:00', 22, 23, 0, 1, 2, 3, 4, 5, 6], ['23:00 - 08:00', 23, 0, 1, 2, 3, 4, 5, 6, 7], */ - ]; + //]; /** * @Menu(selected="analytics_forecast") @@ -123,8 +123,9 @@ class AnalyticsController extends Controller $shift = $req->request->get('shift_schedule'); // TODO: populate the hour_shift array, depending on the shift selected - $hour_shift = $this->populateHourShift($shift); + $hour_shifts = $this->populateHourShift($shift); + error_log(print_r($hour_shifts, true)); // error_log(print_r($hub_list, true)); // $hub_list = [ 6, 4, 36, 7, 8, 126, 127, 18, 12, 9, 60, 10, 21, 135 ]; @@ -176,7 +177,7 @@ class AnalyticsController extends Controller // error_log(print_r($scheduler_data, true)); // run scheduler - $sched_res = $this->runScheduler($scheduler_data); + $sched_res = $this->runScheduler($scheduler_data, $hour_shifts, $shift); // tally total JOs for the month foreach ($scheduler_data as $sday_data) @@ -251,7 +252,7 @@ class AnalyticsController extends Controller return $day_data; } - protected function runScheduler($scheduler_data) + protected function runScheduler($scheduler_data, $hour_shifts, $shift) { // run python script to solve scheduling for riders @@ -266,13 +267,18 @@ class AnalyticsController extends Controller foreach ($scheduler_data as $weekday_data) $args[] = implode('-', $weekday_data); - // error_log(print_r($args, true)); + // add shift + $args[] = $shift; + + //error_log(print_r($args, true)); error_log('running...' . $sched_script); $proc = new Process($args); $proc->run(); + //error_log('getErrorOutput() ' . $proc->getErrorOutput()); + if (!$proc->isSuccessful()) error_log('SCHEDULER DID NOT RUN PROPERLY'); @@ -311,7 +317,7 @@ class AnalyticsController extends Controller $total_riders += $rider_count; - $label = $this->day_shifts[$day_shift_index][0] . ' ' . $this->hour_shifts[$hour_shift_index][0]; + $label = $this->day_shifts[$day_shift_index][0] . ' ' . $hour_shifts[$hour_shift_index][0]; $shifts[] = [ 'label' => $label, @@ -322,8 +328,8 @@ class AnalyticsController extends Controller $rider_hours = []; for ($i = 0; $i < 24; $i++) $rider_hours[$i] = 0; - for ($i = 1; $i < count($this->hour_shifts[$hour_shift_index]); $i++) - $rider_hours[$this->hour_shifts[$hour_shift_index][$i]] = 1; + for ($i = 1; $i < count($hour_shifts[$hour_shift_index]); $i++) + $rider_hours[$hour_shifts[$hour_shift_index][$i]] = 1; // error_log('allocating ' . $rider_count . ' for ' . $label); diff --git a/utils/schedule_solver/solver.py b/utils/schedule_solver/solver.py index da4f960e..98a87974 100644 --- a/utils/schedule_solver/solver.py +++ b/utils/schedule_solver/solver.py @@ -45,32 +45,38 @@ def main(): for hour_index in range(0, len(hours)): req_hours[day_index][hour_index] = int(hours_data[hour_index]) - # all hour shifts available - hour_shifts = [ - #['00 - 09', 0, 1, 2, 3, 4, 5, 6, 7, 8], - #['01 - 10', 1, 2, 3, 4, 5, 6, 7, 8, 9], - #['02 - 11', 2, 3, 4, 5, 6, 7, 8, 9, 10], - #['03 - 12', 3, 4, 5, 6, 7, 8, 9, 10, 11], - #['04 - 13', 4, 5, 6, 7, 8, 9, 10, 11, 12], - #['05 - 14', 5, 6, 7, 8, 9, 10, 11, 12, 13], - #['06 - 15', 6, 7, 8, 9, 10, 11, 12, 13, 14], - ['07 - 16', 7, 8, 9, 10, 11, 12, 13, 14, 15], - ['08 - 17', 8, 9, 10, 11, 12, 13, 14, 15, 16]] - #['09 - 18', 9, 10, 11, 12, 13, 14, 15, 16, 17], - #['10 - 19', 10, 11, 12, 13, 14, 15, 16, 17, 18], - #['11 - 20', 11, 12, 13, 14, 15, 16, 17, 18, 19], - #['12 - 21', 12, 13, 14, 15, 16, 17, 18, 19, 20], - #['13 - 22', 13, 14, 15, 16, 17, 18, 19, 20, 21], - #['14 - 23', 14, 15, 16, 17, 18, 19, 20, 21, 22], - #['15 - 00', 15, 16, 17, 18, 19, 20, 21, 22, 23], - #['16 - 01', 16, 17, 18, 19, 20, 21, 22, 23, 0], - #['17 - 02', 17, 18, 19, 20, 21, 22, 23, 0, 1], - #['18 - 03', 18, 19, 20, 21, 22, 23, 0, 1, 2], - #['19 - 04', 19, 20, 21, 22, 23, 0, 1, 2, 3], - #['20 - 05', 20, 21, 22, 23, 0, 1, 2, 3, 4], - #['21 - 06', 21, 22, 23, 0, 1, 2, 3, 4, 5], - #['22 - 07', 22, 23, 0, 1, 2, 3, 4, 5, 6], - #['23 - 08', 23, 0, 1, 2, 3, 4, 5, 6, 7]] + shift = sys.argv[8] + hour_shifts = [] + if shift == "24_7": + hour_shifts = [ + ['00 - 09', 0, 1, 2, 3, 4, 5, 6, 7, 8], + ['01 - 10', 1, 2, 3, 4, 5, 6, 7, 8, 9], + ['02 - 11', 2, 3, 4, 5, 6, 7, 8, 9, 10], + ['03 - 12', 3, 4, 5, 6, 7, 8, 9, 10, 11], + ['04 - 13', 4, 5, 6, 7, 8, 9, 10, 11, 12], + ['05 - 14', 5, 6, 7, 8, 9, 10, 11, 12, 13], + ['06 - 15', 6, 7, 8, 9, 10, 11, 12, 13, 14], + ['07 - 16', 7, 8, 9, 10, 11, 12, 13, 14, 15], + ['08 - 17', 8, 9, 10, 11, 12, 13, 14, 15, 16], + ['09 - 18', 9, 10, 11, 12, 13, 14, 15, 16, 17], + ['10 - 19', 10, 11, 12, 13, 14, 15, 16, 17, 18], + ['11 - 20', 11, 12, 13, 14, 15, 16, 17, 18, 19], + ['12 - 21', 12, 13, 14, 15, 16, 17, 18, 19, 20], + ['13 - 22', 13, 14, 15, 16, 17, 18, 19, 20, 21], + ['14 - 23', 14, 15, 16, 17, 18, 19, 20, 21, 22], + ['15 - 00', 15, 16, 17, 18, 19, 20, 21, 22, 23], + ['16 - 01', 16, 17, 18, 19, 20, 21, 22, 23, 0], + ['17 - 02', 17, 18, 19, 20, 21, 22, 23, 0, 1], + ['18 - 03', 18, 19, 20, 21, 22, 23, 0, 1, 2], + ['19 - 04', 19, 20, 21, 22, 23, 0, 1, 2, 3], + ['20 - 05', 20, 21, 22, 23, 0, 1, 2, 3, 4], + ['21 - 06', 21, 22, 23, 0, 1, 2, 3, 4, 5], + ['22 - 07', 22, 23, 0, 1, 2, 3, 4, 5, 6], + ['23 - 08', 23, 0, 1, 2, 3, 4, 5, 6, 7]] + if shift == "8AM_5PM": + hour_shifts = [ + ['07 - 16', 7, 8, 9, 10, 11, 12, 13, 14, 15], + ['08 - 17', 8, 9, 10, 11, 12, 13, 14, 15, 16]] # all possible days riders come in day_shifts = [