Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Simple Assignment Problem

    Posted 05/29/19 02:18 PM

    Originally posted by: Chris Metzger


    I have a simple problem but I'm not sure how to structure it. I have a list of rooms each of which can contain a certain number of people. I also have a list of people of various ages. I want to minimize the difference in ages within each room while assigning as many people to rooms as possible. Right now I have a couple tuple sets for the inputs and I generate another tuple set based off the rooms list with an extra column for number of possible people in the room. My boolean decision variable is indexed by these two tuple sets. I'm not sure how to get at the ages of those assigned to a given room so I can set the constraint though. Any suggestions?


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Simple Assignment Problem



  • 3.  Re: Simple Assignment Problem

    Posted 05/29/19 05:19 PM

    Originally posted by: Chris Metzger


    I think I can use some of this. My difficulty is that the rooms have defined capacities, and the participants have defined ages. The example seems to have arbitrary groups. There's also some restrictions I need to put on the assignments so that room and participant characteristics match up. It looks like I should enumerate the rooms as integers and refer to their characteristics using that integer through an indexed array. I will start with that.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Simple Assignment Problem

    Posted 05/30/19 08:37 AM

    Hi,

    then you could try

    tuple room
    {
    int id;
    int capacity;
    }

    tuple person
    {
    int id;
    int age;
    }

    int big=100000;
    int nbRooms=5;
    int nbPersons=40;

    {room} rooms={<i,10+rand(10)> |i in 1..nbRooms};
    {person} persons={<i,18+rand(20)> |i in 1..nbPersons};

    dvar boolean x[persons][rooms]; // Is a given person in a given room
    dvar int minAge[rooms];
    dvar int maxAge[rooms];
    dvar int maxdelta;

    // first try to assign all persons and then minimize max delta per room
    maximize staticLex(sum(p in persons,r in rooms) x[p][r],-maxdelta);
    subject to
    {
    forall(p in persons) sum(r in rooms) x[p][r]<=1; // a person is in 0 or 1 room

    forall(r in rooms) sum(p in persons) x[p][r]<=r.capacity;

    forall(r in rooms)
      {
         maxAge[r]==max(p in persons) p.age*x[p][r];
         minAge[r]==big-max(p in persons) (big-p.age)*(x[p][r]);
      }
     
    forall(r in rooms) (maxAge[r]-minAge[r])<=maxdelta;  
    }

    regards

     

    https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Simple Assignment Problem

    Posted 05/30/19 08:54 AM

    Originally posted by: Chris Metzger


    Ah, I think that will work! I was trying to wrap my brain around finding the min and max age in a room and getting tripped up by not indexing by rooms and getting strange results with the max function (it was returning either 0 or a very large number for some reason). Thanks Alex!


    #DecisionOptimization
    #OPLusingCPLEXOptimizer