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

Scheduling problems

Problem name and type, featuresDifficultyRelated examples
B‑1 Construction of a stadium: Project scheduling (Method of Potentials) *** projplan_graph.mos
2 problems; selection with `|', sparse/dense format, naming and redefining constraints, subroutine: procedure for solution printing, forward declaration, array of set
B‑2 Flow shop scheduling **** flowshop_graph.mos
alternative formulation using SOS1
B‑3 Job shop scheduling *** jobshop_graph.mos
formulating disjunctions (BigM); dynamic array, range, exists, forall-do,array of set, array of list
B‑4 Sequencing jobs on a bottleneck machine: Single machine scheduling *** sequencing_graph.mos
3 different objectives; subroutine: procedure for solution printing, localsetparam, if-then
B‑5 Paint production: Asymmetric Traveling Salesman Problem (TSP) ***
solution printing, repeat-until, cast to integer, selection with `|', round
B‑6 Assembly line balancing ** linebal_graph.mos
encoding of arcs, range

Further explanation of this example: 'Applications of optimization with Xpress-MP', Chapter 7: Scheduling problems[download all files]

Source Files

Data Files


   Mosel Example Problems

   file b1stadium2.mos
   Construction of a stadium
   - Set version -

   A town is planning to build a new stadium and need to
   determine the earliest it can be completed. Additionally,
   the town would like to project to finish earlier than the
   initial estimate. The town is prepared to pay the builder
   a bonus for every week the project completes early. Each
   task has a max week reduction with added costs. The
   second problem determines when the project will finish
   if the builder maximizes their profit.

   The first problem is a classical project scheduling problem.
   To define the precedence relations between tasks, we work 
   with an array 'SUCC' that holds the set of direct successors   
   per task and define constraints for related tasks. The second
   problem is called 'scheduling with project crashing' and it
   requires the result of the first problem. The new variable
   'advance' is introduced to represent how many weeks early 
   each task can be finished.

   (c) 2008-2022 Fair Isaac Corporation
       author: S. Heipcke, Jan. 2006, rev. Mar. 2022

model "B-1 Stadium construction (2)"
 uses "mmxprs"
 forward procedure printsol
  N = 19                                ! Number of tasks in the project
                                        ! (last = fictitious end task)
  SUCC: array(TASKS) of set of integer  ! Successors of tasks
  DUR: array(TASKS) of real             ! Duration of tasks
  start: array(TASKS) of mpvar          ! Start times of tasks
  obj1: real                            ! Solution of first problem

 initializations from 'b1stadium2.dat'
! Precedence relations between tasks
 forall(i in TASKS, j in SUCC(i))  
  Prec(i,j):= start(j) - start(i) >= DUR(i)

! Solve the first problem: minimize the total duration
! Solution printing

! **** Extend the problem ****
  BONUS: integer                      ! Bonus per week finished earlier
  MAXW: array(TASKS) of real          ! Max. reduction of tasks (in weeks)
  COST: array(TASKS) of real          ! Cost of reducing tasks by a week
  advance: array(TASKS) of mpvar      ! Number of weeks finished early

 initializations from 'b1stadium2.dat'

! Second objective function
 Profit:= BONUS*advance(N) - sum(i in 1..N-1) COST(i)*advance(i)

! Redefine precedence relations between tasks
 forall(i in TASKS, j in SUCC(i))  
  Prec(i,j):= start(j) - start(i) + advance(i) >= DUR(i)

! Total duration
 start(N) + advance(N) = obj1

! Limit on number of weeks that may be saved
 forall(i in 1..N-1) advance(i) <= MAXW(i)

! Solve the second problem: maximize the total profit
! Solution printing
 writeln("Total profit: ", getsol(Profit))


 procedure printsol
  writeln("Total duration: ", getsol(start(N)), " weeks")
  forall(i in 1..N-1)
   write(strfmt(i,2), ": ", strfmt(getsol(start(i)),-3),
    if(i mod 9 = 0,"\n",""))


Back to examples browserPrevious exampleNext example