Skip to content

Add more tests to DominguezRios #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion test/algorithms/DominguezRios.jl
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,44 @@ function test_vector_of_variables_objective()
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
MOI.add_constraint(model, sum(1.0 * xi for xi in x), MOI.GreaterThan(1.0))
MOI.optimize!(model)
MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMAL
@test MOI.get(model, MOI.TerminationStatus()) == MOI.OPTIMAL
return
end

function test_issue_105()
cost = [100.0, 120.0, 150.0, 110.0, 200.0, 170.0]
time = [8.0, 3.0, 4.0, 2.0, 5.0, 4.0]
capacity = [10.0, 8.0]
demand = [5.0, 8.0, 5.0]
m, n = 2, 3
model = MOI.instantiate(; with_bridge_type = Float64) do
return MOA.Optimizer(HiGHS.Optimizer)
end
MOI.set(model, MOA.Algorithm(), MOA.DominguezRios())
MOI.set(model, MOI.Silent(), true)
x = MOI.add_variables(model, m * n)
MOI.add_constraint.(model, x, MOI.GreaterThan(0.0))
MOI.add_constraint.(model, x, MOI.Integer())
X = reshape(x, m, n)
for i in 1:m
f_i = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(1.0, X[i, :]), 0.0)
MOI.add_constraint(model, f_i, MOI.LessThan(capacity[i]))
end
for j in 1:n
f_j = MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(1.0, X[:, j]), 0.0)
MOI.add_constraint(model, f_j, MOI.EqualTo(demand[j]))
end
f = MOI.Utilities.operate(
vcat,
Float64,
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(cost, x), 0.0),
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(time, x), 0.0),
MOI.ScalarAffineFunction(MOI.ScalarAffineTerm.(1.0, x), 0.0),
)
MOI.set(model, MOI.ObjectiveSense(), MOI.MIN_SENSE)
MOI.set(model, MOI.ObjectiveFunction{typeof(f)}(), f)
MOI.optimize!(model)
@test MOI.get(model, MOI.ResultCount()) == 6
return
end

Expand Down
Loading