Vous êtes sur la page 1sur 2

Handling LP problem with integer or binary variable in Lingo Take exercise 1a as an example, the LP problem is Min 12q + 5r + 3s s.t.

q+2r+4s > 6 5q+6r-7s < 5 8q-9r+11s = 10 q,r,s > 0 In the class, Lindo syntax was introduced to solve the problem as min 12q + st q+2r + 4s 5q + 6r 8q-9r+11s 5r + 3s > 6 7s < 5 = 10

With solution, Global optimal solution found. Objective value: Infeasibilities: Total solver iterations:

6.068966 0.000000 2

Variable Q R S Row 1 2 3 4

Value 0.000000 0.4482759 1.275862 Slack or Surplus 6.068966 0.000000 11.24138 0.000000

Reduced Cost 12.51724 0.000000 0.000000 Dual Price -1.000000 -1.413793 0.000000 0.2413793

However, if the variable q,r,s should be limited to integer or binary type, the above Lindo program has to be converted to Lingo syntax, then use functions @gin() and @int to declare integer or binary variables. For example, the above code can be modified to the following, @gin(q); @gin(r); @gin(s); min= 12*q + 5*r + 3*s; q+2*r + 4*s > 6; 5*q + 6*r - 7*s < 5; 8*q-9*r+11*s = 10; Save it as Lingo format file. It will then solve the above program with integer variables. The solution shall be similar to the following, Global optimal solution found. Objective value: Objective bound:

20.00000 20.00000

Infeasibilities: Extended solver steps: Total solver iterations:

0.000000 0 0

Variable Q R S Row 1 2 3 4

Value 1.000000 1.000000 1.000000 Slack or Surplus 20.00000 1.000000 1.000000 0.000000

Reduced Cost 12.00000 5.000000 3.000000 Dual Price -1.000000 0.000000 0.000000 0.000000

Vous aimerez peut-être aussi