FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserPrevious exampleNext example

'producer_consumer' constraints: solving a resource-constrained project scheduling problem

Description
So-called 'producer_consumer' relations combine tasks that produce or consume quantities of the same non-renewable resource. Such problems may be modeled in two ways, namely
  • using 'producer_consumer' constraints (producer_consumer_alt.mos), or
  • using 'task' and 'resource' model objects that are configured correspondingly (producer_consumer.mos)
Further explanation of this example: 'Xpress Kalis Reference Manual'

producerconsumer.zip[download all files]

Source Files





producer_consumer.mos

(!****************************************************************
   CP example problems
   ===================
   
   file producer_consumer.mos
   ``````````````````````````
   Resource-constrained project planning problem (construction of 
   a house) modeled with task and resource objects.

   (c) 2008 Artelys S.A. and Fair Isaac Corporation

*****************************************************************!)
model "Producer Consumer"  
 uses "kalis"
 
 declarations
  Masonry, Carpentry, Roofing, Windows, Facade, Garden, Plumbing, 
    Ceiling, Painting, MovingIn : cptask    ! Declaration of tasks
  money_available : cpresource              ! Resource declaration
 end-declarations

! 'money_available' is a cumulative resource with max. amount of 29$
 set_resource_attributes(money_available,KALIS_DISCRETE_RESOURCE,29)

! Limit resource availability to 20$ in the time interval [0,14]
 setcapacity(money_available, 0, 14, 20)

! Setting the task durations and predecessor sets
 set_task_attributes(Masonry  , 7 ) 
 set_task_attributes(Carpentry, 3, {Masonry} )
 set_task_attributes(Roofing  , 1, {Carpentry} )
 set_task_attributes(Windows  , 1, {Roofing} )
 set_task_attributes(Facade   , 2, {Roofing} )
 set_task_attributes(Garden   , 1, {Roofing} )
 set_task_attributes(Plumbing , 8, {Masonry} )
 set_task_attributes(Ceiling  , 3, {Masonry} )
 set_task_attributes(Painting , 2, {Ceiling} )
 set_task_attributes(MovingIn , 1, {Windows,Facade,Garden,Painting})

! Setting the resource consumptions
 consumes(Masonry  , 7, money_available )
 consumes(Carpentry, 3, money_available )
 consumes(Roofing  , 1, money_available )
 consumes(Windows  , 1, money_available )
 consumes(Facade   , 2, money_available )
 consumes(Garden   , 1, money_available )
 consumes(Plumbing , 8, money_available )
 consumes(Ceiling  , 3, money_available )
 consumes(Painting , 2, money_available )
 consumes(MovingIn , 1, money_available )

! Find the optimal schedule (minimizing the makespan)
 if cp_minimize(getmakespan) then	
   cp_show_sol		
 else
   writeln("No solution found")
 end-if

end-model

Back to examples browserPrevious exampleNext example