7.1 Data Constants

Data constants or scalars are mainly used to aid readability and make the model easier to maintain. You can specify them in two different ways: by assigning them a value in the model or interactively, that is, by prompting the user for the value when the model file is read.

To use the interactive method, place a question mark following the coefficient value.

Example:

    DATA
       InventoryCost     :=  8.8
       MaximumInventory  :=  1200?

Here the InventoryCost is given the value 8.8 which will be used whenever the constant is referred to in the model.

The value for MaximumInventory is prompted at runtime as in the Data Request dialog box like the one shown here below in Figure 7.1. It will then used in the model like any other constant.

Data Constant Entered at Run-time Screenshot Figure 7.1: Data Constant Entered at Run-time

Named data constants can be used almost anywhere in the model. This can be used to help make the model truly dynamic and easy to change. Here are some examples:

    DATA
        NrOfYears    = 10 ?
        December     = 12
        HolidayMonth = 7
    INDEX
        i := 1..NrOfYears
        j := 1..December
    VARIABLES
        Inventory[i,j]
        Production[i,j]
           .
       .
    BOUNDS
        Inventory[i,December]  > 200 ;
        Production[i,HolidayMonth] < 100 ;
    END

The value of the named data constant NrOfYears is prompted at run-time using the default value of 10. It is then used to define the index i. The HolidayMonth constant is used to enter a fixed month for the Production variable.

Like with indexes and data vectors, MPL allows you to import data constant entries from datafiles and Excel spreadsheets. Please note, that since data constants are not indexed they cannot easily be imported from databases. To read from a datafile just enter the DATAFILE keyword followed by the filename in parentheses. To read from an Excel spreadsheet, enter the EXCELRANGE keyword followed by the workbook filename and the cell range in parentheses. For example:


    DATA
        NrOfYears    = DATAFILE("years.dat");
        December     = 12;
        HolidayMonth = EXCELRANGE("worksched.xls", "B5");

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