Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

RCPSP - Penalty for late activities

  • 1.  RCPSP - Penalty for late activities

    Posted Tue May 08, 2018 05:58 AM

    Originally posted by: SaumyaB


    Hi,

    I am trying to formulate a variant of RCPSP using Java and CP Optimizer where my objective is to minimize weighted number of late activities. To do so, I have a boolean variable Ui for activity i such that:

    Ui := 0, if Ci ≤ di

    and Ui := 1, otherwise

     

    where Ci is the completion time of activity i (variable in this case) and di is the due date of that activity (known from data). Is there a way to formulate such an if-else condition as a logical constraint.

    Any help would be greatly appreciated.

     


    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: RCPSP - Penalty for late activities

    Posted Tue May 08, 2018 06:21 AM

    Hi

    House building with earliness/tardiness costs

    This is a problem of building a house; the masonry, roofing, painting, etc. must be scheduled. Some tasks must necessarily take place before others and these requirements are expressed through precedence constraints.

    Moreover, there are earliness and tardiness costs associated with some tasks. The objective is to minimize these costs.

    To access this example, go to: examples/opl/sched_time.

    at CPLEX_Studio128\cpoptimizer\examples\src\java you have the same in java : SchedTime.java

    regards


    #ConstraintProgramming-General
    #DecisionOptimization


  • 3.  Re: RCPSP - Penalty for late activities

    Posted Thu May 10, 2018 11:38 PM

    Originally posted by: SaumyaB


    Hi,

    Thanks for the quick response. I will try formulating with this approach.


    #ConstraintProgramming-General
    #DecisionOptimization


  • 4.  Re: RCPSP - Penalty for late activities

    Posted Wed June 20, 2018 04:22 AM

    Originally posted by: SaumyaB


    Hi Alex,

    While trying out the suggested approach and going through the example SchedTime.java, I notice that in the function TardinessCost, two scenarios are possible, depending upon whether or not the useFunction = 0. I am not sure in which scenarios the else condition of the function is executed (line no 52) since useFunction is set to 1 in the line 89. 

    Any help on this is greatly appreciated. Thanks.

     

    Code Snippet (from the example):

    public static IloNumExpr TardinessCost(IloCP cp, IloIntervalVar task, int dd, double weight, int useFunction) throws IloException {
            if (useFunction != 0) {
                double[] arrX = {(double)dd};
                double[] arrV = {0.0, weight};
                IloNumToNumSegmentFunction f = cp.piecewiseLinearFunction(arrX, arrV, dd, 0.0);
                return cp.endEval(task,f);
            } else {
                return cp.prod(weight, cp.max(0, cp.diff(cp.endOf(task), dd)));
            }
        }

     

     


    #ConstraintProgramming-General
    #DecisionOptimization


  • 5.  Re: RCPSP - Penalty for late activities

    Posted Wed June 20, 2018 04:55 AM

    Hi,

    in order to better understand you could have a look at the equivalent OPL example at CPLEX_Studio128\opl\examples\opl\sched_time

    For your question, since useFunction==1

    double[] arrX = {(double)dd};
                double[] arrV = {0.0, weight};
                IloNumToNumSegmentFunction f = cp.piecewiseLinearFunction(arrX, arrV, dd, 0.0);
                return cp.endEval(task,f);

    is called.

    regards


    #ConstraintProgramming-General
    #DecisionOptimization