gym_warehouse/envs/warehouse_env.py
def _update_transactions(self, p=0.5):
        """
        Randomly adds new items to staging in area or staging out area.
        When this method is called, with probability p/2 a new inbound item is
        added, with probability p/2 a new outbound item is added, and with
        probability 1 - p nothing is added. If a new item is to be added but
        the corresponding area is full, nothing happens.

        Parameters
        ----------
        p : float
            The probability of a new transaction-item being added.
        """
        flip = random.random()

        bin_items = np.array([])
        for bin_ in self.bins:
            bin_items = np.append(bin_items, bin_.status)
        #bin_items = np.append(bin_items,self.agent.status)
        bin_items = bin_items.flatten()

        y = lambda x: True if x != 0 else False
        bin_items_bool = [y(i) for i in bin_items]

        warehouse_full = all(bin_items_bool)

        emptyslots = self.num_bin_slots * self.num_bins - np.sum(bin_items_bool)
        #if emptyslots ==0:
        #    warehouse_full = True

        if (flip < p or np.sum(bin_items) == 0) and not (warehouse_full):
            while True:
                self.staging_in_area.status = self.observation_staging_areas.sample()

                # verifies that the number of slots is enough for the incoming in transaction
                sampleslots = np.sum([y(i) for i in self.staging_in_area.status])
                if np.sum(self.staging_in_area.status) != 0 and emptyslots >= sampleslots:
                    break

        else:
            missing_items = True;
            bin_counts = np.zeros(self.num_items + 1)
            for i in bin_items:
                bin_counts[int(i)] += 1
            while (np.sum(self.staging_out_area.status) == 0 or missing_items):
                self.staging_out_area.status = self.observation_staging_areas.sample()
                # checking that an outbound transaction always has the "required" items in bins.
                staging_counts = np.zeros(self.num_items + 1)
                for i in self.staging_out_area.status:
                    staging_counts[i] += 1
                missing_items = not (all(bin_counts[1:] >= staging_counts[1:]))

        Randomly adds new items to staging in area or staging out area.
        When this method is called, with probability p/2 a new inbound item is
        added, with probability p/2 a new outbound item is added, and with
        probability 1 - p nothing is added. If a new item is to be added but
        the corresponding area is full, nothing happens.

        Parameters
        ----------
        p : float
            The probability of a new transaction-item being added.
        
Randomly adds new items to staging in area or staging out area.
When this method is called, with probability p/2 a new inbound item is
added, with probability p/2 a new outbound item is added, and with
probability 1 - p nothing is added. If a new item is to be added but
the corresponding area is full, nothing happens.

Parameters

p : float
The probability of a new transaction-item being added.
Randomly adds new items to staging in area or staging out area . When this method is called with probability p / 2 a new inbound item is added with probability p / 2 a new outbound item is added and with probability 1 - p nothing is added . If a new item is to be added but the corresponding area is full nothing happens . Parameters p : float The probability of a new transaction - item being added .
def _update_transactions(self, p=0.5):
        flip = random.random()
        bin_items = np.array([])
        for bin_ in self.bins:
            bin_items = np.append(bin_items, bin_.status)
        bin_items = bin_items.flatten()
        y = lambda x: True if x != 0 else False
        bin_items_bool = [y(i) for i in bin_items]
        warehouse_full = all(bin_items_bool)
        emptyslots = self.num_bin_slots * self.num_bins - np.sum(bin_items_bool)
        if (flip < p or np.sum(bin_items) == 0) and not (warehouse_full):
            while True:
                self.staging_in_area.status = self.observation_staging_areas.sample()
                sampleslots = np.sum([y(i) for i in self.staging_in_area.status])
                if np.sum(self.staging_in_area.status) != 0 and emptyslots >= sampleslots:
                    break
        else:
            missing_items = True;
            bin_counts = np.zeros(self.num_items + 1)
            for i in bin_items:
                bin_counts[int(i)] += 1
            while (np.sum(self.staging_out_area.status) == 0 or missing_items):
                self.staging_out_area.status = self.observation_staging_areas.sample()
                staging_counts = np.zeros(self.num_items + 1)
                for i in self.staging_out_area.status:
                    staging_counts[i] += 1
                missing_items = not (all(bin_counts[1:] >= staging_counts[1:]))
def _update_transactions ( self , p = 0.5 ) : flip = random . random ( ) bin_items = np . array ( [ ] ) for bin_ in self . bins : bin_items = np . append ( bin_items , bin_ . status ) bin_items = bin_items . flatten ( ) y = lambda x : True if x != 0 else False bin_items_bool = [ y ( i ) for i in bin_items ] warehouse_full = all ( bin_items_bool ) emptyslots = self . num_bin_slots * self . num_bins - np . sum ( bin_items_bool ) if ( flip < p or np . sum ( bin_items ) == 0 ) and not ( warehouse_full ) : while True : self . staging_in_area . status = self . observation_staging_areas . sample ( ) sampleslots = np . sum ( [ y ( i ) for i in self . staging_in_area . status ] ) if np . sum ( self . staging_in_area . status ) != 0 and emptyslots >= sampleslots : break else : missing_items = True ; bin_counts = np . zeros ( self . num_items + 1 ) for i in bin_items : bin_counts [ int ( i ) ] += 1 while ( np . sum ( self . staging_out_area . status ) == 0 or missing_items ) : self . staging_out_area . status = self . observation_staging_areas . sample ( ) staging_counts = np . zeros ( self . num_items + 1 ) for i in self . staging_out_area . status : staging_counts [ i ] += 1 missing_items = not ( all ( bin_counts [ 1 : ] >= staging_counts [ 1 : ] ) )
Randomly adds new items to staging in area or staging out area.
Randomly adds new items to staging in area or staging out area .
"""
        Randomly adds new items to staging in area or staging out area.
        When this method is called, with probability p/2 a new inbound item is
        added, with probability p/2 a new outbound item is added, and with
        probability 1 - p nothing is added. If a new item is to be added but
        the corresponding area is full, nothing happens.

        Parameters
        ----------
        p : float
            The probability of a new transaction-item being added.
        """ #bin_items = np.append(bin_items,self.agent.status) #if emptyslots ==0: #    warehouse_full = True # verifies that the number of slots is enough for the incoming in transaction # checking that an outbound transaction always has the "required" items in bins.
self
p