Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Alternative task

  • 1.  Alternative task

    Posted Tue July 14, 2015 01:24 PM

    Originally posted by: Adriano199


    Hi everyone, 

     

    I'm trying to schedule some tasks that part of an item do be done that follows a recipe however some tasks can be done in different machines. E.g

    Product A-:

    Task       Machine    alternative machine

    P1        Drill1                Drill2

    The problem is I'm not able to do this without either with the order of the tasks and the precedence's :-/.

    How to solve this? 

    Any Idea? By the way I'm using the an example as a template 

    Here is my code:

    The Model

    using CP;
    
    {string} Task  = ...;
    
    {string} Resource  = ...;
    
    tuple Distance {
      string pre;
      string post;
      int    dist;
    };
    
    tuple Precedence {
      string pre;
      string post;
    };
    
    int taskDuration[Task] = ...;
    
    
    {Distance} max_nf = ...;
    
    {string} tasksOnResource[Resource] = ...;
    {Precedence} precedences = ...;
    
    
    
    dvar interval a[t in Task] 
      size taskDuration[t] ;
    
      
    
    dvar sequence resourceUsage[r in Resource] in all(t in tasksOnResource[r]) a[t]; 
    
    execute {
                    cp.param.FailLimit = 10000;
    }
    
    minimize max(t in Task) endOf(a[t]);
    
    subject to {  
    
      
      forall(r in Resource)
        noOverlap(resourceUsage[r]);
    
      forall(t in precedences )
        endBeforeStart(a[t.pre], a[t.post])
        ;
        
        
      
      forall( t in max_nf )
        endBeforeStart(a[t.pre], a[t.post], -t.dist);
    
      
    };
    

     and the data file

     

     ComputerTypes = { 
       A, 
       B 
       
    };
    
    ActivityTypes = { 
       P1, 
       P2,  
       P3, 
       P4, 
       P5, 
       P6, 
       P7,
       P8,
       P9,
       Z11,
       Z22,
        Z222,
       Z33,
       Z99
    };
    
    ResourceTypes = { 
       Drill1, Drill2,punch1,punch2,insp,rfid,stor
    };
    
    requiredQuantities = [10,5];
    max_nf  = {
         <P1,P2,30>,
         <P1,P3,30>,
         <P3,P4,0>,
         <P5,P6,0>
    };
    activities = #[
    //     task,ptime,ressource,precedence
       A:
            { <P7, 750, stor, {}>, 
              <P1, 820, punch1, {P7}>,
              <Z11, 820, Drill1, {P1}>,
              <Z33, 740, Drill1, {Z11}>,
              <P4, 830, Drill1, {Z33}>,
              <P9, 826, insp, {P4}>},
              <Z99, 826, Robot, {P6}>},
      B:
            { <P7, 750, stor, {}>, 
              <P5, 840, Drill2, {P7}>,
              <P6, 740, Drill2, {P5}>,
              <P2, 830, punch2, {P3}>,
              <Z22, 840, punch2, {P2}>,
              <P9, 826, insp, {Z22}>},
              <Z99, 826, Robot, {Z222}>}
    ]#;
    

    Thanks for the help

     


    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: Alternative task

    Posted Thu July 16, 2015 07:36 AM

    Originally posted by: ol


    Hello,

    you can use an Alternative constraint: your task P1 will be associated to two tasks P1OnDrill1, P1OnDrill2 and the alternative constraint ensures that only one of these two additional tasks is present, and is linked to P1.  You can see for instance the example sched_optional.cpp.

    Regards

    ol


    #ConstraintProgramming-General
    #DecisionOptimization