-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example for concrete multi-stage model #121
Comments
I was looking at the example from the |
The hydro example in mpi-sppy is multi-stage. Let me know if that helps.
Dave
…On Fri, May 21, 2021 at 2:31 AM ibayer-ny ***@***.***> wrote:
Thanks for this great library!
I'm interested in modeling multi-stage problems as ConcreteModels so that
I have full flexibility to modify
them in python.
Thanks to the examples I have been able to adjust newsvendor and farmer to
my needs. However this are
only two-stage problems and I'm now stuck trying to convert the financial
planning example to a direct model.
I have studied the docs but not everything is clear yet, an example for a
concrete multi-stage model would help me a lot. Is there such a model in
the examples that I overlooked or can someone share such an example?
Thanks
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#121>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD4VTBH7NJSTOPWB7YPNPM3TOYSALANCNFSM45IZCC6Q>
.
|
I finally had time to dig deeper. Yes, the hydro example is very helpful, thanks for the hint. |
@DLWoodruff I'm a bit stuck at the moment. It would be great if you could give me an hint. :-) Current Understanding: Scenario based EF optimization with mpi-sppyThe following illustrates on a abstract level my current understanding how stochastic programming problems can be solved with mpi-sppy. As a first step I only focus on the extended form (EF) representation that can be solved for simple and small problem with a standard pyomo solver.
From a modeling and testing perspective it is very convenient to start with a single scenario setting. Without uncertainty we can solve and reason about a standard pyomo optimization problem of the following form: def build_model(scenario):
"""scenario: Contains the realization of the random variables that we
observe in this scenario."""
model = pyo.ConcreteModel()
# model specifc code goes here
return model
model = build_model(scenario)
solve(model) However, we are interested in a solution that is optimal in expectation across all scenarios.
We now need to define the def scenario_creator(scenario_name, scenarios):
model = build_model(scenarios[scenario_name])
model._mpisppy_node_list = create_scenario_nodes(scenario_name, instance)
return model For readability and to simplify testing we can create a helper function to create the node list. def create_scenario_nodes(name, instance):
return [ScenarioNode(name='ROOT', ...), ScenarioNode(name='ROOT_0', ..., parent_name='ROOT'), ...] Missing piecesIt seems that a very specific naming convention is required for the scenario and node names that I can't deduce from the sppy examples. I found the following naming scheme in the pysp examples
but I don't think this would be valid for I found the following in the
It would be really helpful to have a valid naming scheme example (scenario names and node names) for the financial planning problem (the diagram on top of this comment represents its scenario tree). |
@bknueven Could you point me to the relevant library source files that could help me to understand the current naming conventions? I'll happy to provide a summary of my findings as reference for other users. |
I'm sorry I didn't respond earlier, for some reason I don't seem to get a notification of these issues. |
Thanks for the head up regarding the upcoming release. I'll make sure to update asap.
IMO adapting to the new naming convention is a cheap price to pay for better multi-stage support. :)
@DLWoodruff |
@ibayer-ny Thank you for opening this issue. I found it very helpful. Are you willing to share the multi-stage example with concrete models you were working on? @DLWoodruff @bknueven Have there been any updates to mpi-sppy about multi-stage problems during the last 12 months? |
One big change is mpi-sppy can now read a PySP-style model directly, including multistage. An example is here: https://github.com/Pyomo/mpi-sppy/blob/0.10/examples/hydro/hydro_cylinders_pysp.py. A more minor change is we enabled the FWPH-spoke to work with multi-stage models. The release notes for 0.10 aren't a bad resource for this: https://github.com/Pyomo/mpi-sppy/releases/tag/0.10 |
@ibayer-ny Thank you for the nice summary for newcommers like me, would you mind sharing the financial investment example you worked on? I am currently trying to transform such setting into a battery dispatch optimization problem, but i am not sure it is doable. @jialuw96 were you able to work out the multi-stage example? |
@jialuw96 @ibayer-ny is any multistage example with a general description that we can easily reproduce? |
Thanks for this great library!
I'm interested in modeling multi-stage problems as
ConcreteModels
so that I have full flexibility to modifythem in python.
Thanks to the examples I have been able to adjust
newsvendor
andfarmer
to my needs. However this areonly two-stage problems and I'm now stuck trying to convert the
financial planning
example to a direct model.I have studied the docs but not everything is clear yet, an example for a concrete multi-stage model would help me a lot. Is there such a model in the examples that I overlooked or can someone share such an example?
Thanks
The text was updated successfully, but these errors were encountered: