from gekko import GEKKO m = GEKKO() tabs = 5.0 / 100 # m = cm * (1m/100cm) Area = 0.8 # m^2 w = m.Var(lb=0) # width of the cardboard piece x = m.Var(lb=0) # length of cut-out h = m.Intermediate(Area / w) # Area = w h box_width = m.Intermediate(w - 2 * x) box_length = m.Intermediate(h - 2 * x) box_height = m.Intermediate(x) box_width_with_tabs = m.Intermediate(box_width + 2 * tabs) Volume = m.Intermediate(box_width * box_length * box_height) # upper constraint for box width with tabs m.Equation(box_width_with_tabs < w) # lower constraint for box width with tabs m.Equations([box_width > 0,box_length > 0,Volume>0.01]) m.Maximize(Volume) m.solve() print('width = ' + str(w.value[0])) print('length = ' + str(h.value[0])) print('height = ' + str(x.value[0])) print('volume = ' + str(Volume.value[0]))