-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Failure with CachingOptimizer #2384
Comments
Here's a reproducible example: julia> import MathOptInterface as MOI
julia> import CSDP
julia> inner = MOI.instantiate(CSDP.Optimizer; with_bridge_type = Float64)
MOIB.LazyBridgeOptimizer{MOIU.CachingOptimizer{CSDP.Optimizer, MOIU.UniversalFallback{MOIU.Model{Float64}}}}
with 0 variable bridges
with 0 constraint bridges
with 0 objective bridges
with inner model MOIU.CachingOptimizer{CSDP.Optimizer, MOIU.UniversalFallback{MOIU.Model{Float64}}}
in state EMPTY_OPTIMIZER
in mode AUTOMATIC
with model cache MOIU.UniversalFallback{MOIU.Model{Float64}}
fallback for MOIU.Model{Float64}
with optimizer CSDP.Optimizer
julia> MOI.set(inner, MOI.Silent(), true)
julia> model = MOI.Utilities.CachingOptimizer(MOI.Utilities.Model{Float64}(), inner)
MOIU.CachingOptimizer{MOIB.LazyBridgeOptimizer{MOIU.CachingOptimizer{CSDP.Optimizer, MOIU.UniversalFallback{MOIU.Model{Float64}}}}, MOIU.Model{Float64}}
in state EMPTY_OPTIMIZER
in mode AUTOMATIC
with model cache MOIU.Model{Float64}
with optimizer MOIB.LazyBridgeOptimizer{MOIU.CachingOptimizer{CSDP.Optimizer, MOIU.UniversalFallback{MOIU.Model{Float64}}}}
with 0 variable bridges
with 0 constraint bridges
with 0 objective bridges
with inner model MOIU.CachingOptimizer{CSDP.Optimizer, MOIU.UniversalFallback{MOIU.Model{Float64}}}
in state EMPTY_OPTIMIZER
in mode AUTOMATIC
with model cache MOIU.UniversalFallback{MOIU.Model{Float64}}
with 1 optimizer attribute
fallback for MOIU.Model{Float64}
with optimizer CSDP.Optimizer
julia> x = MOI.add_variables(model, 2)
2-element Vector{MathOptInterface.VariableIndex}:
MOI.VariableIndex(1)
MOI.VariableIndex(2)
julia> MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
julia> f = 1.0 * x[1] + 2.0 * x[2]
0.0 + 1.0 MOI.VariableIndex(1) + 2.0 MOI.VariableIndex(2)
julia> MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
julia> MOI.add_constraint.(model, x, MOI.GreaterThan(1.0))
2-element Vector{MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.GreaterThan{Float64}}}:
MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.GreaterThan{Float64}}(1)
MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.GreaterThan{Float64}}(2)
julia> MOI.optimize!(model)
julia> MOI.delete(model, x[1])
julia> MOI.optimize!(model)
julia> print(inner)
Minimize ScalarAffineFunction{Float64}:
1.0 + 2.0 v[-2]
Subject to:
VariableIndex-in-GreaterThan{Float64}
v[-2] >= 1.0
julia> @assert isapprox(MOI.get(model, MOI.ObjectiveValue()), 2.0)
ERROR: AssertionError: isapprox(MOI.get(model, MOI.ObjectiveValue()), 2.0)
Stacktrace:
[1] top-level scope
@ REPL[283]:1 Note that the objective of |
The other issue is: julia> using Test, Revise
julia> import MathOptInterface as MOI
julia> import CSDP
julia> inner = MOI.instantiate(CSDP.Optimizer, with_bridge_type = Float64)
MOIB.LazyBridgeOptimizer{MOIU.CachingOptimizer{CSDP.Optimizer, MOIU.UniversalFallback{MOIU.Model{Float64}}}}
with 0 variable bridges
with 0 constraint bridges
with 0 objective bridges
with inner model MOIU.CachingOptimizer{CSDP.Optimizer, MOIU.UniversalFallback{MOIU.Model{Float64}}}
in state EMPTY_OPTIMIZER
in mode AUTOMATIC
with model cache MOIU.UniversalFallback{MOIU.Model{Float64}}
fallback for MOIU.Model{Float64}
with optimizer CSDP.Optimizer
julia> model = MOI.Utilities.CachingOptimizer(MOI.Utilities.Model{Float64}(), inner)
MOIU.CachingOptimizer{MOIB.LazyBridgeOptimizer{MOIU.CachingOptimizer{CSDP.Optimizer, MOIU.UniversalFallback{MOIU.Model{Float64}}}}, MOIU.Model{Float64}}
in state EMPTY_OPTIMIZER
in mode AUTOMATIC
with model cache MOIU.Model{Float64}
with optimizer MOIB.LazyBridgeOptimizer{MOIU.CachingOptimizer{CSDP.Optimizer, MOIU.UniversalFallback{MOIU.Model{Float64}}}}
with 0 variable bridges
with 0 constraint bridges
with 0 objective bridges
with inner model MOIU.CachingOptimizer{CSDP.Optimizer, MOIU.UniversalFallback{MOIU.Model{Float64}}}
in state EMPTY_OPTIMIZER
in mode AUTOMATIC
with model cache MOIU.UniversalFallback{MOIU.Model{Float64}}
fallback for MOIU.Model{Float64}
with optimizer CSDP.Optimizer
julia> x = MOI.add_variable(model)
MOI.VariableIndex(1)
julia> c1 = MOI.add_constraint(model, x, MOI.GreaterThan(1.0))
MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.GreaterThan{Float64}}(1)
julia> c2 = MOI.add_constraint(model, x, MOI.LessThan(1.0))
MathOptInterface.ConstraintIndex{MathOptInterface.VariableIndex, MathOptInterface.LessThan{Float64}}(1)
julia> MOI.optimize!(model)
CSDP 6.2.0
This is a pure primal feasibility problem.
This is a pure dual feasibility problem.
Iter: 0 Ap: 0.00e+00 Pobj: 0.0000000e+00 Ad: 0.00e+00 Dobj: 0.0000000e+00
Iter: 1 Ap: 9.00e-01 Pobj: 0.0000000e+00 Ad: 1.00e+00 Dobj: 0.0000000e+00
Success: SDP solved
Primal objective value: 0.0000000e+00
Dual objective value: 0.0000000e+00
Relative primal infeasibility: 5.00e-11
Relative dual infeasibility: 0.00e+00
Real Relative Gap: 0.00e+00
XZ Relative Gap: 7.50e-10
DIMACS error measures: 5.00e-11 0.00e+00 0.00e+00 0.00e+00 0.00e+00 7.50e-10
julia> MOI.get(model, MOI.VariablePrimal(), x)
1.000000000025
julia> MOI.get(model, MOI.ConstraintPrimal(), c1)
1.000000000025
julia> MOI.get(model, MOI.ConstraintPrimal(), c2)
-2.5e-11 The last value is |
Simplified to one julia> import MathOptInterface as MOI
julia> import CSDP
julia> cache = MOI.Utilities.Model{Float64}();
julia> x, c1 = MOI.add_constrained_variable(cache, MOI.GreaterThan(1.0));
julia> c2 = MOI.add_constraint(cache, 1.0x, MOI.EqualTo(2.0));
julia> model = MOI.instantiate(CSDP.Optimizer, with_bridge_type = Float64);
julia> index_map, _ = MOI.optimize!(model, cache);
CSDP 6.2.0
This is a pure primal feasibility problem.
Iter: 0 Ap: 0.00e+00 Pobj: 0.0000000e+00 Ad: 0.00e+00 Dobj: 0.0000000e+00
Iter: 1 Ap: 1.00e+00 Pobj: 0.0000000e+00 Ad: 1.00e+00 Dobj: 9.0000000e+00
Success: SDP solved
Primal objective value: 0.0000000e+00
Dual objective value: 0.0000000e+00
Relative primal infeasibility: 0.00e+00
Relative dual infeasibility: 5.00e-11
Real Relative Gap: 0.00e+00
XZ Relative Gap: 5.00e-11
DIMACS error measures: 0.00e+00 0.00e+00 5.00e-11 0.00e+00 0.00e+00 5.00e-11
julia> MOI.get(model, MOI.VariablePrimal(), index_map[x])
2.0
julia> MOI.get(model, MOI.ConstraintPrimal(), index_map[c1])
2.0
julia> MOI.get(model, MOI.ConstraintPrimal(), index_map[c2])
1.0
julia> MOI.Bridges.print_active_bridges(model)
* Supported objective: MOI.ScalarAffineFunction{Float64}
* Supported constraint: MOI.ScalarAffineFunction{Float64}-in-MOI.EqualTo{Float64}
* Unsupported variable: MOI.GreaterThan{Float64}
| bridged by:
| MOIB.Variable.VectorizeBridge{Float64, MOI.Nonnegatives}
| may introduce:
| * Supported variable: MOI.Nonnegatives |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems like a bug in
CachingOptimizer
orLazyBridgeOptimizer
. CSDP passes the tests without this additional cache and when adding this cache (which gives the setting of the JuMP backend, we have a failure). It seems SDPA has the same issue since it's failing on the same tests with the same wrong answers6
and0
.produces
The text was updated successfully, but these errors were encountered: