Skip to content

Commit 34d9cb3

Browse files
authored
Merge pull request #574 from bknueven/fix-572
apply denom max to independent denom
2 parents 64f61f2 + 5409b65 commit 34d9cb3

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

examples/run_all.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ def do_one_mmw(dirname, modname, runefstring, npyfile, mmwargstring):
198198
"--rel-gap 0.001 --max-iterations=50 "
199199
"--grad-rho --grad-order-stat 0.5 "
200200
"--default-rho=2 --solver-name={} --lagrangian --xhatshuffle".format(solver_name))
201+
do_one("farmer", "../../mpisppy/generic_cylinders.py", 3,
202+
"--module-name farmer --num-scens 6 "
203+
"--rel-gap 0.001 --max-iterations=50 "
204+
"--grad-rho --indep-denom "
205+
"--default-rho=2 --solver-name={} --lagrangian --xhatshuffle".format(solver_name))
201206
do_one("farmer", "../../mpisppy/generic_cylinders.py", 4,
202207
"--module-name farmer --num-scens 6 "
203208
"--rel-gap 0.001 --max-iterations=50 "

mpisppy/extensions/grad_rho.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,16 @@ def _scen_indep_denom(self):
115115
op=MPI.SUM,
116116
)
117117

118+
# max over *all* nodes
119+
denom_max = max(max(denom) for denom in global_denoms.values())
118120
scen_indep_denom = {}
119121
for ndn, global_denom in global_denoms.items():
120-
for i, v in enumerate(global_denom):
121-
scen_indep_denom[ndn, i] = v
122+
for i, denom in enumerate(global_denom):
123+
# xbar is for rescaling, e.g., if the variable value is "naturally" small
124+
if denom <= self.denom_bound * xbars[ndn, i]._value:
125+
scen_indep_denom[ndn, i] = max(denom_max, self.denom_bound * xbars[ndn, i]._value)
126+
else:
127+
scen_indep_denom[ndn, i] = denom
122128

123129
return scen_indep_denom
124130

mpisppy/utils/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,9 +984,9 @@ def gradient_args(self):
984984
default=False)
985985

986986
self.add_to_config("grad_order_stat",
987-
description="order statistic for rho: must be between 0 (the min) and 1 (the max); 0.5 is the average",
987+
description="order statistic for rho: must be between 0 (the min) and 1 (the max); 0.5 is the average (default 0.5)",
988988
domain=float,
989-
default=-1.0)
989+
default=0.5)
990990

991991
self.add_to_config("grad_rho_relative_bound",
992992
description="factor that bounds rho/cost",

0 commit comments

Comments
 (0)