X-FeedAbuse: http://nntpfeed.proxad.net/abuse.pl feeded by 78.192.65.63 Path: csiph.com!usenet.pasdenom.info!nntpfeed.proxad.net!news.muarf.org!news.roellig-ltd.de!open-news-network.org!border2.nntp.ams1.giganews.com!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'mention': 0.26; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'forgot': 0.30; 'code': 0.31; 'libraries': 0.31; 'subject:all': 0.32; 'url:python': 0.33; 'maybe': 0.34; 'etc': 0.35; 'there': 0.35; 'url:ie': 0.36; '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; 'interest': 0.64; 'dear': 0.65; 'charset:windows-1252': 0.65; 'received:as9105.com': 0.84; 'received:dsl.as9105.com': 0.84; 'received:dynamic.dsl.as9105.com': 0.84; 'subject:find': 0.84; 'zhang': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Python: How to find out values of all feasible x under constraints. Date: Sat, 16 May 2015 01:16:04 +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: 80-44-148-0.dynamic.dsl.as9105.com User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1431735384 news.xs4all.nl 2835 [2001:888:2000:d::a6]:44371 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90700 On 15/05/2015 13:35, Mark Lawrence wrote: > 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 > Forgot to mention this http://numberjack.ucc.ie/ Maybe of general interest see also http://www.csplib.org/ http://www.hakank.org/constraint_programming_blog/ -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence