Assertion error with MOI.initialize(d, [:Grad])


#1

I’m on JuMP#v0.19-alpha.

using JuMP

plants = ["seattle", "san-diego"]
markets = ["new-york", "chicago", "topeka"]
distance = [ 2.5 1.7 1.8 ;
             2.5 1.8 1.4  ]
d = Dict()
for i in 1:length(plants), j in 1:length(markets)
    d[plants[i], markets[j]] = distance[i,j]
end

m = Model()
@variable(m, w[i in plants] >= 0)
@NLexpression(m, c[i in plants, j in markets],  d[i,j] )
@NLexpression(m, profit[i in plants, j in markets],    w[i] + c[i,j])
@NLconstraint(m, [i in plants, j in markets], profit[i,j] == 0)
d = JuMP.NLPEvaluator(m)
MOI.initialize(d, [:Grad])

This produces

**ERROR:** AssertionError: subex.linearity != CONSTANT
Stacktrace:
[1] **initialize(** ::JuMP.NLPEvaluator, ::Array{Symbol,1} **)** at **/Users/chkwon/.julia/packages/JuMP/LjMor/src/nlp.jl:372**
[2] top-level scope at **none:0**

How should I fix this?


#2

Haven’t looked at it yet, but it’s clearly a bug: https://github.com/JuliaOpt/JuMP.jl/issues/1561.