Originally posted by: rdumeur
Dear Fara,
To use integer variable as indices in lookup tables, all you need to do is to create the appropriate float arrays in the model.
First declare your variables, with domain 1..m (m being the size of the lookup tables)
using CP;
int n = 10;
int m = 5;
dvar int x[1..n] in 1..m;
Then define, suitable arrays for your cost / power functions:
float c[1..m] = [4.7, 3, <other values > ...];
float p[1..m] = [3, 2.8, < other values> ... ];
float r[1..m] = [ 55, 7, <other values> ... ];
then declare your objective using element expressions on "c" :
minimize pow(c[x[1]], 5) + pow(c[x[2]], 3) + c[x[3]]*c[x[1]]*pow(c[x[2]],2) + <other terms> ... ;
then declare your constraints using the contraint element on "p" array with "x" values :
subject to {
p[x[1]] + 0.5 * p[x[2]] >= 7;
4 * r[x[2]] + r[x[1]]^3 <= 30;
}
I hope this helps!
Cheers,
#ConstraintProgramming-General#DecisionOptimization