I have a simple math prog that I am trying to solve:
m = Model(solver=MosekSolver())
@variable(m, x[1:8] >= 0)
@objective(m,Min,sum(x))
@constraint(m,A*x .== given)
@constraint(m, x, sum(x)==1)
status = solve(m)
println("x = ", getvalue(x))
A is some matrix with type Array{Float64,2
The line:
@constraint(m, x, sum(x)==1))
Changes the type of x
from Array{JuMP.Variable,1}
to JuMP.ConstraintRef{JuMP.Model,JuMP.GenericRangeConstraint{JuMP.GenericAffExpr{Float64,JuMP.Variable}}}
.
Since
x
has been previously declared as a variable shouldn't the type remain the same? (Furthermore if the above line is executed, everything still works, but,getvalue
will not due to the change in type.)Is there a way to add the summation constraint without changing the type of
x