Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Nov 6, 2024
1 parent 508f9d0 commit 4062b31
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
4 changes: 1 addition & 3 deletions test/test_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2199,9 +2199,7 @@ function test_shadow_price_errors()
@variable(model, x >= 0)
set_optimizer(
model,
() -> MOI.Utilities.MockOptimizer(
MOI.Utilities.Model{Float64}(),
),
() -> MOI.Utilities.MockOptimizer(MOI.Utilities.Model{Float64}()),
)
optimize!(model)
mock = unsafe_backend(model)
Expand Down
2 changes: 1 addition & 1 deletion test/test_model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,7 @@ function test_copy_nonlinear()
@test_throws(
ErrorException(
"copy is not supported yet for models with nonlinear constraints" *
" and/or nonlinear objective function"
" and/or nonlinear objective function",
),
copy_model(model),
)
Expand Down
42 changes: 42 additions & 0 deletions test/test_nlp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1683,4 +1683,46 @@ function test_get_node_type_comparison()
return
end

function test_NL_dot()
model = Model()
@variable(model, x)
y = (; abc = x)
@NLexpression(model, ref, y.abc)
nlp = nonlinear_model(model)
@test MOI.Nonlinear.parse_expression(nlp, x) == nlp[index(ref)]
return
end

function test_NL_adjoint()
model = Model()
@variable(model, x)
@NLexpression(model, ref, x')
nlp = nonlinear_model(model)
@test MOI.Nonlinear.parse_expression(nlp, x) == nlp[index(ref)]
return
end

function test_NL_too_many_arguments_errors()
model = Model()
@test_throws_parsetime(
ErrorException(
"At `@NLexpression()`: To few arguments (0); must pass the model and nonlinear expression as arguments.",
),
@NLexpression(),
)
@test_throws_parsetime(
ErrorException(
"At `@NLexpression(model, ex, 1, 2)`: To many arguments (4).",
),
@NLexpression(model, ex, 1, 2),
)
@test_throws_parsetime(
ErrorException(
"At `@NLconstraint(model, ex, 1, 2)`: too many arguments.",
),
@NLconstraint(model, ex, 1, 2),
)
return
end

end

0 comments on commit 4062b31

Please sign in to comment.