Originally posted by: SystemAdmin
[pmarley2 said:]
Hi all,
I am trying to write a conditional statement into my constraints. However, when I use decision variables inside the condition, I get an error. For example,
1 subject to {
2 forall (t in 0..nbHours-1) {
3 forall (p in providers) {
4 if (Power[p][t]/(suppliers[p][4] - suppliers[p][3]) >= 1)
5 {
6 abs(Power[p][t] - Power[p][t+1]) <= suppliers[p][5];<br />7 }
8 }
9 } }
I get an error on line 4 that says "Decision variable "Power" not allowed."
I try to bypass using the if statement by writing the following.
1 subject to {
2 forall (t in 0..nbHours-1) {
3 forall (p in providers) {
4 (Power[p][t]/(suppliers[p][4] - suppliers[p][3]) >= 1) &&
5 abs(Power[p][t] - Power[p][t+1]) <= suppliers[p][5];<br />6 }
7 } }
And the code works correctly. But is there a way to write a conditional statement in an easier way?
Thanks.
#DecisionOptimization#OPLusingCPLEXOptimizer