protected function canLoad($pointSequence) { // $this->_checks++; $canLoad = App::getSingleton('\\Litvinenko\\Combinatorics\\Pdp\\Helper')->canLoad($pointSequence, $this->getPythonFile(), $this->getLoadArea(), $this->getWeightCapacity(), $this->getPoints()); if (!$canLoad) { App::dispatchEvent('cant_load', ['point_sequence' => $pointSequence]); } return $canLoad; // return ($this->getCheckLoading()) ? App::getSingleton('\Litvinenko\Combinatorics\Pdp\Helper')->canLoad($pointSequence, $this->getCheckLoadingCommandPrefix(), $this->getLoadArea(), $this->getWeightCapacity()) : true; }
protected function _generate($object) { if ($this->objectIsComplete($object)) { $this->_data['generatedObjects'][] = $object; } else { foreach ($this->generateNextObjects($object) as $nextObject) { if ($this->getLogSteps()) { App::dispatchEvent("new_path_generated", ['tuple' => $nextObject]); } $this->_generate($nextObject); } } }
protected function _getSuccessiveElements($tuple) { $result = []; // we assume that tuple contain \Litvinenko\Combinatorics\Pdp\Point objects $currentPath = $this->_getCurrentPath($tuple); foreach ($this->getGeneratingElements() as $element) { $point = $element['value']; // if current path does not contain this point if (!$currentPath->doesContain($point)) { // add pickup point if whether vehicle can take box at this point if ($point->isPickup() && $currentPath->getCurrentWeight() + $point->getBoxWeight() <= $this->getWeightCapacity() && $currentPath->getCurrentVolume() + $point->getBoxVolume() <= Helper::getLoadAreaVolume($this->getLoadArea()) || $point->isDelivery() && $currentPath->doesContain($point->getPairId())) { $resultContainer = new \stdClass(); // event observers will write info to this object App::dispatchEvent('point_add_before', ['point' => $point, 'point_sequence' => $tuple, 'result_container' => $resultContainer]); if (!isset($resultContainer->result) || isset($resultContainer->result) && $resultContainer->result !== false) { $result[] = $element; } } } } return $result; }
protected function _logEvent($eventName, $data) { App::dispatchEvent("branch_bound_{$eventName}", $data); }