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()); }
/** * @param Solver $solver * @return Solver * @throws OptimiseException */ private function setAllMeetingsInfo(Solver $solver) { /** * @var $meetings \Illuminate\Support\Collection */ $meetings = collect($this->company->getMeetingsTimeSlots($this->startTime, $this->endTime)); if ($meetings->count() == 0) { throw (new OptimiseException("No meetings for this week"))->withEmpty(true); } $timeslots = $meetings->groupBy('id')->map(function ($item) { //convert timeslots return $this->durationConverter($this->timeSlotsConverter($item)); }); return $solver->setMeetings($timeslots->keys()->toArray())->setMeetingsDuration($meetings->pluck('duration', 'id')->toArray())->setMeetingsAvailability(self::getAvailabilityArray($timeslots, $this->time_slots, $solver->getMeetings())); }