With X
a vector of binary variables, and W
a vector of float variables,
I want to write a constraint such that if W[i] > 0
, then I should have X[i] = 1
.
dvar boolean X[I]; // we choosed stocks i or not
dvar float W[I]; // weight of stocks i in portfolio
How can I state this constraint?