Initializing help system before first use

Construction of a stadium: project planning


Type: Project planning
Rating: 2 (easy-medium)
Description:
  • Project planning problem modeled with linear constraints, demonstrating the effect of constraint propagation (b1stadium_ka.mos).
  • Alternative formulation as scheduling problem with precedence constraints, modeled with task objects (b1stadium2_ka.mos).
File(s): b1stadium_ka.mos, b1stadium2_ka.mos
Data file(s): b1stadium.dat


b1stadium_ka.mos
(!****************************************************************
   Mosel Example Problems
   ======================
   
   file b1stadium_ka.mos
   `````````````````````
   Construction of a stadium
   (See "Applications of optimization with Xpress-MP",
        Section 7.1 Construction of a stadium)

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

model "B-1 Stadium construction (CP)"
 uses "kalis"
 
 declarations
  N = 19                              ! Number of tasks in the project 
                                      ! (last = fictitious end task)
  TASKS = 1..N
  ARC: dynamic array(range,range) of integer  ! Matrix of the adjacency graph 
  DUR: array(TASKS) of integer        ! Duration of tasks
  HORIZON : integer                   ! Time horizon 

  start: array(TASKS) of cpvar        ! Start dates of tasks
  bestend: integer
 end-declarations

 initializations from 'Data/b1stadium.dat'
  DUR ARC
 end-initializations

 HORIZON:= sum(j in TASKS) DUR(j)

 forall(j in TASKS) do
  0 <= start(j); start(j) <= HORIZON
 end-do

! Task i precedes task j
 forall(i, j in TASKS | exists(ARC(i, j))) do
  Prec(i,j):= start(i) + DUR(i) <= start(j)
  if not cp_post(Prec(i,j)) then
   writeln("Posting precedence ", i, "-", j, " failed")
   exit(1)
  end-if
 end-do

! Since there are no side-constraints, the earliest possible completion
! time is the earliest start of the fictitious task N
 bestend:= getlb(start(N))
 start(N) <= bestend
 writeln("Earliest possible completion time: ", bestend)

! For tasks on the critical path the start/completion times have been fixed
! by setting the bound on the last task. For all other tasks the range of
! possible start/completion times gets displayed.
 forall(j in TASKS) writeln(j, ": ", start(j))

end-model

b1stadium2_ka.mos
(!****************************************************************
   Mosel Example Problems
   ======================
   
   file b1stadium2_ka.mos
   ``````````````````````
   Construction of a stadium
   (See "Applications of optimization with Xpress-MP",
        Section 7.1 Construction of a stadium)
   - Alternative formulation using tasks -

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

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

model "B-1 Stadium construction (CP)"
 uses "kalis"
 
 declarations
  N = 19                              ! Number of tasks in the project 
                                      ! (last = fictitious end task)
  TASKS = 1..N
  ARC: dynamic array(range,range) of integer  ! Matrix of the adjacency graph 
  DUR: array(TASKS) of integer        ! Duration of tasks
  HORIZON : integer                   ! Time horizon 

  task: array(TASKS) of cptask        ! Tasks to be planned
  bestend: integer
 end-declarations

 initializations from 'Data/b1stadium.dat'
  DUR ARC
 end-initializations

 HORIZON:= sum(j in TASKS) DUR(j)

! Setting up the tasks 
 forall(j in TASKS) do
  setdomain(getstart(task(j)), 0, HORIZON)   ! Time horizon for start times
  set_task_attributes(task(j), DUR(j))       ! Duration
  setsuccessors(task(j), union(i in TASKS | exists(ARC(j,i))) {task(i)})
 end-do                                      ! Precedences
          
 if not cp_propagate or not cp_shave then
  writeln("Problem is infeasible")
  exit(1)
 end-if 

! Since there are no side-constraints, the earliest possible completion
! time is the earliest start of the fictitious task N
 bestend:= getlb(getstart(task(N)))
 getstart(task(N)) <= bestend
 writeln("Earliest possible completion time: ", bestend)

! For tasks on the critical path the start/completion times have been fixed
! by setting the bound on the last task. For all other tasks the range of
! possible start/completion times gets displayed.
 forall(j in TASKS) writeln(j, ": ", getstart(task(j)))

! Complete enumeration: schedule every task at the earliest possible date
 if cp_minimize(getstart(task(N))) then
  writeln("Solution after optimization: ")
  forall(j in TASKS) writeln(j, ": ", getsol(getstart(task(j))))
 end-if
end-model

© 2001-2020 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.