Decision Optimization

 View Only
  • 1.  Urgent Help Needed

    Posted Fri February 24, 2023 08:06 AM

    Hi,

    I appreciate very much if you help me resolve the error in the following simple example. Here are the mod and dat files:

    // mod file

    using CP;

    tuple Task {

      key int id;

      int   duration;

      {int} FSSuccs;

      {int} FSLags;  

    }

    {Task} Tasks = ...;

    dvar interval task[t in Tasks] size t.duration;

    minimize   max(tt in Tasks) endOf(task[tt]);

    subject to {

                                //Gives error "Not an Array" on the Lag t1.FSLags[<t2>] 

                                //but works if I put any constant value, like 0 or any other value

      forall (t1 in Tasks, t2 in t1.FSSuccs) endBeforeStart(task[t1], task[<t2>], t1.FSLags[<t2>]);  

    }

    execute {

     }

    //.dat File

    Tasks = {

      < 1, 8, {6},{6}>,

      < 2, 8, {5,3,4},{2,0,3}>,

      < 3, 7, {5},{0} >,

      < 4, 4, {5,6},{0,0} >,

      < 5, 9, {8},{8} >,

      < 6, 6, {},{}>,

      < 7, 12, {},{} >,

      < 8, 4, {},{} >,

     };



    ------------------------------
    Tarek Hegazy
    ------------------------------


  • 2.  RE: Urgent Help Needed

    Posted Fri February 24, 2023 08:25 AM
    Edited by Hugues Juille Fri February 24, 2023 08:28 AM

    Hi Tarek,

    t1.FSLags is a set, not an array. It is however considered as an ordered set where elements can be accessed by their index.

    For instance, one could write your constraint as follows:

    endBeforeStart(task[t1], task[<t2>], item(t1.FSLags, 0));

    I hope this can help you.

    Best regards,

    Hugues

    PS: I suppose a better formulation would be: item(t1.FSLags, t2). However, I'm not sure to understand the values for FSSucc in your data. The later formulation will result in errors if executed with your data.



    ------------------------------
    Hugues Juille
    ------------------------------



  • 3.  RE: Urgent Help Needed

    Posted Fri February 24, 2023 09:07 AM

    Fantastic. It worked. Very much appreciated. You are a life saver. Thank you.

    Tarek



    ------------------------------
    Tarek Hegazy
    ------------------------------



  • 4.  RE: Urgent Help Needed

    Posted Tue September 19, 2023 05:49 PM

    Hi,

      item(t1.FSLags, t2) is the correct thing to use. Without it the answers are wrong. Is there any other way to get the proper index to t2?

    Thanks in advance.



    ------------------------------
    Tarek Hegazy
    ------------------------------