Skip to content

Commit

Permalink
add a little bit of doc for slicing when adding nonants (Pyomo#224)
Browse files Browse the repository at this point in the history
* add a little bit of doc for slicing when adding nonants

* using list

Co-authored-by: Bernard Knueven <[email protected]>
  • Loading branch information
DLWoodruff and bknueven authored Feb 17, 2022
1 parent 206c459 commit 6991960
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions doc/src/scenario_creator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ illustrates use of the utility function
(``mpisppy.utils.sputils.attach_root_node``) that attaches the node
list for you.

Node list entries can be entered indididually, by adding an entire
variable implicitly including all index values, and/or by using wildcards. This is
illustrated in the netdes example:

::
# Add all indexes of model.x
sputils.attach_root_node(model, model.FirstStageCost, [model.x, ])

::
# Add all index of model.x using wild cards
sputils.attach_root_node(model, model.FirstStageCost, [model.x[:,:], ])

The scenario probability should be attached by `scenario_creator` as
``_mpisppy_probability``. However, if you don't attach it, the scenarios are
assumed to be equally likely.
Expand Down
2 changes: 1 addition & 1 deletion examples/netdes/netdes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def scenario_creator(scenario_name, path=None):
model = build_scenario_model(path, scenario_ix)

# now attach the one and only scenario tree node
sputils.attach_root_node(model, model.FirstStageCost, model.x[:,:])
sputils.attach_root_node(model, model.FirstStageCost, [model.x[:,:], ])

return model

Expand Down

0 comments on commit 6991960

Please sign in to comment.