I'm scoping a project this week with a client who has a workflow that uses a set of spreadsheets to solve a balancing problem. The spreadsheets are very complex but as they explained more about them, I believe they are trying to hard code a load balancing algorithm with if then statements. Can anybody confirm and point me to an explanation or pseudo-code for load balancing? Many thanks.

Here are the details, they have 5 contracts. Every day they nominate a quantity of product available for sale. Buyers agree to purchase a quantity of the product and the client delivers it to the buyer. Since measurement is inaccurate, they are allowed to deliver anywhere within 98% - 104% of the agreed quantity without penalty.

If the client delivers anymore or less, penalties are applied. To avoid penalties, they balance between the 5 contracts any quantity extra or shortage.

In a previous life, I had a programming project for load balancing with constraints that was similar (moving stock between warehouses, IIRC ). Unfortunately I've got no clue now.