No, pyomo callbacks only apply to the ‘pyomo’ command-line executable. PySP takes a slightly different approach.
If you want to inject code into the PH algorithm you can do so by implementing an extension plugin. The way this works is you copy the file “<install_dir>/pyomo/pyomo/pysp/plugins/examplephextension.py” to the location/name of your choice. Inside this file you will find two classes (which you can rename as well) with methods having names like ‘post_iteration_k_solve’ and descriptors of when they get called during the PH algorithm. You can fill in these methods with whatever you want (you can even break the algorithm if you try hard enough).
The second class is for when you use the phpyro solver manager. I’ll skip explaining just in case you already know about it, and just say that it is a more-parallelized version of the pyro solver manager (instead of pyro_mip_server, you launch one or more phsolverservers). With phpyro, the scenario instances are not constructed on the master process, and so only the minimum amount of solution info is sent back to the master to do the PH parameter updates. If you plan on using phpyro, then you will have to go extract duals on the solver servers because that information won’t make it back to the master. Note that the standard pyro solver manager builds all instances on the master process and just spawns threads to do the solves.
I’m out of time for now, but see where you can get with this and shoot back any questions you have. There’s plenty of example code in the plugins directory to help figure out how to navigate around the ph objects as well.
Gabe
P.S. Here is an example command-line that uses the two extension classes with phpyro as the solver manager (extension classes are in junk.py)
mpirun -np 1 pyomo_ns -k -r -n localhost :
-np 1 dispatch_srvr localhost :
-np 3 phsolverserver localhost --user-defined-extension=junk.py :
-np 1 runph -m model.py -i ScenarioStructure.dat -r 1.0 --user-defined-extension=junk.py --solver-manager=phpyro --phpyro-required-workers=3 --pyro-hostname=localhost