4 Solve an example problem with lp_solve.
11 # Basically, add '../src' to our path.
12 # Needed for the imports that follow.
13 site
.addsitedir(os
.path
.dirname(os
.path
.abspath(sys
.argv
[0])) + '/../src')
15 import LinearProgramming
18 lp
= LinearProgramming
.LinearProgram()
20 lp
.objective_function_coefficients
= [5, 100, 30, 10, 20, 300]
22 lp
.constraint_matrix
= [ [1,1,1,0,0,0],
28 lp
.inequalities
= ([LinearProgramming
.LEQ
] * 2) + ([LinearProgramming
.EQ
] * 3)
30 lp
.rhs
= [ 500, 600, 400, 300, 200 ]
32 [v
,x
,duals
] = lp
.solve()
34 print 'Optimal objective function value: ', v
35 print 'Optimal solution vector: ', x
36 print 'Duals: ', duals