The constructor allows you to specify the names of the input files using command line syntax. If you do not specify input files, the defaults will be used. This constructor will be called from the main
function. It calls the following functions: addDimensions
, createIloNodes
, createVehicles
, and createVisits
. The following code is provided for you:
RoutingModel::RoutingModel( IloEnv env,
int argc,
char* argv[]):
_env(env), _mdl(env) {
addDimensions();
//create IloNodes
char * nodeFileName;
if(argc < 2) nodeFileName =
(char*) "../../../examples/data/vrp20/vrp20nodes.csv";
else nodeFileName = argv[1];
createIloNodes(nodeFileName);
//create vehicles
char * vehiclesFileName;
if(argc < 3) vehiclesFileName =
(char*) "../../../examples/data/vrp20/vrp20vehicles.csv";
else vehiclesFileName = argv[2];
createVehicles(vehiclesFileName);
//create visits
char * visitsFileName;
if(argc < 4) visitsFileName =
(char*) "../../../examples/data/vrp20/vrp20visits.csv";
else visitsFileName = argv[3];
createVisits(visitsFileName);
}
|
Now you have finished creating the RoutingModel
class. In the next lesson, you will create the RoutingSolver
class and compile and run the program. The complete VRP program is listed at the end of Chapter 3, Solving a Vehicle Routing Problem.