Hi Anderson,
There is usually a lot you can do to speed up the construction time of a Pyomo model after it is first written. If you are starting from an AbstractModel formulation, you can add the "--output-instance-construction-time” option to the runef command to see detailed output about the time taken to construct each component on your model.
If you see output like "Cloning detected! (clone counters: …” under the output for a constraint where a lot of time is being spent, it tells you that you need to focus on rewriting that constraint expression in such a way that Pyomo doesn’t have to build and throw away a lot of intermediate expressions. We can tell you how to do this once you identify some spots like this.
A more detailed profile can be obtained by adding something like “--profile 1000” to the runef command. It is usually best to pipe all output to a file when this option is used (e.g., runef … --profile 1000 > out). If you want to send this output to me directly (off of the forum), I don't might taking a quick look to see if I can identify anything obvious.
I can also point you at some more bleeding-edge developments that speed up Pyomo (e.g., alternate API’s), but we shouldn’t go there until checking for more low-hanging fruit.
Finally, note that the runef command isn’t really meant to scale. The decomposition algorithms in PySP (like runph) are designed to allow you to distribute scenario instances over many compute nodes and do work in parallel, but everything in runef is in serial. I could envision a tool that allows us to merge separate scenario LP files into a final LP file with the additional non-anticipativity constraints (which would allow one to parallelize the model building part of runef for certain solvers), but something like this isn’t really a priority for the developers at the moment.
Gabe
P.S. We are also in the final stages of adding support for the PyPy interpreter, which would possibly allow your code to run 6 or so times faster for free.