Initializing help system before first use

resusage

Purpose
Creates a resource usage. A resource usage is a means to specify the way that a resource will be produced/consumed/provided/required by a task. Three types of resource usages can be used:
Scheduling/resusage.png
  • CASE 1: Constant resource usage. This is the simplest case where the resource usage is constant all along the execution of the task. For example a task A will require 2 units of resource R during its execution.
  • CASE 2: Variable resource usage but constant over the execution of the task. This case allows the resource usage to be variable but constant during the execution of the task. Therefore, a decision variable is associated with the resource usage that can be constrained like any other variable. For example a task A will require between 2 units and 4 units of resource R during its execution.
  • CASE 3: Variable resource usage over the execution of the task. This case allows the resource usage to vary during the execution of the task using a resource usage profile defined as a list of integers. For example a task A will require [2,3,2,3,2,1,2,1] resource units wich means '2' for the first timestep of its execution; '3' for the second etc.. If the duration of the task exceeds the length of the profile, then the resource usage is considered as 0 after the end of the profile. If the task duration is smaller than the length of the profile, the profile will be truncated to the duration of the task.

Synopsis
function resusage(resource:cpresource, usage:integer) : cpresusage
function resusage(resource:cpresource, usagemin:integer, usagemax:integer) : cpresusage
function resusage(resource:cpresource, profile:array of integer) : cpresusage
Arguments
resource 
the resource
usage 
the constant resource usage
usagemin 
minimal resource usage
usagemax 
maximal resource usage
profile 
profile of resource usage
Example
The following example illustrates this:
model "Non constant resource usage"
 uses "kalis"

 forward procedure print_solution(tasks: set of cptask,
                                  resources: set of cpresource)

 declarations
  res1,res2: cpresource
  taska,taskb,taskc: cptask
 end-declarations

 taska.start    <= 15
 taska.duration = 4
 taskb.start    <= 15
 taskb.duration = 3
 taskc.start    <= 15
 taskc.duration = 5

! Define a discrete resource with periods of unavailability
 set_resource_attributes(res1, KALIS_DISCRETE_RESOURCE, 6)
 setcapacity(res1, 0, 15, 0)
 setcapacity(res1, 1, 5, 6)
 setcapacity(res1, 7, 11, 6)

 requires(taska, {resusage(res1,[1,3,5,6])})
 requires(taskb, {resusage(res1,[5,3,1])})
 requires(taskc, {resusage(res1,1,1)})

! Define a resource with initial capacity at 0
 set_resource_attributes(res2, KALIS_DISCRETE_RESOURCE, 0)

 provides(taska, resusage(res2,[1,3,1,2]))
 consumes(taskb, resusage(res2,[3,1,2]))
 produces(taskc, resusage(res2,[3,1,2,0,2]))

 if not cp_propagate then
  writeln("Problem is infeasible"); exit(1)
 end-if

 while (cp_find_next_sol) do
  print_solution({taska,taskb,taskc},{res1,res2})
 end-do

!-------------------------------------------------------------
!**** Display results ****
 procedure print_solution(tasks: set of cptask,
                          resources: set of cpresource)

  forall(res in resources) do
   writeln("Resource ", res.name)
   forall(timeindex in 0..getub(getmakespan)) do
    write(strfmt(timeindex,3), " Cap: ", getcapacity(res,timeindex))

    forall(t in tasks)
     if getrequirement(t,res,timeindex)>0 then
      write(", ", t.name, "(req):", getrequirement(t,res,timeindex))
     elif getproduction(t,res,timeindex)>0 then
      write(", ", t.name, "(prod):", getproduction(t,res,timeindex))
     elif getconsumption(t,res,timeindex)>0 then
      write(", ", t.name, "(cons):", getconsumption(t,res,timeindex))
     elif getprovision(t,res,timeindex)>0 then
      write(", ", t.name, "(prov):", getprovision(t,res,timeindex))
     end-if

    writeln
   end-do
  end-do

 end-procedure

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.