Comments (6)
Following up on this, I have run into a use case (the case study behind the FOCAPO-CPC paper) where using one variable significantly improves the performance for a linear model solved with Gurobi (i.e., the pre-solve is not able to reduce the problem size automatically). Hence, I will try to put together a PR soon to try to implement this feature.
from disjunctiveprogramming.jl.
Hi @schlichtanders , when adding a disjunction, the Exactly 1 logical variable is selected constraint is added (unless exactly1 = false
in the disjunction macro). If you have a disjunction with 2 options, you will have Select exactly 1 option (y1 or y2) which will be formulated to the algebraic constraint y1 + y2 = 1
. During presolve, the solver will likely replace y2
with 1-y1
, which is essentially what you are describing. That way when y1 = 1
the first disjunct is selected, and when y1 = 0
(meaning y2 = 1
) the second disjunct is selected.
So presolve will likely take care of reducing the variables from 2 to 1.
from disjunctiveprogramming.jl.
@hdavid16 I think it may be worth keeping this feature request open to only use one logical variable when there are two disjuncts. For linear/quadratic problems that are compatible with solver like Gurobi I agree that a presolver will likely take care of the redundancy. However, for general MINLP solvers I don't think this will be the case for most solvers. Hence, for nonlinear problems, I think this would be a worthy feature addition.
from disjunctiveprogramming.jl.
I don't think we should support it. This would complicate the syntax a bit. How would you define the second disjunct constraint? @constraint(m, x <= b, Disjunct(\neg Y))
? We would have to support expressions inside the Disjunct
tag. I don't know if it is worth taking such a shortcut.
from disjunctiveprogramming.jl.
I don't think we should support it. This would complicate the syntax a bit.... I don't know if it is worth taking such a shortcut.
I think this feature addition would be more than a convenient shortcut, but rather a way to construct better formulations.
How would you define the second disjunct constraint?
@constraint(m, x <= b, Disjunct(\neg Y))
? We would have to support expressions inside theDisjunct
tag.
It would be a relatively simply feature addition to have Disjunct accept \neg Y
and only that. Then we could add a flag to the data structure to know if the negation should be used on the indicator or not.
Alternatively, we could keep the user API the same and instead check when reformulating if there are only 2 disjuncts. If there are then we can reformulate using only one indicator variable instead of two. This could be an opt-in feature, to prevent any surprises.
from disjunctiveprogramming.jl.
Yeah, this could be a behind the scenes feature because it will only work if the disjunction is not Nested and the exactly1 relation is enforced on the logical variables. So letting the user do this has some gotchas
from disjunctiveprogramming.jl.
Related Issues (20)
- Have `@disjunction` automatically add exactly one constraints with a keyword argument HOT 10
- Add a short alias for `LogicalVariable`
- Replace DisjunctConstraint with Disjunct
- Support the new `:=` logical constraint syntax used by JuMP HOT 1
- Generalize to `AbstractModel`s
- Restore `JuMP.` prefixes HOT 2
- Add printing for references
- Support `JuMP.value` for `LogicalVariableRef`
- Support Methods to Query and Modify Disjunct Constraints
- Support Cardinality Constraints with Logical Expressions HOT 2
- Add Summarizing Printing Methods
- Update the disjunction macro to use new JuMP extension API HOT 3
- Disjunct constraints cannot contain binary or integer variables. HOT 17
- Having a set of logical variables Y, is it possible to constraint them all to be equal? HOT 7
- Handle printing empty disjuncts HOT 1
- Error ... is not a valid logical variable reference. HOT 2
- [Documentation Request] What does `@disjunction(model, Y, exactly1=false)` actually do? HOT 15
- Is it possible to use this package to optimize the selection of indices for a vector? HOT 2
- Support cardinality clauses within more complex logic HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from disjunctiveprogramming.jl.