Skip to content

Commit

Permalink
Remove remnants of parameter scen_name_list of ScenarioNode.__init__ (P…
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew-Signorotti authored Mar 22, 2022
1 parent 6991960 commit 0cd3a1a
Show file tree
Hide file tree
Showing 19 changed files with 5 additions and 41 deletions.
1 change: 0 additions & 1 deletion examples/acopf3/ccopf_multistage.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,6 @@ def aggregate_ramping_rule(m):
cond_prob=enode.CondProb,
stage=stage,
cost_expression=inst.stage_models[stage].obj,
scen_name_list=enode.ScenarioList,
nonant_list=[inst.stage_models[stage].pg,
inst.stage_models[stage].qg],
scen_model=inst, parent_name=parent_name))
Expand Down
2 changes: 1 addition & 1 deletion examples/battery/battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def big_M_constraint_rule(model, t):

model._mpisppy_node_list = [
stree.ScenarioNode(name='ROOT', cond_prob=1., stage=1,
cost_expression=model.first_stage_cost, scen_name_list=None,
cost_expression=model.first_stage_cost,
nonant_list=[model.y], scen_model=model)
]

Expand Down
1 change: 0 additions & 1 deletion examples/farmer/afarmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def scenario_creator(
cond_prob=1.0,
stage=1,
cost_expression=model.FirstStageCost,
scen_name_list=None, # Deprecated?
nonant_list=[model.DevotedAcreage],
scen_model=model,
)
Expand Down
1 change: 0 additions & 1 deletion examples/farmer/farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def scenario_creator(
cond_prob=1.0,
stage=1,
cost_expression=model.FirstStageCost,
scen_name_list=None, # Deprecated?
nonant_list=[model.DevotedAcreage],
scen_model=model,
)
Expand Down
4 changes: 0 additions & 4 deletions examples/hydro/hydro.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def MakeAllScenarioTreeNodes(model, bf):
1.0,
1,
model.StageCost[1],
None,
[model.Pgt[1],
model.Pgh[1],
model.PDns[1],
Expand All @@ -169,7 +168,6 @@ def MakeAllScenarioTreeNodes(model, bf):
1.0/bf,
2,
model.StageCost[2],
None,
[model.Pgt[2],
model.Pgh[2],
model.PDns[2],
Expand All @@ -191,7 +189,6 @@ def MakeNodesforScen(model, BFs, scennum):
1.0,
1,
model.StageCost[1],
None,
[model.Pgt[1],
model.Pgh[1],
model.PDns[1],
Expand All @@ -201,7 +198,6 @@ def MakeNodesforScen(model, BFs, scennum):
1.0/BFs[0],
2,
model.StageCost[2],
None,
[model.Pgt[2],
model.Pgh[2],
model.PDns[2],
Expand Down
2 changes: 1 addition & 1 deletion examples/sslp/sslp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def scenario_creator(scenario_name, data_dir=None):
# now attach the one and only tree node (ROOT is a reserved word)
model._mpisppy_node_list = [
scenario_tree.ScenarioNode(
"ROOT", 1.0, 1, model.FirstStageCost, None, [model.FacilityOpen], model
"ROOT", 1.0, 1, model.FirstStageCost, [model.FacilityOpen], model
)
]
return model
Expand Down
1 change: 0 additions & 1 deletion examples/uc/uc_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def pysp2_callback(scenario_name, scenario_count=None, path=None,
1.0,
1,
instance.StageCost["Stage_1"], #"Stage_1" hardcodes the commitments in all time periods
None,
[instance.UnitOn],
instance,
[instance.UnitStart, instance.UnitStop, instance.StartupIndicator],
Expand Down
13 changes: 1 addition & 12 deletions mpisppy/scenario_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class ScenarioNode:
cond_prob (float): conditional probability
stage (int): stage number (root is 1)
cost_expression (pyo Expression or Var): stage cost
scen_name_list (str): OPTIONAL scenario names at the node
just for debugging and reporting; not really used as of Dec 31
nonant_list (list of pyo Var, Vardata or slices): the Vars that
require nonanticipativity at the node (might not be a list)
scen_model (pyo concrete model): the (probably not 'a') concrete model
Expand All @@ -67,7 +65,7 @@ class ScenarioNode:
nonant_vardata(list of vardata objects): vardatas to blend
x_bar_list(list of floats): bound by index to nonant_vardata
"""
def __init__(self, name, cond_prob, stage, cost_expression, scen_name_list,
def __init__(self, name, cond_prob, stage, cost_expression,
nonant_list, scen_model, nonant_ef_suppl_list=None,
parent_name=None):
"""Initialize a ScenarioNode object. Assume most error detection is
Expand Down Expand Up @@ -96,12 +94,3 @@ def __init__(self, name, cond_prob, stage, cost_expression, scen_name_list,
self.nonant_ef_suppl_list)
else:
self.nonant_ef_suppl_vardata_list = []
@property
def scen_name_list(self):
""" DLW Jan 2019: I am thinking we will not have the nodes know this.
The scenarios will know what nodes they are in, and that might be enough.
This is a big changes from PySP 1.0; 2.0 relies on reduction to get x-bar
"""
raise RuntimeError ("The scen name list for a node is not maintained.")


1 change: 0 additions & 1 deletion mpisppy/tests/examples/afarmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def scenario_creator(
cond_prob=1.0,
stage=1,
cost_expression=model.FirstStageCost,
scen_name_list=None, # Deprecated?
nonant_list=[model.DevotedAcreage],
scen_model=model,
)
Expand Down
3 changes: 0 additions & 3 deletions mpisppy/tests/examples/aircond.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ def MakeNodesforScen(model,nodenames,branching_factors,starting_stage=1):
cond_prob=1.0,
stage=stage,
cost_expression=model.stage_models[stage].StageObjective,
scen_name_list=None, # Not maintained
nonant_list=nonant_list,
scen_model=model,
nonant_ef_suppl_list = nonant_ef_suppl_list
Expand All @@ -277,7 +276,6 @@ def MakeNodesforScen(model,nodenames,branching_factors,starting_stage=1):
cond_prob=1.0,
stage=stage,
cost_expression=model.stage_models[stage].StageObjective,
scen_name_list=None, # Not maintained
nonant_list=nonant_list,
scen_model=model,
nonant_ef_suppl_list = nonant_ef_suppl_list,
Expand All @@ -291,7 +289,6 @@ def MakeNodesforScen(model,nodenames,branching_factors,starting_stage=1):
cond_prob=1.0/branching_factors[stage-starting_stage-1],
stage=stage,
cost_expression=model.stage_models[stage].StageObjective,
scen_name_list=None, # Not maintained
nonant_list=nonant_list,
scen_model=model,
nonant_ef_suppl_list = nonant_ef_suppl_list,
Expand Down
3 changes: 1 addition & 2 deletions mpisppy/tests/examples/apl1p.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ def scenario_creator(sname, num_scens=None):
cond_prob=1.0,
stage=1,
cost_expression=model.Total_Cost_Objective,
scen_name_list=None, # Deprecated?
nonant_list=[model.CapacityGenerators],
scen_model=model,
)
Expand Down Expand Up @@ -254,4 +253,4 @@ def xhat_generator_apl1p(scenario_names, solvername="gurobi", solver_options=Non
stochastic_sampling=False)

res = apl1p_pb.run()
print(res)
print(res)
3 changes: 0 additions & 3 deletions mpisppy/tests/examples/delme_aircond_submodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ def MakeNodesforScen(model,nodenames,branching_factors,starting_stage=1):
cond_prob=1.0,
stage=stage,
cost_expression=model.stage_models[stage].StageObjective,
scen_name_list=None, # Not maintained
nonant_list=nonant_list,
scen_model=model,
nonant_ef_suppl_list = [model.stage_models[stage].Inventory],
Expand All @@ -211,7 +210,6 @@ def MakeNodesforScen(model,nodenames,branching_factors,starting_stage=1):
cond_prob=1.0,
stage=stage,
cost_expression=model.stage_models[stage].StageObjective,
scen_name_list=None, # Not maintained
nonant_list=nonant_list,
scen_model=model,
nonant_ef_suppl_list = [model.stage_models[stage].Inventory],
Expand All @@ -225,7 +223,6 @@ def MakeNodesforScen(model,nodenames,branching_factors,starting_stage=1):
cond_prob=1.0/branching_factors[stage-starting_stage-1],
stage=stage,
cost_expression=model.stage_models[stage].StageObjective,
scen_name_list=None, # Not maintained
nonant_list=nonant_list,
scen_model=model,
nonant_ef_suppl_list = [model.stage_models[stage].Inventory],
Expand Down
1 change: 0 additions & 1 deletion mpisppy/tests/examples/farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def scenario_creator(
cond_prob=1.0,
stage=1,
cost_expression=model.FirstStageCost,
scen_name_list=None, # Deprecated?
nonant_list=[model.DevotedAcreage],
scen_model=model,
)
Expand Down
1 change: 0 additions & 1 deletion mpisppy/tests/examples/gbd/gbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ def scenario_creator(sname, num_scens=None):
cond_prob=1.0,
stage=1,
cost_expression=model.obj,
scen_name_list=None, # Deprecated?
nonant_list=[model.x],
scen_model=model,
)
Expand Down
4 changes: 0 additions & 4 deletions mpisppy/tests/examples/hydro/hydro.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def MakeAllScenarioTreeNodes(model, bf):
1.0,
1,
model.StageCost[1],
None,
[model.Pgt[1],
model.Pgh[1],
model.PDns[1],
Expand All @@ -169,7 +168,6 @@ def MakeAllScenarioTreeNodes(model, bf):
1.0/bf,
2,
model.StageCost[2],
None,
[model.Pgt[2],
model.Pgh[2],
model.PDns[2],
Expand All @@ -191,7 +189,6 @@ def MakeNodesforScen(model, BFs, scennum):
1.0,
1,
model.StageCost[1],
None,
[model.Pgt[1],
model.Pgh[1],
model.PDns[1],
Expand All @@ -201,7 +198,6 @@ def MakeNodesforScen(model, BFs, scennum):
1.0/BFs[0],
2,
model.StageCost[2],
None,
[model.Pgt[2],
model.Pgh[2],
model.PDns[2],
Expand Down
1 change: 0 additions & 1 deletion mpisppy/tests/examples/uc/uc_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def pysp2_callback(scenario_name):
1.0,
1,
instance.StageCost["Stage_1"], #"Stage_1" hardcodes the commitments in all time periods
None,
[instance.UnitOn],
instance,
[instance.UnitStart, instance.UnitStop, instance.StartupIndicator],
Expand Down
1 change: 0 additions & 1 deletion mpisppy/utils/pysp_model/pysp_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ def scenario_creator_callback(self, scenario_name, **kwargs):
cond_prob=node.conditional_probability,
stage=node._mpisppy_stage,
cost_expression=node._mpisppy_cost_expression,
scen_name_list=None,
nonant_list=node._mpisppy_nonant_list,
scen_model=None,
nonant_ef_suppl_list=node._mpisppy_nonant_ef_suppl_list,
Expand Down
2 changes: 1 addition & 1 deletion mpisppy/utils/sputils.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ def attach_root_node(model, firstobj, varlist, nonant_ef_suppl_list=None):
attaches a list consisting of one scenario node to the model
"""
model._mpisppy_node_list = [
scenario_tree.ScenarioNode("ROOT",1.0,1,firstobj, None, varlist, model,
scenario_tree.ScenarioNode("ROOT", 1.0, 1, firstobj, varlist, model,
nonant_ef_suppl_list = nonant_ef_suppl_list)
]

Expand Down
1 change: 0 additions & 1 deletion paperruns/larger_uc/uc_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def pysp2_callback(scenario_name, path=None, scenario_count=None):
1.0,
1,
instance.StageCost["Stage_1"], #"Stage_1" hardcodes the commitments in all time periods
None,
[instance.UnitOn],
instance,
[instance.UnitStart, instance.UnitStop, instance.StartupIndicator],
Expand Down

0 comments on commit 0cd3a1a

Please sign in to comment.