Class ResourceProvider

    • Field Detail

      • myResourceSet

        protected ResourceSet myResourceSet
        The resource set used by this provider to ask for and and return idle resources
      • myEntityQ

        protected Queue<Entity> myEntityQ
        A queue to hold waiting requests when an idle resource is not immediately available.
      • myServiceRV

        protected RandomVariable myServiceRV
        The service time when using the provider
      • myInitialRequestSelectionRule

        protected EntitySelectionRuleIfc myInitialRequestSelectionRule
        Can be used to supply a rule for how the requests are selected for allocation
      • myEntitySelectionRule

        protected EntitySelectionRuleIfc myEntitySelectionRule
        Can be used to supply a rule for how the requests are selected for allocation
      • myEndServiceListener

        protected jsl.modeling.elements.entity.ResourceProvider.EndServiceListener myEndServiceListener
    • Constructor Detail

      • ResourceProvider

        public ResourceProvider​(ModelElement parent)
        Creates a ResourceProviderr that uses a FIFO queue discipline. An empty ResourceSet is created and must be filled
        Parameters:
        parent -
      • ResourceProvider

        public ResourceProvider​(ModelElement parent,
                                java.lang.String name)
        Creates a ResourceProviderr that uses a FIFO queue discipline. An empty ResourceSet is created and must be filled
        Parameters:
        parent -
        name -
      • ResourceProvider

        public ResourceProvider​(ModelElement parent,
                                java.lang.String name,
                                ResourceSet set)
        Creates a ResourceProvider that uses the supplied set and FIFO queue discipline
        Parameters:
        parent -
        name -
        set -
      • ResourceProvider

        public ResourceProvider​(ModelElement parent,
                                ResourceSet set)
        Creates a ResourceProvider that uses the supplied set and FIFO queue discipline
        Parameters:
        parent -
        set -
      • ResourceProvider

        public ResourceProvider​(ModelElement parent,
                                ResourceSet set,
                                Queue.Discipline discipline)
        Creates a ResourceProvider that uses the supplied set and queue discipline
        Parameters:
        parent -
        set -
        discipline -
      • ResourceProvider

        public ResourceProvider​(ModelElement parent,
                                java.lang.String name,
                                ResourceSet set,
                                Queue.Discipline discipline)
        Creates a ResourceProvider that uses the supplied set and queue discipline
        Parameters:
        parent -
        name -
        set -
        discipline -
    • Method Detail

      • setServiceTime

        public void setServiceTime​(RandomIfc d)
      • getResourceSet

        public final ResourceSet getResourceSet()
        Returns a reference to the resource set used within the provider
        Returns:
      • addResource

        public final Resource addResource()
        Adds a resource with unit capacity to the underlying resource set
        Returns:
      • addResource

        public final Resource addResource​(int capacity)
        Adds a resource with the given capacity to the underlying resource set
        Parameters:
        capacity -
        Returns:
      • addResource

        public Resource addResource​(int capacity,
                                    java.lang.String name)
        Adds a resource with the given capacity and name to the underlying resource set
        Parameters:
        capacity -
        name -
        Returns:
      • addResource

        public final void addResource​(Resource resource)
        Adds the given resource to the underlying set of the provider
        Parameters:
        resource -
      • getNumberOfIdleResources

        public final int getNumberOfIdleResources()
        Returns the current number of idle resources within the underlying resource set
        Returns:
      • changeQueueDiscipline

        public final void changeQueueDiscipline​(Queue.Discipline discipline)
        This will change the queue discipline of the underlying Queue
        Parameters:
        discipline -
      • getQueueInitialDiscipline

        public final Queue.Discipline getQueueInitialDiscipline()
        Returns the initial discipline for the queue
        Returns:
      • setQueueInitialDiscipline

        public final void setQueueInitialDiscipline​(Queue.Discipline discipline)
        Sets the initial queue discipline
        Parameters:
        discipline -
      • getNumberInQueue

        public final int getNumberInQueue()
        Returns the current number of requests in the queue
        Returns:
      • getRequestSelectionRule

        public final EntitySelectionRuleIfc getRequestSelectionRule()
        Returns a reference to the request selection rule. May be null.
        Returns:
      • setRequestSelectionRule

        public final void setRequestSelectionRule​(EntitySelectionRuleIfc rule)
        A request selection rule can be supplied to provide alternative behavior within the selectNextRequest() method. A request selection rule, provides a mechanism to select the next request from the queue of waiting requests
        Parameters:
        rule -
      • getInitialRequestSelectionRule

        public final EntitySelectionRuleIfc getInitialRequestSelectionRule()
        The rule to use when this provider is initialized
        Returns:
      • setInitialRequestSelectionRule

        public final void setInitialRequestSelectionRule​(EntitySelectionRuleIfc rule)
        The rule to use when this provider is initialized
      • initialize

        protected void initialize()
        Description copied from class: ModelElement
        This method should be overridden by subclasses that need actions performed to initialize prior to a replication. It is called once before each replication occurs if the model element wants initialization. It is called after beforeReplication() is called
        Overrides:
        initialize in class ModelElement
      • setResourceSet

        protected final void setResourceSet​(ResourceSet set)
      • selectNextEntity

        protected Entity selectNextEntity()
        Selects a candidate request from the queue for allocation to one of the resources. The selection process does not remove the request from the queue.
        Returns:
        The request that was selected to for a resource
      • seize

        public void seize​(Entity entity)
      • seize

        public void seize​(Entity entity,
                          int amtNeeded)
      • seize

        public void seize​(Entity entity,
                          int amtNeeded,
                          int priority)
      • seize

        public void seize​(Entity entity,
                          int amtNeeded,
                          int priority,
                          boolean partialFillFlag)
        The client asks the ResourceProvider to seize the given amount of the resource. The entity associated with the request immediately enters the providers queue. If there is an idle resource available that can be used to allocate to the request then the request is processed. If the request can be satisfied in full it is removed from the queue and the units of the resource are allocated to it. If it cannot be allocated in full, it is checked to see if it allows partial filling, if so the available units of the resource are allocated to it, but it remains in the queue. NOTE: It is up to the ResourceAllocationListenerIfc to check if the request is still in the queue or if it has been satisfied before proceeding. The amount requested must not exceed the maximum capacity of the underlying resource set.
        Parameters:
        entity -
        amtNeeded -
        priority -
        partialFillFlag -
      • allocated

        protected void allocated​(Request request)
      • endOfService

        protected void endOfService​(Allocation a)