This page defines the LP format syntax in form of a grammar defined in Bachus-Naur form. All correct LP format inputs can be derived from the nonterminal <LP-document>. For a brief explanation of the BNF notation conventions see BNF notation.

In the grammar below names in <> are non-terminals or tokens. Tokens are the basic elements of an LP document. These are IDENTs, NUMBERs, STRINGs, keywords, which are given in double quotes, and literals, which are given in single quotes. All tokens are pahasized shown bold face in the following BNF grammar. For further discussion of the LP tokens please see LP format tokens

<LP-document> --> [ <Problem-Name> ]
    <Min-or-Max> <objective>
    <constraint-section>
    "BOUNDS"  |  "BOUND" ] <bounds-section>
    "INTEGER"  |  "INT" ] <integer-section>
    "END"
<Problem-Name> --> ("PROBLEM"  |  "PROB")   STRING
<Min-or-Max> --> "MIN"  |  "MINIMUM"  |  "MINIMIZE"
  --> "MAX"  |  "MAXIMUM"  |  "MAXIMIZE"
<objective> --> <constraint-expr>
<constraint-section> --> ("ST"  |  "SUBJECT"  |  "SUBJECT TO")
    (<constraint-expr> <sense> <rhs>)+
<constraint-expr> --> IDENT ':' ]
    NUMBER IDENT ( ('+'  |  '-') NUMBER IDENT  )* ]
    % The optional identifier before the ':'
% designates a row/constraint name.
% All other identifiers are column/variable names
<sense> --> <smaller-equal>  |  <greater-equal>  |  '='
<smaller-equal> --> '<'  |  '<='  |  '=<'
<greater-equal> --> '>'  |  '>='  |  '=>'
<bounds-section> --> <bounds-item>*
<bounds-item> --> <num-or-Inf> <smaller-equal> IDENT
    [ <smaller-equal> <num-or-Inf> ]
  --> <num-or-Inf> <greater-equal> IDENT
    [ <greater-equal> <num-or-Inf> ]
  --> IDENT <smaller-equal> <num-or-Inf>
  --> IDENT <greater-equal> <num-or-Inf>
  --> IDENT '=' NUMBER
  --> IDENT 'FREE'
<num-or-Inf> --> NUMBER  |  '-INF'  |  '+INF'  |  'INF'  | 
    '-INFINITY' |  '+INFINITY'  |  'INFINITY'
<integer-section> --> IDENT*