Skip to content

Commit 2d297c9

Browse files
committed
include variable-in-set constraints when include_inequality is specified in identify_unique_variables
1 parent 4df6f9d commit 2d297c9

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/identify_variables.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,7 @@ function identify_unique_variables(
9292
# rather than silently ignoring these constraints.
9393
constraints = JuMP.all_constraints(
9494
model,
95-
# TODO: Should this be an optional argument to this function?
96-
include_variable_in_set_constraints=false,
95+
include_variable_in_set_constraints=true,
9796
)
9897
else
9998
constraints = get_equality_constraints(model)

test/identify_variables.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@ function test_fixing_constraint()
189189
@test variables[1] === x[1]
190190
end
191191

192+
function test_inequality_with_bounds()
193+
m = jmp.Model()
194+
@jmp.variable(m, x[1:2])
195+
@jmp.variable(m, 0 <= y[1:2])
196+
@jmp.constraint(m, x[1] + 2*x[2]^2 == 1)
197+
variables = identify_unique_variables(m, include_inequality = true)
198+
pred_var_set = Set([x[1], x[2], y[1], y[2]])
199+
@test Set(variables) == pred_var_set
200+
end
201+
192202
function runtests()
193203
test_linear()
194204
test_quadratic()
@@ -202,6 +212,7 @@ function runtests()
202212
test_model_bad_constr_no_ineq()
203213
test_function_with_variable_squared()
204214
test_fixing_constraint()
215+
test_inequality_with_bounds()
205216
return
206217
end
207218

0 commit comments

Comments
 (0)