Skip to content

Commit c68932a

Browse files
committed
add test
1 parent 599584f commit c68932a

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/test_cubic.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,31 @@ function test_jump_cubic_pvv_update_no_change()
15151515
return
15161516
end
15171517

1518+
function test_jump_cubic_objective_skips_when_unrelated_param_changes()
1519+
# Cubic objective uses parameter p. Parameter q is unrelated (no cubic term).
1520+
# Updating q triggers update_parameters! -> _update_cubic_objective!, but all
1521+
# deltas are empty because p was not updated, so the early return is taken.
1522+
model = Model(() -> POI.Optimizer(HiGHS.Optimizer()))
1523+
set_silent(model)
1524+
1525+
@variable(model, 0 <= x <= 10)
1526+
@variable(model, p in MOI.Parameter(1.0))
1527+
@variable(model, q in MOI.Parameter(0.0))
1528+
1529+
@objective(model, Min, p * x^2 - 2 * x)
1530+
1531+
optimize!(model)
1532+
@test termination_status(model) in (OPTIMAL, LOCALLY_SOLVED)
1533+
@test value(x) 1.0 atol = ATOL
1534+
1535+
# Update q only — p (in cubic objective) unchanged
1536+
set_parameter_value(q, 5.0)
1537+
optimize!(model)
1538+
@test termination_status(model) in (OPTIMAL, LOCALLY_SOLVED)
1539+
@test value(x) 1.0 atol = ATOL
1540+
return
1541+
end
1542+
15181543
function test_optimize_skips_update_without_parameter_change()
15191544
# Call optimize! twice with no parameter updates between calls.
15201545
# After the first optimize!, all updated_parameters are reset to NaN.

0 commit comments

Comments
 (0)