Пример #1
0
 /**
  * builds array of emptyRides in this builder and returns it
  * gets hash array with nodes, where key is concatenated coordinate
  * hash (md2) from start and destination
  *
  * @return array
  */
 public function buildAllPossibleEmptyRides()
 {
     $this->sortNodesByStartMinute($this->rideNodes);
     $workNodes = $this->rideNodes;
     foreach ($workNodes as $key => $workNode) {
         //fill rides from and to vehicleDepot
         foreach ($this->vehicleDepotAddresses as $depotAddress) {
             $depotToNode = RideNode::registerEmptyRide($depotAddress, $workNode->startAddress);
             $nodeToDepot = RideNode::registerEmptyRide($workNode->targetAddress, $depotAddress);
             $this->emptyRideNodes[$depotToNode->getRideRouteHash()] = $depotToNode;
             $this->emptyRideNodes[$nodeToDepot->getRideRouteHash()] = $nodeToDepot;
         }
         //fill possible rides between any time-feasible nodes
         $comparesNodes = $workNodes;
         foreach ($comparesNodes as $compareNode) {
             if ($workNode->endMinute < $compareNode->startMinute) {
                 $node = RideNode::registerEmptyRide($workNode->targetAddress, $compareNode->startAddress);
                 $this->emptyRideNodes[$node->getRideRouteHash()] = $node;
             }
         }
         unset($workNodes[$key]);
     }
     return $this->emptyRideNodes;
 }