Hi,
I am trying to solve the model below but the constraints are not being satisfied if I input a vector on the rhs (u[j] - 1). But, when I type it with hand (34, 28). It is being satisfied.
ap.p
3
ap.n
5
ap.c
3×5×5 Array{Int64, 3}:
[:, :, 1] =
6 6 10 15 11
2 7 4 10 10
1 17 19 2 1
[:, :, 2] =
1 8 13 3 20
6 10 11 7 15
6 20 13 15 9
[:, :, 3] =
20 6 1 5 16
9 10 1 1 20
20 8 7 12 20
[:, :, 4] =
2 9 10 1 12
10 6 13 19 11
5 8 18 10 7
[:, :, 5] =
3 6 15 11 9
18 2 1 12 7
9 20 17 3 6
begin
k = 1
u = [0, 35, 29]
model = Model(optimizer_with_attributes(HiGHS.Optimizer, "output_flag" => false))
@variable(model, x[1:ap.n, 1:ap.n], Bin)
@constraint(model, [r = 1:ap.n], sum(x[r, l] for l in 1:ap.n) == 1)
@constraint(model, [l = 1:ap.n], sum(x[r, l] for r in 1:ap.n) == 1)
@constraint(model, [j = 1:ap.p; j ≠ k ], sum(ap.c[j,:,:] .* x) <= u[j] - 1)
@objective(model, Min, sum(ap.c[k,:,:] .* x))
# print(model)
optimize!(model)
status = termination_status(model)
println([sum(ap.c[j,:,:] .* value.(x)) for j in 1:ap.p])
end
Sounds like something I am missing something obvious but I appreciate any help?!
EDIT:
I just realized even if I type it like the following it still does not work:
@constraint(model, sum(ap.c[2,:,:] .* x) <= 34)
@constraint(model, sum(ap.c[3,:,:] .* x) <= 28)
Thanks