-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathfwph_spoke.py
42 lines (35 loc) · 1.55 KB
/
fwph_spoke.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
###############################################################################
# mpi-sppy: MPI-based Stochastic Programming in PYthon
#
# Copyright (c) 2024, Lawrence Livermore National Security, LLC, Alliance for
# Sustainable Energy, LLC, The Regents of the University of California, et al.
# All rights reserved. Please see the files COPYRIGHT.md and LICENSE.md for
# full copyright and license information.
###############################################################################
import mpisppy.cylinders.spoke
class FrankWolfeOuterBound(mpisppy.cylinders.spoke.OuterBoundSpoke):
converger_spoke_char = 'F'
def main(self):
self.opt.fwph_main()
def is_converged(self):
return self.got_kill_signal()
def sync(self):
# The FWPH spoke can call "sync" before it
# even starts doing anything, so its possible
# to get here without any bound information
if not hasattr(self.opt, '_local_bound'):
return
# Tell the hub about the most recent bound
self.send_bound(self.opt._local_bound)
# Update the nonant bounds, if possible
self.receive_nonant_bounds()
def finalize(self):
# The FWPH spoke can call "finalize" before it
# even starts doing anything, so its possible
# to get here without any bound information
# if we terminated early
if not hasattr(self.opt, '_local_bound'):
return
self.send_bound(self.opt._local_bound)
self.final_bound = self.opt._local_bound
return self.final_bound