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
Uh oh!
There was an error while loading. Please reload this page.
-
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 useLpConstraintto 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
=0printed.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
lpSumis because my logic is way more complex than in the toy example above and even in the toy example, IMO, the one-liner withlpSumis difficult to read.Beta Was this translation helpful? Give feedback.
All reactions