PHP Classes

PHP Vehicle Routing Problem: Compute routes of trucks delivering client orders

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum (3)   Blog    
Ratings Unique User Downloads Download Rankings
StarStar 35%Total: 889 This week: 1All time: 3,974 This week: 560Up
Version License PHP version Categories
ocvrp 0.1BSD License3.0Algorithms, Geography
Description 

Author

This class can compute routes of trucks delivering client orders.

It takes the geographic coordinates of a depot and the locations clients with orders to be delivered by a fleet of trucks.

The class uses a 2-phase algorithm for solving the open capacitated vehicle routing problem.

It tries to minimize the total route cost by trying all possible combinations. The trucks are not required to return to the depot.

Innovation Award
PHP Programming Innovation award winner
July 2014
Winner


Prize: PhpStorm IDE personal permanent license
Some businesses need to deliver products to their customers using cargo transportation vehicles.

To reduce the costs it is necessary to optimize the routes that the vehicles take to deliver the products.

This class implements an alternative vehicle routing solution that is very accurate, as it computes the euclidean distance between client sites.

Manuel Lemos
Picture of Chi H.
  Performance   Level  
Name: Chi H. <contact>
Classes: 28 packages by
Country: France France
Age: 39
All time rank: 34222 in France France
Week rank: 109 Up5 in France France Up
Innovation award
Innovation award
Nominee: 22x

Winner: 3x

Recommendations

What is the best PHP vehicle tracking system class?
Getting distance to calculate fuel used and cost from map

Vehicle routing problem
Vehicle routing problem using the branch and bound algorithm

Example

<?php
/* * *************************************************************
 * Copyright notice
 *
 * (c) 2010-2014 Chi Hoang (info@chihoang.de)
 * All rights reserved
 *
 * **************************************************************/
  
 
require_once("ocvr.php");
 
$clients = array (
               array(
"latlng"=>"50.1005233,8.6544487",
                     
"zipcode"=>"12341",
                     
"load"=>"2"),
               array(
"latlng"=>"50.0907496,8.7839489",
                     
"zipcode"=>"12342",
                     
"load"=>"3"),
               array(
"latlng"=>"50.2002273,8.1004734",
                     
"zipcode"=>"12343",
                     
"load"=>"4"),
               array(
"latlng"=>"50.0951493,8.4117234",
                     
"zipcode"=>"12344",
                     
"load"=>"2"),
               array(
"latlng"=>"49.4765982,8.3508367",
                     
"zipcode"=>"12345",
                     
"load"=>"1"),
               array(
"latlng"=>"48.7827027,9.1828630",
                     
"zipcode"=>"12347",
                     
"load"=>"8"),
               array(
"latlng"=>"48.7686426,9.1686483",
                     
"zipcode"=>"12348",
                     
"load"=>"9"),
               array(
"latlng"=>"48.7829101,9.2118466",
                     
"zipcode"=>"12349",
                     
"load"=>"10"),
               array(
"latlng"=>"48.9456327,8.9670738",
                     
"zipcode"=>"12350",
                     
"load"=>"7"));
                      
   
$depot=array(array( "latlng"=>"49.7957240,6.6790269",
                      
"zipcode"=>"55555"
               
));
               
   
$route=new ocvr;
    echo
"Please wait.\r\n<br>";
   
$result=$route->main($depot,$clients);
    echo
"Calculation time:".round($route->dur)."Sek.\r\n<br>";
    echo
"Number of combinations:".round($route->nCr/1000)."K\r\n<br>";
    echo
"Peak memory:".round($route->peakmem/1024)."MB\r\n<br>";
    echo
"Max. load per truck:".MAXCAPACITY."\r\n<br>";
    echo
"Number of trucks:".$result["no"]."\r\n<br>";
    foreach (
$result["trucks"] as $key=>$arr)
    {
         echo
"Truck $key:".$arr."Load\r\n<br>" ;
    }
    echo
"Totaldistance:".$result["totaldist"]."km\r\n<br>";
?>


Screenshots  
  • screenshot.png
  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example example
Plain text file hilbert.php Class helper class
Plain text file mercator.php Class helper class
Plain text file ocvr.php Class main class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:889
This week:1
All time:3,974
This week:560Up
User Ratings User Comments (1)
 All time
Utility:50%StarStarStar
Consistency:50%StarStarStar
Documentation:-
Examples:50%StarStarStar
Tests:-
Videos:-
Overall:35%StarStar
Rank:4094