Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Using a decision variable in a range

    Posted 09/08/16 11:55 AM

    Originally posted by: CharlCillie


    Hi, I have a problem that I cannot find a solution for. I've looked through the other questions and couldn't find any similar questions or answers.

     

    I'm allocating students into groups, while creating diversity in the groups regarding the departments they are from.

    Currently, I have this in my model:

    int N = 510;        // number of students
    int G = 99;        // number of groups

    int P = 9;        // number of groups that a pool should consist of

    range students = 1..N;

    range groups = 1..G;

    etc.

     

    FIRST PROBLEM: I want every group to either have a size of 5 students, or 6 students. This means that there can be either more groups consisting mostly of smaller amounts of students, or less groups consisting mostly of a larger amount of students. The size for every group, and thus the amount of groups should be decided by Cplex when optimizing. Then, this amount of groups is used in the place of the "G" used above. Is this possible to do, and how??

    My idea was something like having this constraint:

    (N/6) <= G <= (N/5);

    but this obviously won't work.

     

    SECOND PROBLEM: The number of groups formed must be a multiple of the pool size (in this example, the pool size is 9. Therefore there must be 90 groups, or 99 groups, or 108 groups, etc, with each group having a size of either 5 or 6 students. How could I go about doing this??

    My idea was to use this constraint:

    (G/P) == (integer)

    but i dont know how to implement this - is there a symbol to tell Cplex that i want the answer to be an integer?

     

    Regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Using a decision variable in a range

    Posted 09/08/16 12:53 PM

    Hi,

    if you want x to be integer you should use dvar int

    For example:

    dvar int x in 0..5;

    will say that x should b integer and between 0 and 5

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Using a decision variable in a range

    Posted 09/08/16 02:40 PM

    Originally posted by: CharlCillie


    Not sure if you understand my question correctly. Otherwise I don't understand where I should implement your suggestion - could you just make that a bit more clear, please?

    Thanks


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Using a decision variable in a range

    Posted 09/08/16 03:23 PM

    Hi

     

    First problem:

    using CP;
        
    int N = 510;        // number of students
    int G = 99;        // number of groups

    int P = 9;        // number of groups that a pool should consist of

    range students = 1..N;

    range groups = 1..G;

    dvar int x[1..N] in 1..G; // which group for each student

    subject to
    {
    // every group to either have a size of 5 students, or 6 students

    forall(g in groups) count(x,g) in 5..6;


    }

    Second problem

     

    Do check that G / P is integer, you may compute G % P

     

    Do you do some research or do you tackle a business problem ?

     

    regards

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: Using a decision variable in a range

    Posted 10/12/16 07:37 PM

    Originally posted by: CharlCillie


    Hi Alex

    Sorry for taking so long to reply, I had to put my work aside for a while. And yes - the questions I'm asking is regarding research that I'm doing.

     

    Thank you very much for your answers. Im not sure that you understood my first questions correctly, so let me try again by giving some more detail. I have a problem where I need to divide 500 students into groups. An interval for the group sizes must be chosen by the user, which will determine the sizes of the groups. The number of groups that are created, however, should be an output by the program. In other words, the model will decide how many groups should be created. (For example, if the limits for group sizes are specified to be between 4 and 5 students per group, then the model can either choose to create 100 groups of size 5 each, or 125 groups of size 4 each, or a combination of 100 groups of size 4 each and 20 groups of size 5 each, etc.). Also, the amount of groups that are created should be a multiple of the variable P (also defined by the user). This means that if P is defined to be 10, then there must be 90 groups, or 100 groups, or 110 groups, etc that are created by the model. This amount of groups that the model choose to create are then saved as the integer G, which is then used in the model. I am not sure how to implement this, but let me try to explain:

     

    MODEL:

    int N = 500;        // number of students

    int P = 9;        // number of groups that a pool should consist of

    dvar int G = ...;        // number of groups that will be created by the model

    float a[students] = ...;           // marks of the students that are read in from the Excel sheet

    dvar boolean x[students][groups];        // decision variable, equal to 1 if student i is allocated to group j

     

    // lower and upper bounds for the sizes of the groups, that will be defined by the user in an Excel sheet:

    int cl = ...;
    int cu = ...;

     

    range students = 1..N;

    range groups = 1..G;

     

    // variables to be minimized in the objective function:
    dvar float vpos[groups][groups];

    dvar float vneg[groups][groups]; 

     

    // Objective function:

    minimize sum(j in groups, k in groups)(vpos[j][k] + vneg[j][k]);

     

    subject to{
      forall(j in groups, k in groups)

            sum(i in students)x[i][j]*a[i] - sum(y in students)x[y][k]*a[y] - vpos[j][k] + vneg[j][k] == 0;      // goal programming formulation just allocate values to variables vpos and vneg in order to minimize the difference in marks between groups.

     

    // other general constraints:
      forall(i in students)
        sum(j in groups) x[i][j] == 1;        // ensures that every student is only allocated to one group.
        
      forall(j in groups)
        cl <= sum(i in students)x[i][j] <= cu;          // group sizes must be larger than the lower bound and smaller than the upper bound for group sizes
        
      forall(j in groups)
        (N/cu) <= G <= (N/cl);       //  ensures that the amount of groups formed will be able to contain all of the students.

     

    // NB - NOW I STILL NEED A CONSTRAINT IN ORDER TO MAKE SURE THAT THE AMOUNT OF GROUPS FORMED ARE A MULTIPLE OF THE VARIABLE P.

    }

     

    DATA:

    SheetConnection allocations2016("Data");

     

    //The following variables are filled in on the Excel sheet by the user:

    P from SheetRead(allocations2016,"'Data'!L4");
    cl from SheetRead(allocations2016,"'Data'!I8");
    cu from SheetRead(allocations2016,"'Data'!O8");

    N from SheetRead(allocations2016,"'Data'!U2");

     

    a from SheetRead(allocations2016,"'Marks'!E2:E502"); // This is read from the excel sheet from a list containing all the marks of all the students.


    #DecisionOptimization
    #OPLusingCPLEXOptimizer