Running a VRPSolver application
On this page
This tutorial teaches you how to run the VRPSolver on Linux and Windows/MacOS systems using Docker. While assuming the use of Cplex 12.10, this tutorial can be used in an equivalent way for installation with Cplex 12.9.
Basic usage#
To run the application from your local machine command line, you must mount (-v) the user Julia VRPSolver application folder under any name and the last arguments must be the main script .jl of the application, followed by the application arguments:
docker run --rm -v /ABSOLUTE_PATH_TO_VRPSOLVER_APP:/MyApp bapdock /MyApp/myapp.jl arg1 arg2 ... argn
The VRPSolver application folder is mounted as /MyApp
in the Docker container filesystem. For example, for the Capacitated Vehicle Routing Problem (CVRP) demo (available here), we can call:
docker run --rm -v /ABSOLUTE_PATH_TO_CVRP_APP:/CVRP bapdock /CVRP/src/run.jl /CVRP/data/A/A-n37-k6.vrp -m 6 -M 6 -u 950 -o /CVRP/sol/A-n37-k6.sol
This solves the instance A-n37-k6.vrp
using exactly 6 vehicles (-m and -M define the minimum and maximum number of vehicles, respectively), an upper bound of 950, and writes the solution at /CVRP/sol/A-n37-k6.sol
. Note that for the arguments after bapdock
, we need to consider the container filesystem (/CVRP
) to access the application and I/O arguments. All changes into /CVRP
and subdirectories will be reflected at /ABSOLUTE_PATH_TO_CVRP_APP
.
When running from the local machine command line, Julia code will be compiled each time, and thus building the model takes some time (like 30 seconds on a typical machine) even for small instances. The reported solution time, counted only after the code is compiled, is not affected.
To decrease recompilation time while creating/debugging the application, you can run the application in the interactive mode:
docker run -it --rm -v /ABSOLUTE_PATH_TO_VRPSOLVER_APP:/MyApp bapdock
For example, for the CVRP demo, we can call:
docker run -it --rm -v /ABSOLUTE_PATH_TO_CVRP_APP:/CVRP bapdock
And to run the application inside the Julia environment, type (one at a time):
include("/CVRP/src/run.jl") # load CVRP demo
main(["/CVRP/data/A/A-n37-k6.vrp","-m","6","-M","6","-u","950","-o","/CVRP/sol/A-n37-k6.sol"]) # run CVRP demo
main(["/CVRP/data/A/A-n37-k5.vrp","-m","5","-M","5","-u","670"]) # running another instance without writing the solution
args = ["/CVRP/data/A/A-n37-k5.vrp","-m","5","-M","5","-u","671"] # defining arguments before
main(args) # running with predefined arguments
You can edit the application on your local machine and load it inside the Julia environment in the Docker to test your changes, using include
. In this case, recompilation time will be minimized.
To quit the Julia environment, type:
exit()
Other demos are available here.
Basic usage#
To run the application from your local machine command line, you must mount (-v) the user Julia VRPSolver application folder under any name and the last arguments must be the main script .jl of the application, followed by the application arguments:
docker run --rm -v /ABSOLUTE_PATH_TO_VRPSOLVER_APP:/MyApp bapdock /MyApp/myapp.jl arg1 arg2 ... argn
The VRPSolver application folder is mounted as /MyApp
in the Docker container filesystem. For example, for the Capacitated Vehicle Routing Problem (CVRP) demo (available here), we can call:
docker run --rm -v /ABSOLUTE_PATH_TO_CVRP_APP:/CVRP bapdock /CVRP/src/run.jl /CVRP/data/A/A-n37-k6.vrp -m 6 -M 6 -u 950 -o /CVRP/sol/A-n37-k6.sol
This solves the instance A-n37-k6.vrp
using exactly 6 vehicles (-m and -M define the minimum and maximum number of vehicles, respectively), an upper bound of 950, and writes the solution at /CVRP/sol/A-n37-k6.sol
. Note that for the arguments after bapdock
, we need to consider the container filesystem (/CVRP
) to access the application and I/O arguments. All changes into /CVRP
and subdirectories will be reflected at /ABSOLUTE_PATH_TO_CVRP_APP
.
When running from the local machine command line, Julia code will be compiled each time, and thus building the model takes some time (like 30 seconds on a typical machine) even for small instances. The reported solution time, counted only after the code is compiled, is not affected.
To decrease recompilation time while creating/debugging the application, you can run the application in the interactive mode:
docker run -it --rm -v /ABSOLUTE_PATH_TO_VRPSOLVER_APP:/MyApp bapdock
For example, for the CVRP demo, we can call:
docker run -it --rm -v /ABSOLUTE_PATH_TO_CVRP_APP:/CVRP bapdock
And to run the application inside the Julia environment, type (one at a time):
include("/CVRP/src/run.jl") # load CVRP demo
main(["/CVRP/data/A/A-n37-k6.vrp","-m","6","-M","6","-u","950","-o","/CVRP/sol/A-n37-k6.sol"]) # run CVRP demo
main(["/CVRP/data/A/A-n37-k5.vrp","-m","5","-M","5","-u","670"]) # running another instance without writing the solution
args = ["/CVRP/data/A/A-n37-k5.vrp","-m","5","-M","5","-u","671"] # defining arguments before
main(args) # running with predefined arguments
You can edit the application on your local machine and load it inside the Julia environment in the Docker to test your changes, using include
. In this case, recompilation time will be minimized.
To quit the Julia environment, type:
exit()
Other demos are available here.
Simplified usage#
There is a bash script called VRPSolver
available for each demo application to avoid calling Docker directly. For example, for the CVRP demo (see README.txt in the demo for more details), we can call:
./VRPSolver data/A/A-n37-k5.vrp -m 5 -M 5 -u 670
Instead of:
docker run --rm -v /ABSOLUTE_PATH_TO_CVRP_APP:/CVRP bapdock /CVRP/src/run.jl /CVRP/data/A/A-n37-k5.vrp -m 5 -M 5 -u 670
If you are using MacOS terminal or Docker QuickStart Terminal
(available for Docker Toolbox on Windows and MacOS), it is possible to use the bash script VRPSolver
available for each demo application to avoid calling Docker directly. For example, for the CVRP demo (see README.txt in the demo for more details), we can call:
./VRPSolver data/A/A-n37-k5.vrp -m 5 -M 5 -u 670
Instead of:
docker run --rm -v /ABSOLUTE_PATH_TO_CVRP_APP:/CVRP bapdock /CVRP/src/run.jl /CVRP/data/A/A-n37-k5.vrp -m 5 -M 5 -u 670