Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  CP sched_flowshop2 extend

    Posted 12/31/18 11:50 AM

    Originally posted by: JackA89


    Hi everyone,

    Currently I'm playing around with example from https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.8.0/ilog.odms.ide.help/examples/html/opl/models/sched_flowshop2/sched_flowshop2.mod.html

    When I try to extend the model to enable several machines units of the same resource type. It look like the constraint was ignored or I am doing wrong, please help me out.

    resources =  { 
       <CPUInstaller, 1>, 
       <DriveInstaller, 1>, 
       <CardInstaller, 1>,
       <CommInstaller, 1>,
       <Tester, 1>,
       <Packer, 1>
    };
    

    and the model look like

                                  
    tuple ResourceData {
            key string resourceType;
            int available;
    }
    
    tuple ResourceUnit{
            string resourceType;
            int unit;
    }
    
    {ResourceData} resources = ...;
    
    {ResourceUnit} availableResources = {<r.resourceType, i> | r in resources, i in 1..r.available};
    
    tuple JobAllocation {
             ComputerActivityMatch job;
             int machineId;
    }
    
    // Define the domain for the different choices when assigning a job to a machine
    {JobAllocation} jobAllocations = {<job, unit> | 
                                                                       job in allActivities, r in resources, unit in 1..r.available : job.activity.requirement == r.resourceType};
    
    dvar interval activity[a in allActivities] size a.activity.duration;
    
    dvar interval jobAllocation[j in jobAllocations] optional size j.job.activity.duration;
    
    dvar sequence resource[r in availableResources] in 
       all(a in allActivities: a.activity.requirement==r.resourceType) activity[a];
    

    .....

    constraint

    // Each activity is performed only once
    forall (r in allActivities) {
        noOverlap(all (a in jobAllocations : a.job == r) activity[r]); // <----- Problem here
    }
    

     

     

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: CP sched_flowshop2 extend

    Posted 01/02/19 04:32 AM

    Originally posted by: Petr Vilím


    Hello,

    could you please elaborate your question? The copy-pasted code in the question does not match with the code from the archive. Also model from the archive gives an error because "resources" from the data file are not used in model file. If I delete "resources" from data file then it seems to work fine. Why do you think the constraint is ignored? Could you give us a pair of intervals which overlap?

    Thanks, Petr


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: CP sched_flowshop2 extend

    Posted 01/02/19 08:05 AM

    Originally posted by: JackA89


    Hi Petr,
    Sorry because the previous model has errors. I would like to attach the new one here. 
    I want to extend the example by adding resource (to enable several machines units of the same resource type). I want to experiment, if I add 1 more Driverstaller then what will happen with the make span. The codes give error when increase the resources.

     

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: CP sched_flowshop2 extend

    Posted 01/02/19 11:29 AM

    Originally posted by: Petr Vilím


    I see now. And to say the truth I don't know why there are duplicate intervals in the sequence variable.

    However I think that you actually want to model something else: if there are 2 DriverInstallers then it is no longer a noOverlap resource. It is a resource that can handle up to two tasks at the same time (so some tasks my overlap, but not more than 2 at the same time). Such resources are modeled using cumul functions, see the following page for more information:

    https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.ide.help/refcppopl/html/cumul_functions.html

    You may also have a look at example sched_rcpsp: there are such resources and tasks that require some amount of some resource(s) (RCPSP is a classical scheduling problem).

    Best regards, Petr

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: CP sched_flowshop2 extend

    Posted 01/04/19 03:01 PM

    Originally posted by: JJC_UAB


    In this case, how should be formulated the cumul function for this example? 

    Thank you...

    I would like to know how to formulate the following constraint: 


    // Each activity is performed only once


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: CP sched_flowshop2 extend

    Posted 01/07/19 10:38 AM

    Originally posted by: Petr Vilím


    Here's what I would write, but I don't really understand the problem:

    subject to {
      
      // Remove symmetry
            forall(a1,a2 in allActivities: (a1.activity == a2.activity &&  a1.computerType == a2.computerType &&  a1.computer < a2.computer) ) {
                    BreakSymmetry: endBeforeStart(activity[a1], activity[a2]);
            }  
            
            forall (r in resources)
              ( sum (a in allActivities : a.activity.requirement == r.resourceType) pulse(activity[a], 1)) <= r.available;
     
            // Precedences
            forall( a in allActivities)
            forall( p in precedences[a])
                    Precedence[a,p]: endBeforeStart(activity[p], activity[a]);
      
    };
    

    The constraint for "each activity is performed only once" is not really necessary since we have only one interval variable for each activity.

    Is it some kind of homework? I saw another questions on the forum by you.

    Petr


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: CP sched_flowshop2 extend

    Posted 01/07/19 12:50 PM

    Originally posted by: JJC_UAB


    Hi Petr,

    Yes, it is a homework. We have to complete the code without modify the other parts. And the makespam should be less than the original problem. 

    The question is: 

    Extend your model from Exercise 1 to enable several machine units of

    the same resource type. The new required data set and structures are given to you in

    the data file and jobScheduling model template respectively.

    Neither data sets nor data structures should be modified. You must complete the

    decision variable declarations and adapt the constraints from Exercise 1 and add the

    new constraint as indicated in the model template.

     

     

    using CP;

     

    {string} ComputerTypes = ...;

    {string} ActivityTypes = ...;

    {string} ResourceTypes = ...;

     

    // Production work orders

    int requiredQuantities[ComputerTypes] = ...;

     

     

    /*************************************************

    * An activity consists of

    *   - an activity type,

    *   - a duration,

    *   - a unary resource requirement, and

    *   - a list of precedences.

    *************************************************/

    tuple ActivityData {

       key string  name;

              int     duration;

              string  requirement;

          {string} precedences;

    };

     

    {ActivityData} activities[ComputerTypes] = ...;

     

    /********************************************************

    * Each particular activity for each computer consist of:

    *   - a defined activity

    *   - for a computer type

    *   - for each computer to be manufatured

    ********************************************************/

    tuple ComputerActivityMatch {

       ActivityData activity;

       string       computerType;

       int          computer;            

    };

    // All activities that must get scheduled

    {ComputerActivityMatch} allActivities = {<a,c,j> | c in ComputerTypes,

                         a in activities[c],

                         j in 1..requiredQuantities[c]};

    // The activities which must precede an activity

    {ComputerActivityMatch} precedences[a in allActivities] = { b | b in allActivities :

                                     a.computerType == b.computerType &&

                                     a.computer == b.computer &&

                                     b.activity.name in a.activity.precedences };

     

    /********************************************************

      * Resource data consists of:

      *  - ResourceType

      *  - Number of available resorces of this type

      *******************************************************/                                 

    tuple ResourceData {

        key string resourceType;

        int available;

    }

     

    // for describing each resource (machine)

    tuple ResourceUnit{

        string resourceType;

        int unit;

    }

     

    /*************************************

    * Reads the defined resource units

    * for each resource type

    *************************************/

    {ResourceData} resources = ...;

     

    {ResourceUnit} availableResources = {<r.resourceType, i> | r in resources, i in 1..r.available};

     

    /**********************************************

    * Represent the pairs activity<->resouce unit

    **********************************************/

    tuple JobAllocation {

         ComputerActivityMatch job;

          int machineId;

    }

     

    /*********************************************

    * Define the domain for the different

    * choices when assigning a job to a machine

    *********************************************/

    {JobAllocation} jobAllocations = {<job, unit> |

                                    job in allActivities, r in resources, unit in 1..r.available : job.activity.requirement == r.resourceType};

                                     

    dvar interval activity[a in allActivities] size a.activity.duration;

    dvar interval jobAllocation [j in jobAllocations] optional size j.job.activity.duration; // complete the dvar declaration accordingly

    dvar sequence resource[r in availableResources] in

      all(a in allActivities: a.activity.requirement==r.resourceType) activity[a]; // complete the dvar declaration accordingly

       

    // Constraints labels

    constraint Precedence[allActivities,allActivities];

     

    execute {

            cp.param.FailLimit = 10000;

    }

     

    dexpr int makespan = max(a in allActivities) endOf(activity[a]);// Complete makespan expression;

     

    minimize makespan;

    subject to {

      // Remove symmetry

    forall(a1,a2 in allActivities:

            (a1.activity == a2.activity &&

             a1.computerType == a2.computerType &&

             a1.computer < a2.computer) )

         

               BreakSymmetry: endBeforeStart(activity[a1], activity[a2]);

               

            

    // Each activity is performed only once

       

              

      // Resource Requirements

             forall (r in availableResources)

            NoOverlap: noOverlap(resource[r]);

      // Precedences

      forall( a in allActivities)

         forall( p in precedences[a])

           Precedence[a,p]: endBeforeStart(activity[p], activity[a]);

    };


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 8.  Re: CP sched_flowshop2 extend

    Posted 01/07/19 12:52 PM

    Originally posted by: JJC_UAB


    Thank you for your help. And I try with your suggestion and it does not work either 

     

     

     

     

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 9.  Re: CP sched_flowshop2 extend

    Posted 01/08/19 04:17 AM

    Originally posted by: Petr Vilím


    Hello,

    I'm sorry, I cannot really make your homework for you..

    Best regards, Petr


    #DecisionOptimization
    #OPLusingCPOptimizer