badej60
badej60

Reputation: 67

Minizinc - variable value equal 0, 0.5 or 1

I've got array array[1..num_compute_nodes,1..num_access_nodes,1..num_request] of var 0..1: assignment;. I need to ensure that value in this array is 0, 0.5 or 1, not 0 or 1.

1.I tried to change that by usign set of float: domain_cn = { 0, 0.5, 1}; and array[1..num_compute_nodes,1..num_access_nodes,1..num_request] of domain_cn: assignment; but this doesn't work (MiniZinc: arithmetic error: arithmetic operation on infinite value).

  1. I tried make a constraint constraint forall(m in 1..num_compute_nodes)(forall(req in 1..num_request )((assignment[m,request_loc[req],req]) = 1 \/(assignment[m,request_loc[req],req]) = 0)\/ ssignment[m,request_loc[req],req]) = 0.5) )); and float instead of var 0..1 but it doesn't work too (MiniZinc: flattening error)

Is there any other way to solve my problem?

EDIT: Full Code: EDIT2: Deleted code

Upvotes: 0

Views: 177

Answers (2)

hakank
hakank

Reputation: 6854

[This was originally as a comment but moved as an answer.]

One way would be to multiply with some constants, e.g. 10 (to get 0, 5, 10), but you might have other float variables in your code?

Upvotes: 2

badej60
badej60

Reputation: 67

As @hakank posted, multiplying with constants, by 10 in my example, works! Thanks. I would show it in my code, but I had to delete it.

Upvotes: 0

Related Questions