The task is fairly straightforward. I need to group the numbers in A
into pairs, such that the sum of each pair corresponds to one of the numbers in S
.
using HiGHS
using JuMP
m = Model(HiGHS.Optimizer)
A = [
119 225 511 259 173 28
486 374 375 227 164 314
389 136 72 241 81 326
]
S = reshape(100:100:900, 3, 3)'
@variable(m, x[i=1:3, j=1:6, z=1:9], binary=true)
# you can only have 2 numbers from A in a group
for i ∈ 1:9
@constraint(m, sum(x[:, :, i] .== true) == 2)
end
# the sums of the products of each group and A must equal S
@constraint(m, reshape([sum(x[:, :, i] .* A) for i ∈ 1:9], 3, 3)' .== S)
optimize!(m)
With HiGHS, it just tells me that it’s infeasible…