BYU-PRISM / GEKKO

GEKKO Python for Machine Learning and Dynamic Optimization
https://machinelearning.byu.edu
Other
569 stars 102 forks source link

Invalid inequalities #151

Closed Mark531 closed 1 year ago

Mark531 commented 1 year ago

I've designed a simple MINP problem using this kind of inequalities: model.Equation(w[i - 1] <= w[i] for i in I if i)

But when solving the model, I get the folowing error:

invalid inequalities: z > x < y

That's true, if you take for instance x_0, it will be lesser than w_1, w_2, ..., w_n. The idea was to create a series of binary variables of this kind:

0 0 0 ... 0 1 1 1 ... 1

Is it possible to model it with gekko?

APMonitor commented 1 year ago

Use model.Equations([w[i - 1] <= w[i] for i in I if i]) to create multiple equations from a list comprehension. Issues on GitHub are typically for feature requests or bug reports. Please use StackOverflow with tag gekko for future syntax questions. https://stackoverflow.com/questions/tagged/gekko The response time is typically faster and it is easier to search for similar Q+A posts.