The Init Section

The init section is another optional section offered by LINGO. In the init section, you enter initialization statements that look much like the data statements found in the data section. The values you input in the init section are used as starting points by LINGO's solver. Unlike the variables that are initialized in the data section, the solver is free to alter the values of variables initialized in the init section.

Note:Starting points specified in an init section are only of use in nonlinear or integer models. Starting points currently offer no help in purely linear models. If you are not sure whether your model is linear or nonlinear, you can check the count of nonlinear constraints in the solver status window. If there are any nonlinear constraints, then your model is nonlinear. For more information on the nature of nonlinear models and how good starting points can be of assistance, please see On Mathematical Modeling.
Note:As an example, in a set defining a group of stocks, you may have a known price of each stock, but the amount to buy or sell of each stock is unknown. You would typically initialize the price attribute in the data section. If approximate values of the buy and sell attributes are known, you can tell LINGO this information by entering it in the init section. LINGO then uses the values specified as a starting point in its search for the optimal solution. If your starting point is relatively close to an optimal solution, you may save on the solution time required to run your model.

An init section begins with the keyword INIT: and ends with the keyword ENDINIT. The syntax rules for init statements in the init section are identical to the rules for data section statements. You can have multiple attributes on the left-hand side of a statement, you can initialize an entire attribute to a single value, you can omit values in an attribute, and you can use the question mark to have LINGO prompt you for an initialization value whenever you solve the model.

As an example of how a good starting point may help to reduce solution times, consider the small model:

Y <= @LOG( X);

X^2 + Y^2 <=1;

The function @LOG( X) returns the natural logarithm of X. This model has only one feasible point of (X,Y) = (1,0). If we solve this model without an init section, we get the solution:

Feasible solution found at step:       12

 

    Variable           Value

           Y       0.5721349E-03

           X       1.000419

Note it required 12 iterations to solve. Now, let's add an init section to initialize X and Y to a point close to the solution, so we have:

INIT:

  X = .999;

  Y = .002;

ENDINIT

 

Y <= @LOG( X);

X^2 + Y^2 <=1;

Solving this modified model, we get the solution:

Feasible solution found at step:        3

 

    Variable           Value

           X       0.9999995

           Y      0.0000000

Note our solution required only 3 iterations compared to the 12 iterations required without the init section.

Note:Variables may also be initialized in a calc section as illustrated in the next section, The Calc Section of a Model.