11.3 Export Variable Values to Database

After optimizing the problem, MPL can export the variable values to the database where it can be used to report the solution back to the user. In the DECISION VARIABLES section, where you define the variable vector, enter the keyword EXPORT TO after the defined variable, followed by the keyword DATABASE and parentheses containing the table name and the column/field name you want to export to.

Example:

          DECISION VARIABLES
       FactDepShip[factory,depot]

          EXPORT TO DATABASE("FactDep","Shipment");

    

In the above example, MPL will open the database table FactDep, locate the columns Shipment, FactID, and DepotID, and then export the solution values for the variable vector FactDepShip.

Here is an example of the FactDep table after the solution values have been exported.

Notice that MPL automatically uses the same name as the default for the index columns FactID and DepotID, as in the original tables the indexes were defined from.

If an index column does have a different name than in the original table you can specify it following the table name by first entering the index name followed by an equal sign and the column name.

          DECISION VARIABLES
       FactDepShip[factory,depot]
          EXPORT TO DATABASE("FactDep","Shipment"
                                       factory="Factory",
                                       depot="Depot");

    

This means, if you are consistent in naming the columns in different tables, you do not have to specify them each time you refer to them in MPL.

The column name defaults to the name of the datavector so if it is the same you do not have to specify it. In the example below, the column name in the database table is FactDepShip which is the same is the datavector FactDepShip.

          DECISION VARIABLES
       FactDepShip[factory,depot]
          EXPORT DATABASE("FactDep");

    

MPL supports multiple databases for both importing and exporting data. The default database is specified in the Database Options dialog box in the Options menu. If you need to export a variable vector to a table in a database other than the default, you can do so by specifying the database name before the name of the table.

In the example below, MPL will export the solutions values of the variable vector FactDepShip from Paradox instead of the default database.

           DECISION VARIABLES
       FactDepShip[factory,depot]
          EXPORT TO DATABASE(DBase,"FactDep","Shipment");

    

MPL also allows you to export variable values other than the activity. You can export the reduced costs, the upper and lower ranges for the objective function, as well as the objective function coefficient values. You can change which values will be exported by entering one of the following keywords directly after the keyword EXPORT: Activity, ReducedCost, ObjectCoeff, ObjectLower, ObjectUpper . For example, if you want to export the reduced cost for a variable enter the following:

          DECISION VARIABLES
       FactDepShip[factory,depot]
          EXPORT ReducedCost TO DATABASE("FactDep","ReducedCost");

    

If you need to export more than one value for a variable vector you can do so by entering multiple export statements after the variable definition.

MPL offers three different options on how the database table is updated by the EXPORT statement. The first one, which is the default, searches through the database and for each record locates the corresponding value in the solver solution and updates the database entry with it. This option minimizes the changes done to the database table since only the existing values are updated, but can sometimes be slow especially on SQL type databases.

The second option is to use the REFILL keyword right after the EXPORT keyword to specify that the whole database table should be emptied and then refilled with the entries from the solver solution. Since this takes out the necessity to search the table this can often lead to faster export times for larger tables.

The third option is to use the CREATE keyword right after the EXPORT keyword to specify that the database table should be created and then filled with the entries from the solver solution. This option is mainly useful when exporting to the database table for the first time.


Back To Top | Maximal Home Page | Table of Contents | Previous Page | Next Page