To understand my question let me first introduce my model. The process starts when around 50 order agents enter at the same time the "enter" block (see picture). After that, the delay block delays the orders for 1 second, to separate them. Then, the wait block is used to create batch sizes such that they are smaller than the maximum capacity of the selected vehicle. This is done by summing the parameter "amount" (saved in the order agent) until the maximum capacity of 20 is reached (see code). The orders are saved in a collection called 'collection' and the size of the collection is used as the batch size in the next block.
The problem is that when looking at the delivery location of the orders, orders are sometimes unlogical batched. For example, vehicle 1 and vehicle 2 both go to places A and B, while it's more efficient if vehicle 1 goes to place A and vehicle 2 goes to place B. Is there a way that the batches will take delivery location into account such that they are close to each other? The delivery locations are stored in the order agents as a parameter "deliveryLocation" of type Customer (location on a GIS map).
inventory=agent.amount+inventory;
collection.add(agent);
if(inventory>=20){
batch.set_batchSize(collection.size());
wait.freeAll();
collection.clear();
inventory=0;
}