Comments (7)
Here is a hacky workaround:
julia> model = Model()
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: NO_OPTIMIZER
Solver name: No optimizer attached.
julia> @variable(model, x)
x
julia> c = @NLconstraint(model, exp(x + 1) <= 2)
exp(x + 1.0) - 2.0 ≤ 0
julia> println(model)
Feasibility
Subject to
exp(x + 1.0) - 2.0 ≤ 0
No suppose I want to replace constraint c
by a constraint where x
is substituted by x / z
where z
is a variable. This can be achieved as follows:
julia> @variable(model, z)
z
julia> expr = :(exp($x / $z + 1.0) - 2.0)
:(exp(x / z + 1.0) - 2.0)
julia> con = JuMP._NonlinearConstraint(JuMP._NonlinearExprData(model, expr), -Inf, 0.0)
JuMP._NonlinearConstraint(JuMP._NonlinearExprData(JuMP._Derivatives.NodeData[JuMP._Derivatives.NodeData(JuMP._Derivatives.CALL, 2, -1), JuMP._Derivatives.NodeData(JuMP._Derivatives.CALLUNIVAR, 12, 1), JuMP._Derivatives.NodeData(JuMP._Derivatives.CALL, 1, 2), JuMP._Derivatives.NodeData(JuMP._Derivatives.CALL, 5, 3), JuMP._Derivatives.NodeData(JuMP._Derivatives.MOIVARIABLE, 1, 4), JuMP._Derivatives.NodeData(JuMP._Derivatives.MOIVARIABLE, 2, 4), JuMP._Derivatives.NodeData(JuMP._Derivatives.VALUE, 1, 3), JuMP._Derivatives.NodeData(JuMP._Derivatives.VALUE, 2, 1)], [1.0, 2.0]), -Inf, 0.0)
julia> model.nlp_data.nlconstr[c.index.value] = con
JuMP._NonlinearConstraint(JuMP._NonlinearExprData(JuMP._Derivatives.NodeData[JuMP._Derivatives.NodeData(JuMP._Derivatives.CALL, 2, -1), JuMP._Derivatives.NodeData(JuMP._Derivatives.CALLUNIVAR, 12, 1), JuMP._Derivatives.NodeData(JuMP._Derivatives.CALL, 1, 2), JuMP._Derivatives.NodeData(JuMP._Derivatives.CALL, 5, 3), JuMP._Derivatives.NodeData(JuMP._Derivatives.MOIVARIABLE, 1, 4), JuMP._Derivatives.NodeData(JuMP._Derivatives.MOIVARIABLE, 2, 4), JuMP._Derivatives.NodeData(JuMP._Derivatives.VALUE, 1, 3), JuMP._Derivatives.NodeData(JuMP._Derivatives.VALUE, 2, 1)], [1.0, 2.0]), -Inf, 0.0)
julia> println(model)
Feasibility
Subject to
exp(x / z + 1.0) - 2.0 ≤ 0
from disjunctiveprogramming.jl.
I cannot guarantee that this will work, it just seems that it might; we've discussed that offline and tried to worked this through at the INFORMS Annual Meeting.
At the moment, this issue blocking for this package so it might be worth trying even if it using internal JuMP function and hence might break.
from disjunctiveprogramming.jl.
we've discussed that offline
Ah cool. Just checking
from disjunctiveprogramming.jl.
This will require rebuilding the model. We have no immediate plans to implement deletion of nonlinear constraints.
from disjunctiveprogramming.jl.
Yeah... that's what we'll have to do for now.
from disjunctiveprogramming.jl.
Awesome! Many thanks. I will start using your trick for the constraint reformulation.
from disjunctiveprogramming.jl.
I don't know how much @blegat has tested this or looked into it, but to clarify:
doing so is extremely unsupported and may break in any future JuMP release.
I'm also unsure if this breaks any internal assumptions JuMP makes around resolving nonlinear models, so this may silently return incorrect solutions.
from disjunctiveprogramming.jl.
Related Issues (20)
- Allow support for iterators in Boolean operators
- Bug: Big-M Reformulation for `MOI.EqualTo` constraints
- Using nothing for an empty disjunction HOT 1
- Implement more Reformulation Methods
- Big-M Tightness HOT 2
- Only disaggregate variables involved in disjunction constraints (Hull reformulation) HOT 2
- checking proposition expressions fails
- Error when adding disjunctions in a loop with EqualTo constraints
- Upcoming refactoring of JuMP's nonlinear API
- new constraints output for nonlinear models HOT 1
- Update code to access a Nonlinear constraint name when supported by JuMP HOT 6
- Checking variables in a constraint
- Leverage JuMP extension infrastructure
- `infer_bigm` without parsing expressions or using IntervalArithmetic
- Calculate BigM parameter for nonlinear constraints HOT 1
- Copy extension objects to support copying model HOT 1
- `check_logical_proposition` should be more robust HOT 1
- Look into Alternate CNF
- `@disjunction` macro requires a name to be passed to the disjunction HOT 1
- Interval arithmetic can't be applied to quadratic constraints to insert big M value
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.