I’m trying to minimize a function with JuMP. The variable of the objective function is a 30 element vector x and the optimization is supposed to start from a given vector x0.
How can I give vector x0 as the start? If i define the x variable as follows:
Thanks for the aswer @abelsiqueira. Unfortunately I still get error messages.
If I declare with index:
@variable(model, x[i=1:n], start=x0[i])
I get:
ERROR: LoadError: MethodError: Cannot `convert` an object of type JuMP.GenericQuadExpr{Float64,JuMP.
Variable} to an object of type JuMP.GenericAffExpr{Float64,JuMP.GenericQuadExpr{Float64,JuMP.
Variable}}
This may have arisen from a call to the constructor JuMP.GenericAffExpr{Float64,JuMP.GenericQuadExpr
{Float64,JuMP.Variable}}(...),
since type constructors fall back to convert methods.
And if I use setvalue:
@variable(model, x)
setvalue(x, x0)
I get:
ERROR: LoadError: MethodError: no method matching setvalue(::JuMP.Variable, ::Array{Float64,1})
Closest candidates are:
setvalue(::JuMP.Variable, ::Number) at C:\Users\mra136\.julia\v0.6\JuMP\src\JuMP.jl:400
setvalue(::Array{T<:JuMP.AbstractJuMPScalar,N} where N, ::Array) where T<:JuMP.AbstractJuMPScalar
at C:\Users\mra136\.julia\v0.6\JuMP\src\JuMP.jl:926
Thanks @abelsiqueira and @migarstka for your answers, they both make sense. I tried both ways you suggested, and now I get a new error:
ERROR: LoadError: MethodError: Cannot `convert` an object of type JuMP.GenericQuadExpr{Float64,JuMP.Variable}
to an object of type JuMP.GenericAffExpr{Float64,JuMP.GenericQuadExpr{Float64,JuMP.Variable}}
This may have arisen from a call to the constructor JuMP.GenericAffExpr{Float64,JuMP.GenericQuadExpr{Float64,
JuMP.Variable}}(...),
since type constructors fall back to convert methods.
I could be misunderstanding your question, but if you’re trying to do this with an arbitrary user-defined function, then I think you probably want something like this.