Esempio n. 1
0
 public static function getReadableStepInfo($stepInfo, $stepNo = '?')
 {
     $result = '';
     if ($stepInfo) {
         $result .= "\n\n -------------- Step " . $stepNo . "-------------- \n\n";
         $result .= "\nactive nodes at the begin: \n";
         foreach ($stepInfo['active_nodes_at_the_begin'] as $node) {
             $result .= IO::getPathAsText($node->getContent()) . ' with bound ' . $node->getOptimisticBound() . "\n";
         }
         $result .= "\nbest full node at the begin: " . IO::getPathAsText($stepInfo['best_full_node_at_the_begin']->getContent()) . ' with bound ' . $stepInfo['best_full_node_at_the_begin']->getOptimisticBound() . "\n";
         $result .= "\nbranching node: " . IO::getPathAsText($stepInfo['branching_node']->getContent()) . ' with bound ' . $stepInfo['branching_node']->getOptimisticBound() . "\n";
         $result .= "\ngenerated children: \n";
         foreach ($stepInfo['children_generated'] as $child) {
             $result .= IO::getPathAsText($child->getContent()) . ' with bound ' . $child->getOptimisticBound() . "\n";
         }
         if (isset($stepInfo['paths_could_not_be_loaded'])) {
             $result .= "\nfull paths could not be loaded: \n";
             foreach ($stepInfo['paths_could_not_be_loaded'] as $pointSequence) {
                 $result .= IO::getPathAsText($pointSequence) . "\n";
             }
         }
         $result .= "\nbest full node at the end: " . IO::getPathAsText($stepInfo['best_full_node_at_the_end']->getContent()) . ' with bound ' . $stepInfo['best_full_node_at_the_end']->getOptimisticBound() . "\n";
         $result .= "\nactive nodes at the end: \n";
         foreach ($stepInfo['active_nodes_at_the_end'] as $node) {
             $result .= IO::getPathAsText($node->getContent()) . ' with bound ' . $node->getOptimisticBound() . "\n";
         }
     }
     $result .= "\n\n -------------- End of step " . $stepNo . "-------------- \n\n";
     return $result;
 }
Esempio n. 2
0
 public function canLoad($pointSequence, $pythonFile, $loadArea, $weightCapacity, $allPoints)
 {
     $result = false;
     $points = self::removeDepotFromPointSequence($pointSequence);
     $boxFileName = dirname($pythonFile) . '/boxes.txt';
     if (!$this->getBoxesFileIsFilled()) {
         file_put_contents($boxFileName, IO::getBoxesTextForExternalPdpHelper($allPoints));
         $this->setBoxesFileIsFilled(true);
     }
     if (!file_exists($pythonFile)) {
         throw new \Exception("Python file '{$pythonFile}' does not exist!");
     }
     $cmdString = "python {$pythonFile}" . " -b {$boxFileName}" . " -n " . (int) (count($allPoints) / 2) . " -c \"" . implode(' ', $loadArea) . ' ' . $weightCapacity . "\"" . " -r \"" . implode(' ', Point::getPointIds($points)) . "  1\"" . " -p";
     $cmdResult = exec($cmdString);
     //  echo $cmdResult . "\n";
     $result = $cmdResult == 'True';
     return $result;
 }