Problem with adding a column


I’m trying to add an anonymous variable to two constraints but I get an error.

using JuMP
m = Model()
@constraint(m, con1, 0 <= 1)
@constraint(m, con2, 0 <= 1)
constrrefs = Vector{ConstraintRef}(0)
values = [1; 1]
@variable(m, lowerbound = 0.0, upperbound = 1.0, objective = 10.0, inconstraints = constrrefs, coefficients = values)

ERROR: MethodError: no method matching constructvariable!(::JuMP.Model, ::JuMP.#_error#101{Tuple{Symbol,Expr,Expr,Expr,Expr,Expr}}, ::Float64, ::Float64, ::Symbol, ::Float64, ::Array{JuMP.ConstraintRef,1}, ::Array{Int64,1}, ::String, ::Float64)
Closest candidates are:
  constructvariable!(::JuMP.Model, ::Function, ::Number, ::Number, ::Symbol, ::Number, ::Array{T,1}, ::Array{Float64,1}, ::AbstractString, ::Number; extra_kwargs...) at /home/possm/.julia/v0.5/JuMP/src/macros.jl:821
  constructvariable!(::JuMP.Model, ::Function, ::Number, ::Number, ::Symbol, ::AbstractString, ::Number; extra_kwargs...) at /home/possm/.julia/v0.5/JuMP/src/macros.jl:828


values is an Int array. Try:

values = [1.0 , 1.0]





did this solution worked for you? I’m having the same problem and no idea how to solve it.


Yes it did.