Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

define type of interval in sequence ?

  • 1.  define type of interval in sequence ?

    Posted Sun October 27, 2013 11:21 PM

    Originally posted by: qtbgo


    Hi, I want to implement something like the following definition:

    dvar sequence sq[i in T][j in C][n in T][m in C] in append(Y[i][j],Y[n][m]) types [i*100+j, n*100+m] ; 

    What I want is to assign the  type to the two intervals, but the above definition cannot be accepted by ILOG. Can anyone tell me how to achieve it?

    Thanks in advance.


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: define type of interval in sequence ?

    Posted Mon October 28, 2013 12:13 PM

    Originally posted by: GGR


    Hi qtbgo

    I do not think you can use the syntax of data declaration of array : [i*100+j, n*100+m] in the model declaration. If the append function on two interval variable Y[i][j],Y[n][m] is accepted, then it is also true for appending two integers append(*100+j, n*100+m);

     

    Your expression seems very weird, you are declaring (|C|*|T|)^2 interval variables of two intervals Y[i][j],Y[n][m] which are the same if(i ==n and j == m. You will not have any solution!. Moreover if all pairs of interval are in noOverlap, you only need one interval variables sequences of all the interval variables.

     

    Hope that helps

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: define type of interval in sequence ?

    Posted Mon October 28, 2013 09:15 PM

    Originally posted by: qtbgo


    Hi, GGR, thanks for your help.

    In fact, my purpose is to reproduce a CP model from a paper. In the paper, it said:

    Sijnm: a sequence variable that keeps the relative ordering of tasks i and n processed by QCs j and m, respectively, domain(Sijnm)={order of Yij and Ynm}, with transition distance matrix Wijnm=|li-ln| + (1 +s)(m-j) for all i, j in T,  j, m in C.

    Then it gave the following constraints:

    disjunctive(Sijnm, W) ;  forall i,n in T, j,m in C: mm>j && ln<li+(1+s)*(mm-j)

    It seems that it defined many sequence variables and the transition time depends on i,j,n,m. I find  it difficult to implement it. Could you give me some suggestion?

     

     

     

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: define type of interval in sequence ?

    Posted Wed October 30, 2013 09:33 PM

    Originally posted by: qtbgo


    Hi, GGR

      You said  " If the append function on two interval variable Y[i][j],Y[n][m] is accepted, then it is also true for appending two integers append(*100+j, n*100+m);", so I define the following:

    dvar sequence sq[i in T][j in C][n in T][m in C] in append(Y[i][j],Y[n][m]) types  append(i*100+j, n*100+m);

    forall(i, n in T, j, m in C : m>j && l[n]<l[i]+(1+s)*(m-j)) 

       noOverlap(sq[i][j][n][m]);

    For the testing purpose, I didn't use transition time in the noOverlap. But it still report error: the initializing expression of sq is invalid. It seems that we cannot use i, j, m, n this way to define types.


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: define type of interval in sequence ?

    Posted Thu October 31, 2013 11:54 AM

    Originally posted by: GGR


    Hi

     

    If you do not use the transition features in the model (transition distance, type/Start/End/LenghtOfNext/Previous you do not need type of the intervals in declaration of the sequence variable.

     

    If you have an error, please check out it is an OPL language syntax error or if the error comes form the solving part. If it is a syntax error, refer to the OPL documentation.

     

    Hope that helps

     

     

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: define type of interval in sequence ?

    Posted Thu October 31, 2013 10:48 PM

    Originally posted by: qtbgo


    Hi, GGR, I check the error, but still cannot figure out why. I build  a simplified version of the model as follows, the error message is attached also, it is in Chinese. In the following code, when I use append(1,2), no error, when I use append(i*100+j, nn*100+mm), error occurs.

    //Quay Crane Scheduling Problem
    using CP;
    int n=10;
    int b=10;
    int q=2;
     
    range T = 1..n; //tasks set
    range B = 1..b; //bays set
    range C = 1..q; //quay cranes set
     
    int l[T] = [2,10,3,2,6,2,7,7,3,5]; //li bay of task i
     
     
    tuple triplet { int loc1; int loc2; int value; }; 
    {triplet} W = { <t1, t2, t1+t2> | t1, t2 in 1..10000}; // 
     
     
    dvar interval Y[i in T][j in C] optional in 0..10000 size 10 ;  
    dvar sequence sq[i in T][j in C][nn in T][mm in C] in append(Y[i][j],Y[nn][mm])  types append(i*100+j, nn*100+mm);//append(1,2); 
     
    ////////////////////////    
    minimize  max(i in T, j in C) endOf(Y[i][j]);  //objective
     
    subject to {
      forall(i, nn in T, j, mm in C : mm>j && l[nn]<l[i]+2*(mm-j))   
         noOverlap(sq[i][j][nn][mm], W);
    };
     
       
     

    #DecisionOptimization
    #OPLusingCPOptimizer


  • 7.  Re: define type of interval in sequence ?

    Posted Mon November 04, 2013 10:20 AM

    Originally posted by: GGR


    Hi

     

    You have two problems:

    1) You are created 10k sequences using a 10^4 full square matrix array for your transition matrix. I think OPL is exploding in memory usage!!

     

    As I told you before, you have to rethink your model avoiding a huge number of sequence.. Second, the transition type framework is made for contiguous 0..N-1 indexed matrix array without any holes but contingent. You have to create tuple set to compute  your sequences and their arguments for the declaration and noOverlap constraint. 

     

    2) It seems there is a bug in  the line  types append(i*100+j, nn*100+mm).

     

    Hope that helps

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 8.  Re: define type of interval in sequence ?

    Posted Tue November 12, 2013 11:58 PM

    Originally posted by: qtbgo


    Thank you GGR, Your suggestion is very good.

    1. But for now, I just wonder if it is possible to reference the subscripts in types keyword, if can, how?  Even I set n and b to a smaller number, say 5, it still has error.

    2  "It seems there is a bug in  the line  types append(i*100+j, nn*100+mm)"

    could you tell me what the bug is?

      

     

     

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 9.  Re: define type of interval in sequence ?

    Posted Fri November 15, 2013 07:57 AM

    Originally posted by: GGR


    Hi

     

    The bug is using  integer expressions in an append constructor of array in the size field of the sequence variable declaration

    You have to pass by all formulation for creating the array in the size field of the sequence variable declaration

    Cheers


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 10.  Re: define type of interval in sequence ?

    Posted Fri November 15, 2013 09:01 AM

    Originally posted by: qtbgo


    Dear GGR, thanks for your response. I am so sorry that I troubled you so much.

    But I am still confused about how to achieve it. I don't see the size field in the sequence variable declaration. 

    Would you be kind enough to write out the correct definition of the sequence variable, which could achieve my purpose.


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 11.  Re: define type of interval in sequence ?

    Posted Fri November 15, 2013 12:38 PM

    Originally posted by: GGR


    Hi

     

    Sorry my mistake. I meant the field types of interval sequence variable.

     

    Cheers

     

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 12.  Re: define type of interval in sequence ?

    Posted Tue October 29, 2013 06:45 AM

    Originally posted by: GGR


    Hi

    If the model define a lot of sequence on set of  non intersecting variable, you have no choice.

    There is anyway some practices to have a lighter model

    Created the sequence for the strongly connected component from the set of sequences:

    That is if you have 3 sequence (a,b), (b,c), c, a) preprocess it as one sequence only (a, b, c)

    second, if a sequence has two variable it is less expensive to use an explicit model:

    dvar interval a;
    dvar interval b;
    int a2b=10;
    int b2a=8;
    dvar interval a1 optional;
    dvar interval a2 optional;
    dvar interval b1 optional;
    dvar interval b2 optional;
    alternative(a, append(a1, a2]);
    alternative(a, append(b1, b2);
    endBeforeStart(a1, b1, a2b);
    endBeforeStart(a2, b2, b2a);

    Hope that helps


    #DecisionOptimization
    #OPLusingCPOptimizer