Objective in LP file format

CPLEX conforms to these rules about objective function and objective offset in the LP file format.

LP file format supports an objective function and optionally an objective offset.

Objective function

The objective function definition must follow MINIMIZE or MAXIMIZE in LP file format. The objective function can be entered on multiple lines as long as no variable, constant, or sense indicator is split by a return. For example, this objective function 1x1 + 2x2 +3x3 can be entered like this:


1x1 + 2x2
+ 3x3

but not like this:


1x1 + 2x
2 + 3x3         \ a bad idea

because the second style splits the variable name x2 with a return.

The objective function may be named by typing a name and a colon before the objective function. The objective function name and the colon must appear on the same line. Objective function names must conform to the same guidelines as variable names. (See the rule about Variable names in LP file format.) If no objective function name is specified, CPLEX assigns the name obj .

An objective function may be quadratic. For an example and details about formatting a quadratic objective function, see the rule about Quadratic terms in LP file format.

Objective offset

You can optionally include an objective offset as a final constant term in the objective function. For example, the following line declares an objective offset of 3.1415.

obj:  x1 + 2 x2 + 3.1415
Likewise, the objective offset follows any quadratic expressions in LP file format of a quadratic program, like the following line:

 obj: x + 2 y + [ x ^2 - 3 x * y ] / 2 + 3.1415