Originally posted by: SystemAdmin
[jfk said:]
Hello,
well, actually reading the first sentence of yours I would have said a definite "yes!" and I could have written just no.2 below, but here we go:
1. Have you tried to run the code you wrote? for me the following works (at the end is the result):
int InputValue = 1;//3;
dvar int a in 1..4;
dvar int b in 1..5;
int domainLowerBound[1..InputValue] = [1];//[1,2,3];
int domainUpperBound[1..InputValue] = [8];//[8,9,10];
dvar int A[i in 1..InputValue] in domainLowerBound[i]..domainUpperBound[i];
maximize
sum(i in 1..InputValue) A[i];
subject to {
forall (i in 1..InputValue-1)
forall (j in i+1..InputValue)
a + b >= A[j];
/*
//with InputValue = 1
// solution (optimal) with objective 8
A = [8];
a = 1;
b = 1;
// solution (optimal) with objective 26
A = [8 9 9];
a = 4;
b = 5;
*/
and you can see for InputValue =1 no constraint is taken into account (a and b set to some value since they are not involved in any constraint), while for InputValue=3 constraints are posted and respected. A sidecomment: in your sample code you don't have index i used just j which is fine but not very efficient if you post the same constraint many times. OK, you wanted to demonstrate something and didn't care about some details and yet... :-)
2. if you want to make your constraints posted or not posted depending on input data the "if - then" statement is for exactly that purpose:
ILOG OPL Development Studio 6.x > Language > Language Reference Manual > OPL, the modeling language > Constraints > Using constraints > Conditional constraints
I hope it helps
cheers
#DecisionOptimization#MathematicalProgramming-General