Well, Alan, you have a specific model, a specific problem, specific constaints and specific aims. You just need to write it down... there won't be a general tool or code you can use (at least without changing or setting up a lot - what is as much work as coding the sim yourself).
So I could only give you a pseudocode, but this is too obvious and not helpful.
You are wellcome. Please ask again if you have any specific problem with this, e.g. with using a function or extracting a particular statistic or something like this. Good luck!