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

'cumulative' and 'disjunctive' constraints for scheduling and planning problems

Description
  • cumulative.mos: using the 'cumulative' constraint to formulate a scheduling problem with resource constraints (renewable resource with discrete capacity)
  • disjunctive.mos: using the 'disjunctive' constraint for implementing a sequencing problem (single-maching scheduling minimizing the total weighted tardiness.
  • resource_capacity.mos: using 'task' and 'resource' objects to model a cumulative resource relation (renewable resource with different capacity levels over time).
  • resource_coupled_setup_times.mos: specifying setup times between pairs of tasks assigned to the same resource.
Further explanation of this example: 'Xpress Kalis Reference Manual'


Source Files





disjunctive.mos

(!****************************************************************
   CP example problems
   ===================
   
   file disjunctive.mos
   ````````````````````
   Scheduling disjunctive tasks.

   (c) 2008 Artelys S.A. and Fair Isaac Corporation
       Creation: 2005, rev. 2007, rev. Mar. 2013
*****************************************************************!)
model "Disjunctive scheduling with settle_disjunction"
 uses "kalis"
  
 declarations
  NBTASKS = 5
  TASKS = 1..NBTASKS                     ! Set of tasks
  DUR: array(TASKS) of integer           ! Task durations
  DURs: array(set of cpvar) of integer   ! Durations
  DUE: array(TASKS) of integer           ! Due dates
  WEIGHT: array(TASKS) of integer        ! Weights of tasks
  start: array(TASKS) of cpvar           ! Start times
  tmp: array(TASKS) of cpvar             ! Aux. variable
  tardiness: array(TASKS) of cpvar       ! Tardiness
  twt: cpvar                             ! Objective variable
  zeroVar: cpvar                         ! 0-valued variable
  Strategy: array(range) of cpbranching  ! Branching strategy
  Disj: set of cpctr                     ! Disjunctions
 end-declarations
 
 DUR :: [21,53,95,55,34]
 DUE :: [66,101,232,125,150]
 WEIGHT :: [1,1,1,1,1]
               
 setname(twt, "Total weighted tardiness")
 zeroVar = 0
 setname(zeroVar, "zeroVar")

! Setting up the decision variables
 forall (t in TASKS) do
  start(t) >= 0
  setname(start(t), "Start("+t+")")
  DURs(start(t)):= DUR(t)
  tmp(t) = start(t) + DUR(t) - DUE(t)
  setname(tardiness(t), "Tard("+t+")")
  tardiness(t) = maximum({tmp(t), zeroVar})
 end-do    
 
 twt = sum(t in TASKS) (WEIGHT(t) * tardiness(t)) 
 
! Create the disjunctive constraints
 disjunctive(union(t in TASKS) {start(t)}, DURs, Disj, 1)

! Define the search strategy
 Strategy(1):= settle_disjunction
 Strategy(2):= split_domain(KALIS_LARGEST_MIN,KALIS_MIN_TO_MAX)
 cp_set_branching(Strategy) 
 setparam("KALIS_DICHOTOMIC_OBJ_SEARCH",true)
 
 if not(cp_minimize(twt)) then
  writeln("Problem is inconsistent")
  exit(0)
 end-if
   
 forall (t in TASKS)
  writeln("[", getsol(start(t)), "==>", 
          getsol(start(t)) + DUR(t), "]:\t ",
	  getsol(tardiness(t)), "  (", getsol(tmp(t)), ")") 
 writeln("Total weighted tardiness: ", getsol(twt))
  
end-model

Back to examples browserPrevious exampleNext example