Setting up the transportation model and data
Describes the model and data files.
To start working with this example:
- Use the File > New > Example menu command to open the transp example.
The IDE displays the
transpproject in the OPL Projects Navigator. Open the model file in the editing area. - Double-click transp4.mod to display the model in the editor.
- Scroll to the
executeblocks.There are three preprocessing
executeblocks before the objective, as shown in the following code extract.Preprocessing statements
(transp4.mod)execute PARAMS { cplex.tilim = 100; } execute SETTINGS { settings.displayComponentName = true; settings.displayWidth = 40; writeln("Routes: ",Routes); } execute DISPLAY { function printRoute(r) { write(" ",r.p,":"); writeln(r.e.o,"->",r.e.d); } writeln("Routes:"); for (var r in Routes) { printRoute(r); } } -
The data is initialized in the
transp4.datdata file. You can double-click transp4.dat to open that file in the editing area if you want to follow along with the following elements:Note that the tuple set
TableRoutesis database-friendly in that it would allow the loading of data on routes and costs with a single SELECT statement.In this example, the tuples in set
TableRoutesand in arraysSupplyandDemandare explicitly initialized in the data file because the matrix is sparse and only some tuples exist.The model requires routes and costs separately, so in the model file, the tuples in tuple set
Routesare derived from those inTableRoutesand the tuples in setsSuppliesandCustomersare then derived from those inRoutes.