Applied Energistics 2

Applied Energistics 2

137M Downloads

Feature Request: Send Crafting Requests to Smallest storage first

polysillycon opened this issue ยท 1 comments

commented

When crafting items in an AE2 system, it appears that a random available CPU is picked. This results in an inefficient use of crafting storage, where a small order can be sent to a large storage CPU, which may block a later request for a craft of large quantity of items. The second order could have fit if the first smaller order was prioritized to a small capacity storage CPU.

When a crafting request is made, ContainerCraftingStatus attempts to find the first available CPU. It does this by pulling a list of cached CPUs, then iterates individually through looking at the .size of the CPU.

However, the next available CPU is not "random", it is actually pulling an unsorted list of CPUs from the cached list of multi-blocks, specifically the CraftingGridCache cache. So the order in which CPUs was added to the cache will affect the first available CPU selected.

It appears that the prioritization feature could be implemented by sorting the returned list of CPUs in the CraftingGridCache object, specifically at the getCpus() method :

@OverRide
public ImmutableSet getCpus()
{
return ImmutableSet.copyOf( new ActiveCpuIterator( this.craftingCPUClusters ) );
}

The sorting could be done here, or in the constructor of ActiveCpuIterator.

Instead of returning a copy of the iterator, return a list of clusters sorted by the .size parameter, ascending. In this way, the first inactive CPU will be the smallest size available, and it will optimally fill as more recipes are done in parallel.

commented