Skip to content

UniversalFallback should throw key error rather than return canget == false if attribute partially set #302

@mlubin

Description

@mlubin

https://github.com/JuliaOpt/MathOptInterface.jl/blob/7164fdc573f3f92acb93de1bf18a3d3bd5e315c7/src/Utilities/universalfallback.jl#L54-L57

The check on the length of the dictionary means that:

m = Model()
@variable(m, x, start = 1)
@variable(m, y)
JuMP.startvalue(x)

gives

 Attribute MathOptInterface.VariablePrimalStart() not accessible
  Stacktrace:
   [1] get(::MathOptInterface.Utilities.CachingOptimizer, ::MathOptInterface.VariablePrimalStart, ::MathOptInterface.VariableIndex) at /home/mlubin/.julia/v0.6/MathOptInterface/src/Utilities/cachingoptimizer.jl:380
   [2] get(::JuMP.Model, ::MathOptInterface.VariablePrimalStart, ::JuMP.Variable) at /home/mlubin/.julia/v0.6/JuMP/src/JuMP.jl:379
   [3] startvalue(::JuMP.Variable) at /home/mlubin/.julia/v0.6/JuMP/src/variables.jl:379

The attribute values should be available immediately after you set them, and there should be a key error in the case that you ask for a value that's not defined.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions