Originally posted by: EdKlotz
I don't have time to run your model; in general you may get more responses if you point to the specific lines that cause the
errors. I suspect they involve the multiplications of a float variable by a binary, such as
allocate1: (sum(i in Investments) Return[i]*Binary[i]*Allocation[i])>= 0.02;
// sum of allocations equals amount to be invested
allocate2: (sum (i in Investments) (Allocation[i]*Binary[i])) == Wealth;
You declared these as
dvar int Binary[Investments] in 0..1;
dvar float Allocation[Investments] in FloatRange; // Investment Level
I don't think any of CPLEX's APIs will directly extract the product of a binary and continuous variable.
You either need to linearize this expression through a series of constraints (you can search this forum and
also www.or-exchange.org and will probably find a description of how to do that if it is unfamiliar, but you might
want to try it yourself first), or you can make use OPL's logical if/then functionality and let OPL/CPLEX do the internal
linearization. In other words, declare an array of dvars, say z[i], and then specify the logical constraint
if Binary[i] == 1 then z[i] = Allocate[i]
if Binary[i] == 0 then z[i] = 0
#CPLEXOptimizers#DecisionOptimization