Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed4a.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.06; 'problem?': 0.07; 'received:67.192': 0.09; 'received:67.192.241': 0.09; 'received:dfw.emailsrvr.com': 0.09; 'python': 0.11; 'wrote': 0.14; 'question.': 0.14; 'inputs': 0.16; 'luck,': 0.16; 'nodes.': 0.16; 'solver.': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'basically': 0.19; 'everyone,': 0.19; 'input': 0.22; 'header:User-Agent:1': 0.23; 'received:emailsrvr.com': 0.24; 'fine': 0.24; '(or': 0.24; 'question': 0.24; 'received:(smtp server)': 0.26; 'header:In- Reply-To:1': 0.27; 'am,': 0.29; "i'm": 0.30; 'code': 0.31; 'gary': 0.31; 'subject:skip:i 10': 0.31; 'running': 0.33; 'could': 0.34; 'but': 0.35; 'subject:?': 0.36; 'thank': 0.38; 'to:addr:python- list': 0.38; 'rather': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'most': 0.60; 'forum': 0.61; 'email addr:gmail.com': 0.63; 'kind': 0.63; 'sum': 0.64; 'more': 0.64; 'answer.': 0.68; 'below.': 0.71; 'subject:this': 0.83 X-Virus-Scanned: OK Date: Tue, 10 Jun 2014 13:06:18 -0700 From: Gary Herron User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Is this sort of a constraint implementable in Python? References: <7d4f1623-35c1-42b5-bbbb-a4a045b60b19@googlegroups.com> In-Reply-To: <7d4f1623-35c1-42b5-bbbb-a4a045b60b19@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1402431103 news.xs4all.nl 2920 [2001:888:2000:d::a6]:48524 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:73121 On 06/10/2014 02:12 AM, varun7rs@gmail.com wrote: > Hello Everyone, > > I'm working on a python code to input matrices into CPLEX solver. I have most of my code running fine but as of now, I don't know how to express this constraint. My objective is to minimize the number of nodes. I have got one of the weirdest looking constraints which I don't know how to express in Python because python basically takes matrices and inputs them into cplex. My constraint is as below. This was what I wrote in AMPL > > minimize phy_nodes: sum {w in PHY_NODES} x_ns[w] ; > > s.t. Phy_nodes_Eq{w in PHY_NODES, dns in DEMAND}: > x_ns[w] = 1 ==> x_SGW[dns, w] + x_PGW[dns, w] + x_MME[dns, w] + x_IMS[dns, w] + x_PoP[dns, w] >= 1 > else x_SGW[dns, w] + x_PGW[dns, w] + x_MME[dns, w] + x_IMS[dns, w] + x_PoP[dns, w] = 0; > Could you help me fix this problem? > > Thank You This is more a CPLEX question than a Python question. (Or rather a question about some Python/Cplex interface.) Do you have access to any kind of a CPLEX forum or a Cplex-via-Python forum? I think that's much more likely to get you an answer. Luck, Gary Herron