04 641 model inspection error

Upload: ale-hdez

Post on 08-Apr-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 04 641 Model Inspection Error

    1/33

    Introduction to GAMS:Model inspection & Error messages

    Dhazn Gillig&

    Bruce A. McCarl

    Department of Agricultural Economics

    Texas A&M University

  • 8/7/2019 04 641 Model Inspection Error

    2/33

    Are you sure that you know EXACTLY what is in the model?

    GAMS can cause one to lose touch with the exact optimization

    model being solved, especially when one has a big complicated

    data set containing many data calculations.

    Thus, when setting up a model one may need to look at individual

    equations and variables. GAMS permits this through the use of

    model element displays using

    ! LIMROW and LIMCOL options

    ! GAMSCHK

    Model Inspection

  • 8/7/2019 04 641 Model Inspection Error

    3/33

    LIMROW controls the number of rows listed in the equation listing

    LIMCOL controls the number of columns listed in the variable listing

    If we want more or less variables or equations we can do this by

    altering the LIMROW and LIMCOL options

    To eliminate => OPTION LIMROW = 0;OPTION LIMCOL = 0;

    To expand => OPTION LIMROW = 100 ; (or any other number)

    OPTION LIMCOL = 100 ;

    Model Inspection Limrow / Limcol

  • 8/7/2019 04 641 Model Inspection Error

    4/33

    Min Cost of shipping goods from S to D

    minimization of total cost across all possible

    shipment routesLimited outgoing shipments from each S point i

    Minimum demand constraint at each D point j

    Nonnegative shipments

    Limrow / Limcol Transportation problem illustration

  • 8/7/2019 04 641 Model Inspection Error

    5/33

    Limrow / Limcol Transportation problem illustration

  • 8/7/2019 04 641 Model Inspection Error

    6/33

    For equations we get something like

    Limrow / Limcol Transportation problem illustration

  • 8/7/2019 04 641 Model Inspection Error

    7/33

    Limrow / Limcol Transportation problem illustration

  • 8/7/2019 04 641 Model Inspection Error

    8/33

    Limrow / Limcol Transportation problem illustration

  • 8/7/2019 04 641 Model Inspection Error

    9/33

  • 8/7/2019 04 641 Model Inspection Error

    10/33

    Limrow / Limcol Transportation problem illustration

  • 8/7/2019 04 641 Model Inspection Error

    11/33

    Unfortunately, for large models the LIMROW/ LIMCOL option

    can generate very substantial output files. An alternative way

    of displaying models called GAMSCHK will be discussed in the

    next class.

    Model Inspection Limrow / Limcol

  • 8/7/2019 04 641 Model Inspection Error

    12/33

    Common Error Messages

    What to do when ERRORS STRIKE and GAMS stops running?

    Not to worry, when GAMS detects errors, it inserts coded error messages

    inside the echo print in the *.LST file. All errors are marked with four

    asterisks **** at the beginning of a line. One can use

    to find where errors occur and fix them.

  • 8/7/2019 04 641 Model Inspection Error

    13/33

    Common Error Messages

    Double click on Red Color Lines in the process window,

    causes the cursor to jump to location in *.gms file where

    error occurs.

    Note: always concentrate on

    fixing the first or first few errors

    and ignore the others since

    many subsequent errors may

    result from a previous error.

  • 8/7/2019 04 641 Model Inspection Error

    14/33

    Common Error Messages

    Double click on Black Color Lines in the process window,then a cursor will jump to a *.lst file where the error is listed.

  • 8/7/2019 04 641 Model Inspection Error

    15/33

    Common Error Messages

    To have error messages displayed

    immediately following an error line,

    go to GAMS 20.7 directory and open

    gmsprm95.txt (for window) or

    gmsprmNT.txt (for NT), then typeerrmsg = 1

    errmsg controls the location in the

    listing file (*.lst) of error messages.

    Alternatively,

    errmsg = 0

    error messages at the end of*.lst file

    errmsg = 2

    no error messages

  • 8/7/2019 04 641 Model Inspection Error

    16/33

    Note that in every equation all the subscripts (SETS) must behandled in every term. This means

    ! they either must be summed over, or

    ! they must appear in the equation definition

    Common Error Messages

    Not obeying this will cause errors as on next pages.

  • 8/7/2019 04 641 Model Inspection Error

    17/33

    Set is under control already.

    Common Error Messages

    Source set is used in conflicting ways. By appearing in the equation

    specification (.. Command) SupplyBal(Source).. this defines these

    equations for all elements of the set Source, but then how can you

    sum over this. The answer is that you cannot and GAMS gives an error.Simultaneously, Destination set is not controlled. How do you FIX this?

  • 8/7/2019 04 641 Model Inspection Error

    18/33

    Uncontrolled set entered as constant

    Common Error Messages

    Here the set Source is not operated over in a sum or the ..

    specification. So what is GAMS to do give an error message.

    C E M

  • 8/7/2019 04 641 Model Inspection Error

    19/33

    Now for some other common errors

    Floating entry ignored

    Common Error Messages

    We have made an error in typing of a table. We have not aligned the dataunder a column set name so GAMS does not know which data column a

    number goes with and issues an error.

  • 8/7/2019 04 641 Model Inspection Error

    20/33

    Common Error Messages

  • 8/7/2019 04 641 Model Inspection Error

    21/33

    Common Error Messages

    Duplicate names

    We already defined TransCost as a parameter and then we used it again in

    equation specification. GAMS will object to these multiple declarations.

    Common Error Messages

  • 8/7/2019 04 641 Model Inspection Error

    22/33

    Common Error Messages

    Omitted set elements

    We forgot to include San Diego element in Source set, but this San

    Diego is used later in the PARAMETERS. Therefore, an error arises.

    Common Error Messages

  • 8/7/2019 04 641 Model Inspection Error

    23/33

    Common Error Messages

    Mismatched parentheses

    We had an excess number of close ) in (A) but we had an excess number of

    open ( in (B). We can use to check for parenthesis.

    ?

    (A)

    (B)

    Common Error Messages

  • 8/7/2019 04 641 Model Inspection Error

    24/33

    Commo o essages

    Entering improper nonlinear expressions

    The CostSum equation contains nonlinear terms beyond the capacity of

    the solver being used. In SOVLE statement, we define to solve this

    problem as a LP problem.

    Common Error Messages

  • 8/7/2019 04 641 Model Inspection Error

    25/33

    g

    Using undefined data

    We declared a TransCost as a parameter but we did not declare numerical

    values to the TransCost and it is used in the CostSum equation.

    Common Error Messages

  • 8/7/2019 04 641 Model Inspection Error

    26/33

    g

    No variable, parameter, or equation definition

    A CostSum equation is used but it has not been declared.

    Common Error Messages

  • 8/7/2019 04 641 Model Inspection Error

    27/33

    g

    Insufficient semi colon

    We forgot to terminate the EQUATIONS statement with the semi colon.

    ;

  • 8/7/2019 04 641 Model Inspection Error

    28/33

    Common Error Messages

  • 8/7/2019 04 641 Model Inspection Error

    29/33

    = or .. operator expected

    Common Error Messages

    The algebraic structure of equations must be specified by using .. notation.Here we omitted the .. in CostSum equation.

    Common Error Messages

  • 8/7/2019 04 641 Model Inspection Error

    30/33

    Unknown symbol

    Common Error Messages

    We named a model Tranpor, but then later we solve the model called

    Transport. Obviously, misspelled in the MODEL statement.

    More Help on Error Messages

  • 8/7/2019 04 641 Model Inspection Error

    31/33

    More Help on Error Messages

    Double click on a

    topic to view details

    Hands On

  • 8/7/2019 04 641 Model Inspection Error

    32/33

    Learning Objectives (handson4.gms):

    1. Learn how to inspect a model structure using OPTION

    LIMROW and LIMCOL

    2. Learn how to find and fix errors

    Things To Do

    1. Please run handson2.gms and then fix errors and re-run the problem.

    2. Please open handson3.gms and save it as handson4.gms. Alter yourobjective function from

    to

    Then run handson4.gms and inspect the model using OPTION

    LIMROW and LIMCOL. Is there anything wrong with the model

    structure or solutions?

    References

  • 8/7/2019 04 641 Model Inspection Error

    33/33

    References

    McCarl, B. A. Basic GAMS class.(http://ageco.tamu.edu/faculty/mccarl/mccarl.htm).