Solving Linear Programming Problem in SymPy

1,777 views
Skip to first unread message

Shekhar Prasad Rajak

unread,
Dec 29, 2016, 9:23:51 AM12/29/16
to sympy
Hello,
This thread is about the solving Linear/Non linear Programming problem. This topic is related to Optimization Technique, Operations Research.
Linear programming (LP) (also called linear optimization) is a method to achieve the best
outcome (such as maximum profit or lowest cost) in a mathematical model whose requirements are represented by
linear relationships. Linear programming is a special case of mathematical programming (mathematical optimization).
Currently I don't see any method to solve these kinds of problems in SymPy. Most of the time we use simplex method or its
expansion to solve them.

Example:

Maximize z = 12x+40y
subjected to :
  x+y<=16
  x+3y<=36
  x<=10
  x>=0
  y>=0

find x,y and maximum value of z.
Soln : (x, y) = (0,12) and maxi value at this point is 480.

Let me know if there is already some way to solve these using SymPy methods or it is good idea to implement it.

Related links :

--
Shekhar

Jason Moore

unread,
Dec 29, 2016, 12:47:59 PM12/29/16
to sy...@googlegroups.com
Shekar,

Here is an example that uses sympy to let a user specify linear program optimization problems symbolically and then it is solved numerically:

https://github.com/biosustain/optlang

Here is another package I wrote that does NLP for optimal control systems.

https://github.com/csu-hmc/opty

--
You received this message because you are subscribed to the Google Groups "sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscribe@googlegroups.com.
To post to this group, send email to sy...@googlegroups.com.
Visit this group at https://groups.google.com/group/sympy.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/53960b94-87ee-4270-bee3-97e7917a8eca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shekhar Prasad Rajak

unread,
Dec 30, 2016, 12:53:32 PM12/30/16
to sympy
Thanks Jason for sharing the links. They are good.

--
Shekhar
To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.

Denis Akhiyarov

unread,
Jan 17, 2017, 10:29:53 PM1/17/17
to sympy
The de-facto standard for solving linear programming problems in Python are PuLP and Pyomo. Pyomo can also handle non-linear problems and even differential equations. In fact, Pyomo calls into SymPy for differentiation! Pyomo was heavily inspired by AMPL.
Now if you want to ensure convexity of your problem, then go for CVX(PY).
Recently scipy added linear programming, but I have not seen much use for it.

Shekhar Prasad Rajak

unread,
Jan 21, 2017, 11:37:40 PM1/21/17
to sympy
Thanks Denis. 

I personally feel that SymPy must have similar functions which uses(wrote with) internal methods of SymPy.

--
Shekhar

Donaldson Tan

unread,
Sep 5, 2023, 3:40:49 AM9/5/23
to sympy
Does Sympy have a backend to interface with Pyomo?

Chris Smith

unread,
Sep 5, 2023, 2:49:12 PM9/5/23
to sympy
There are now functions for doing linear programming in the `simplex.py`. Here is a similar question at SO with answer: https://stackoverflow.com/a/77045152/1089161

/c

Reply all
Reply to author
Forward
0 new messages