Skip to content

Commit e464682

Browse files
committed
include variable-in-set constraints when including inequalities in incidence graph creation
1 parent 2d297c9 commit e464682

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

src/incidence_graph.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,7 @@ function get_bipartite_incidence_graph(
9797
# to standardize at some point. E.g. a get_scalar_constraints function.
9898
constraints = JuMP.all_constraints(
9999
model,
100-
# TODO: Should this be an optional argument to this function?
101-
include_variable_in_set_constraints=false,
100+
include_variable_in_set_constraints = true,
102101
)
103102
else
104103
constraints = get_equality_constraints(model)

test/incidence_graph.jl

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,25 @@ function test_get_incidence_graph_badconstraint()
9393
return
9494
end
9595

96+
function test_include_bound_as_inequality()
97+
m = jmp.Model()
98+
@jmp.variable(m, 0 <= x[1:2])
99+
@jmp.constraint(m, eq1, x[1] + 2*x[2] == 1)
100+
graph, con_node_map, var_node_map = get_bipartite_incidence_graph(
101+
m, include_inequality = true
102+
)
103+
A, B, E = graph
104+
@test length(A) == 3
105+
@test length(B) == 2
106+
@test length(E) == 4
107+
pred_con_set = Set([eq1, jmp.LowerBoundRef(x[1]), jmp.LowerBoundRef(x[2])])
108+
@test pred_con_set == keys(con_node_map)
109+
end
110+
96111
function runtests()
97112
test_get_incidence_graph()
98113
test_get_incidence_graph_badconstraint()
114+
test_include_bound_as_inequality()
99115
return
100116
end
101117

test/interface.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,19 @@ function test_overconstrained_due_to_fixed_variable()
238238
@test length(con_dmp.unmatched) == 1
239239
end
240240

241+
function test_overconstrained_due_to_including_bound()
242+
m = JuMP.Model()
243+
@JuMP.variable(m, x)
244+
@JuMP.variable(m, 0.01 <= y)
245+
@JuMP.constraint(m, 2*x + y == 1)
246+
@JuMP.NLconstraint(m, x == sqrt(y))
247+
igraph = ji.IncidenceGraphInterface(m, include_inequality = true)
248+
con_dmp, var_dmp = ji.dulmage_mendelsohn(igraph)
249+
@test length(var_dmp.overconstrained) == 2
250+
@test length(con_dmp.overconstrained) == 2
251+
@test length(con_dmp.unmatched) == 1
252+
end
253+
241254
function runtests()
242255
test_construct_interface()
243256
test_construct_interface_rectangular()
@@ -248,6 +261,7 @@ function runtests()
248261
test_maximum_matching()
249262
test_dulmage_mendelsohn()
250263
test_overconstrained_due_to_fixed_variable()
264+
test_overconstrained_due_to_including_bound()
251265
end
252266

253267
end

0 commit comments

Comments
 (0)