# Decision Optimization

View Only

## Bin Packing Problem using interval variables (docplex.cp)

• #### 1.  Bin Packing Problem using interval variables (docplex.cp)

Posted Mon December 04, 2023 01:36 AM

Hello all,

I am new to programming in CPLEX and I am trying to solve a problem similar to bin packing problem using constraint programming.
The items to be added in the bins are linked to each other, e.g. item A needs to be put in a bin before item B can be put in a bin. I believe the scheduling functions such as start_before_start, etc. would be a fit for this constraint, hence I am trying to use interval variables for my tasks and bins but I am unable to do so.

Any help or ideas on how to use interval variables for bin packing problem are welcome.

------------------------------
Aarushi Gupta
------------------------------

• #### 2.  RE: Bin Packing Problem using interval variables (docplex.cp)

Posted Mon December 04, 2023 01:39 AM

@ALEX FLEISCHER any inputs on this would be helpful! TIA

------------------------------
Aarushi Gupta
------------------------------

• #### 3.  RE: Bin Packing Problem using interval variables (docplex.cp)

Posted Tue December 05, 2023 09:59 AM
Edited by Olivier Lhomme Tue December 05, 2023 10:00 AM

What do you mean by "before" in "A needs to be put in a bin before item B"?

(1) B in a bin implies A in the same bin

(2) a bin has some positions, and A must be in a position smaller than B, because for example the bin is a truck and heavy items should be under the light ones.

(3) This term is really related with the time, and this is a scheduling problem.

In the case (3) you can use intervalVariables, and cumul functions should be able to express your capacity constraint.

In (1) and (2), no interval variables needed. Only some additional constraints are to be added.

------------------------------
Olivier Lhomme
------------------------------