Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #90672
| Path | csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'url:pypi': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'skip:[ 20': 0.04; 'subject:Python': 0.06; 'pypi': 0.07; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:How': 0.10; 'python': 0.11; 'language.': 0.14; 'appreciated!': 0.16; 'code?': 0.16; 'feasible': 0.16; 'hint': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:under': 0.16; 'subject:values': 0.16; 'x_1': 0.16; 'x_2': 0.16; 'language': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'example': 0.22; 'header:User-Agent:1': 0.23; 'own.': 0.24; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'code': 0.31; 'libraries': 0.31; 'subject:all': 0.32; 'url:python': 0.33; 'etc': 0.35; 'there': 0.35; 'url:org': 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'our': 0.64; 'dear': 0.65; 'charset:windows-1252': 0.65; 'subject:find': 0.84; 'zhang': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
| Subject | Re: Python: How to find out values of all feasible x under constraints. |
| Date | Fri, 15 May 2015 13:35:18 +0100 |
| References | <12da2c70-fd4e-430b-83d2-fad4ac1e3f8f@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | host-78-147-26-70.as13285.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 |
| In-Reply-To | <12da2c70-fd4e-430b-83d2-fad4ac1e3f8f@googlegroups.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.35.1431693331.17265.python-list@python.org> (permalink) |
| Lines | 33 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1431693331 news.xs4all.nl 2967 [2001:888:2000:d::a6]:48720 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:90672 |
Show key headers only | View raw
On 15/05/2015 04:58, Xiang Zhang wrote: > Dear all, > > I am writing a code using Python now. > > I want to know how to find out values of all feasible x under constraints. > > x = [x_1, x_2, x_3,..., x_10] > > > constraints: > x_i = 0,1,2,3 or 4, where i=1,2,....10 > x_1 + x_2 + x_3 +...+x_10 <= 15 > > How to find out all the feasible solutions x (domain of x) using python, like [0,0,0,0,0,0,0,0,0,0], [1,1,1,1,1,1,1,1,1,1] etc ? What should be the code? > > Any hint or help would be highly appreciated! > > Sincerely, > > Xiang Zhang > There are several constraint libraries on pypi if you don't want to roll your own. See for example https://pypi.python.org/pypi/python-constraint/1.2 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Python: How to find out values of all feasible x under constraints. Xiang Zhang <zhangxiangsunny@gmail.com> - 2015-05-14 20:58 -0700 Re: Python: How to find out values of all feasible x under constraints. Peter Otten <__peter__@web.de> - 2015-05-15 09:47 +0200 Re: Python: How to find out values of all feasible x under constraints. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-15 13:35 +0100 Re: Python: How to find out values of all feasible x under constraints. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-16 01:16 +0100
csiph-web