Hi folks,
This is my first time using Julia for math optimization (was previously running Xpress FICO).
I am trying to run a relatively easy anti-covering model. But I am running into issue with indices (or something else). I was hoping you could help me figure it out.
The following command:
@constraint(aclp, con[j in 1:length(jsites)], length(omega[j]) * x[j] + sum(x[k] for k in omega[j]) <= length(omega[j]))
Produces erroneous constraints (see the part in bold ):
con[1] : 8 x[1] + x[2] + x[3] + x[5] + x[6] + x[8] + x[10] <= 7.0
con[2] : 11 x[2] + x[1] + x[3] + x[4] + x[5] + x[6] + x[8] + x[9] + x[10] + x[11] <= 10.0
con[3] : 11 x[3] + x[1] + x[2] + x[4] + x[5] + x[6] + x[8] + x[10] + x[11] + x[12] <= 10.0
con[4] : 10 x[4] + x[2] + x[3] + x[5] + x[6] + x[7] + x[8] + x[9] + x[11] <= 9.0
con[5] : 13 x[5] + x[1] + x[2] + x[3] + x[4] + x[6] + x[8] + x[9] + x[10] + x[11] + x[12] + x[13] <= 12.0
So for con[1] the command length(omega[j]) in LHS produces 8, when in actuality it should be 7 (RHS). This repeats for all other constraints.
To work around the issue I have to manually deduct 1 from length(jsites) in LHS.
This could me an indexing issues or something else, or maybe I am using the Julia wrong. The following code produces correct constraints.
@constraint(aclp, con[j in 1:length(jsites)], **(length(omega[j])-1)** * x[j] + sum(x[k] for k in omega[j]) <= length(omega[j]))
con[1] : 7 x[1] + x[2] + x[3] + x[5] + x[6] + x[8] + x[10] <= 7.0
con[2] : 10 x[2] + x[1] + x[3] + x[4] + x[5] + x[6] + x[8] + x[9] + x[10] + x[11] <= 10.0
con[3] : 10 x[3] + x[1] + x[2] + x[4] + x[5] + x[6] + x[8] + x[10] + x[11] + x[12] <= 10.0
con[4] : 9 x[4] + x[2] + x[3] + x[5] + x[6] + x[7] + x[8] + x[9] + x[11] <= 9.0
con[5] : 12 x[5] + x[1] + x[2] + x[3] + x[4] + x[6] + x[8] + x[9] + x[10] + x[11] + x[12] + x[13] <= 12.0
Full runnable code with data can be downloaded from here.
I checked different solvers and the error is the same, so this is not solver-related.
I am running Julia v1.4 inside VS Code. JuMP v0.21.2. Windows 10.