Solver Foundation Optimization - 1D Bin Packing

c#, optimization

Solution

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)

Problem

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. - Marble can be in any weight between 1 to 24 Tons. - A truck can hold maximum of 24 Tons. - It can be loaded as many marble cubes, as it can take up to 24 tones, which means there is no Volume limitation. - There can be between 200 up to 500 different marble blocks depending on time. 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

Original source