Inventory management with simultaneously horizontal and vertical substitution