jopt.js.spi.domain.resource
Class GranularResourceDomain

java.lang.Object
  extended byjopt.csp.spi.arcalgorithm.domain.AbstractDomain
      extended byjopt.js.spi.domain.resource.ResourceDomain
          extended byjopt.js.spi.domain.resource.GranularResourceDomain
All Implemented Interfaces:
jopt.csp.spi.solver.ChoicePointDataSource, jopt.csp.spi.solver.ChoicePointEntryListener, jopt.csp.spi.arcalgorithm.domain.Domain, jopt.csp.spi.arcalgorithm.domain.DomainChangeSource

public class GranularResourceDomain
extends ResourceDomain

Extension of a standard resource domain. Behavior is similar to a standard resource, but capacity is split into uniformly sized buckets. The user simply needs to specify size of the bucket as well as an index to base the buckets off of. The provided functionality is important for situations in which the unit of time used for resource availability is not the same as that of the activities. For instance, supposed an activity requires X units of resource A every 15 minutes; thus, 1 unit of time = 15 minutes. However, resource A has Y units available each hour (60 minutes). Rather than estimating the availability of resource A to be Y/4 per unit of time, we can model resource A as a granular resource with a bucket size of 4.

Author:
James Boerkoel

Constructor Summary
GranularResourceDomain(ResourceDomain resDom, int bucketSize, int offset)
          Constructs an instance of a granular Resource Domain
 
Method Summary
 void afterChoicePointPopEvent()
           
 void afterChoicePointPushEvent()
           
 void beforeChoicePointPopEvent()
           
 void beforeChoicePointPushEvent()
           
 boolean choicePointStackSet()
           
 void clearDelta()
           
 java.lang.Object clone()
           
 jopt.csp.util.IntIntervalSet findAvailIntervals(int start, int end, int quantity)
          Returns a set indicating the intervals that this resource is available in the given quantity within the specified range
 jopt.csp.util.IntIntervalSet findAvailIntervals(int operationID, int start, int end, int quantity)
          Returns a set indicating the intervals that this resource is available to the given operation in the given quantity within the specified range
 java.lang.Object getDomainState()
           
 int getNumberOfOperationsAssigned()
          Returns the number of operations currently assigned to the resource
 int getResourceEnd()
          This obtains the last point for which this resource is, or ever was, available
 int getResourceStart()
          Obtains the first point for which this resource is, or ever was, available
 int getTotalCapacityAvailable()
          This method will return the total amount of resource available.
 int getType()
          Returns an int representing the type of resource this is domain represents
 boolean isBuilt()
          Determines if this domain is in "built" status
 boolean isResourceAvailable(int operationID, int start, int end, int quantity)
          Determines whether the resource is available in the specified quantity between specified start and end times for the given operation
 boolean isUsed()
          Checks to see if any operation requires the use of this resource at any time.
 int maxAvailableResource(int start, int end)
          Gives the highest consistently available amount of this resource over the given range
 int maxAvailableResource(int operationID, int start, int end)
          Gives the highest consistently available amount of this resource over the given range for the given operation
 int maxAvailableResource(int operationID, int start, int end, int minDur)
          Gives the highest consistently available amount of this resource over the given range for the given operation and assuming that the reource will be used for at least the specified duration
 boolean needsPropagation()
          Returns whether or not this class has been altered, thus rendering its arcs in need of propagation
 void registerAllocatedOperation(int opID, int est, int let, int minDur)
          Lets the resource know that although a specific time has not necessary been decided, the specified operation will use this resource.
 void restoreDomainState(java.lang.Object state)
           
 void setActualOperationTimeline(int operationID, jopt.csp.util.IntIntervalSet timeline)
          Registers the amount of time the specified operation will be using this resource
 void setBuilt(boolean built)
          Sets the built status of this domain
 void setChoicePointStack(jopt.csp.spi.solver.ChoicePointStack cps)
           
 void setNeedsPropagation(boolean needsPropagation)
          Sets the nnedsPropagation flag to the given boolean
 void setPotentialOperationTimeline(int operationID, jopt.csp.util.IntIntervalSet timeline)
          Indicates the time during which the specified operation may be using this resource
 java.lang.String toString()
           
 
Methods inherited from class jopt.js.spi.domain.resource.ResourceDomain
getBeginTime, getCompleteTime, getMakeSpan, getNumOps, isBound
 
Methods inherited from class jopt.csp.spi.arcalgorithm.domain.AbstractDomain
addDomainChangeListener, addRangeChangeListener, addValueChangeListener, changed, removeDomainChangeListener, removeRangeChangeListener, removeValueChangeListener
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GranularResourceDomain

public GranularResourceDomain(ResourceDomain resDom,
                              int bucketSize,
                              int offset)
Constructs an instance of a granular Resource Domain

Parameters:
resDom - resource domain to which make granular
bucketSize - number of units in one grouping
offset - an index off of which to base the buckets
Method Detail

isUsed

public boolean isUsed()
Description copied from class: ResourceDomain
Checks to see if any operation requires the use of this resource at any time.

Overrides:
isUsed in class ResourceDomain
Returns:
true if any operation requires the use of this resource at any point in time.

getType

public int getType()
Description copied from class: ResourceDomain
Returns an int representing the type of resource this is domain represents

Specified by:
getType in class ResourceDomain
Returns:
Resource.UNARY, Resource.DISCRETE, etc.

findAvailIntervals

public jopt.csp.util.IntIntervalSet findAvailIntervals(int start,
                                                       int end,
                                                       int quantity)
Description copied from class: ResourceDomain
Returns a set indicating the intervals that this resource is available in the given quantity within the specified range

Specified by:
findAvailIntervals in class ResourceDomain
Parameters:
start - start of interval inquired about
end - end of interval inquired about
quantity - amound of resource required
Returns:
An IntInterval set that represents the intervals that this resource is available in the given quantity for the specified interval

registerAllocatedOperation

public void registerAllocatedOperation(int opID,
                                       int est,
                                       int let,
                                       int minDur)
                                throws jopt.csp.variable.PropagationFailureException
Description copied from class: ResourceDomain
Lets the resource know that although a specific time has not necessary been decided, the specified operation will use this resource. This allows the resource to account for operations that have been assigned to the resource but not completely bound

Specified by:
registerAllocatedOperation in class ResourceDomain
Parameters:
opID - operation id of operation using resource
est - earliest start time
let - latest end time
minDur - minimum duration
Throws:
jopt.csp.variable.PropagationFailureException

getNumberOfOperationsAssigned

public int getNumberOfOperationsAssigned()
Description copied from class: ResourceDomain
Returns the number of operations currently assigned to the resource

Overrides:
getNumberOfOperationsAssigned in class ResourceDomain
Returns:
number of operations currently assigned to the resource

getResourceStart

public int getResourceStart()
Description copied from class: ResourceDomain
Obtains the first point for which this resource is, or ever was, available

Overrides:
getResourceStart in class ResourceDomain
Returns:
int representing the first point this resource is, or ever was, available

getResourceEnd

public int getResourceEnd()
Description copied from class: ResourceDomain
This obtains the last point for which this resource is, or ever was, available

Overrides:
getResourceEnd in class ResourceDomain
Returns:
int representing the last point this resource is, or ever was, available

getTotalCapacityAvailable

public int getTotalCapacityAvailable()
Description copied from class: ResourceDomain
This method will return the total amount of resource available. That is, the sum of the capacity over time.

Specified by:
getTotalCapacityAvailable in class ResourceDomain
Returns:
sum of available capacity over time

findAvailIntervals

public jopt.csp.util.IntIntervalSet findAvailIntervals(int operationID,
                                                       int start,
                                                       int end,
                                                       int quantity)
Description copied from class: ResourceDomain
Returns a set indicating the intervals that this resource is available to the given operation in the given quantity within the specified range

Specified by:
findAvailIntervals in class ResourceDomain
Parameters:
operationID - operation for whome we are checking the availability
start - start of interval inquired about
end - end of interval inquired about
quantity - amound of resource required
Returns:
An IntInterval set that represents the intervals that this resource is available in the given quantity for the specified interval

isResourceAvailable

public boolean isResourceAvailable(int operationID,
                                   int start,
                                   int end,
                                   int quantity)
Description copied from class: ResourceDomain
Determines whether the resource is available in the specified quantity between specified start and end times for the given operation

Specified by:
isResourceAvailable in class ResourceDomain
Parameters:
operationID - the operationID of the operation in question
start - start of interval being inquired about
end - end of interval being inquired about
quantity - quantity of resource needed
Returns:
true if resource is available in quantity specified between start and end

maxAvailableResource

public int maxAvailableResource(int start,
                                int end)
Description copied from class: ResourceDomain
Gives the highest consistently available amount of this resource over the given range

Specified by:
maxAvailableResource in class ResourceDomain
Parameters:
start - start of range being inquired about
end - end of range being inquired about
Returns:
returns the highest consistently available amount of this resource over the given range, that is, over the range, there is at least X left at all times

maxAvailableResource

public int maxAvailableResource(int operationID,
                                int start,
                                int end)
Description copied from class: ResourceDomain
Gives the highest consistently available amount of this resource over the given range for the given operation

Specified by:
maxAvailableResource in class ResourceDomain
Parameters:
operationID - the operationID of the operation in question
start - start of range being inquired about
end - end of range being inquired about
Returns:
the highest consistently available amount of this resource

maxAvailableResource

public int maxAvailableResource(int operationID,
                                int start,
                                int end,
                                int minDur)
Description copied from class: ResourceDomain
Gives the highest consistently available amount of this resource over the given range for the given operation and assuming that the reource will be used for at least the specified duration

Specified by:
maxAvailableResource in class ResourceDomain
Parameters:
operationID - the operationID of the operation in question
start - start of range being inquired about
end - end of range being inquired about
minDur - the minimum duration
Returns:
the highest consistently available amount of this resource

setPotentialOperationTimeline

public void setPotentialOperationTimeline(int operationID,
                                          jopt.csp.util.IntIntervalSet timeline)
                                   throws jopt.csp.variable.PropagationFailureException
Description copied from class: ResourceDomain
Indicates the time during which the specified operation may be using this resource

Overrides:
setPotentialOperationTimeline in class ResourceDomain
Parameters:
operationID - id of operation
timeline - times potentially being used
Throws:
jopt.csp.variable.PropagationFailureException

setActualOperationTimeline

public void setActualOperationTimeline(int operationID,
                                       jopt.csp.util.IntIntervalSet timeline)
                                throws jopt.csp.variable.PropagationFailureException
Description copied from class: ResourceDomain
Registers the amount of time the specified operation will be using this resource

Overrides:
setActualOperationTimeline in class ResourceDomain
Parameters:
operationID - id of operation
timeline - times being used
Throws:
jopt.csp.variable.PropagationFailureException

clearDelta

public void clearDelta()
Specified by:
clearDelta in interface jopt.csp.spi.arcalgorithm.domain.Domain
Overrides:
clearDelta in class ResourceDomain

beforeChoicePointPopEvent

public void beforeChoicePointPopEvent()

afterChoicePointPopEvent

public void afterChoicePointPopEvent()

beforeChoicePointPushEvent

public void beforeChoicePointPushEvent()

afterChoicePointPushEvent

public void afterChoicePointPushEvent()

clone

public java.lang.Object clone()

getDomainState

public java.lang.Object getDomainState()
Specified by:
getDomainState in interface jopt.csp.spi.arcalgorithm.domain.Domain
Overrides:
getDomainState in class ResourceDomain

restoreDomainState

public void restoreDomainState(java.lang.Object state)
Specified by:
restoreDomainState in interface jopt.csp.spi.arcalgorithm.domain.Domain
Overrides:
restoreDomainState in class ResourceDomain

choicePointStackSet

public boolean choicePointStackSet()

setChoicePointStack

public void setChoicePointStack(jopt.csp.spi.solver.ChoicePointStack cps)
Specified by:
setChoicePointStack in interface jopt.csp.spi.solver.ChoicePointDataSource
Overrides:
setChoicePointStack in class ResourceDomain

toString

public java.lang.String toString()
Overrides:
toString in class ResourceDomain

isBuilt

public boolean isBuilt()
Description copied from class: ResourceDomain
Determines if this domain is in "built" status

Overrides:
isBuilt in class ResourceDomain
Returns:
true if domain is in built status

setBuilt

public void setBuilt(boolean built)
Description copied from class: ResourceDomain
Sets the built status of this domain

Overrides:
setBuilt in class ResourceDomain
Parameters:
built - boolean indication whether or not the problem has been built

needsPropagation

public boolean needsPropagation()
Description copied from class: ResourceDomain
Returns whether or not this class has been altered, thus rendering its arcs in need of propagation

Overrides:
needsPropagation in class ResourceDomain
Returns:
true if this class has been altered, thus rendering its arcs in need of propagation

setNeedsPropagation

public void setNeedsPropagation(boolean needsPropagation)
Description copied from class: ResourceDomain
Sets the nnedsPropagation flag to the given boolean

Overrides:
setNeedsPropagation in class ResourceDomain
Parameters:
needsPropagation - boolean to set the needs Propagation flag