Initializing help system before first use

setcapacity

Purpose
Sets the maximal capacity (the maximal amount of processing units available) of a discrete resource between two time bounds. This routine can only be applied to resources of type KALIS_DISCRETE_RESOURCE.
Synopsis
procedure setcapacity(resource:cpresource, tmin:integer, tmax:integer, capa:integer)
Arguments
resource 
the resource
tmin 
lower bound of the time interval
tmax 
upper bound of the time interval
capa 
the maximal amount of processing units available of resource in the interval [tmin,tmax]
Example
The following example shows how to use setcapacity:
Scheduling/ResourceCapacity.png
model "Resource capacity"
 uses "kalis"

 declarations
  A, B, C : cptask            ! Declaration of tasks
  resource : cpresource       ! Declaration of resource
 end-declarations

 setname(A,"A"); setname(B,"B"); setname(C,"C")

! The resource is a cumulative resource with maximum capacity 6
 set_resource_attributes(resource, KALIS_DISCRETE_RESOURCE, 6)

! Setting the resource capacity in the interval 0..2 to 3
 setcapacity(resource, 0, 2, 3)
! Setting the resource capacity in the interval 3..4 to 2
 setcapacity(resource, 3, 4, 2)
! Setting the resource capacity in time period 5 to 1
 setcapacity(resource, 5, 5, 1)

! Setting the task durations
 set_task_attributes(A, 1)
 set_task_attributes(B, 2)
 set_task_attributes(C, 3)

! Setting the resource requirements of the tasks
 requires(A, 1, resource)
 requires(B, 2, resource)
 requires(C, 3, resource)

! Find the optimal schedule (minimizing the makespan)
 if cp_schedule(getmakespan) <> 0 then	
  cp_show_sol
 else
  writeln("no solution found") 		
 end-if

end-model

Related topics

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