6
$\begingroup$

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$ and succ[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.

$\endgroup$
3
  • $\begingroup$ Are you saying that CP Optimizer finds a feasible solution to a model you believe to be infeasible? If so, the CPO solution must violate some constraint in the original problem. Figure out which; either you omitted it or you coded it incorrectly. If you can't find the problem, at least you can tell us the nature of the infeasibility (task 3 ends before it starts, task 2 depends on task 3 but starts after task 3, ...). $\endgroup$
    – prubin
    Jan 23, 2020 at 20:40
  • $\begingroup$ No, i'm saying the model is feasible because its solved with Cplex, but its infeasible in or-tools so i guess i have a problem in the modelling. All the constraints works except for the precedence. This is modeled in that way: time of end of task j + lag between task j and their sucessor task s is less or equal than start of s. $\endgroup$ Jan 24, 2020 at 15:15
  • $\begingroup$ I don't use or-tools, but it seems to me that you could remove all constraints, fix all variables to their values in the CPO solution, then add constraints back one at a time until or-tools told you the model was infeasible. The most recently added constraint would likely be wrong or incompatible with prior constraints. $\endgroup$
    – prubin
    Jan 25, 2020 at 19:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.