/**
  * @param $rideNodes
  * @param $emptyRideNodes
  * @param $drivingPools
  * @return RideConfiguration[]
  */
 public function buildConfigurations($rideNodes, $drivingPools, $emptyRideNodes)
 {
     $this->rideNodes = $rideNodes;
     $this->drivingPools = $drivingPools;
     $this->emptyRides = $emptyRideNodes;
     $workNodes = $this->rideNodes;
     ConfigurationBuilder::sortNodesByStartMinute($workNodes);
     $this->adjacenceMatrix = ConfigurationBuilder::buildAdjacenceMatrixFromNodes($workNodes, $emptyRideNodes);
     //build some different configurations
     $rideConfigurations = array();
     $diversity = count($this->drivingPools);
     $factor = $diversity * 2;
     // take for each driving pool another start node,
     // and then shuffle the whole node array some times
     // to create another start set to begin with
     for ($i = 0; $i < $factor; $i++) {
         $workRideNodes = $workNodes;
         if ($i > $diversity) {
             shuffle($workRideNodes);
         } else {
             $switch = $workRideNodes[0];
             $workRideNodes[0] = $workRideNodes[$i];
             $workRideNodes[$i] = $switch;
         }
         $rideConfigurations[] = $this->buildGenericLeastDurationConfiguration($workRideNodes);
     }
     return $rideConfigurations;
 }
Пример #2
0
 /**
  * @param $rideNodes
  * @param $emptyRideNodes
  * @param $drivingPools
  * @return RideConfiguration[]
  */
 public function buildConfigurations($rideNodes, $drivingPools, $emptyRideNodes)
 {
     $this->rideNodes = $rideNodes;
     $this->drivingPools = $drivingPools;
     $this->emptyRideNodes = $emptyRideNodes;
     $workNodes = $this->rideNodes;
     ConfigurationBuilder::sortNodesByStartMinute($workNodes);
     $this->adjacenceMatrix = ConfigurationBuilder::buildAdjacenceMatrixFromNodes($workNodes, $emptyRideNodes);
     //Initial Config by LeastDistance Strategy
     $s = microtime(true);
     //        $initConfig = $this->buildFeasibleConfiguration();
     $initConfig = $this->buildFeasibleConfigFromStrategy(new RideStrategyLeastDuration());
     $e = microtime(true);
     $this->logWithParameters('ride.log.ridenodes', array(count($this->rideNodes), round($e - $s, 3)));
     if ($initConfig) {
         $configurations = $this->annealConfigurations($initConfig);
         return $configurations;
     }
     return null;
 }