As shown in below image, I am trying to pull items where cumulative Value should be <=9.
First Bin Packed with id:2 Value 9 (100% bin utilization)
Second BIn Packed with id:3 Value 9 (100% bin utilization)
Third BIn Packed with id:9 Value 9 (100% bin utilization)
Fourth Bin Packed with id:6 and id:8 cumulative Value 9 (100% bin utilization)
Fifth Bin Packed with id:7 and id:10 cumulative Value is 9 (100% bin utilization)
Sixth Bin packed with id:4 Value 7 (bin Utilization <100)
Seventh Bin packed with id:1 Value 3( bin utilization<100)
For example following code pulls first token in the list with Value 3 because when we add next token Value, the cumulative exceeds >=9. So first token is pulled. Instead need to loop all the tokens and pull the tokens where bin utilization is high.
List itemList = List("ItemList1"); int listLen = itemList.entries().length; int valueSum = 0; for (int i = 1; i <= listLen; i++) { valueSum += List("ItemList1").entries()[i].value.labels["Value"].value; if(valueSum >= 9) { return i - 1; } } return 0;
Team I need to pack the bins in the above mentioned way. Please help me on this.I am attaching model for reference