Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53525
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <vitaletom1@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'algorithm': 0.04; 'interfaces': 0.04; 'column': 0.07; 'conventions': 0.07; 'element': 0.07; 'variables': 0.07; 'conventions.': 0.09; 'linear': 0.09; 'positioned': 0.09; 'variables.': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; "wouldn't": 0.14; '-1.': 0.16; '-2.': 0.16; 'ass': 0.16; 'columns': 0.16; 'easier.': 0.16; 'kern': 0.16; 'programmatic': 0.16; 'reproduce': 0.16; 'solver': 0.16; 'solver,': 0.16; 'third,': 0.16; 'to:addr:robert.kern': 0.16; 'to:name:robert kern': 0.16; 'tommy': 0.16; "variable's": 0.16; 'language': 0.16; 'wrote:': 0.18; 'options.': 0.19; 'properly': 0.19; 'solution.': 0.20; 'work,': 0.20; 'help.': 0.21; '>>>': 0.22; 'programming': 0.22; '(in': 0.22; 'cc:addr:python.org': 0.22; 'header:User- Agent:1': 0.23; 'looks': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; "i've": 0.25; 'compiled': 0.26; 'right.': 0.26; 'this:': 0.26; 'second': 0.26; 'excel': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'am,': 0.29; 'robert': 0.30; "i'm": 0.30; '(which': 0.31; 'code': 0.31; 'getting': 0.31; '>>>>': 0.31; 'bunch': 0.31; 'doc': 0.31; 'second,': 0.31; 'anyone': 0.31; 'class': 0.32; 'this.': 0.32; 'figure': 0.32; 'run': 0.32; 'url:python': 0.33; 'sources': 0.33; 'third': 0.33; 'problem': 0.35; 'basic': 0.35; "can't": 0.35; 'except': 0.35; 'something': 0.35; 'case,': 0.35; 'convert': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'representing': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'so,': 0.37; 'too': 0.37; 'represent': 0.38; 'thank': 0.38; 'displays': 0.38; 'rather': 0.38; 'does': 0.39; 'itself': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'read': 0.60; 'easy': 0.60; 'is.': 0.60; 'simple,': 0.60; "you're": 0.61; 'show': 0.63; 'choose': 0.64; 'different': 0.65; 'spot': 0.65; 'to:addr:gmail.com': 0.65; 'between': 0.67; 'sound': 0.68; 'results': 0.69; '11.': 0.74; 'column.': 0.84; 'forced': 0.84; 'fourth': 0.84; 'maximized': 0.84; 'pain': 0.84; 'vba': 0.84; 'luck': 0.93; 'modelling': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:newsgroups:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=W58/nkGgP6xvsRAuhOMPgQZR6BhUHMyP6QfgY2si2KQ=; b=nUWqd4fRuQ0mXv+h60qDWcsphtPV22ajcgFA9nXyXSCjcNVgiKerMSL5PtkyiMjShW oK9GU6cnHMdApR3xW9ioKlo9XCNo+UEBEurUXHYMc5MbxgLFcOxxIdYoLHQAVUkCGuWt KMLmMVfEZ08ADiAjpmCkld/l9wY9WatyCQU7o8FfYfuHjCXPB4N17z7/QXZR5/YsoSB9 TiDCrledVw8OtSv5J/FzheAY1wrEMKwRVGd+AKonkqRrDlK9bx7gR2IsyD8CaUwWVx5c 41jTd+e7ZX/5S5wIhLUqbfYukk5MqLT6ET7iEuFoVuQdXmwDz7MX+gsBXf9gfxjLbgG1 LVWA== |
| X-Received | by 10.220.140.69 with SMTP id h5mr24385524vcu.0.1378148391870; Mon, 02 Sep 2013 11:59:51 -0700 (PDT) |
| Date | Mon, 02 Sep 2013 14:59:50 -0400 |
| From | Tommy Vee <vitaletom1@gmail.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 |
| MIME-Version | 1.0 |
| Newsgroups | comp.lang.python |
| To | Robert Kern <robert.kern@gmail.com> |
| Subject | Re: Simplex Algorithm |
| References | <1PRUt.242963$ZD2.40442@fx19.iad> <mailman.477.1378115748.19984.python-list@python.org> <5224A963.4040304@xxxxxx.xxx> <mailman.496.1378136639.19984.python-list@python.org> |
| In-Reply-To | <mailman.496.1378136639.19984.python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.512.1378148394.19984.python-list@python.org> (permalink) |
| Lines | 87 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1378148394 news.xs4all.nl 15908 [2001:888:2000:d::a6]:60822 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:53525 |
Show key headers only | View raw
On 9/2/2013 11:43 AM, Robert Kern wrote: > On 2013-09-02 16:06, Tommy Vee wrote: >> On 9/2/2013 5:55 AM, Robert Kern wrote: >>> On 2013-09-02 02:26, Tommy Vee wrote: >>>> Anyone know where I can get an easy to use Python class or algorithm >>>> for the >>>> Simplex optimization algorithm? I've tried the one in the link below, >>>> but I >>>> can't figure out if a) I'm using it properly, or b) where to get the >>>> solution. >>>> BTW, I tried some test scenarios using MS Excel's "Solver" and just >>>> can't get >>>> this algorithm to match Excel's results (which is spot on). >>>> >>>> http://taw9.hubpages.com/hub/Simplex-Algorithm-in-Python >>>> >>>> BTW, if I can't something to work, I'm going to be forced to use the >>>> VBA >>>> programmatic Excel interface. That wouldn't be too bad, but the data >>>> comes from >>>> a DB and getting it properly positioned to use Excel's "Solver" is very >>>> painful. A Python approach would be much cleaner. >>> >>> Can you show some of the test scenarios that you tried? There are >>> different conventions in how to represent a linear programming problem, >>> and different solvers may choose different conventions. You may have to >>> convert between representations. >>> >>> You may have better luck with the PuLP interface: >>> >>> https://pypi.python.org/pypi/PuLP >>> >>> PuLP itself is just a modelling language rather than a solver, but the >>> sources do contain compiled binaries for the CoinMP solver so it will >>> work out-of-box on popular platforms, like Windows. >>> >>> https://projects.coin-or.org/CoinMP >>> >> >> Thank you, I will definitely look at these and other options. BTW, >> try the test >> scenario in the link I sent. Very simple, only 3 variables. >> >> Maximize: 2x+3y+2z >> >> Constraints: 2x+y+z <=4, x+2y+z <=7, z <= 5 >> >> The algorithm displays the Tableau after each pivot, but where is the >> answer for >> x, y and z? > > You will have to read up on the Dantzig Simplex Algorithm to learn how > to read off the results from the final tableau. My understanding is that > you look at the columns representing the basic variables (in this case, > the second, third, and fourth columns represent x, y, and z, > respectively). If the column is all 0s except for a single 1, then the > row with the 1 has the variable's value in the rightmost column. If the > column has other values in it, then the variable's value is 0. > >> When I run this in Excel's Solver, I get x=0, y=3, z=1. which is >> indeed the >> maximized solution (11). > > The final tableau for this problem looks like this: > > [[ 1. 1. 0. 0. 1. 1. 0. 11.] > [ 0. 3. 0. 1. 2. -1. 0. 1.] > [ 0. -1. 1. 0. -1. 1. 0. 3.] > [ 0. -3. 0. 0. -2. 1. 1. 4.]] > > So, for x, we look in the second column and notice that it has a bunch > of different values in it, so x=0. > > For y, we look in the third column and see that it has its single 1 in > the third row. Looking all the way on the right for that row, we get a 3. > > For z, we look in the fourth column and see that it has its single 1 in > the second row. Looking all the way on the right for that row, we get a 1. > > So this solver does reproduce the result x=0, y=3, z=1. The maximized > solution is in the upper-rightmost element of the tableau, 11. > > Sound like a pain in the ass to code up that logic? It is. PuLP and > other industrial grade solver interfaces won't make you go through this. > You nailed it. Thanks for help. And you're right. This is too painful, I just read the PuLP doc and it may be a lot easier.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Simplex Algorithm Tommy Vee <xxxxx@xxxxxx.xxx> - 2013-09-01 21:26 -0400
Re: Simplex Algorithm Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2013-09-02 09:06 +0100
Re: Simplex Algorithm Tommy Vee <xxxxx@xxxxxx.xxx> - 2013-09-02 10:42 -0400
Re: Simplex Algorithm Tommy Vee <vitaletom1@gmail.com> - 2013-09-02 10:42 -0400
Re: Simplex Algorithm Robert Kern <robert.kern@gmail.com> - 2013-09-02 10:45 +0100
Re: Simplex Algorithm Robert Kern <robert.kern@gmail.com> - 2013-09-02 10:55 +0100
Re: Simplex Algorithm Tommy Vee <xxxxx@xxxxxx.xxx> - 2013-09-02 11:06 -0400
Re: Simplex Algorithm Robert Kern <robert.kern@gmail.com> - 2013-09-02 16:43 +0100
Re: Simplex Algorithm Tommy Vee <xxxxx@xxxxxx.xxx> - 2013-09-02 14:59 -0400
Re: Simplex Algorithm Tommy Vee <vitaletom1@gmail.com> - 2013-09-02 14:59 -0400
Re: Simplex Algorithm Tommy Vee <vitaletom1@gmail.com> - 2013-09-02 11:06 -0400
Re: Simplex Algorithm Tony the Tiger <tony@tiger.invalid> - 2013-09-16 13:47 -0500
csiph-web