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

Resource usage profiles

Special cases of resource constraints:
  • residle.mos: Preemptive scheduling ('resource idle times'); definition of resource usage profiles.
  • resprofile.mos: Scheduling with resource usage profiles; 'requires' constraints with sets of 'resusage'
  • altresource.mos: Scheduling with resource choice; 'requires' constraints with sets of 'resusage'
Further explanation of this example: 'Xpress Kalis Mosel User Guide', Section 5.6 Extensions: setup times, resource choice, usage profiles[download all files]

Source Files


   CP example problems
   file residle.mos
   Preemptive scheduling.

   (c) 2008 Artelys S.A. and Fair Isaac Corporation
       Creation: 2008, rev. Apr. 2022        
model "Preemption"
 uses "kalis", "mmsystem"
 setparam("KALIS_DEFAULT_LB", 0)

 forward procedure print_solution

  aprofile,bprofile: list of integer
  a,b: cptask
  res: cpresource
! Define a discrete resource
 set_resource_attributes(res, KALIS_DISCRETE_RESOURCE, 3)

! Create a 'hole' in the availability of the resource:
! Uncomment one of the following two lines to compare their effect
! setcapacity(res, 1, 2, 0);  setcapacity(res, 7, 8, 0)
 setidletimes(res, (1..2)+(7..8))

! Define two tasks (a: constant resource use, b: resource profile)
 a.duration >= 4 "task_a"
 aprofile:= [1,1,1,1]
 b.duration >= 8 "task_b"
 bprofile:= [1,1,1,2,2,2,1,1]
! Resource usage constraints
 requires(a, resusage(res,aprofile))
 requires(b, resusage(res,bprofile)) 


! Solve the problem
 if cp_schedule(getmakespan)<>0 then
  writeln("No solution") 

! ****************************************************************

 procedure print_solution    
  writeln("Solution: ", getsol(getmakespan))
  writeln("Schedule: a: ", getsol(getstart(a)), "-", getsol(getend(a))-1,  
          ", b: ", getsol(getstart(b)), "-", getsol(getend(b))-1)
  writeln("Resource usage:")
  forall(t in 0..getsol(getmakespan)-1)
   writeln(formattext("%5d: Cap: %d, a:%d, b:%d", t, getcapacity(res,t), 
           getrequirement(a, res, t), getrequirement(b, res, t)) )


Back to examples browserPrevious exampleNext example