I am trying to fit images to A4 piece of paper, I am getting infeasible solution but I don’t understand why.
params = Dict()
params["ROWS"] = 1:297
params["COLS"] = 1:210
params["TOTAL"] = 210 * 297
params["IMAGES"] = Dict{String,Dict{String,Any}}([
"1" => Dict(["w"=>50, "h" => 70, "rotate" => 0]),
"2" => Dict(["w"=>30, "h" => 20, "rotate" => 0]),
"3" => Dict(["w"=>100, "h" => 50, "rotate" => 0]),
"4" => Dict(["w"=>90, "h" => 60, "rotate" => 0]),
"5" => Dict(["w"=>20, "h" => 90, "rotate" => 0]),
"6" => Dict(["w"=>100, "h" => 120, "rotate" => 0]),
"7" => Dict(["w"=>40, "h" => 70, "rotate" => 0])
])
premex = Model()
_ROWS = params["ROWS"]
_COLS = params["COLS"]
_IMAGES = params["IMAGES"]
_TOTAL = params["TOTAL"]
@variable(premex, ASSIGNed[R in _ROWS, C in _COLS, i_k in keys(_IMAGES)], Bin)
@objective(
premex,
Min,
_TOTAL - sum((ASSIGNed[R, C, i_k])
for R in _ROWS, C in _COLS, (i_k, i) in _IMAGES)
)
@constraint(
premex,
[R in _ROWS, C in _COLS],
[ASSIGNed[R, C, i_k] for (i_k, i) in _IMAGES] in SOS1()
)
**@constraint(**
** premex,**
** [i_k in keys(_IMAGES), R in _ROWS],**
** sum(ASSIGNed[R, C, i_k] for C in _COLS) == _IMAGES[i_k]["w"]**
** )**
** @constraint(**
** premex,**
** [i_k in keys(_IMAGES), C in _COLS],**
** sum(ASSIGNed[R, C, i_k] for R in _ROWS) == _IMAGES[i_k]["h"]**
** )**
bolded ones are problematic, I wanted to make some constraints that will say: the sum of all width that are chosen must match with the actual images sizes