2 Classes to create, solve, and make dinner for linear programs. Handles
3 integration with lp_solve.
10 # Add LP_SOLVE_PATH to our path. There is no point to this variable
11 # other than to make the site.addsitedir() line fit within 80
13 LP_SOLVE_PATH
= '/../lib/lp_solve'
14 site
.addsitedir(os
.path
.dirname(os
.path
.abspath(sys
.argv
[0])) + LP_SOLVE_PATH
)
16 from lp_solve
import *
19 # Constants denoting the three different types of (in)equalities.
20 # These are defined by lp_solve.
21 LEQ
= -1 # Less than or equal to.
23 GEQ
= 1 # Greater than or Equal to.
26 class LinearProgram(object):
28 Represents an instance of an lp_solve linear program.
32 self
.objective_function_coefficients
= []
33 self
.constraint_matrix
= []
35 self
.inequalities
= []
39 [v
,x
,duals
] = lp_solve(self
.objective_function_coefficients
,
40 self
.constraint_matrix
,