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





b4seq.mos

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

   file b4seq.mos
   ``````````````
   Sequencing jobs on a bottleneck machine

   This problem provides a simple model for scheduling tasks
   on a single machine (a critical machine or bottleneck).
   Three objectives are solved for - minimizing the total
   schedule duration 'makespan', the average completion time,
   or the total lateness.
   
   A parameter is passed to the print solution procedure to
   indicate which objective was solved and print results
   accordingly, applying format settings locally within
   the subroutine.

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

model "B-4 Sequencing"
 uses "mmxprs"

 forward procedure printsol(obj:integer)
 
 declarations   
  NJ = 7                          ! Number of jobs
  JOBS=1..NJ

  REL: array(JOBS) of integer     ! Release dates of jobs
  DUR: array(JOBS) of integer     ! Durations of jobs
  DUE: array(JOBS) of integer     ! Due dates of jobs

  rank: array(JOBS,JOBS) of mpvar ! =1 if job j at position k
  start: array(JOBS) of mpvar     ! Start time of job at position k
  comp: array(JOBS) of mpvar      ! Completion time of job at position k
  late: array(JOBS) of mpvar      ! Lateness of job at position k
  finish: mpvar                   ! Completion time of the entire schedule
 end-declarations
 
 initializations from 'b4seq.dat'
  DUR REL DUE
 end-initializations

! One job per position
  forall(k in JOBS) sum(j in JOBS) rank(j,k) = 1

! One position per job
  forall(j in JOBS) sum(k in JOBS) rank(j,k) = 1

! Sequence of jobs
  forall(k in 1..NJ-1)
   start(k+1) >= start(k) + sum(j in JOBS) DUR(j)*rank(j,k)

! Start times
  forall(k in JOBS) start(k) >= sum(j in JOBS) REL(j)*rank(j,k)

! Completion times
  forall(k in JOBS) comp(k) = start(k) + sum(j in JOBS) DUR(j)*rank(j,k)

 forall(j,k in JOBS) rank(j,k) is_binary 
 
! Objective function 1: minimize latest completion time
 forall(k in JOBS) finish >= comp(k)
 minimize(finish)
 printsol(1)

! Objective function 2: minimize average completion time
 minimize(sum(k in JOBS) comp(k))
 printsol(2)

! Objective function 3: minimize total tardiness
 forall(k in JOBS) late(k) >= comp(k) - sum(j in JOBS) DUE(j)*rank(j,k) 
 minimize(sum(k in JOBS) late(k))
 printsol(3)

!-----------------------------------------------------------------

! Solution printing
 procedure printsol(obj:integer)
  writeln("Objective ", obj, ": ", getobjval,
          if(obj>1, "  completion time: " + getsol(finish), "") ,
          if(obj<>2, "  average: " + getsol(sum(k in JOBS) comp(k)), ""),
          if(obj<>3, "  lateness: " + getsol(sum(k in JOBS) late(k)), ""))
  write("\t")
  localsetparam("REALFMT","%4g")  ! Reserve 4 characters for display of reals
  forall(k in JOBS) write(getsol(sum(j in JOBS) j*rank(j,k)))
  write("\nRel\t")
  forall(k in JOBS) write(getsol(sum(j in JOBS) REL(j)*rank(j,k)))
  write("\nDur\t")
  forall(k in JOBS) write(getsol(sum(j in JOBS) DUR(j)*rank(j,k)))
  write("\nStart\t")
  forall(k in JOBS) write(getsol(start(k)))
  write("\nEnd\t")
  forall(k in JOBS) write(getsol(comp(k)))
  write("\nDue\t")
  forall(k in JOBS) write(getsol(sum(j in JOBS) DUE(j)*rank(j,k)))
  if(obj=3) then
   write("\nLate\t")
   forall(k in JOBS) write(getsol(late(k)))
  end-if
  writeln
 end-procedure
 
end-model 
 

Back to examples browserPrevious exampleNext example