-1

How i do the code that is in fugure link in Minizinc? A code that take a minimum number

I try this: constraint forall(i in nurse, j in patient where j != 1)(start[i] == min((arrive[i,j] + ((1-y[i,1,j])*H) - sum(u in patient)(dist[1,j]*y[i,1,u])), H ));

but it is have not limits

  • Exactly what error is thrown? Also, it's quite hard to say much about this without the rest of the model, e.g. what `patient`, `dist`, `y` is. – hakank Feb 20 '18 at 17:17
  • patient is a array of int, dist is a array of float and y is a array of 0..1 that error: with i = 1 in call 'ub' cannot determine bounds But i have two values after compile that sentence: constraint forall(i in nurse, j in patient where j != 1)(start[i] == min((arrive[i,j] + ((1-y[i,1,j])*H) - sum(u in patient)(dist[1,j]*y[i,1,u])), H )) – Julia Campos Feb 20 '18 at 17:20
  • It's almost impossible to know exactly what's wrong with this since you don't show the complete code. You can try a different solver and see if you get the same message. – hakank Feb 20 '18 at 17:24
  • i use minizinc solver(gecode), and its work, but i need use the gurobi solver, because a gecode don't support all the nurse scheduling . – Julia Campos Feb 20 '18 at 17:27
  • 1
    Well, it seems that the problem is Gurubi and how it handles decision variable. A tip is to ensure that all decision variables has proper domains, i.e. don't use "var int" (or "var float"). Also, I don't understand what you mean that gecode "don't support all the nurse scheduling". It this some specific global constraints that Gurobi supports? – hakank Feb 20 '18 at 17:34
  • When i compile with gecode, i get the following answer: "Compiling hhcp.mzn, with additional data hhcpn3p7.dzn Running hhcp.mzn Error: Gecode: Float::linear: Number out of limits " And gurobi solver return that answer: "cannot determine bounds". Why i can't use var int or var float? – Julia Campos Feb 20 '18 at 21:52

1 Answers1

2

This problem is most likely caused by the use of a constraint that uses equality encoding on variables without a specific domain (i.e., var int).

When we decompose constraints within the linear library, for Gurobi, CBC, or CPLEX, not all statements are easily rewritten into a linear form. For constraints like the element or min constraint, we use equality encoding. This means that we use a 0/1 variable for every possible value of an integer variable and use these new variables to formulate the constraints we need.

The problem here is that this does not work if a variable has no bounds. We would have to create a 0/1 variable for every value in the integer domain, which according to mathematics would be infinite. Since this would not work for the solver, constraints that require equality encoding will require bounds on the variables used.

Dekker1
  • 5,565
  • 25
  • 33