added a call to an initialize function to generic_cylinders per a sug…#498
added a call to an initialize function to generic_cylinders per a sug…#498DLWoodruff merged 19 commits intoPyomo:mainfrom
Conversation
bknueven
left a comment
There was a problem hiding this comment.
I'm a little confused by this. If a user wanted to use a class instead of a module, couldn't we enable that fairly easily? E.g.,
class MyClassForMpiSppy:
def __init__(self, cfg):
# anything sensible
pass
def scenario_creator(self, scenario_name, **kwargs):
## build the scenario
return scenario
# Maybe here, maybe somewhere else. Could have a different name.
# If we see this name in the module, we construct this class instead and
# use it in place of `module` in generic_cylinders.py.
mpisppy_class = MyClassForMpiSppy
# Or, we could require the user to provide a function which returns an
# instance of this class
def get_mpisppy_data(cfg):
return MyClassForMpiSppy(cfg)|
I like your second idea best. I would change the function name to be |
…le'; TBD: no test yet
Co-authored-by: Tomás Valencia <113071884+tvalenciaz@users.noreply.github.com>
|
This still needs a test/example. |
doc/src/generic_cylinders.rst
Outdated
| Note this verification is automatically performed by WheelSpinner if you call your custom writer functions through | ||
| ``wheel.write_first_stage_solution(solution_file_name, first_stage_solution_writer=my_first_stage_writer)`` and ``wheel.write_tree_solution(solution_dir_name, scenario_tree_solution_writer=my_tree_solution_writer)``. |
There was a problem hiding this comment.
Should we just be handling this for the user, e.g., pass the function they provide into write_first_stage_solution or write_tree_solution? These methods also determine which cylinder has the optimal solution to write, so it's a bit more subtle than checking the cylinder rank. Plus, if you need the tree solution, you have to write from every rank.
There was a problem hiding this comment.
Agreed, that is probably safer and does not really restrict what the user can do; they can just put it inside the corresponding custom writer.
…into initialize
…into initialize
…gestion by Tomas. Also added callouts to a custom writer.