Setting up the transportation model and data

Describes the model and data files.

To start working with this example:

  1. Use the File > New > Example menu command to open the transp example.

    The IDE displays the transp project in the OPL Projects Navigator. Open the model file in the editing area.

  2. Double-click transp4.mod to display the model in the editor.
  3. Scroll to the execute blocks.

    There are three preprocessing execute blocks 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);
      }
    }
    
  4. The data is initialized in the transp4.dat data 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 TableRoutes is 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 TableRoutes and in arrays Supply and Demand are 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 Routes are derived from those in TableRoutes and the tuples in sets Supplies and Customers are then derived from those in Routes.