Skip to content

Commit 2e79dd9

Browse files
committed
Update
1 parent a108dde commit 2e79dd9

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/Utilities/product_of_sets.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,15 @@ Return the number of rows corresponding to a set of type `S`. That is, it is
255255
the sum of the dimensions of the sets of type `S`.
256256
"""
257257
function num_rows(sets::OrderedProductOfSets, ::Type{S})::Int where {S}
258-
@assert sets.final_touch
259258
i = set_index(sets, S)::Int
260259
rows = sets.rows[i]
261260
if isempty(rows)
262261
return 0
262+
elseif sets.final_touch
263+
return max(0, last(rows[end]) - first(rows[1]) + 1)
264+
else
265+
return mapreduce(length, +, rows)
263266
end
264-
return max(0, last(rows[end]) - first(rows[1]) + 1)
265267
end
266268

267269
function MOI.get(

test/Utilities/test_product_of_sets.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,9 @@ function test_zero_dimensional_function_mix_of_sets()
328328
MOI.Utilities.add_set(sets, i1, 1)
329329
MOI.Utilities.add_set(sets, i3)
330330
MOI.Utilities.add_set(sets, i1, 0)
331+
@test MOI.Utilities.num_rows(sets, MOI.Nonpositives) == 3
332+
@test MOI.Utilities.num_rows(sets, MOI.Nonnegatives) == 1
333+
@test MOI.Utilities.num_rows(sets, MOI.EqualTo{Int}) == 1
331334
MOI.Utilities.final_touch(sets)
332335
# MOI.Nonpositives
333336
F, S = MOI.VectorAffineFunction{Int}, MOI.Nonpositives

0 commit comments

Comments
 (0)