Skip to content

Commit

Permalink
Merge d497114 into 8c36bf2
Browse files Browse the repository at this point in the history
  • Loading branch information
mlubin committed Oct 26, 2018
2 parents 8c36bf2 + d497114 commit f03be31
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/nlp.jl
Expand Up @@ -369,7 +369,6 @@ function MOI.initialize(d::NLPEvaluator, requested_features::Vector{Symbol})
d.subexpressions[k] = SubexpressionStorage(nldata.nlexpr[k].nd, nldata.nlexpr[k].const_values, num_variables_, d.subexpression_linearity, moi_index_to_consecutive_index)
subex = d.subexpressions[k]
d.subexpression_linearity[k] = subex.linearity
@assert subex.linearity != CONSTANT
if d.want_hess
empty!(coloring_storage)
compute_gradient_sparsity!(coloring_storage,subex.nd)
Expand Down
11 changes: 11 additions & 0 deletions test/nlp.jl
Expand Up @@ -493,4 +493,15 @@
@test h_view == h
end

@testset "Constant expressions" begin
model = Model()
@variable(model, x)
@NLexpression(model, expr, 10)
@NLobjective(model, Min, expr + x)
d = JuMP.NLPEvaluator(model)
MOI.initialize(d, [:Grad])
grad = zeros(1)
MOI.eval_objective_gradient(d, grad, [2.0])
@test grad == [1.0]
end
end

0 comments on commit f03be31

Please sign in to comment.