Class KResource

java.lang.Object
com.artelys.kalis.KResource
Direct Known Subclasses:
KDiscreteResource, KUnaryResource

public class KResource extends Object
Resources (machines, raw material etc) can be of two different types :
- Disjunctive when the resource can process only one task at a time (represented by the class KUnaryResource).
- Cumulative when the resource can process several tasks at the same time (represented by the class KDiscreteResource).

Traditional examples of disjunctive resources are Jobshop problems,
cumulative resources are heavily used for the Resource-Constrained Project
Scheduling Problem (RCPSP). Note that a disjunctive resource is semantically
equivalent to a cumulative resource with maximal capacity one and unit
resource usage for each task using this resource but this equivalence does
not hold in terms of constraint propagation.

The following schema shows an example with three tasks A,B and C executing on a disjunctive resource and on a cumulative resource with resource usage 3 for task A, 1 for task B and 1 for task C :



Tasks may require, provide, consume and produce resources :
- A task requires a resource if some amount of the resource capacity must be made available for the execution of the activity. The capacity is renewable which means that the required capacity is available after the end of the task.
- A task provides a resource if some amount of the resource capacity is made available through the execution of the task. The capacity is renewable which means that the provided capacity is available only during the execution of the task.
- A task consumes a resource if some amount of the resource capacity must be made available for the execution of the task and the capacity is non-renewable which means that the consumed capacity if no longer available at the end of the task.
- A task produces a resource if some amount of the resource capacity is made available through the execution of the task and the capacity is non-renewable which means that the produced capacity is definitively available after the starting of the task.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
     
    Empty constructor
    protected
    KResource​(long cPtr, boolean cMemoryOwn)
     
     
    KResource​(KResource toCopy)
    Copy constructor
     
    KResource​(KSchedule schedule)
    Basic constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addIdleTimeSteps​(KIntArray idleTimeSteps)
    Add idle time steps to this resource.

    During "idle time steps", the resource does nothing, i.e. its usage
    (consumption, production, ...) for any task T is set to zero and delayed
    one time step after (if T is executed on this very time step).
    void
    addTask​(KTask task)
     
    void
    Close this resource
    void
     
    protected void
     
    Return a copy of this object
    protected static long
     
     
    Return the KIntVar representing the difference between LST and EST variables
    Return the KIntVar representing the earliest starting time of all the tasks executing on this resource
     
    int
    Return the capacity at timestep 0
    int
    Return the initial resource stock at time step `t`
    boolean
    Return true if all the tasks on this resource are fixed
    Return the KIntVar representing the latest completion time of all the tasks executing on this resource
    int
    getLocalSlack​(com.artelys.kalis.SWIGTYPE_p_p_KTask_I t1, com.artelys.kalis.SWIGTYPE_p_p_KTask_I t2)
     
    int
    Return the initial resource storage at time step 0
    int
    Return the initial resource storage at time step t
    int
    Return the minimum tasks duration
    int
     
    int
    getMinUsageAt​(int t)
    Return the initial resource stock at time step t
    Return the name of this resource
    int
    Return the number of tasks using this resource
    com.artelys.kalis.SWIGTYPE_p_KResource_I
     
     
    Return the KIntVar representing the slack for this resource
    getTask​(int index)
    Return task with index 'index' in this resource
     
    boolean
    isIdleTimeStep​(int timestep)
    Return true IFF `timestep` is an idle timestep for this resource
    void
    Pretty printing of this resource
    void
    print​(com.artelys.kalis.SWIGTYPE_p_void ctx, com.artelys.kalis.SWIGTYPE_p_f_p_void_p_q_const__char__int pfp)
    Pretty printing of this resource with a print function pointer
    void
    Pretty printing the resource Gantt chart
    void
    printResourceGantt​(KSolution s, int factor)
    Pretty printing the resource Gantt chart in the console

    void
    Pretty printing the task Gantt chart
    void
    printTaskGantt​(KSolution s, int factor)
    Pretty printing the task Gantt chart in the console

    void
    setInitialCapacityBetween​(int t0, int t1, int capa)
    Set the initial resource stock between time steps `t0` and `t1` to `capa`

    void
    setMaxAvailabilityBetween​(int t0, int t1, int capa)
    Set the initial resource stock between time steps `t0` and `t1` to `capa`

    void
    setMinUsageBetween​(int t0, int t1, int capa)
    Set the initial resource stock between time steps `t0` and `t1` to `capa`

    void
    setName​(String name)
    Set the name of this resource
    void
    setResourceIPtr​(com.artelys.kalis.SWIGTYPE_p_KResource_I r)
     
    void
    setSetupTime​(KTask task1, KTask task2, int afterT1)
    Add a coupled setup time between two tasks for the current resource.
    This means that if the two given tasks are assigned to the resource,
    then the start of the second task must be after the end of the first task
    plus the given duration :

    r.assign(t1) and r.assign(t2) => t1.end + d <= t2.start
    void
    setSetupTime​(KTask task1, KTask task2, int afterT1, int afterT2)
    Add a coupled setup time between two tasks for the current resource.
    This means that if the two given tasks are assigned to the resource,
    then the start of the second task must be after the end of the first task
    plus the given duration :

    r.assign(t1) and r.assign(t2) => t1.end + d <= t2.start

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • swigCMemOwn

      protected transient boolean swigCMemOwn
  • Constructor Details

    • KResource

      protected KResource(long cPtr, boolean cMemoryOwn)
    • KResource

      public KResource()
      Empty constructor
    • KResource

      public KResource(KSchedule schedule)
      Basic constructor
    • KResource

      public KResource(KResource toCopy)
      Copy constructor
  • Method Details

    • getCPtr

      protected static long getCPtr(KResource obj)
    • finalize

      protected void finalize()
      Overrides:
      finalize in class Object
    • delete

      public void delete()
    • getSchedule

      public KSchedule getSchedule()
    • getCopyPtr

      public KResource getCopyPtr()
      Return a copy of this object
    • addTask

      public void addTask(KTask task)
    • print

      public void print()
      Pretty printing of this resource
    • print

      public void print(com.artelys.kalis.SWIGTYPE_p_void ctx, com.artelys.kalis.SWIGTYPE_p_f_p_void_p_q_const__char__int pfp)
      Pretty printing of this resource with a print function pointer
    • close

      public void close()
      Close this resource
    • getName

      public String getName()
      Return the name of this resource
    • setName

      public void setName(String name)
      Set the name of this resource
    • printResourceGantt

      public void printResourceGantt(KSolution s, int factor)
      Pretty printing the resource Gantt chart in the console

      Parameters:
      s - Given scheduling solution
      factor - distortion factor to print the Gantt in the console
    • printResourceGantt

      public void printResourceGantt()
      Pretty printing the resource Gantt chart
    • printTaskGantt

      public void printTaskGantt(KSolution s, int factor)
      Pretty printing the task Gantt chart in the console

      Parameters:
      s - Given scheduling solution
      factor - distortion factor to print the Gantt in the console
    • printTaskGantt

      public void printTaskGantt()
      Pretty printing the task Gantt chart
    • getMinimumTasksDuration

      public int getMinimumTasksDuration()
      Return the minimum tasks duration
    • getSlackVar

      public KIntVar getSlackVar()
      Return the KIntVar representing the slack for this resource
    • getLCTVar

      public KIntVar getLCTVar()
      Return the KIntVar representing the latest completion time of all the tasks executing on this resource
    • getESTVar

      public KIntVar getESTVar()
      Return the KIntVar representing the earliest starting time of all the tasks executing on this resource
    • getDURVar

      public KIntVar getDURVar()
      Return the KIntVar representing the difference between LST and EST variables
    • getNumberOfTasks

      public int getNumberOfTasks()
      Return the number of tasks using this resource
    • getTask

      public KTask getTask(int index)
      Return task with index 'index' in this resource
    • getIsInstantiated

      public boolean getIsInstantiated()
      Return true if all the tasks on this resource are fixed
    • getLocalSlack

      public int getLocalSlack(com.artelys.kalis.SWIGTYPE_p_p_KTask_I t1, com.artelys.kalis.SWIGTYPE_p_p_KTask_I t2)
    • getFirstDisjunctionWithUnknownStatus

      public KDisjunction getFirstDisjunctionWithUnknownStatus()
    • getDisjunctionInvolving

      public KDisjunction getDisjunctionInvolving(KTask t1, KTask t2)
    • getInitialCapacity

      public int getInitialCapacity()
      Return the capacity at timestep 0
    • getInitialCapacityAt

      public int getInitialCapacityAt(int t)
      Return the initial resource stock at time step `t`
    • setInitialCapacityBetween

      public void setInitialCapacityBetween(int t0, int t1, int capa)
      Set the initial resource stock between time steps `t0` and `t1` to `capa`

      Parameters:
      t0 - start of the interval
      t1 - end of the interval
      capa - initial resource stock
    • getMaxAvailability

      public int getMaxAvailability()
      Return the initial resource storage at time step 0
    • getMaxAvailabilityAt

      public int getMaxAvailabilityAt(int t)
      Return the initial resource storage at time step t
    • setMaxAvailabilityBetween

      public void setMaxAvailabilityBetween(int t0, int t1, int capa)
      Set the initial resource stock between time steps `t0` and `t1` to `capa`

      Parameters:
      t0 - start of the interval
      t1 - end of the interval
      capa - initial resource stock
    • getMinUsage

      public int getMinUsage()
    • getMinUsageAt

      public int getMinUsageAt(int t)
      Return the initial resource stock at time step t
    • setMinUsageBetween

      public void setMinUsageBetween(int t0, int t1, int capa)
      Set the initial resource stock between time steps `t0` and `t1` to `capa`

      Parameters:
      t0 - start of the interval
      t1 - end of the interval
      capa - initial resource storage
    • addIdleTimeSteps

      public void addIdleTimeSteps(KIntArray idleTimeSteps)
      Add idle time steps to this resource.

      During "idle time steps", the resource does nothing, i.e. its usage
      (consumption, production, ...) for any task T is set to zero and delayed
      one time step after (if T is executed on this very time step).
    • isIdleTimeStep

      public boolean isIdleTimeStep(int timestep)
      Return true IFF `timestep` is an idle timestep for this resource
    • setSetupTime

      public void setSetupTime(KTask task1, KTask task2, int afterT1, int afterT2)
      Add a coupled setup time between two tasks for the current resource.
      This means that if the two given tasks are assigned to the resource,
      then the start of the second task must be after the end of the first task
      plus the given duration :

      r.assign(t1) and r.assign(t2) => t1.end + d <= t2.start
    • setSetupTime

      public void setSetupTime(KTask task1, KTask task2, int afterT1)
      Add a coupled setup time between two tasks for the current resource.
      This means that if the two given tasks are assigned to the resource,
      then the start of the second task must be after the end of the first task
      plus the given duration :

      r.assign(t1) and r.assign(t2) => t1.end + d <= t2.start
    • getResourceIPtr

      public com.artelys.kalis.SWIGTYPE_p_KResource_I getResourceIPtr()
    • setResourceIPtr

      public void setResourceIPtr(com.artelys.kalis.SWIGTYPE_p_KResource_I r)
    • getTimeTable

      public KTimeTable getTimeTable()