Originally posted by: Petr Vilím
Hello,
the solution depends on what do you want to achieve. I understand that you want the oven to be in state 2 until the first task starts. Is it because (a) there are some other tasks that could be performed before, i.e. during the state 2? Or (b) you want to make sure that there is enough time to change the state from 2 to the state required for the first task? I'm assuming you passed a transition matrix to the state function in the case (b).
In the case (b) I think that you don't have to make sure that the state 2 ends as late as possible. You can e.g. enforce state 2 during interval [0, 1] using alwaysEqual as suggested by Alex.
In the case (a) constraint alwaysEqual(f, s, e, v) cannot be used because FirstStartAt[o] is not a constant, it is decision expression (it is an expression that depends on some decision variables). And alwaysEqual(f, s, e, v) requires s and e to be constants. So it is necessary to use alwaysEqual(f, interval, v) instead and create an auxiliary interval variable that starts at 0 and ends at the time the first taskOvenAlts starts. There are multiple ways to do that:
1) You can constraint the end of the interval to be equal to something similar to your FirstStartAt[o] expression: endOf(interval) = min(t in allTasks) startOf(taskOvenAlts[t][o], 1000000). The value 1000000 is used when the interval is absent, you can use some other number of course.
2) You can use span constraint. Using span, you can create an interval that exactly covers all present intervals taskOvenAlts[t][o]. Then using endAtStart you can force the auxiliary interval to end at the time the spanning interval starts.
There shouldn't be a big difference in speed between 1) and 2).
Best regards, Petr
#CPOptimizer#DecisionOptimization