Initializing help system before first use

Resource-constrained project scheduling problem


Type: Resource-constrained project scheduling
Rating: 3 (intermediate)
Description: Formulating and solving resource-constrained project scheduling problems via scheduling objects of the Kalis solver
  • Resource-constrained project scheduling problem (RCPSP): rcpsp.mos. Tasks have fixed durations and require specific amounts of several resources with discrete capacity.
  • Multi-mode resource constrained project scheduling problem (MRCPSP): mrcpsp.mos. Task durations and amounts of resource use (or consumption) by tasks depend on the selected task mode. Some resources are renewable, others are non-renewable.
File(s): rcpsp.mos, mrcpsp.mos
Data file(s): j102_2.dat, j102_4.dat, j102_5.dat, j102_6.dat, j102_7.dat, j102_9.dat, j102_10.dat, j301_1.dat, j301_2.dat, j301_3.dat, j301_4.dat, j301_5.dat, j301_6.dat, j301_7.dat, j301_8.dat, j301_9.dat, j301_10.dat

rcpsp.mos
(!****************************************************************
   CP example problems
   ===================

   file rcpsp.mos
   ``````````````
   Resource-constrained project scheduling problem (RCPSP).

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

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

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

model "RCPSP"
 uses "kalis", "mmsystem"

 parameters
  DATAFILE = "j301_1.dat"
 end-parameters

 declarations
  HORIZON: integer                            ! Time horizon
  TASKS: set of integer                       ! Set of tasks
  RESOURCES: set of integer                   ! Set of resources
  SUCC: array(TASKS) of set of integer        ! Successors of each task
  CAPA: array(RESOURCES) of integer           ! Resource capacities
  DUR: array(TASKS) of integer                ! Task durations
  CONSO: array(TASKS,RESOURCES) of integer    ! Resource consumption

  tasks: array(TASKS) of cptask               ! Tasks
  resources: array(RESOURCES) of cpresource   ! Resources   
 end-declarations

 initializations from "Data/"+DATAFILE
  TASKS RESOURCES HORIZON SUCC CAPA DUR CONSO
 end-initializations

! Setting up the resources with discrete capacities
 forall(j in RESOURCES) 
  set_resource_attributes(resources(j), KALIS_DISCRETE_RESOURCE, CAPA(j))

! Setting up the variables representing task properties
 forall(i in TASKS) do
  setdomain(getstart(tasks(i)), 0, HORIZON)
  setdomain(getend(tasks(i)), 0, HORIZON)
  set_task_attributes(tasks(i),DUR(i))
  setsuccessors(tasks(i),union(j in SUCC(i)) {tasks(j)})
 end-do

! Resource constraints
 forall(i in TASKS, j in RESOURCES | CONSO(i,j) > 0)
  requires(tasks(i), CONSO(i,j), resources(j))

! Solve the problem
 starttime:= gettime
 if cp_schedule(getmakespan) = 0 then
  writeln("(", gettime-starttime, "sec) No solution found")
 else
  writeln("(", gettime-starttime, "sec) Best solution: Makespan = ",
          getsol(getmakespan))
 end-if
 cp_show_stats

end-model

mrcpsp.mos
(!****************************************************************
   CP example problems
   ===================

   file mrcpsp.mos
   ```````````````
   Multi-mode resource constrained project scheduling problem (MRCPSP)

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

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

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

model "MRCPSP"
 uses "kalis", "mmsystem"
 
 parameters
  DATAFILE = "j102_2.dat"
 end-parameters

 declarations
  HORIZON: integer                           ! Time horizon
  TASKS: set of integer                      ! Set of tasks
  RESOURCES: set of integer                  ! Set of resources
  REN: array(RESOURCES) of boolean           ! Resource type: (non)renewable
  MODES: array(TASKS) of set of integer      ! Task processing modes
  SUCC: array(TASKS) of set of integer       ! Successors of each task
  CAPA: array(RESOURCES) of integer          ! Resource capacities
  DUR: dynamic array(TASKS,set of integer) of integer  ! Task durations
  CONSO: dynamic array(TASKS,set of integer,RESOURCES) of integer  ! Resource use

  tasks: array(TASKS) of cptask              ! Tasks
  modes: array(TASKS) of cpvar               ! Mode selected per task
  resources: array(RESOURCES) of cpresource  ! Resources
 end-declarations

 initializations from "Data/"+DATAFILE
  TASKS RESOURCES HORIZON SUCC CAPA DUR CONSO REN MODES
 end-initializations

! Setting up the resources
 forall(j in RESOURCES)
  set_resource_attributes(resources(j), KALIS_DISCRETE_RESOURCE, CAPA(j))

! Setting up the variables representing task properties
 forall(i in TASKS) do
  setdomain(getstart(tasks(i)), 0, HORIZON)
  setdomain(getend(tasks(i)), 0, HORIZON)
  setdomain(getduration(tasks(i)), min(k in MODES(i)) DUR(i,k), 
            max(k in MODES(i)) DUR(i,k))
  setdomain(modes(i), min(k in MODES(i)) k, max(k in MODES(i)) k)
  setsuccessors(tasks(i), union(j in SUCC(i)) {tasks(j)})
 end-do

! Resource constraints
 forall(i in TASKS, j in RESOURCES)
  if REN(j) then 
   requires(tasks(i), min(k in MODES(i)) CONSO(i,k,j), 
            max(k in MODES(i)) CONSO(i,k,j), resources(j))
  else
   consumes(tasks(i), min(k in MODES(i)) CONSO(i,k,j), 
            max(k in MODES(i)) CONSO(i,k,j), resources(j))
  end-if

! Constraints on modes
 forall(i in TASKS) do
  element(array(k in MODES(i)) DUR(i,k), modes(i)) = getduration(tasks(i))
  forall(j in RESOURCES) do
   if REN(j) then 
    element(array(k in MODES(i)) CONSO(i,k,j), modes(i)) = 
     getrequirement(tasks(i), resources(j))
   else
    element(array(k in MODES(i)) CONSO(i,k,j), modes(i)) = 
     getconsumption(tasks(i), resources(j))
   end-if
  end-do
 end-do

! Solve the problem
 starttime:= gettime
 if cp_schedule(getmakespan) = 0 then
  writeln("(", gettime-starttime, "sec) No solution found")
 else
  writeln("(", gettime-starttime, "sec) Best solution: Makespan = ",
          getsol(getmakespan))
 end-if
 cp_show_stats
 
end-model

© 2001-2024 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.