Skip to content

Commit d82f765

Browse files
Replacing the formula calculating cylinder ranks. Seems to work with several ranks per cylinder and multiple cylinders
1 parent e0eeb20 commit d82f765

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Diff for: mpisppy/utils/admm_ph.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import mpisppy.utils.sputils as sputils
33
import pyomo.environ as pyo
44
import mpisppy
5+
from mpisppy import MPI
6+
global_rank = MPI.COMM_WORLD.Get_rank()
57

68
def _consensus_vars_number_creator(consensus_vars):
79
"""associates to each consensus vars the number of time it appears
@@ -65,7 +67,8 @@ def __init__(self,
6567
scenario_names_to_rank, _rank_slices, _scenario_slices =\
6668
scenario_tree.scen_names_to_ranks(ranks_per_cylinder)
6769

68-
self.cylinder_rank = mpicomm.Get_rank() % ranks_per_cylinder
70+
self.cylinder_rank = mpicomm.Get_rank() // n_cylinders
71+
#self.cylinder_rank = mpicomm.Get_rank() % ranks_per_cylinder
6972
self.all_scenario_names = all_scenario_names
7073
#taken from spbase
7174
self.local_scenario_names = [
@@ -149,7 +152,9 @@ def assign_variable_probs(self, verbose=False):
149152

150153

151154
def admm_ph_scenario_creator(self, sname):
152-
#this is the function the user will supply for all cylinders
155+
#this is the function the user will supply for all cylinders
156+
assert sname in self.local_scenario_names, f"{global_rank=} {sname=} \n {self.local_scenario_names=}"
157+
#should probably be deleted as it takes time
153158
scenario = self.local_scenarios[sname]
154159

155160
# Grabs the objective function and multiplies its value by the number of scenarios to compensate for the probabilities

0 commit comments

Comments
 (0)