How to use the ciw.state_tracker.StateTracker function in Ciw

To help you get started, we’ve selected a few Ciw examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CiwPython / Ciw / ciw / state_tracker.py View on Github external
"""
        Changes the state of the system when a customer is released.
        """
        if blocked:
            self.state[node_id-1][1] -= 1
        else:
            self.state[node_id-1][0] -= 1

    def hash_state(self):
        """
        Returns a hashable state
        """
        return tuple(tuple(obs) for obs in self.state)


class MatrixTracker(StateTracker):
    """
    The matrix tracker records the order and destination of
    blockages in the form of a matrix. Alongside this the number
    of customers at each node is tracked.

    Example:
        ((((1, 4), (2)),
           (3),    ())),
           (5, 8))
        This denotes 5 customers at the first node 8 customer at
        the second; 2 customer blocked from the first node to the
        first, one from the first node to the second, and on from
        the second node to the first. The numbers denote the order
        at which they became blocked.
    """
    def __init__(self, simulation):
github CiwPython / Ciw / ciw / state_tracker.py View on Github external
def change_state_release(self, node_id, destination,
        cust_clss, blocked):
        """
        Changes the state of the system when a customer is released.
        """
        pass

    def hash_state(self):
        """
        Returns a hashable state
        """
        return None


class NaiveTracker(StateTracker):
    """
    The naive tracker simple records the number of customers at each
    node, and how many of those customers are currently blocked.

    Example:
        ((3, 0), (1, 4))
        This denotes 3 customers at the first node, 0 of which
        are blocked, 5 customers at the second node, 4 of which
        are blocked.
    """
    def __init__(self, simulation):
        """
        Initialises the naive tracker class
        """
        self.simulation = simulation
        self.state = [[0, 0] for i in range(