Created
October 27, 2019 21:32
-
-
Save ericphanson/9ab9f8460bbe5200be82d0b0cb55ecd5 to your computer and use it in GitHub Desktop.
Problem trying to warmstart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using SCS | |
using MathOptInterface # MathOptInterface v0.9.6 | |
const MOI = MathOptInterface | |
const MOIU = MOI.Utilities | |
const MOIB = MOI.Bridges | |
function make_model(vector) | |
optimizer = SCS.Optimizer(verbose=false) | |
T = Float64 | |
model = MOIB.full_bridge_optimizer( | |
MOIU.CachingOptimizer( | |
MOIU.UniversalFallback(MOIU.Model{T}()), | |
optimizer | |
), | |
T | |
) | |
vars = MOI.add_variables(model, 3) | |
# Add objective | |
obj_terms = [ MOI.ScalarAffineTerm(one(T), vars[k]) for k in 1:3 ] | |
obj = MOI.ScalarAffineFunction{T}(obj_terms, zero(T)) | |
MOI.set(model, MOI.ObjectiveFunction{MOI.ScalarAffineFunction{T}}(), obj) | |
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE) | |
# Add constraint | |
VAF = MOI.VectorAffineFunction{T}([ MOI.VectorAffineTerm{T}(k, MOI.ScalarAffineTerm{T}(vector[k], vars[k])) for k = 1:3], zeros(T, 3)) | |
constr_indices = MOI.add_constraint(model, VAF, MOI.Zeros(3)) | |
return model, constr_indices | |
end | |
vector = rand(3) | |
model, constr_indices = make_model(vector) | |
MOI.optimize!(model) # works | |
dual_value = MOI.get(model, MOI.ConstraintDual(), constr_indices) | |
# Get a fresh model | |
model, constr_indices = make_model(vector) | |
# Attempt to warmstart | |
MOI.set(model, MOI.ConstraintDualStart(), constr_indices, dual_value) # works | |
MOI.optimize!(model) # errors |
The error is
ERROR: MethodError: no method matching map_indices(::MathOptInterface.Utilities.var"#7#8"{MathOptInterface.Utilities.IndexMap}, ::Array{Array{Float64,1},1})
Closest candidates are:
map_indices(::AbstractDict{T,T}, ::Any) where T<:Union{MathOptInterface.VariableIndex, MathOptInterface.ConstraintIndex} at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Utilities/functions.jl:73
map_indices(::Function, ::Union{Nothing, AbstractString, DataType, Function, Number, Tuple{Vararg{Union{Nothing, AbstractString, DataType, Function, Number, MathOptInterface.AbstractConstraintAttribute, MathOptInterface.AbstractModelAttribute, MathOptInterface.AbstractOptimizerAttribute, MathOptInterface.AbstractSet, MathOptInterface.AbstractVariableAttribute, MathOptInterface.ModelLike, Enum},N} where N}, MathOptInterface.AbstractConstraintAttribute, MathOptInterface.AbstractModelAttribute, MathOptInterface.AbstractOptimizerAttribute, MathOptInterface.AbstractSet, MathOptInterface.AbstractVariableAttribute, MathOptInterface.ModelLike, AbstractArray{#s48,N} where N where #s48<:Union{Nothing, AbstractString, DataType, Function, Number, Tuple{Vararg{Union{Nothing, AbstractString, DataType, Function, Number, MathOptInterface.AbstractConstraintAttribute, MathOptInterface.AbstractModelAttribute, MathOptInterface.AbstractOptimizerAttribute, MathOptInterface.AbstractSet, MathOptInterface.AbstractVariableAttribute, MathOptInterface.ModelLike, Enum},N} where N}, MathOptInterface.AbstractConstraintAttribute, MathOptInterface.AbstractModelAttribute, MathOptInterface.AbstractOptimizerAttribute, MathOptInterface.AbstractSet, MathOptInterface.AbstractVariableAttribute, MathOptInterface.ModelLike, Enum}, Enum}) at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Utilities/functions.jl:80
map_indices(::Function, ::MathOptInterface.VariableIndex) at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Utilities/functions.jl:82
...
Stacktrace:
[1] map_indices(::MathOptInterface.Utilities.IndexMap, ::Array{Array{Float64,1},1}) at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Utilities/functions.jl:73
[2] _pass_attributes(::SCS.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Array{MathOptInterface.AbstractConstraintAttribute,1}, ::Tuple{DataType}, ::Tuple{Array{MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64},MathOptInterface.Zeros},1}}, ::Tuple{Array{MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64},MathOptInterface.Zeros},1}}, ::typeof(MathOptInterface.Utilities.allocate)) at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Utilities/copy.jl:147
[3] pass_attributes(::SCS.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Array{MathOptInterface.ConstraintIndex{MathOptInterface.VectorAffineFunction{Float64},MathOptInterface.Zeros},1}, ::Function) at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Utilities/copy.jl:124
[4] pass_constraints(::SCS.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::Bool, ::MathOptInterface.Utilities.IndexMap, ::Array{DataType,1}, ::Array{Array{#s112,1} where #s112<:(MathOptInterface.ConstraintIndex{MathOptInterface.SingleVariable,S} where S),1}, ::Array{DataType,1}, ::Array{Array{#s13,1} where #s13<:(MathOptInterface.ConstraintIndex{MathOptInterface.VectorOfVariables,S} where S),1}, ::typeof(MathOptInterface.Utilities.allocate_constraints), ::typeof(MathOptInterface.Utilities.allocate)) at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Utilities/copy.jl:266
[5] allocate_load(::SCS.Optimizer, ::MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}, ::Bool) at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Utilities/copy.jl:684
[6] #automatic_copy_to#97 at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Utilities/copy.jl:17 [inlined]
[7] #automatic_copy_to at ./none:0 [inlined]
[8] #copy_to#29 at /Users/eh540/.julia/packages/SCS/Y9wx3/src/MOI_wrapper.jl:139 [inlined]
[9] #copy_to at ./none:0 [inlined]
[10] attach_optimizer(::MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Utilities/cachingoptimizer.jl:149
[11] optimize!(::MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}) at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Utilities/cachingoptimizer.jl:185
[12] optimize!(::MathOptInterface.Bridges.LazyBridgeOptimizer{MathOptInterface.Utilities.CachingOptimizer{SCS.Optimizer,MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.Model{Float64}}}}) at /Users/eh540/.julia/packages/MathOptInterface/US9Wf/src/Bridges/bridge_optimizer.jl:225
[13] top-level scope at REPL[16]:1
I get the same error on MOI master.
Should be fixed by jump-dev/MathOptInterface.jl#941
I can confirm it works for me on the brand new 0.9.7 :). Thanks very much!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is the error ? Does it work with MOI master ? We just added support for starting values of a lot of bridges