Re: n variables, diffrents upBounds

28 views
Skip to first unread message

Stuart Mitchell

unread,
Sep 2, 2020, 10:07:55 PM9/2/20
to pulp-or...@googlegroups.com
objective = sum(x * parameters["margin"][x]  for x in zip(x))

don't use zip
X = [LpVariable("x{}".format(i+1), lowBound = 0,  upBound = z[i], cat='Integer'  ) for i in range(len(lpVars))]
objective = sum(x * parameters["margin"][x]  for x in X)


Stuart Mitchell
PhD Engineering Science
Extraordinary Freelance Programmer and Optimisation Guru


On Thu, Sep 3, 2020 at 12:30 AM nicolas...@gmail.com <nicolas...@gmail.com> wrote:


Hello,

 This will be my last message for a few months

I'm setting my lp variables like this ( I need differents  upBound s, so I can't use
LpVariable.dicts(),I guess):

z=[40,80]
   x = [LpVariable("x{}".format(i+1), lowBound = 0,  upBound = z[i], cat='Integer'  ) for i in range(len(lpVars))]


How should  I write my objective function, , please :

objective = sum(x * parameters["margin"][x]  for x in zip(x))
prob +=  objective

is giving me
KeyError: (x1,)

The problem is that I can't use lpSum()
Thanks

--
New posters to this group are moderated which can take up to 48 hours, so please be patient if your first post takes a while to turn up.
---
You received this message because you are subscribed to the Google Groups "pulp-or-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pulp-or-discu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pulp-or-discuss/c0da92dc-630d-4d8c-81ec-782dfce7ed64n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages