Problem!!

B

Balaji

Hello everybody..

I have a problem!!!

suppose i want to define

c1=x(i)+y(i)<=b for i in s1 ------------ suppose it is the first
constraint..
c2=x(i)+y(i)<=b for i in s2------------- suppose it is the second
constraint..

now as i is indexed over s1 so is c1.. but what it does is it overites
the first constraint..

I guess there should be some problem with the iterators...

any help in this regard is apreciated..

Thanx

Balaji
 
M

Mike C. Fletcher

Balaji said:
Hello everybody..

I have a problem!!!

suppose i want to define

c1=x(i)+y(i)<=b for i in s1 ------------ suppose it is the first
constraint..
c2=x(i)+y(i)<=b for i in s2------------- suppose it is the second
constraint..

now as i is indexed over s1 so is c1.. but what it does is it overites
the first constraint..
You will likely need to define, (preferably with Python code), what you
are doing, what you are expecting, and what is going wrong (what you
actually get). If I'm understanding you correctly, the problem is that
you want to apply these two constraints to the lists s1 and s2 something
like:

c1 = [ result for result in [ x(i) + y(i) for i in s1] if result <= b]
c2 = [ result for result in [ x(i) + y(i) for i in s2] if result <= b]

but it could just as readily be that you want:

c1 = [ (x(i)+y(i)<=b) for i in s1 ]
c2 = [ (x(i)+y(i)<=b) for i in s2 ]

just to be clear, that expression will yield a list of True/False
values, i.e. whether the sum of the results of the two functions on i is
less than b. Adding brackets around the first part of the expression:

( x(i)+y(i) ) <= b

will help maintainers of the code by eliminating the need for them to
verify the order of operations.

Good luck,
Mike

_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,970
Members
47,537
Latest member
BellCorone

Latest Threads

Top