public function getSolution() { // $this->validate(); // $this->getHelper()->validateObjects($this->getPoints()); // $this->_checks=0; $generator = new Generator(['tuple_length' => Point::getPointCount($this->getPoints()), 'generating_elements' => Helper::getGeneratorDataFromPoints($this->getPoints()), 'weight_capacity' => $this->getWeightCapacity(), 'load_area' => $this->getLoadArea(), 'precise' => $this->getPrecise(), 'metrics' => $this->getEvaluator()->getMetrics(), 'initial_object' => Helper::getGeneratorDataFromPoints([$this->getDepot()]), 'log_steps' => true]); $pointSequences = Helper::getPointSequencesFromGeneratorData($generator->generateAll()); $bestPointSequence = null; foreach ($pointSequences as &$pointSequence) { $pointSequence[] = $this->getDepot(); $currentCost = $this->_getCost($pointSequence); if (is_null($bestPointSequence) || $this->_compareCosts($currentCost, $bestCost) === 1) { // if needed, check 3D constraints and skip path if it's incorrect if ($this->getData('check_final_loading')) { if (!$this->canLoad($pointSequence)) { continue; } } $bestPointSequence = $pointSequence; $bestCost = $currentCost; } } $this->setGeneratedPointSequences($pointSequences); // echo $this->_checks."\n"; return new Path(['points' => $bestPointSequence]); }
protected function _generateNestedPointSequences($node) { $pointSequence = $node->getContent()->getPoints(); $generator = new Generator(['tuple_length' => Point::getPointCount($this->getPoints()), 'generating_elements' => Helper::getGeneratorDataFromPoints($this->getPoints()), 'current_path' => $node->getContent(), 'weight_capacity' => $this->getWeightCapacity(), 'load_area' => $this->getLoadArea()]); // $generator->validate(); $points = Helper::getGeneratorDataFromPoints($pointSequence); $result = Helper::getPointSequencesFromGeneratorData($generator->generateNextObjects($points)); if ($result) { // hack: if all PDP points except of depot are present, add depot $nodeHasAllPointsExceptOfDepot = Helper::pointSequenceIncludesAllPickupsAndDeliveries(reset($result), $this->getPoints()); if ($nodeHasAllPointsExceptOfDepot) { foreach ($result as &$resultPointSequence) { $resultPointSequence = array_merge($resultPointSequence, [$this->getDepot()]); } } } return $result; }