Skip to content

Commit 67467ce

Browse files
committed
Add test
1 parent 34ee0e3 commit 67467ce

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/problems.jl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,4 +441,35 @@ function test_problem_issue_105(model)
441441
return
442442
end
443443

444+
function test_issue_122(model)
445+
m, n = 3, 10
446+
p1 = [5.0 1 10 8 3 5 3 3 7 2; 10 6 1 6 8 3 2 10 6 1; 2 3 1 6 9 7 1 5 4 8]
447+
p2 = [4.0 6 4 3 1 6 8 2 9 7; 8 8 8 2 4 8 8 1 10 1; 8 7 8 5 9 2 2 7 10 10]
448+
p3 = [4.0 3 6 4 7 5 9 5 8 4; 8 6 2 2 6 8 5 2 2 3; 2 8 10 3 5 7 5 9 5 5]
449+
w = [5.0 9 3 5 10 5 7 10 7 8; 4 8 8 6 10 8 10 7 5 1; 10 7 5 8 8 2 8 1 10 3]
450+
b = [34.0, 33.0, 31.0]
451+
x_ = MOI.add_variables(model, m * n)
452+
x = reshape(x_, m, n)
453+
MOI.add_constraint.(model, x, MOI.ZeroOne())
454+
f = MOI.Utilities.operate(
455+
vcat,
456+
Float64,
457+
sum(p1 .* x),
458+
sum(p2 .* x),
459+
sum(p3 .* x),
460+
)
461+
MOI.set(model, MOI.ObjectiveSense(), MOI.MAX_SENSE)
462+
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
463+
for i in 1:m
464+
f_i = sum(w[i,j] * x[i,j] for j in 1:n)
465+
MOI.add_constraint(model, f_i, MOI.LessThan(b[i]))
466+
end
467+
for j in 1:n
468+
MOI.add_constraint(model, sum(1.0 .* x[:,j]), MOI.EqualTo(1.0))
469+
end
470+
MOI.optimize!(model)
471+
@test MOI.get(model, MOI.ResultCount()) == 42
472+
return
473+
end
474+
444475
end # module Problems

0 commit comments

Comments
 (0)