Decision Optimization

 View Only
  • 1.  Sequence of an interval?

    Posted Wed December 30, 2020 02:05 PM

    Hi everyone!

    I have a cumul function for each sequence and I need to limit the value of this function based on the intervals in those sequences.

    So, for example, if one of the intervals in a sequence has a characteristic of 1 the function will be f<=5.

    The problem is that I don't know how to obtain the sequence from each interval (it's part of the problem).

    These intervals are not repeated, they are distributed among the sequences.

    //Example

    range sequences = 1..2

    int intervals = 1..10

    int charac[intervals]=[0 1 0 0 0 0 0 0 0 1];

    dvar interval intv[i in intervals][a in sequences] size 1;
    dvar sequence s[a in sequences] in all(i in intervals) intv[c][a];

    I have tried this with no success:

    • forall (a in sequences)
      forall(i in Intervals: charac[i] == 1)
      if (presenceOf(intv[i][a]) == True) {
         f[a] <= 5;
      }

    Thanks for helping :)



    ------------------------------
    Tomas
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Sequence of an interval?

    Posted Thu December 31, 2020 03:56 AM
    Hi

    using CP;
    
    range sequences = 1..2;
    
    range intervals = 1..10;
    
    int charac[intervals]=[0 ,1 ,0, 0 ,0 ,0 ,0 ,0, 0, 1];
    
    dvar interval intv[i in intervals][a in sequences] size 1;
    dvar sequence s[a in sequences] in all(i in intervals) intv[i][a];
    
    cumulFunction f[a in sequences]=sum(i in intervals) pulse(intv[i][a],1);
    
    subject to
    {
    forall (a in sequences)
    forall(i in intervals: charac[i] == 1)
     
       (f[a] <= 5*(presenceOf(intv[i][a]) == 1)+1000*(presenceOf(intv[i][a]) == 0));
    }​


    works fine

    regards



    ------------------------------
    [Alex] [Fleischer]
    [EMEA CPLEX Optimization Technical Sales]
    [IBM]
    ------------------------------



  • 3.  RE: Sequence of an interval?

    Posted Mon January 04, 2021 07:32 AM
    Hi Alex,
    Thanks for your reply. I tried your code and I saw that, if intervals are optional, unlimited expression error is obtained. 

    dvar interval intv[i in intervals][a in sequences] optional size 1;​


    As the intervals are distributed among the sequences (through an alternative constraint, similar to the sched_tcost example), intervals need to be optional. Actually I don't really know why, but this example doesn't work if intervals aren't optional.



    ------------------------------
    Tomas
    ------------------------------



  • 4.  RE: Sequence of an interval?

    Posted Mon January 04, 2021 08:40 AM
    Hi

    using CP;
    range sequences = 1..2;
    
    range intervals = 1..10;
    
    int charac[intervals]=[0 ,1 ,0, 0 ,0 ,0 ,0 ,0, 0, 1];
    
    dvar interval  intv[i in intervals][a in sequences] optional size 1;
    dvar sequence s[a in sequences] in all(i in intervals) intv[i][a];
    
    cumulFunction f[a in sequences]=sum(i in intervals) pulse(intv[i][a],1);
    
    dvar int v[i in intervals][a in sequences];
    
    subject to
    {
      forall(a in sequences,i in intervals) v[i][a]==5*presenceOf(intv[i][a]) +1000*(1-presenceOf(intv[i][a]));
      
      
    forall(a in sequences)
      forall(i in intervals: charac[i] == 1)
     (f[a] <= v[i][a]);
     }​


    works fine

    regards



    ------------------------------
    [Alex] [Fleischer]
    [EMEA CPLEX Optimization Technical Sales]
    [IBM]
    ------------------------------



  • 5.  RE: Sequence of an interval?

    Posted Mon January 04, 2021 02:34 AM
    Do you need to constrain the cumul function f during the complete horizon (for all t: f(t)<=5) of only during some interval ?

    ------------------------------
    Philippe Laborie
    ------------------------------



  • 6.  RE: Sequence of an interval?

    Posted Mon January 04, 2021 07:36 AM
    Hi Philippe,
    Yes, cumul function need to contrain during the complete horizon.

    ------------------------------
    Tomas
    ------------------------------



  • 7.  RE: Sequence of an interval?

    Posted Mon January 04, 2021 10:03 AM
    Edited by System Fri January 20, 2023 04:41 PM
    There is something strange in this model.
    As you are using some sequences of interval variables, I guess at some point you will post a noOverlap constraint on these sequences otherwise you do not need to use the concept of sequence variable. 
    But then, if the intervals on a sequence do not overlap, the cumul function will always be <= 1 so I do not see why you would post some maximal level (like 5) on these cumul functions.

    ------------------------------
    Philippe Laborie
    ------------------------------



  • 8.  RE: Sequence of an interval?

    Posted Mon January 04, 2021 04:24 PM
    True. Alex wrote the model with a pulse cumulfunction.
    In the model I am working at I have a stepAtStart, so I can limit the amount of intervals in each sequence.

    ------------------------------
    Tomas
    ------------------------------



  • 9.  RE: Sequence of an interval?

    Posted Tue January 05, 2021 03:28 AM
    Ok, I see. I guess you also have some decrease of the cumul function so a mix of +stepAtStart and some -stepAtStart|End ?

    ------------------------------
    Philippe Laborie
    ------------------------------