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

Timetabling and personnel planning

Description
Problem name and type, featuresDifficultyRelated examples
I‑1 Assigning personnel to machines: Assignment problem **** assignment_graph.mos, c6assign.mos
formulation of maximin objective; heuristic solution + 2 different problems (incremental definition) solved, working with sets, while-do, forall-do
I‑2 Scheduling nurses ***
2 problems, using mod to formulate cyclic schedules; forall-do, set of integer, getact
I‑3 Establishing a college timetable *** timetable_graph.mos
many specific constraints, tricky (pseudo) objective function
I‑4 Exam schedule **
symmetry breaking, no objective
I‑5 Production planning with personnel assignment ***
2 problems, defined incrementally with partial re-definition of constraints (named constraints), exists, create, dynamic array
I‑6 Planning the personnel at a construction site ** persplan_graph.mos
formulation of balance constraints using inline if


Further explanation of this example: 'Applications of optimization with Xpress-MP', Chapter 14: Timetabling and personnel planning

mosel_app_9.zip[download all files]

Source Files

Data Files





i6build.mos

(!******************************************************
   Mosel Example Problems
   ======================

   file i6build.mos
   ````````````````
   Personnel planning at a construction site

   A company must plan the number of construction workers 
   at a specific site for a planning horizon. Transfers 
   from other sites to the specific site are possible at 
   the beginning of each period with an associated cost. 
   Under and over staffing is possible with a related cost. 
   How many workers should be planned at each time period
   while minimizing the total cost?

   This IP formulation models the problem with five different
   set of variables to facilitate the understanding of the 
   mathematical model. The balance constraints (for the number
   of workers at the site at each time period) are grouped 
   into a single expression using the inline 'if'.

   (c) 2008-2022 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002, rev. Mar. 2022
*******************************************************!)

model "I-6 Construction site personnel"
 uses "mmxprs"

 declarations
  FIRST = 3; LAST = 8
  MONTHS = FIRST..LAST                 ! Set of time periods (months)
  
  CARR, CLEAVE: integer                ! Cost per arrival/departure
  COVER, CUNDER: integer               ! Cost of over-/understaffing
  NSTART, NFINAL: integer              ! No. of workers at begin/end of plan
  REQ: array(MONTHS) of integer        ! Requirement of workers per month
  
  onsite: array(MONTHS) of mpvar       ! Workers on site
  arrive,leave: array(MONTHS) of mpvar ! Workers arriving/leaving
  over,under: array(MONTHS) of mpvar   ! Over-/understaffing
 end-declarations

 initializations from 'i6build.dat'
  CARR CLEAVE COVER CUNDER NSTART NFINAL REQ
 end-initializations
 
! Objective: total cost
 Cost:= sum(m in MONTHS) (CARR*arrive(m) + CLEAVE*leave(m) +
                          COVER*over(m) + CUNDER*under(m))

! Satisfy monthly need of workers
 forall(m in MONTHS) onsite(m) - over(m) + under(m) = REQ(m) 

! Balances
 forall(m in MONTHS)
  onsite(m) = if(m>FIRST, onsite(m-1) - leave(m-1), NSTART) + arrive(m)
 NFINAL = onsite(LAST) - leave(LAST)
  
! Limits on departures, understaffing, arrivals; integrality constraints
 forall(m in MONTHS) do
  leave(m) <= 1/3*onsite(m)
  under(m) <= 1/4*onsite(m)
  arrive(m) <= 3
  arrive(m) is_integer; leave(m) is_integer; onsite(m) is_integer
  under(m) is_integer; over(m) is_integer  
 end-do
 
! Solve the problem
 minimize(Cost)

! Solution printing
 declarations
  NAMES: array(MONTHS) of string       ! Names of months
 end-declarations
 
 initializations from 'i6build.dat'
  NAMES
 end-initializations
 
 writeln("Total cost: ", getobjval)
 write("Month     ")
 forall(m in MONTHS) write(NAMES(m)," ") 
 setparam("realfmt","%4g")    ! Reserve 4 char.s for real number display
 write("\nOn site ")
 forall(m in MONTHS) write(getsol(onsite(m))) 
 write("\nArrive  ")
 forall(m in MONTHS) write(getsol(arrive(m))) 
 write("\nLeave   ")
 forall(m in MONTHS) write(getsol(leave(m))) 
 write("\nOverst. ")
 forall(m in MONTHS) write(getsol(over(m))) 
 write("\nUnderst.")
 forall(m in MONTHS) write(getsol(under(m)))
 writeln
 
end-model

Back to examples browserPrevious exampleNext example