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





i4exam.mos

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

   file i4exam.mos
   ```````````````
   Scheduling exams

   A university must schedule the exams of both mandatory 
   and optional modules for fourth-year students. The exam
   duration and available time slots are given, as well as 
   the incompatibilities between different exams that cannot
   be taken at the same time. No student can have more than
   one exam at a time. What exam should be scheduled at each
   time slot?

   The incompatibilities are modeled as a Boolean matrix to 
   define conditions over the IP model constraints. Since 
   no objective is stated in the problem description, this
   model basically finds a feasible solution by defining
   a constant value as objective function.
   
   (c) 2008 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002
*******************************************************!)

model "I-4 Scheduling exams"
 uses "mmxprs"

 declarations
  EXAM = {"DA","NA","C++","SE","PM","J","GMA","LP","MP","S","DSE"}
                                      ! Set of exams
  TIME = 1..8                         ! Set of time slots
  
  INCOMP: array(EXAM,EXAM) of integer ! Incompatibility between exams
  
  plan: array(EXAM,TIME) of mpvar     ! 1 if exam in a time slot, 0 otherwise
 end-declarations

 initializations from 'i4exam.dat'
  INCOMP
 end-initializations

! Schedule all exams
 forall(e in EXAM) sum(t in TIME) plan(e,t) = 1
 
! Respect incompatibilities
 forall(d,e in EXAM, t in TIME | d<e and INCOMP(d,e)=1) 
  plan(e,t) + plan(d,t) <= 1    

 forall(e in EXAM, t in TIME) plan(e,t) is_binary

! Breaking symmetries
(!
 plan("DA",1)=1
 plan("NA",2)=1
 plan("PM",3)=1
 plan("GMA",4)=1
 plan("S",5)=1
 plan("DSE",6)=1
!) 

! Solve the problem (no objective)
 minimize(0)
 
! Solution printing
 forall(e in EXAM) 
  writeln(strfmt(e+":",4) ," slot ", getsol(sum(t in TIME) t*plan(e,t)))

end-model

Back to examples browserPrevious exampleNext example