Comments (9)
from mathoptinterface.jl.
Here's a pure MOI
julia> import MathOptInterface as MOI
julia> src = MOI.Utilities.UniversalFallback(MOI.Utilities.Model{Float64}())
MOIU.UniversalFallback{MOIU.Model{Float64}}
fallback for MOIU.Model{Float64}
julia> x = MOI.add_variable(src)
MOI.VariableIndex(1)
julia> MOI.add_constraint(src, x, MOI.GreaterThan(1.0))
MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.GreaterThan{Float64}}(1)
julia> c = MOI.add_constraint(src, 2.0 * x, MOI.EqualTo(3.0))
MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}(1)
julia> MOI.Utilities.@model(
Model2452,
(),
(),
(MOI.Nonnegatives, MOI.Zeros),
(),
(),
(),
(MOI.VectorOfVariables,),
(MOI.VectorAffineFunction,)
)
MathOptInterface.Utilities.GenericModel{T, MathOptInterface.Utilities.ObjectiveContainer{T}, MathOptInterface.Utilities.VariablesContainer{T}, Model2452FunctionConstraints{T}} where T
julia> function MOI.supports_constraint(
::Model2452{T},
::Type{MOI.VariableIndex},
::Type{
<:Union{
MOI.GreaterThan{T},
MOI.LessThan{T},
MOI.EqualTo{T},
MOI.Interval{T},
MOI.ZeroOne,
MOI.Integer,
},
},
) where {T}
return false
end
julia> function MOI.supports_constraint(
::Model2452{T},
::Type{MOI.VectorOfVariables},
::Type{MOI.Reals},
) where {T}
return false
end
julia> dest = MOI.instantiate(Model2452{Float64}; with_bridge_type = Float64)
MOIB.LazyBridgeOptimizer{MOIU.GenericModel{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, Model2452FunctionConstraints{Float64}}}
with 0 variable bridges
with 0 constraint bridges
with 0 objective bridges
with inner model MOIU.GenericModel{Float64, MOIU.ObjectiveContainer{Float64}, MOIU.VariablesContainer{Float64}, Model2452FunctionConstraints{Float64}}
julia> index_map = MOI.copy_to(dest, src)
MathOptInterface.Utilities.IndexMap with 3 entries:
MOI.VariableIndex(1) => MOI.VariableIndex(-1)
ConstraintIndex{VariableIndex, … => ConstraintIndex{VariableIndex, GreaterThan{Float64}}(-1)
ConstraintIndex{ScalarAffineFun… => ConstraintIndex{ScalarAffineFunction{Float64}, EqualTo{Float64…
julia> MOI.get(dest, MOI.ConstraintSet(), index_map[c])
MathOptInterface.EqualTo{Float64}(1.0)
I can't help but think that many Variable
bridges were a bad idea, particularly Vectorize
ones with a non-zero constant.
from mathoptinterface.jl.
I think the issue is the interaction of the variable and constraint bridges, but it gets pretty complicated following the call_in_context
.
from mathoptinterface.jl.
Thanks for following up on that so quick!
What I was missing in trying to build a minimal example was that x
should have a non-zero lower bound (I think, based on your example). Namely, I did not encounter any issue when x
was declared as @variable(model, x >= 0)
.
I think this echoes
particularly Vectorize ones with a non-zero constant
from mathoptinterface.jl.
A hacky work-around for now is remove_bridge
:
julia> using JuMP, Clarabel
julia> model = Model(Clarabel.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: Clarabel
julia> MOI.Bridges.remove_bridge(
backend(model).optimizer,
MOI.Bridges.Variable.VectorizeBridge{Float64},
)
julia> set_silent(model)
julia> @variable(model, x >= 1)
x
julia> @constraint(model, c, 2x == 3)
c : 2 x = 3
julia> optimize!(model)
julia> value(x)
1.4999999999999996
julia> b = normalized_rhs(c)
3.0
julia> set_normalized_rhs(c, b)
julia> optimize!(model)
julia> value(x)
1.4999999999999996
from mathoptinterface.jl.
I need to discuss this with @blegat, but he's a bit busy this week.
from mathoptinterface.jl.
@blegat I think this one is for you. I really don't understand the ins and outs of call_in_context
. I poke one bit and some unrelated stuff starts erroring.
from mathoptinterface.jl.
I swear I tested this:
julia> using JuMP, Clarabel
julia> model = Model(Clarabel.Optimizer)
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: Clarabel
julia> set_silent(model)
julia> @variable(model, x >= 1)
x
julia> @constraint(model, c, 2x == 3)
c : 2 x = 3
julia> optimize!(model)
julia> value(x)
1.4999999999999996
julia> b = normalized_rhs(c)
3.0
julia> set_normalized_rhs(c, b)
julia> optimize!(model)
julia> value(x)
0.9999999995620605
(clarabel) pkg> st
Status `/private/tmp/clarabel/Project.toml`
[61c947e1] Clarabel v0.7.1
[4076af6c] JuMP v1.21.0
[b8f27783] MathOptInterface v1.27.1 `https://github.com/jump-dev/MathOptInterface.jl.git#master`
from mathoptinterface.jl.
Closed by #2472
from mathoptinterface.jl.
Related Issues (20)
- [FileFormats.MPS] Problem when reading generated MPS with CPLEX HOT 3
- [Nonlinear] add initialize timer HOT 1
- [FileFormats.NL] cannot read models with S section
- [FileFormats.NL] write free rows
- ReverseAD doesn't error for out-of-bound writes
- MOI slow to import and precompile HOT 4
- Improve performance of String names
- Reading .mps file with NAME HOT 2
- Add support for nonlinear sign(x) HOT 2
- Support for complex vector cones HOT 35
- [FileFormats.CBF] add support for PSDVAR HOT 31
- [FileFormats.CBF] keep track of variables after reading and writing HOT 3
- Variational inequalities HOT 13
- [FileFormats.MPS] wrong result after parsing file HOT 10
- [FileFormats.MPS] another potential wrong result HOT 13
- [Nonlinear] detect common subexpressions HOT 5
- Order of columns during copy_to HOT 1
- Debug performance issue in Nonlinear submodule HOT 8
- Return type after querying attributes of empty vectors
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 mathoptinterface.jl.