Decision Optimization

Decision Optimization

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

 View Only
  • 1.  clustered task question

    Posted Wed March 31, 2010 11:03 AM

    Originally posted by: SystemAdmin


    I have a tuple that defines a task in my model. Our task may actually be a 'supertask' or cluster of multiple individual tasks.
    The original tuple that did not model clusters ooked something like
    tuple OPP {
    key OppID oppID; //a tuple uniquely identifying this OPP
    int duration;
    int value;
    int realTask; //this identified the ID of the task done by the OPP. This was necessary because multiple OPPs could contain the same task.
    }

    In order to modify this to handle clustered tasks, I naively added an 'int cInd' to the OPP tuple and then created a separate Cluster tuple:
    tuple Cluster {
    int cInd;
    int rInd;
    }

    Thus, I could now associate a set of Cluster tuples to my OPP tuple and therefore know what tasks are contained in the cluster and I could still create an 'alternative' constraint that said I can schedule exactly one interval that contains realTask i:
    forall(i in realTasks)
    alternative(targets[i], all(t in allOpps, c in clusteredOpps: t.cInd == c.cInd && c.rInd == i && t.isPI == 0) routeLegOpps[t]);
    The above is inefficient to say the least, especially if I have large numbers of clustered tasks, which I do. Looking through this forum's messages, I found that I could simply make a set a member of my OPP tuple:
    tuple OPP {
    key OppID oppID; //a tuple uniquely identifying this OPP
    int duration;
    int value;
    sorted {int} cluster;
    }

    However, I cannot figure out how to create the same 'alternative' constraint now. I can't figure out how to access the elements of OPP.cluster in the alternative constraint. My apologies if this is an elementary question, but everything I try brings up some sort of syntax error. Any ideas please?
    Thank you.
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: clustered task question

    Posted Thu April 01, 2010 05:36 AM

    Originally posted by: SystemAdmin


    Hello,
    There is something I do not understand in your tuples: why do you need an additional member "cInd" in the OPP tuple, can't you just reuse the "oppID" key?

    Similarly, in the model with sets as member, what does the integer in the "cluster" set represent? Shouldn't it be an OppID too?

    
    tuple OPP 
    { key OppID oppID; 
    //a tuple uniquely identifying this OPP 
    
    int duration; 
    
    int value; sorted 
    {
    
    int
    } cluster; 
    }
    


    Then, I also do not understand the way alternative constraints are created:

    
    forall(i in realTasks) alternative(targets[i], all(t in allOpps, c in clusteredOpps: t.cInd == c.cInd && c.rInd == i && t.isPI == 0) routeLegOpps[t]);
    


    The array "routeLegOpps" is indexed by t in allOps so if I understand well, the clusters are used here only to filter some t in allOpps to keep only the ones that contain a cluster element on real task i. In this case, can't you directly store a boolean (instead of a set) in the OPP tuple?

    Philippe
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: clustered task question

    Posted Thu April 01, 2010 10:41 AM

    Originally posted by: SystemAdmin


    Hi Philippe,
    Regarding your first question, when I first tried to do clustering and thought of using a duple with an ID and one member of the cluster, I didn't want to use oppID (which is a triple) to input thousands of such tuples. But since it probably is more efficient internally, once I have everything correct in the updated model, you are correct in that I could reference it using the oppID.
    I don't follow your second question: a cluster should contain the integer IDs of all real tasks in that cluster. Thus, given an oppID of <1,1,1>, assume it clusters tasks 4, 6, and 8 together. I assumed that meant I need to create an integer set called 'cluster' and make it a member of the OPP tuple or create a separate tuple called "Cluster" and make IT a member of the OPP tuple. I don't think I need a separate tuple so I'm assuming I should do:
    
    
    {
    
    int
    } cluster
    
    . The 'sorted' is not necessary though I had it in there to keep my input neat.

    For the alternative constraint question, start with the model I use with no clusters. For real task 5, there may be 25 different OPPs (each with its own unique oppID). If real task 5 is not of type "PI", then exactly one OPP can be scheduled for it:
    
    forall(i in realTasks) ctRealTaskOneLook: 
    //can't do the same underlying task twice except for PIs alternative(targets[i], all(t in allOpps: t.isPI == 0) routeLegOpps[t]);
    

    where 'targets' is an array of optional interval variables over all realTasks.

    If I now allow for clusters, I have to find all OPPs that don't contain tasks of type PI, and I have to look through each OPP's cluster of real tasks to create an alternative constraint accomplishing the same as the above constraint. This is what I don't know how to do using this
    
    
    {
    
    int
    } cluster
    
    idea.

    Using my only successful modeling of the clustering idea (however inefficient), where I use the tuple Cluster {
    int cInd;
    int rInd;
    }
    construct, this enabled me to use the 'alternative' constraint that you question below. Your understanding of what I'm trying to do is correct, but I do not understand how a boolean in the oppID would work. Wouldn't I need an array of booleans in every single oppID tuple to know which tasks it contains and which it doesn't? or wouldn't I need an array of arrays for the realtasks, where for each realTask, I store an array of the oppIDs that contain it?

    Again, maybe these are ignorant questions, but all direction is appreciated... thanks.
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: clustered task question

    Posted Thu April 01, 2010 11:41 AM

    Originally posted by: SystemAdmin


    So if the notion of type "PI" is attached to real tasks, I think you should associate the two data for instance in a tuple.
    What about something like that:

    
    tuple OppID 
    { 
    
    int i; 
    
    int j; 
    
    int k; 
    };   tuple OPP 
    { key   OppID oppID; 
    // a tuple uniquely identifying this OPP 
    {
    
    int
    } cluster; 
    }   tuple RealTask 
    { key 
    
    int id; 
    
    int     isTI; 
    }   
    {OPP
    } allOpps = 
    { < <1,1,1>, 
    {4, 6, 8 
    }          >, < <1,1,2>, 
    {1, 4, 5, 6, 8 
    }    >, < <1,1,3>, 
    {1, 2, 3, 4, 6, 7 
    } >, < <1,1,4>, 
    {2, 3, 7 
    }          > 
    };   
    {RealTask
    } realTasks = 
    { <1, 1>, <2, 0>, <3, 0>, <4, 0>, <5, 0>, <6, 1>, <7, 0>, <8, 0> 
    };   dvar interval targets[i in realTasks] optional; dvar interval routeLegOpps[t in allOpps] optional;   constraints 
    { forall(i in realTasks: i.isTI==0) alternative(targets[i], all(t in allOpps: i.id in t.cluster) routeLegOpps[t]); 
    }
    


    Philippe
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: clustered task question

    Posted Thu April 01, 2010 06:44 PM

    Originally posted by: SystemAdmin


    Philippe,
    Thanks for the insight - I can't believe how blind I was to the simple fix I needed to make the alternative constraint work (which your example showed me below).
    Here's my full tuple and alternative constraint:
    
    tuple OPP 
    { key OppID    oppID; 
    
    int          duration; 
    
    int          value; sorted 
    {
    
    int
    } taskSet; 
    //contains the set of realTasks 
    };   forall(i in realTasks) ctRealTaskOneLook: alternative(targets[i], all(t in allOpps: i.rId in t.taskSet && i.isPI == 0) routeLegOpps[t]);
    


    The reason I hadn't made each real task a tuple with an 'isPI' field is that any cluster that contains a PI task becomes itself a PI. However, due to some future changes in our model, I think your idea of separating them makes real sense.

    Thank you very much.
    #DecisionOptimization
    #OPLusingCPOptimizer