0

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;
 }

Process figure

Jaco-Ben Vosloo
  • 3,770
  • 2
  • 16
  • 33
  • 1
    "is there a way that the batches will take delivery location into account such that they are close to each other?" -> Sure, but you need to code this yourself, there is no pre-defined way to do this, unfortunately. – Benjamin Aug 27 '21 at 16:25
  • There is no delay block in your picture... – Jaco-Ben Vosloo Aug 29 '21 at 08:58

1 Answers1

0

This question is very similar to this one https://stackoverflow.com/a/68917002/4019094, please review it there for an alternative way of implementation.

The example below builds on your existing logic of doing all the coding when an Order enters the wait block

In order to release orders based on their location you need to change your collection to a map with Location as a key.

enter image description here

For this example I created an option list Location, and each Order agent has a parameter of type location. Thus when they enter the wait I can simply add them to a list of orders waiting for the same location, and release them if they meet the batch criteria

if (!collection.containsKey(agent.location)) collection.put(agent.location, new ArrayList<Order>());
collection.get(agent.location).add(agent);

if (collection.get(agent.location).size() > batchSize) {
    for (Order order:collection.get(agent.location)) {
        wait.free(order);
    }
}


And remember to remove them from the collection when they leave the wait block.

enter image description here

Jaco-Ben Vosloo
  • 3,770
  • 2
  • 16
  • 33