How do you define the "fastest combo"? How do you see this optimization working?
How do you do this workflow now?
What does it mean that a box is "consumed"? When it has one part, two parts, or what?
How would an emergency order be done?
What do you mean by re-adjust? How would parts in the emergency order go to other boxes?
I think if you rigorously define all these terms, create flow diagrams (both for yourself and the ability to communicate a complicated process with others), and clearly define your optimization's goals, you'll be in much better shape to start the project. Currently, it seems you're just at the brainstorming stage, which is fine, but it seems way too early to worry about a computer implementation.
Agreed with @fmpdude: doesn't sound like you have all the rules defined. Once you do based on his questions as a start, and you start mapping out the flowcharts, it will be become clear how to 'program' this.