Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Assigning teams to projects across time periods with precedence and teams allowed in time period constraints using Python

  • 1.  Assigning teams to projects across time periods with precedence and teams allowed in time period constraints using Python

    Posted Mon May 04, 2020 02:43 AM
    I have an assignment problem where I have projects to be completed in time periods. Each project has it's own team requirement and each time period can only accommodate a maximum number of teams. The projects also have precedence constraints. I have pasted some sample data below:

    Project Data:                                                                                                
    Project Priority Teams Needed
    A001 1 4
    A002 1 2
    A003 2 2
    A004 2 3

    Time Period Data:
    Time Period Teams Allowed
    PI01 3
    PI02 4
    PI03 6

    Here are my constraints that need to be satisfied:
    1) All the projects should be completed - The required number of teams should be assigned to the projects across the 3 time periods
    2) The 3 time periods cannot have more teams than their respective Teams Allowed
    3) Projects with priority 1 should start before projects with priority 2

    How do I model this in docplex.cp in Python? I have thought about using interval variables, but how do I code the constraint where each time period can only the maximum number of teams allowed in that time period? A skeleton code snippet in Python would be amazing. Thanks in advance!

    ------------------------------
    Keerthivasan C
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Assigning teams to projects across time periods with precedence and teams allowed in time period constraints using Python

    Posted Mon May 04, 2020 03:00 AM
    How about creating a binary variable for each combination of team/project/period that is 1 iff a team is assigned to a project in a certain period? With this you can easily state the constraints you required. For example (untested code) each team can only serve one project in each period:
    mdl.add_constraints(mld.sum(x[team, project, period] for project in projects) <= 1 for team in teams for period in periods)
    For the starting time you may need extra variables to model this. Maybe the same can be achieved with interval variables as well.

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 3.  RE: Assigning teams to projects across time periods with precedence and teams allowed in time period constraints using Python

    Posted Mon May 04, 2020 09:07 AM

    Hey Daniel

    Thanks for the reply. In my problem, I don't have a pre-defined set of teams available. I am using the constraints, i.e., the teams needed for each project, maximum teams allowed in each time period and the precedence constraints to inform how many teams I should hire. Let me illustrate further:

    PI01 PI02 PI03
    A001 2 2
    A002 1 1
    A003 1 1
    A004 3

    The above table is one of the many possible solutions for my problem. Here, as you can see - the teams needed for all projects are satisfied, each time period doesn't have more teams assigned than it's permissible limit and A003, A004 whose precedences are 2 start after A001, A002 whose precedences are 1. Now, with this solution in hand, I know I need 3, 4, 4, teams across the 3 time periods respectively and hence I can go hire/contract them. With binary variables, I can't model this as it can only take the values 0 or 1 and with integer variables, I am unable to understand how to specify the max. teams allowed in each time period constraint. It would be great if you can explain how I can model this with a sample code snippet as I am a complete beginner to CPLEX/docplex. Thanks in advance.

    ------------------------------
    Keerthivasan C
    ------------------------------