Pyomo / mpi-sppy

MPI-based Stochastic Programming in PYthon
https://mpi-sppy.readthedocs.io
Other
65 stars 38 forks source link

XhatShuffleInnerBound keeps retrying the same solution #357

Closed pdb5627 closed 8 months ago

pdb5627 commented 8 months ago

It seems like XhatShuffleInnerBound keeps retrying the same solution again and again until a new set of solutions is provided by the hub. If I'm right, I think the culprit might be that the nonanticipatory variables are not reset after trying the solution, so when the "next" solution is loaded, it just reloads the variable values that were just set and are still in the scenario.

https://github.com/Pyomo/mpi-sppy/blob/34bd37cbc5a84997c4baf3cc2806d89a521c71fe/mpisppy/cylinders/xhatshufflelooper_bounder.py#L69-L74

I think that changing restore_nonants from False to True in the call to _try_one will fix this.

A second observation, which maybe should be a separate issue, is that it seems like, if the hub takes long enough before giving a new solution, XhatShuffleInnerBound keeps looping over the same scenarios, even once it has already tried them all. I realize that maybe others don't consider this a problem if the assumption is that the number of scenarios is large compared to the solve time of the hub. I don't really understand what XhatShuffleInnerBound is doing with begin_epoch, _iter_scen, and the nodescen_dict, but it seems like the object is keeping track of tried scenarios in _scenarios_this_epoch such that it could avoid retrying scenarios that had already been tried. I have an idea of how this might be done, and I'd be glad to submit a PR.

DLWoodruff commented 8 months ago

Working on it... we'll have a fix in a day or two, I hope.

DLWoodruff commented 8 months ago

Thanks for reporting this! I submitted a PR with the fix you suggested, which does the trick. I haven't looked at the second part. If you would like to do a PR for that it would be great. If you need something right away that will avoid duplicates, the looper bounder takes the number of scenarios to try as an argument.