lingo syntax

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 + 5r + 3s st q+2r + 4s > 6 5q + 6r - 7s < 5 8q-9r+11s = 10 With solution, Global optimal solution found. Objective value: 6.068966 Infeasibilities: 0.000000 Total solver iterations: 2 Variable Value Reduced Cost Q 0.000000 12.51724 R 0.4482759 0.000000 S 1.275862 0.000000 Row Slack or Surplus Dual Price 1 6.068966 -1.000000 2 0.000000 -1.413793 3 11.24138 0.000000 4 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: 20.00000 Objective bound: 20.00000

Upload: veeru117

Post on 23-Oct-2015

23 views

Category:

Documents


1 download

DESCRIPTION

Ling Syntax

TRANSCRIPT

Page 1: Lingo Syntax

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 + 5r + 3s st q+2r + 4s > 6 5q + 6r - 7s < 5 8q-9r+11s = 10 With solution, Global optimal solution found. Objective value: 6.068966 Infeasibilities: 0.000000 Total solver iterations: 2 Variable Value Reduced Cost Q 0.000000 12.51724 R 0.4482759 0.000000 S 1.275862 0.000000 Row Slack or Surplus Dual Price 1 6.068966 -1.000000 2 0.000000 -1.413793 3 11.24138 0.000000 4 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: 20.00000 Objective bound: 20.00000

Page 2: Lingo Syntax

Infeasibilities: 0.000000 Extended solver steps: 0 Total solver iterations: 0 Variable Value Reduced Cost Q 1.000000 12.00000 R 1.000000 5.000000 S 1.000000 3.000000 Row Slack or Surplus Dual Price 1 20.00000 -1.000000 2 1.000000 0.000000 3 1.000000 0.000000 4 0.000000 0.000000