Skip to content

Commit

Permalink
Simplify linear programming example.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmtroffaes committed Sep 14, 2024
1 parent 3725bc4 commit 3ad1687
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions docs/source/linprog.rst
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
.. testsetup::

import cdd
import cdd.gmp
from fractions import Fraction

Solving Linear Programs
=======================

>>> mat = cdd.gmp.matrix_from_array([[Fraction(4, 3),-2,-1],[Fraction(2, 3),0,-1],[0,1,0],[0,0,1]])
>>> mat.obj_type = cdd.LPObjType.MAX
>>> mat.obj_func = (0,3,4)
>>> mat.rep_type = cdd.RepType.INEQUALITY
>>> print(mat)
H-representation
begin
4 3 rational
4/3 -2 -1
2/3 0 -1
0 1 0
0 0 1
end
maximize
0 3 4
>>> print(mat.obj_func)
[Fraction(0, 1), Fraction(3, 1), Fraction(4, 1)]
>>> lp = cdd.gmp.linprog_from_matrix(mat)
>>> array = [[Fraction(4, 3),-2,-1],[Fraction(2, 3),0,-1],[0,1,0],[0,0,1],[0,3,4]]
>>> lp = cdd.gmp.linprog_from_array(array, obj_type=cdd.LPObjType.MAX)
>>> cdd.gmp.linprog_solve(lp)
>>> lp.status == cdd.LPStatusType.OPTIMAL
True
Expand Down

0 comments on commit 3ad1687

Please sign in to comment.