1

I have a DataFrame with order number, weight and pallet equvivalent.

    order #   pallets weight
0   31785053    1.0    174.0
1   31785071    1.0    45.0
2   31785044    6.0    8300.0
3   31827117    7.0    9684.0
4   31827228    1.0    1404.0

I want to allocate orders to cars with some specific constraints: max_weight and max_pallet

max_weight = 20000

max_pallets = 44

This is what I came up with:

def fill_one_car():
    car =[]
    pallets_eq = 0
    weight = 0
    for index in range(len(orders)):
        if (orders[index] not in big_orders) and ((pallets_eq + pallets[index]) <= max_pallets) and ((weight + weights[index]) <= max_weight):
            weight += weights[index]
            pallets_eq += pallets[index]
            car.append(orders[index])
    return car

Outcome is list of orders.

I wonder how to allocate the full list of orders to x cars, for example: [[31785053,31785071],[3178504,31785044]], where each list is a seperate car.

eeealesha
  • 33
  • 6
  • what do you mean by "I want to allocate orders to cars with some specific constraints: max_weight and max_pallet". what should the final result look like? – bpfrd Jul 14 '22 at 15:54
  • @bpfrd, Hello! Thank you for the comment. I want to return the list of lists with specific orders: `[[order1,order2],[order3,order4]]` – eeealesha Jul 15 '22 at 07:02

0 Answers0