LINGO is a simple tool to solve linear and nonlinear optimization problems. Lingo free version can support 30 unknowns, Lingo cracked version can support tens of thousands of unknowns and tens of thousands of constraints.
When you start running LINGO system under windows, you will get a window similar to the following:
The outer layer is the main frame window, which contains all menu commands and toolbars, and all other windows will be included under the main window. The window titled LINGO Model–Lingo1in the main window is the default model window of Lingo, and all the established models should be coded and implemented in this window. Here are two examples.
Example 1. 1 How to solve the following LP problems with LINGO:
Enter the following code in the model window:
min = 2 * x 1+3 * x2;
x 1+x2 & gt; =350;
x 1 & gt; = 100;
2 * x 1+x2 & lt; =600;
Then click the button on the toolbar.
The following results were obtained:
So when x 1 is 250 and x2 is 100, the objective function gets the maximum value.
arithmetic operator
Variables in Lingo are case-insensitive and start with letters of no more than 32 characters.
Arithmetic operators operate on numerical values. LINGO provides five binary operators:
Multiply/divide addition and subtraction
The only unary arithmetic operator in argot is the negative function "-"."
The priority of these operators from high to low is:
High (inversion)
^
﹡/
Low.
The operator's operation sequence is from left to right according to the priority. The order of operations can be changed by brackets "()".
Example: at x1+x2 > =350,x 1 & gt; = 100,2 * x 1+x2 & lt; Find the minimum value of 2*x 1+3*x2 under the condition of =600.
Write in the code window
min = 2 * x 1+3 * x2;
x 1+x2 & gt; =350;
x 1 & gt; = 100;
2 * x 1+x2 & lt; =600;
Then click the Solve button under the jargon in the menu above.
mathematical function
Standard mathematical function:
@abs(x) returns the absolute value of x.
@sin(x) returns the sine value of x, and x adopts circular arc system.
@cos(x) returns the cosine of x.
@tan(x) returns the tangent of x.
@exp(x) returns the x power of the constant e.
@log(x) returns the natural logarithm of x.
@lgm(x) returns the natural logarithm of the gamma function of x.
The @ symbol (x) stands for X.
@floor(x) returns the integer part of x, and when x & gt=0, returns the largest integer not exceeding x; When x
Max-min function:
@smax(x 1, x2, …, xn) returns the maximum value of x 1, x2, …, xn.
@smin(x 1, x2, …, xn) returns the minimum value of x 1, x2, …, xn.
Boundary definition function:
@bin(x) constraint x is 0 or 1.
@bnd(L, x, u) constraint L≤x≤U
@free(x) cancels the restriction that the default lower bound of variable x is 0, that is, x can take any real number.
@gin(x) limits x to an integer.
Auxiliary function
1.@if (logical condition, true result, false result)
The @if function evaluates the logical expression logical_condition, and returns true_ result if it is true, otherwise returns false_result.
By default, LINGO specifies that the variable is non-negative, that is, the lower bound is 0 and the upper bound is+∞. @free cancels the default lower limit of 0, so that variables can also take negative values. @bnd is used to set the upper and lower bounds of variables, or to cancel the constraint that the default lower bound is 0.
Example: find x12+3 * x2-x1* x2+ex3 in x/kloc-0 >; =350; x 1+x3 & lt; 50; 2 * x 1+x2+x3 & lt; =600; X 1 can only be 0 or1; X2 is the minimum value under the condition of integer.
Write in the code window
【email=min=x 1^2+3*x2-x 1*x2+@exp(x3]min=x 1^2+3*x2-x 1*x2+@exp(x3[/email】);
x 1+x2 & gt; =350;
x 1+x3 & lt; 50;
2 * x 1+x2+x3 & lt; =600;
@ bin(x 1); @ gin(x2);
The above is the most basic usage of lingo.
Logical operator
LINGO has nine logical operators:
#not# negates the logical value of the operand, and # not # is a unary operator.
# eq # true If two operands are equal; Otherwise, it is false.
# ne # true If two operators are not equal; Otherwise, it is false.
# gt # true If the left operator is strictly greater than the right operator; Otherwise, it is false.
# ge # true If the operator on the left is greater than or equal to the operator on the right; Otherwise, it is false.
# lt # true If the operator on the left is strictly smaller than the operator on the right; Otherwise, it is false.
# le # true If the operator on the left is less than or equal to the operator on the right; Otherwise, it is false.
# and # Only when both parameters are true, the result is true; Otherwise, it is false.
# or # Only when both parameters are false, the result is false; Otherwise it's true.
The priority of these operators from high to low is:
Gao # no #
#eq# #ne# #gt# #ge# #lt# #le#
Low # and # # or #
Example 4.2 Example of Logical Operators
2 # gt # 3 # and # 4 #gt# 2, the result is false (0).
Model solving state
@ Status ()
Return to LINGO's state after solving the model:
0 global optimization (global optimization)
1 Not feasible (not feasible)
2 Unbounded (unbounded)
3 Undefined (uncertain)
4 feasible (feasible)
5 infeasible or unbounded (usually you need to turn off the "preprocessing" option and solve the model again to determine whether the model is infeasible or unbounded)
6 Local Optimum (local optimum)
7 local infeasibility (local infeasibility, although feasible solutions may exist, LINGO has not found one yet)
8 truncation (reaching the truncation value of the target function)
9 Numerical error (Solver stopped due to undefined arithmetic operation in constraint)
Usually, if the return value is not 0, 4 or 6, then this solution is unreliable and almost useless. This function is only used in the data part of the model to output data.