Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  how to model task merge in cp-optimizer?

    Posted 04/17/10 06:17 AM

    Originally posted by: flywithme


    Thank you in advance. It is better to give a example:

    task1 requires resource R with state A,task2 requires resource R with state B, state A and state B maybe real type. if A and B satisfy some condition, like Abs(A-B) < CONSTANT, the state of task1 and task2 can be changed to a new value C. In addition, the total processing times of resource R should be changed from duration(task1) + duration(task2) to Max(endof(task1),endof(task2)) - Min(startof(task1),startof(task2)). if Abs(A-B)<

    how to model the problem above in CP-Optimizer, and get the total processing times of resource R?
    #ConstraintProgramming-General
    #DecisionOptimization


  • 2.  Re: how to model task merge in cp-optimizer?

    Posted 04/17/10 06:22 AM

    Originally posted by: flywithme


    sorry, the last sentence "if Abs(A-B)<" of 2nd paragraph is redundant.
    #ConstraintProgramming-General
    #DecisionOptimization


  • 3.  Re: how to model task merge in cp-optimizer?

    Posted 04/19/10 03:18 AM

    Originally posted by: SystemAdmin


    In the case Abs(A-B)<CONSTANT, you could use some alternative constraint to model the two possibilities: "use states A and B" OR "use state C during an interval that spans task 1 and task2". For instance (in pseudo OPL) assuming the total processing time is just the sum of the length of all tasks on the resource:

    
    dvar interval task1 ...; dvar interval task2 ...;   dvar interval task1A optional ...; 
    // requires stateA dvar interval task2B optional ...; 
    // requires stateB dvar interval task1C optional ...; dvar interval task2C optional ...; dvar interval taskC optional ...; 
    // spans [task1C, task2C] and requires state C   dexpr 
    
    int totalPT = lengthOf(task1A,0)+lengthOf(task2B,0)+lengthOf(taskC,0);   constraints 
    { alternative(task1, [task1A, task1C]); alternative(task2, [task2B, task2C]); span(taskC, [task1C, task2C]); presenceOf(taskC)==presenceOf(task1C); presenceOf(taskC)==presenceOf(task2C); alwaysIn(resource, task1A, A,A); alwaysIn(resource, task2B, B,B); alwaysIn(resource, taskC,  C,C); 
    }
    


    Hope it helps,
    Philippe
    #ConstraintProgramming-General
    #DecisionOptimization


  • 4.  Re: how to model task merge in cp-optimizer?

    Posted 04/19/10 03:42 AM

    Originally posted by: SystemAdmin


    In addition to my previous answer, I realize that maybe the "merging" does not only occurs for pairs of tasks but for any task set. In this case, you could also consider a model:
    • that considers pairs of tasks task1/task2 requiring states A and B such that Abs(A-B)>=CONSTANT as incompatible (cannot execute in parallel) and
    • that estimates the processing time on the resource as the length of the period of time when at least one task executes on the resource
    You can model that as follows. The "activity" of the resource is modeled as a chain of interleaved intervals: resourceUsed[i]->resourceIdle[i]->...

    
    
    
    int n = card(AllTasks); dvar interval tasks[t in AllTasks] ...; 
    
    int states[t in AllTasks] = ...; dvar interval resourceIdle[i in 1..n] optional size ((i==1)?0:1)..BIG_NUMBER; dvar interval resourceUsed[i in 1..n] optional size 1..BIG_NUMBER;   dexpr 
    
    int resourcePT = sum(i in 1..n) lengthOf(resourceUsed[i]);   constraints 
    { forall(t in Tasks) alwaysIn(resource, tasks[t], state[t]-(CONSTANT div 2), state[t]+(CONSTANT div 2)); startOf(resourceIdle[1],0)==0; 
    // Note: length of this first one can be zero forall(i in 1..n) 
    { alwaysNoState(resource, resourceIdle[i]); alwaysConstant(resource, resourceUsed[i]); endAtStart(resourceIdle[i],resourceUsed[i]); presenceOf(resourceUsed[i]) => presenceOf(resourceIdle[i]); 
    
    if (i<n) 
    { endAtStart(resourceUsed[i],resourceIdle[i+1]); presenceOf(resourceIdle[i+1]) => presenceOf(resourceUsed[i]); 
    } 
    } 
    }
    

    #ConstraintProgramming-General
    #DecisionOptimization


  • 5.  Re: how to model task merge in cp-optimizer?

    Posted 04/19/10 05:07 AM

    Originally posted by: SystemAdmin


    A constraint alwaysConstant was missing in my previous model to ensure the resource state is defined during a task. Furthermore, we also need a constraint to make sure the chain Idle->Used->Idle->Used->... covers the complete schedule, you can use spans for that. So a more complete model is:

    
    dvar interval schedule; dvar interval tasks[t in AllTasks] ... ; 
    
    int states[t in AllTasks] = ...; dvar interval resourceIdle[i in 1..n] optional size ((i==1)?0:1)..BIG_NUMBER; dvar interval resourceUsed[i in 1..n] optional size 1..BIG_NUMBER; dexpr 
    
    int resourcePT = sum(i in 1..n) lengthOf(resourceUsed[i]); stateFunction resource;   constraints 
    { forall(t in AllTasks) 
    { alwaysIn(resource, tasks[t], maxl(0,states[t]-(CONSTANT div 2)), states[t]+(CONSTANT div 2)); alwaysConstant(resource, tasks[t]); 
    } span(schedule, all(t in AllTasks) tasks[t]); span(schedule, append(all(i in 1..n) resourceIdle[i], all(i in 1..n) resourceUsed[i])); startOf(resourceIdle[1],0)==0; forall(i in 1..n) 
    { alwaysNoState(resource, resourceIdle[i]); alwaysConstant(resource, resourceUsed[i]); endAtStart(resourceIdle[i],resourceUsed[i]); presenceOf(resourceUsed[i]) => presenceOf(resourceIdle[i]); 
    
    if (i<n) 
    { endAtStart(resourceUsed[i],resourceIdle[i+1]); presenceOf(resourceIdle[i+1]) => presenceOf(resourceUsed[i]); 
    } 
    } 
    }
    


    This model is fine if you want to minimize the resource processing times. For more complex cases, you can have a look at this thread that describes how to create a chain of intervals that exactly covers the set of time-points covered by at least one interval: http://www.ibm.com/developerworks/forums/thread.jspa?threadID=308011

    Regards,
    Philippe
    #ConstraintProgramming-General
    #DecisionOptimization


  • 6.  Re: how to model task merge in cp-optimizer?

    Posted 04/19/10 07:47 AM

    Originally posted by: flywithme


    thanks Philippe for detail model. I try it now.
    #ConstraintProgramming-General
    #DecisionOptimization