From 43b752649788fdfa39982ca9a5c53e4611780142 Mon Sep 17 00:00:00 2001 From: Dimitri Lozeve Date: Sun, 23 Feb 2020 22:20:10 +0100 Subject: [PATCH] Add constraints for fixed plants in garden --- src/optim.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/optim.jl b/src/optim.jl index 340f3ed..a5a4bef 100644 --- a/src/optim.jl +++ b/src/optim.jl @@ -30,7 +30,7 @@ function neighbourmatrix(mask::Matrix)::Matrix{Bool} d end -function definemodel(plantcounts::Vector, mask::Matrix, costs::Matrix) +function definemodel(plantcounts::Vector, garden::Matrix, mask::Matrix, costs::Matrix) N = length(mask) Q = size(costs, 1) @@ -57,6 +57,9 @@ function definemodel(plantcounts::Vector, mask::Matrix, costs::Matrix) @constraint(model, x[i, q] == 0) end end + if garden[i] != 0 + @constraint(model, x[i, garden[i]] == 1) + end end for q = 1:Q