Exemplo n.º 1
0
 public function testSimpleModel()
 {
     if (!$this->doConsole()) {
         return;
     }
     $solver = new Solver(new Schedule(), \App::getInstance());
     $solver->setTimeSlots(4);
     $solver->setMaxTimeSlots(4);
     $solver->setUsers([1, 2, 3]);
     $solver->setMeetings([1, 2]);
     $solver->setMeetingsDuration([1 => 1, 3]);
     $solver->setMeetingsAvailability([1 => [1 => 1, 0, 0, 0], [1 => 1, 1, 1, 0]]);
     $solver->setUsersAvailability([1 => [1 => 1, 1, 0, 0], [1 => 1, 1, 1, 0], [1 => 1, 1, 1, 0]]);
     $solver->setUsersMeetings([1 => [1 => 1, 0], [1 => 1, 1], [1 => 1, 1]]);
     $solver->solve();
     $this->assertEquals([1 => [1 => 1, 0], [1 => 0, 1], [1 => 0, 1]], $solver->getXResults());
     $this->assertEquals([1 => [1 => 1, 0, 0, 0], [1 => 1, 0, 0, 0]], $solver->getYResults());
 }
Exemplo n.º 2
0
 /**
  * @param Solver $solver
  */
 private function saveEmployeesMeetings(Solver $solver)
 {
     $employeesMeetings = $solver->getXResults();
     foreach ($employeesMeetings as $eId => $employeeMeetings) {
         $employee = \plunner\Employee::findOrFail($eId);
         $employeeMeetings = collect($employeeMeetings);
         $employeeMeetings = $employeeMeetings->filter(function ($item) {
             return $item == 1;
         });
         $employee->meetings()->attach($employeeMeetings->keys()->toArray());
     }
 }