Originally posted by: SystemAdmin
Hi all, I need to translate in JAVA the sequence-dependent acitivities C++ sample
In particular I have troubles understanding how to translate the statement
model.add(IloLengthOf(setup[i])==setupDuration[type
i][IloTypeOfNext(machine,cover
i],last));
Can anybody help me?
THANKS a lot
IloEnv env;
IloModel model(env);
IloInt m = ...; // Number of types { 0, 1, ..., m-1 }
IloInt n = ...; // Number of activities on the machine
IloIntervalVarArray act (env, n); // Activities on the machine
IloIntervalVarArray setup(env, n); // Setup activities on the machine
IloIntervalVarArray cover(env, n); // Covering activities on the machine
IloIntArray type (env, n); // Activity types
// ...
for (IloInt i=0; i<n; ++i) {
act [i] = ...;
type [i] = ...;
cover[i] = IloIntervalVar(env);
setup[i] = IloIntervalVar(env);
IloIntervalVarArray dec(env); dec.add(act[i]); dec.add(setup[i]);
model.add(IloSpan(env, cover[i], dec));
model.add(IloEndBeforeStart(env, act[i], setup[i]));
}
IloIntervalSequenceVar machine(env, cover, type);
model.add(IloNoOverlap(env, machine)); // Setup activities
IloIntArray2 setupDuration(env, m);
IloInt last = m; // Type of next for the last activity on the machine
for (IloInt ti=0; ti<m; ++ti) {
setupDuration
ti= IloIntArray(env, m+1);
for (IloInt tj=0; tj<m; ++tj)
setupDuration
titj = ...; // Length of setup activity between types ti and tj
setupDuration
tilast = 0; // Length of last setup activity
}
for (IloInt i=0; i<n; ++i)
model.add(IloLengthOf(setup[i])==setupDuration[type
i][IloTypeOfNext(machine,cover
i],last));
#CPOptimizer#DecisionOptimization