Pyomo "OR* Constraints?

102 views
Skip to first unread message

Jonathan Nowacki

unread,
Dec 13, 2023, 5:18:28 PM12/13/23
to Pyomo Forum
Is there a way to make constraints to be 0 or >=8?   In other words, the number can be 0,8,9,10...to infinity?


Solver Max

unread,
Dec 14, 2023, 12:31:03 PM12/14/23
to Pyomo Forum
Pyomo includes the Generalized Disjunctive Programming (GDP) extension, which does OR constraints (amongst many other things).
Or you can create OR constraints yourself, using the BigM method.

We've recently published a couple of articles using both of those techniques, which might be useful:

Tomasz Gorecki

unread,
Dec 15, 2023, 10:41:05 AM12/15/23
to Pyomo Forum
strictly speaking bigM will not work if you really want you variable (say x) to have no upper bound. if you have a known upper bound M
you would use
x<=M*delta
x>= 8*delta
delta in [0,1] so that delta =0 gives x=0 and delta=1 gives 8<=x<=M
The lower M the better to avoid numerical issues
I am not sure what GDP would actually do to enforce the same, curious if someone can explain !

Yohan Fleuriot

unread,
Dec 17, 2023, 1:19:56 AM12/17/23
to pyomo...@googlegroups.com
Hi!
I would introduce a binary variable and an integer variable and combine them in an expression:
m = ConcreteModel()
m.bin = Var(within=Binary)
m.z = Var(within=NonNegativeIntegers)
m.x = Expression(expr= lambda A: A.bin*(A.z + 8))

Yohan Fleuriot 



--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyomo-forum/2d44a53d-3034-4da1-94db-353bf2d30d92n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages