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

Job-shop scheduling

Description
Job-shop scheduling problem modeled with tasks and resources;
  • using the default scheduling search (jobshop2.mos)
  • or a user search strategy for tasks (jobshop2a.mos and jobshop2b.mos).
  • Model version jobshop2c.mos shows how to change the propagation algorithm for resource constraints.
Further explanation of this example: 'Xpress Kalis User Guide', Section 5.7.2 Task-based enumeration


Source Files

Data Files





jobshop2.mos

(!****************************************************************
   CP example problems
   ===================
   
   file jobshop2.mos
   `````````````````
   Job-shob scheduling problem.
   - Default search - 

   *** This model cannot be run with a Community Licence 
       for the provided data instance ***

   (c) 2008 Artelys S.A. and Fair Isaac Corporation 

*****************************************************************!)

model "Job shop (CP)"
 uses "kalis", "mmsystem"

 parameters
  DATAFILE = "jobshop.dat"
  NJ = 6                                 ! Number of jobs
  NM = 6                                 ! Number of resources
 end-parameters

 declarations
  JOBS = 1..NJ                           ! Set of jobs
  MACH = 1..NM                           ! Set of resources
  RES: array(JOBS,MACH) of integer       ! Resource use of tasks
  DUR: array(JOBS,MACH) of integer       ! Durations of tasks

  res: array(MACH) of cpresource         ! Resources
  task: array(JOBS,MACH) of cptask       ! Tasks
 end-declarations

 initializations from "Data/"+DATAFILE
  RES DUR
 end-initializations

 HORIZON:= sum(j in JOBS, m in MACH) DUR(j,m)
 forall(j in JOBS) getend(task(j,NM)) <= HORIZON 

! Setting up the resources (capacity 1)
 forall(m in MACH) 	  
  set_resource_attributes(res(m), KALIS_UNARY_RESOURCE, 1)

! Setting up the tasks (durations, resource used)
 forall(j in JOBS, m in MACH)  	
  set_task_attributes(task(j,m), DUR(j,m), res(RES(j,m)))

! Precedence constraints between the tasks of every job
 forall (j in JOBS, m in 1..NM-1)
  setsuccessors(task(j,m), {task(j,m+1)})

! Solve the problem
 starttime:= gettime

 if cp_schedule(getmakespan)=0 then
  writeln("Problem is infeasible")
  exit(1)
 end-if
 
! Solution printing
 cp_show_stats
 write(gettime-starttime, "sec ")
 writeln("Total completion time: ", getsol(getmakespan))
 forall(j in JOBS) do
  write("Job ", strfmt(j,-2))
  forall(m in MACH | exists(task(j,m)))
   write(strfmt(RES(j,m),3), ":", strfmt(getsol(getstart(task(j,m))),3),  
         "-", strfmt(getsol(getend(task(j,m))),2))
  writeln
 end-do

end-model

Back to examples browserPrevious exampleNext example