Hi,

There are some situations in which one needs to use a decision variable as an index in a specific constraint. Applying such a case, somewhat, is straightforward by introducing the auxiliary binary variables and adding appropriate constraints. Now, someone needs to use a decision variable as an index in the outer loop (for-each combination). E.g. in the following constraints:

```
eq14(np(i) , nc(j) , t)$(ord(t)<=card(t)-cp) .. z2(i,j,t) =e= z2(i,j,t+cp)
```

“CP” would be a decision variable.

I was wondering if, is there any way to use a decision variable in the outer loop?

Regards

Abbas

Not sure what you mean by “use in outer loop”. In the code you showed, CP can’t be a variable. The compiler will complain. The issue is that this is not a mathematical program that a solver understand. What you can do (in case CP is the only variable) make CP an exogenous scalar and run for each CP values the optimization with a fixed CP. Since CP needs to be integer and is related to the set t you probably need card(t) optimization runs with fixed CP to find the optimal CP.

-Michael

Dear Dr. Bussieck,

Many thanks for your answer. The second paragraph you mentioned is exactly what we were looking for. Now, it is clear to us.

Best regards

Abbas