Originally posted by: SystemAdmin
What you have looks right except for some syntactic errors. Here's a modified version of what you have that runs without errors. I donot know about the model's application and hence will not be able to validate the results. I would thus suggest you to run some tests with some small ranges and see if the outputs are per your expectations:
//int a,b,c,d;//need to initialize them separately
int a=1;
//dummy #s for a,b,c,d
int b=2;
int c=3;
int d=4; range Z= 7..10; range Y= 2..8; dvar
int x; dvar int+ x1;
//dvar int- x2;//do you mean x2 is an integer <= 0?? dvar
int x2; dvar
int y in Y; dvar
int z in Z; dvar
float C; minimize C;
//(a*y + b*x1 + c*x2) subject to
{ d + y == z + x; x1 >= 0; x1 >= x;
//x2 >= 0; //commented, should this be x2<=0 instead?? x2 >= -x; forall(zIndex in Z)
{ a*(zIndex + x - d) + b*x1 + c*x2 <= C;
} a*y + b*x1 + c*x2 == C;
}
If all you want to do is choose z such that it is set at the maximum value of its range, you could simplify the above to:
//int a,b,c,d;//need to initialize them separately
int a=1;
//dummy #s for a,b,c,d
int b=2;
int c=3;
int d=4; range Z= 7..10; range Y= 2..8; dvar
int x; dvar int+ x1;
//dvar int- x2;//do you mean x2 is an integer <= 0?? dvar
int x2; dvar
int y in Y; dvar
int z in Z; minimize (a*y + b*x1 + c*x2); subject to
{ d + y == z + x; x1 >= 0; x1 >= x;
//x2 >= 0; //commented,should this be x2<=0 instead?? x2 >= -x; z==max(zElements in Z)zElements;
}
#DecisionOptimization#OPLusingCPLEXOptimizer