Howto add an objective with a loop? #785
Unanswered
ben-strasser
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Thanks for the nice library!
How do I add an objective with a loop? I currently have:
It seems to work.
lp.solve()
does what I want. However, it seems wrong to useLpConstraint
to create an objective. Also the objective function looks wrong when I dump the lp withprint(lp)
. It states:which is clearly a constraint because of the
=0
printed.When I do
The print changes to:
So the two are definitely not the same.
What is the intended way to set such an objective function using a loop without
lpSum
?The reason I do not want to use
lpSum
is because my logic is way more complex than in the toy example above and even in the toy example, IMO, the one-liner withlpSum
is difficult to read.Beta Was this translation helpful? Give feedback.
All reactions