I'm trying to work with a bunch of interval variables

*J*

_{j}and

*K*

_{k}as follows: the jobs

*J*

_{j}are to be packed into batches

*K*

_{k}via

```
model.add(IloPack(env, batchloads, assignments, sj, batchesUsed));
// batchloads is bounded by capacity = 10
```**
for**(
**
int** k=1; k<nk; k++)
{ model.add(IloEndAtStart(env, K[k-1], K[k], 0));
// batches are pre-sequenced
} model.add(IloStartOf(K[0]==0));

and the packing part works just fine, but now I'd like to ensure that a job assigned to batch

*k*starts at the same time as

*k*; something like

```
model.add(IloIfThen(env,(assignments[j]==k), (IloStartOf(J[j])==IloStartOf(K[k]))));
```

But this runs endlessly, with the implication failing every time. I've tried a couple of other approaches, too (code is "paraphrased"):

```
model.add((assignments[j]==k) <= (IloStartOf(J[j])==IloStartOf(K[k]))));
// since a job could align with multiple (empty) batches, at least one must align with the right one IloOr bbjk(env); bbjk.add((assignments[j]==k) == (IloStartOf(J[j])==IloStartOf(K[k]))); ... model.add(bbjk);
// later (outside of the loop above)
```

or

```
IloIntExpr batchStart(env);
```**
for**(
**
int** k=0; k<nk; k++) batchStart += ((assignments[j]==k) * IloStartOf(K[k])); model.add( IloStartOf(J[j]) == batchStart );

... but nothing works. Something like

```
model.add( IloStartAtStart(J[j], K[assignments[j]], 0) )
```

would obviously be most comfortable, but nested indexing doesn't work, and IloElement doesn't work with IntervalVars either.

What's the best way to implement this? Thanks!