I'm trying to solve an RCPSPDc model It is infeasible, although Ilog Cplex solves it, so I think I have a modelling issue. I have more constraints but the precedence is the one that makes it infeasible.
//Inicializar Modelo
CpModelBuilder cp_model;
const int nbTasks = njobs;
const int nbResources = nresources;
// DEFINE VARIABLES
std::vector<IntVar> starts(nbTasks);
std::vector<IntVar> durations(nbTasks);
std::vector<IntVar> ends(nbTasks);
std::vector<BoolVar> actives(nbTasks);
std::vector<IntervalVar> Intervals(nbTasks);
for (int j=0; j<nbTasks; j++)
{
const IntVar start = cp_model.NewIntVar(Domain(0, tmax)); // generamos una variable intervalo
const IntVar end = cp_model.NewIntVar(Domain(0, tmax)); // para cada job
const BoolVar active = cp_model.NewBoolVar();
const IntVar size = cp_model.NewConstant(duration[j]);
/*if(duration[j])
{
const IntVar size = cp_model.NewConstant(duration[j]);
}
else
{
const IntVar size = cp_model.NewConstant(1);
}
*/
const IntervalVar interval = cp_model.NewOptionalIntervalVar(start, size, end, active);
starts.push_back (start); // añadimos las variables a sus
durations.push_back(size); // diccionarios respectivos
ends.push_back(end);
actives.push_back(active);
Intervals.push_back(interval);
}
// DEFINE PRECEDENCE CONSTRAINTS
for (int j = 0; j < nbTasks; ++j)
{
const int nbSucc = nsucc[j];
for (int s = 0; s < nbSucc; ++s)
{
cp_model.AddLessOrEqual(LinearExpr(ends[j]).AddConstant(lag[j][s]), LinearExpr(starts[succ[j][s]]));
}
}
I can't see where the problem is.
nsucc[j]
is the number of successors from a job $j$,lag[j][s]
is the time successor activity $s$ must wait to start after predecessor activity $j$,succ[j][s]
is the $s$-successor of $j$; $s$ andsucc[j][s]
represent the same but reference different vectors. For example, $s$ is the second successor of $j$, but $s$ is the job $343$.
I'll be thankful for any help.