Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
Expand all | Collapse all

a complex tuples and error in type "date"

  • 1.  a complex tuples and error in type "date"

    Posted 01/19/10 09:34 AM

    Originally posted by: SystemAdmin


    Hello,

    i would like to make a tuple in tuple,
    this is my code :

    K=1..nbcham
    J=1..nbroul

    tuple cham_data{
    int num_ch;
    date DA;
    date DL;
    }

    tuple roul_data{
    int num_roul;
    {string} cat;
    cham_data cham[K];
    }

    roul_data roul[J]
    in this code, i have two errors:
    • type "date" is not exist
    • error in the tuple roul_data
    i use ilog OPL 5.5 ( cplex)
    please, help me!!!
    thanks a lot

    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: a complex tuples and error in type "date"

    Posted 01/26/10 07:25 AM
    Hi,

    first of all date is not a keyword in OPL.
    Second, arrays of tuples are not allowed inside a tuple.

    So what would work:

    range K=1..nbcham;
    range J=1..nbroul;

    tuple cham_data{
    int num_ch;
    int DA;
    int DL;
    }

    tuple roul_data{
    int num_roul;
    {string} cat;
    //cham_data cham[K];
    int num_ch[K];
    int DA[K];
    int DL[K];
    }

    Alex
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: a complex tuple and error in type "date"

    Posted 01/27/10 07:27 AM

    Originally posted by: SystemAdmin


    Hi,

    Thanks alex for your help,

    I have J units of accomodation(roul[J]), each unit(roul) is identified by one number, one category and K of rooms (cham[K]).
    each room (cham) is identified by a number, date of assignment(DA) and date of liberation(DL)

    I must define roul[J] in my model

    I wait your reply as soon as possible
    thanks a lot Alex,
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: define the tuple that contains arrays

    Posted 02/04/10 07:15 AM

    Originally posted by: SystemAdmin


    Hi,
    thank you very much alex, your solution is worked but i find a problem to
    to enter the data about the tuple that contient arrays (roul[J])

    this is my code :

    int nbroul=9;
    int nbch=6;
    range K=1..nbch;
    range J=1..nbroul ;
    tuple roul_data{

    int num_R;
    string cat;
    // cham_data cham[K]
    int num_ch[K];
    int DA[K];
    int DL[K];
    }

    roul_data roul[J]= [<1, "C", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>,
    <2, "NC",1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>,
    <3, "J", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>,
    <4, "N", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>,
    <5, "F", 1,2,3,4,5,6,5,5,3,3,3,3,17,17,12,12,12,12>,
    <6, "F", 1,2,3,4,5,6,5,5,5,3,3,3,17,17,17,12,12,12>,
    <7, "H", 1,2,3,4,5,6,5,5,5,5,5,5,17,17,17,17,17,17>,
    <8, "H", 1,2,3,4,5,6,5,5,3,3,3,3,17,17,12,12,12,12>,
    <9, "H", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12]>;

    i find this error : "invalid initialization expression for element "roul" "

    can you help me please,
    Thanks a lot
    abir
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: define the tuple that contains arrays

    Posted 02/05/10 01:15 PM
    Hello,

    after the = you should follow the type you used.
    So you should write in your .mod

    int nbroul=9;
    int nbch=6;
    range K=1..nbch;
    range J=1..nbroul ;

    tuple roul_data{

    int num_R;
    string cat;
    // cham_data cham[K]
    int num_ch[K];
    int DA[K];
    int DL[K];
    }

    roul_data roul[J]=...;
    and in your .dat

    roul=[
    <1, "C", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>
    <2, "NC",1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>,
    <3, "J", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>,
    <4, "N", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>,
    <5, "F", 1,2,3,4,5,6,5,5,3,3,3,3,17,17,12,12,12,12>,
    <6, "F", 1,2,3,4,5,6,5,5,5,3,3,3,17,17,17,12,12,12>,
    <7, "H", 1,2,3,4,5,6,5,5,5,5,5,5,17,17,17,17,17,17>,
    <8, "H", 1,2,3,4,5,6,5,5,3,3,3,3,17,17,12,12,12,12>,
    <9, "H", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12]> ;

    Alex
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: define the tuple that contains arrays

    Posted 02/12/10 08:51 AM

    Originally posted by: SystemAdmin


    hello,

    thank you very much alex, i don't have un error now in roul[j],
    but i have another problem

    in my .mod (in constraint1), i must use "while" but i think
    is not exist in ILOG OPL (cplex)

    this is the code of constraint1:

    forall ( i in I, j in J)
    while (emp[i].cat != roul[j].cat) do
    X[i][j]==0;

    i think that i must use script in constraint1, but how can i insert the script in .mod?
    Can you help me please???

    thanks in advanced.
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 7.  Re: define the tuple that contains arrays

    Posted 02/12/10 10:00 AM
    hello,

    could you try

    forall ( i in I, j in J:emp[i].cat != roul[j].cat) X[i][j]==0;

    instead?

    Alex
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 8.  Re: define the tuple that contains arrays

    Posted 02/15/10 04:57 AM

    Originally posted by: SystemAdmin


    Hello,
    i tried this code

    forall ( i in I, j in J:emp[i].cat != roul[j].cat) X[i][j]==0;
    instead

    forall(i in I, j in J)
    while (emp[i].cat != roul[j].cat) do
    X[i][j]==0;

    but i found error in result, i usually find X[i][j]==0
    What can i do, so?
    Please help me and thanks in advanced
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 9.  Re: define the tuple that contains arrays

    Posted 02/15/10 04:17 PM
    Hello,

    I would understand that you reported an error if you found X[i][j]!=0 for a (x,y) such as emp[i].cat != roul[j].cat but what is the issue with having too many X[i][j]==0?
    No constraint is violated.

    Alex
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 10.  Re: define the tuple that contains arrays

    Posted 02/16/10 06:43 AM

    Originally posted by: SystemAdmin


    hello,
    i will present the code and explain you the problem

    int nbemp=6;
    int nbch=6;
    int nbroul=9;
    range I=1..nbemp;
    range K=1..nbch;
    range J=1..nbroul ;

    tuple emp_data {
    int num_emp;// Numéro employé
    string n_entrep;//nom entrepreneur
    string cat ;// catégorie d'employé={ homme, femme, jour, nuit, cadre, non cadre}
    int DA; // date d'arrivée de l'employé
    int DD; // date de départ de l'employé
    }

    emp_data emp[I]=...;

    tuple roul_data{

    int num_R; // numéro roulette(unité d'hébergement)
    string cat; // catégorie roulette
    int num_ch[K]; // numéro chambre
    int DA[K]; // date d'affectation de la chambre
    int DL[K]; // date de libération de la chambre
    }

    roul_data roul[J]=...;

    in .dat we have

    emp=[<1 , "Marie" , "H" ,15, 23>,
    <2 , "Richard" , "H" ,15, 23>,
    <3 , "Marie" , "F" ,15, 23>,
    <4 , "Marie" , "F" ,15, 23>,
    <5 , "Richard" , "F" ,15, 23>,
    <6 , "Richard" , "F" ,15, 23>];

    roul= [<1, "C", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>,
    <2, "NC",1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>,
    <3, "J", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>,
    <4, "N", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12>,
    <5, "F", 1,2,3,4,5,6,5,5,3,3,3,3,17,17,12,12,12,12>,
    <6, "F", 1,2,3,4,5,6,5,5,5,3,3,3,17,17,17,12,12,12>,
    <7, "H", 1,2,3,4,5,6,5,5,5,5,5,5,17,17,17,17,17,17>,
    <8, "H", 1,2,3,4,5,6,5,5,3,3,3,3,17,17,12,12,12,12>,
    <9, "H", 1,2,3,4,5,6,3,3,3,3,3,3,12,12,12,12,12,12]>;
    when i compile, i usually found all x[i][j]==0 (false result)
    because with this .dat we musn't have all x[i][j]==0

    for example we must forbiden the assignment of employee 1 with categorie "H" to unit of accomodation 1,2,3,4,5 and 6
    so X[1][1]=X[1][2]=X[1][3]=X[1][4]=X[1][5]=X[1][6]==0
    but X[1][7],X[1][8]and X[1][9] mustn't ==0

    i will more explain

    in constraint1: we mustn't assign (affect) the employee with categorie "Homme"
    (emp[i].cat) to the unit of accomodation with catégorie "Femme"(roul[j].cat)
    and we can't write if (emp[i].cat == roul[j].cat) X[i][j]==1;
    because we have others constraints to do the assignement(affectation).

    taht's why i tried

    1/ forall(i in I) forall(j in J)
    if (emp[i].cat != roul[j].cat)
    X[i][j]==0;
    2/ forall(i in I,j in J :emp[i].cat != roul[j].cat ) X[i][j]==0;

    but it's false
    what can I do,so ?

    tahnks alex for your patience and help
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 11.  Re: define the tuple that contains arrays

    Posted 02/16/10 09:29 AM
    Hi,

    if you want to have some X[i][j]!=0

    maybe you should also write

    forall(i in I,j in J :emp[i].cat == roul[j].cat ) X[i][j]!=0;

    Alex
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 12.  Re: define the tuple that contains arrays

    Posted 02/17/10 12:39 PM

    Originally posted by: SystemAdmin


    Hi Alex,

    i found an error in constraint4 that's why i usually find all X[i][j]==0
    So
    forall(i in I,j in J : emp[i].cat != roul[j].cat ) X[i][j]==0; is right

    thank you vvvvvvery much alex,
    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 13.  Re: define the tuple that contains arrays

    Posted 03/06/10 11:44 AM

    Originally posted by: SystemAdmin


    hello Alex,

    Could you help me please to modeling this constraint(called priority constraint):

    i have 2 units of accommodation types (R[t] and Rnt)

    R[t]= set of units that contain empty rooms and full rooms
    Rnt=set of units that contain only empty rooms = empty units

    i would like to affect employees to the empty rooms of units (each employee must have one room)
    but i must use the empty rooms of R[t] before using empty units (Rnt)

    for exemple:
    i have one unit of accomodation R[1] that contains 4 empty rooms and 2 full rooms
    and another unit R[2] that contains 6 empty rooms (empty unit)

    if i must affect 3 employees to the empty rooms of units.the model will affect the 3 employees to the R[1]
    if i must affect 5 employees to the empty rooms of units.So the model will affect 3 employees to the R[1] and 2 employees to the R[2]
    Thanks in advanced
    Abir,
    #DecisionOptimization
    #OPLusingCPLEXOptimizer