Val Nolav
Val Nolav

Reputation: 902

Solver Foundation Optimization - 1D Bin Packing

I want to optimize loading marble blocks into trucks. I do not know, if I can use Solver Foundation class for that purpose. Before, I start writing code, I wanted to ask it here.

GOAL - The goal is to load marble blocks in minimum truck shipment.

How can I do that without writing a lot of if conditions and for loops?

Can I use Microsoft Solver Foundation for that purpose?

I read the documentation provided by Microsoft however, I could not find a scenario similar to mine.

M1+ M2 + M3 + .... Mn <=24 this is for one truck shipment.

Let say there are 200 different Marble weights and Marble weights are Float.

Thanks

Upvotes: 6

Views: 2424

Answers (1)

Dave Maff
Dave Maff

Reputation: 848

You can use Microsoft Solver Foundation to solve this problem. An example of such a solution can be found here where the OML for the bin packing problem is as follows:

Model[ 
  Parameters[Sets,Items,Bins], 
  Parameters[Integers,OrderWidth[Items],BinWidth[Bins]], 

  Decisions[Integers[0,1],x[Items,Bins]], 
  Decisions[Integers[0,1],y[Bins]], 

  Constraints[    
    Foreach[{i,Items},Sum[{j,Bins}, x[i,j]]==1 ], 
    Foreach[{j,Bins}, Sum[{i,Items}, OrderWidth[i]*x[i,j]] <= BinWidth[j]], 
    Foreach[{i,Items},{j,Bins}, y[j] >= x[i,j]] 
  ], 

  Goals[Minimize[UsedBins->Sum[{j,Bins},y[j]]]] 
]

It would be easy to change OrderWidth to MarbleWeight and BinWidth to TruckCapacity (or just 24 in your case)

Upvotes: 5

Related Questions