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

Scheduling problems

Description
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

mosel_app_2.zip[download all files]

Source Files

Data Files





b2flowshop.mos

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

   file b2flowshop.mos
   ```````````````````
   Flow shop production planning
   
   A workshop has three machines to produce metal pipes.
   A piece must go through each machine and cannot stop
   unless it is between machines. What is the best order
   of pieces so that the total time for completion is minimized
   for all pieces?
   
   This problem uses four variables to track which job is scheduled
   in which position, which machines are empty, which jobs are 
   waiting between machines, and when jobs are starting.
   Note that each job must be assigned a position and every
   position ('rank) must be assigned a job. The 'rank' variables
   are either binary variables or defined as members of two SOS-1.
   
   (c) 2008-2022 Fair Isaac Corporation
       author: S. Heipcke, Mar. 2002, rev. Mar. 2022
*******************************************************!)

model "B-2 Flow shop"
 uses "mmxprs"
 
 declarations   
  NM = 3                               ! Number of machines
  NJ = 6                               ! Number of jobs
  MACH = 1..NM
  RANKS = 1..NJ
  JOBS = 1..NJ

  DUR: array(MACH,JOBS) of integer     ! Durations of jobs on machines

  rank: array(JOBS,RANKS) of mpvar     ! 1 if job j has rank k, 0 otherwise
  empty: array(MACH,1..NJ-1) of mpvar  ! Space between jobs of ranks k and k+1
  wtime: array(1..NM-1,RANKS) of mpvar ! Waiting time between machines m
                                       ! and m+1 for job of rank k
  start: array(MACH,RANKS) of mpvar    ! Start of job rank k on machine m
                                       ! (optional)
 end-declarations

 initializations from 'b2flowshop.dat'
  DUR
 end-initializations

! Objective: total waiting time (= time before first job + times between
! jobs) on the last machine
 TotWait:= sum(m in 1..NM-1,j in JOBS) (DUR(m,j)*rank(j,1)) +
           sum(k in 1..NJ-1) empty(NM,k)

! Every position gets a job
 forall(k in RANKS) sum(j in JOBS) rank(j,k) = 1

! Every job is assigned a rank
 forall(j in JOBS) sum(k in RANKS) rank(j,k) = 1

! Relations between the end of job rank k on machine m and start of job on
! machine m+1
 forall(m in 1..NM-1,k in 1..NJ-1)
  empty(m,k) + sum(j in JOBS) DUR(m,j)*rank(j,k+1) + wtime(m,k+1) =
   wtime(m,k) + sum(j in JOBS) DUR(m+1,j)*rank(j,k) + empty(m+1,k)

! Calculation of start times (to facilitate the interpretation of results)
 forall(m in MACH, k in RANKS) 
  start(m,k) = sum(u in 1..m-1,j in JOBS) DUR(u,j)*rank(j,1) +
               sum(p in 1..k-1,j in JOBS) DUR(m,j)*rank(j,p) + 
               sum(p in 1..k-1) empty(m,p)

! First machine has no idle times
 forall(k in 1..NJ-1) empty(1,k) = 0

! First job has no waiting times
 forall(m in 1..NM-1) wtime(m,1) = 0

 forall(j in JOBS, k in RANKS) rank(j,k) is_binary  

(! Alternative formulations using SOS-1: 
 forall(j in JOBS) sum(k in RANKS) k*rank(j,k) is_sos1 
 forall(k in RANKS) sum(j in JOBS) j*rank(j,k) is_sos1 
!)

! Solve the problem
 minimize(TotWait)

! Solution printing
 writeln("Total waiting time for last machine: ", getobjval)
 write(strfmt("Item",-11))
  forall(k in RANKS) write(strfmt(getsol(sum(j in JOBS) j*rank(j,k)),3))
 writeln 
 forall(m in MACH) do
  write("Machine ", m, ": ")
  forall(k in RANKS) write(strfmt(start(m,k).sol,3))
  writeln
 end-do 

end-model 

Back to examples browserPrevious exampleNext example