liveBook · Manning

Observation

As explained in Applied Reinforcement Learning

An observation is the information supplied by an environment that represents the current situation available to an agent.

In trailer packing, an observation gives the agent the current layout and the item it must place: a 3D occupancy grid for each container, plus the current item’s ID and base dimensions. The agent uses this information to choose a container, position, and orientation. section 3.4

Listing 3.13 Geometric Helper and Placement Validation Logic
def _get_oriented_dims(self, base_dims, o_idx):  
    l,w,h=base_dims
    if o_idx==0: return(l,w,h) #A
    if o_idx==1: return(l,h,w) #A
    if o_idx==2: return(w,l,h) #A
    if o_idx==3: return(w,h,l) #A
    if o_idx==4: return(h,l,w) #A
    if o_idx==5: return(h,w,l) #A
    raise ValueError(f"Invalid orientation: {o_idx}")
 
def _get_observation(self): #B
    item=self._get_current_item_details() #B
    item_info={'id':item['id'],'base_dims':item['dims']} if item else None
    return ([s.copy() for s in self.container_spaces], item_info) #B
 
def _check_placement(self, c_idx, i_dims_o, pos): #C
    space=self.container_spaces[c_idx]; c_dims=self.container_dims_list[c_idx]
    px,py,pz=np.array(pos,dtype=int); dx,dy,dz=np.array(i_dims_o,dtype=int)
    
    if not (px>=0 and px+dx<=c_dims[0] and py>=0 and py+dy<=c_dims[1] and pz>=0 and pz+dz<=c_dims[2]): return False #D
    
    if np.any(space[px:px+dx, py:py+dy, pz:pz+dz]!=0): return False #E
    
    return True

See how the environment returns copies of the container grids alongside current-item details. section 3.4

How Applied Reinforcement Learning covers it

How deep it goes
Specifies copied 3D container grids and current-item ID and dimensions, without detailing an observation-space schema.
Examples
Uses container occupancy grids and an item's ID and dimensions in a trailer-packing episode.
What you can do after
Build it from scratch as copied NumPy grids paired with current-item details.
How it connects
Connects state representation to container occupancy, current items, and placement actions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Applied Reinforcement Learning. The section links point to the parts of the book it draws on.