I am trying to approach a VLSI floor planning problem and trying out ways to plot out the floor plan given the width and height of all the boxes along with the normalized Polish expression to help in figuring out the position of the blocks relative to each other.
Aim is to plot all the boxes in the layout possible
I tried plotting the first box and then plot the remaining with respect to the minimum bounding rectangle being formed by the addition of new blocks , but i faced an issue when a couple of layouts were combined separately and then merged with the starting layout
I have attached a graph representation of the polish expression and a way to know how to place blocks

Here is the code which i have written till now `
def eval_polish(polish_expression, blocks_data):
stack = []
lower_bottom_x = 0 ;
lower_bottom_y = 0 ;
for token in polish_expression:
if token.isdigit(): #means token is operand
block_id = int(token)
width, height = blocks_data[block_id - 1][1:]
stack.append((block_id , width , height))
if(block_id == 1):
plot_rectangle(0,0,width,height,1)
else :
op2 = stack.pop() # one to be plotted
op1 = stack.pop() # this one will already be plotted , could be a combined rectangle or a single one
if token == 'V':
new_block_x = lower_bottom_x + op1[1]
new_block_y = lower_bottom_y
if(op2[0] != -1):
plot_rectangle(new_block_x , new_block_y , op2[1] , op2[2] , op2[0])
stack.append((-1, op1[1] + op2[1] , max(op1[2],op2[2])))
if token == 'H': # horizontal placement , op2 placed above op1
new_block_x = lower_bottom_x
new_block_y = lower_bottom_y + op1[2]
if(op2[0] != -1):
plot_rectangle(new_block_x , new_block_y , op2[1] , op2[2] , op2[0])
stack.append((-1 , max(op1[1], op2[1]) , op1[2] + op2[2]))`