def improve_admm(x0, prob, *args, **kwargs):
num_iters = kwargs.get('num_iters', 1000)
viol_lim = kwargs.get('viol_lim', 1e4)
tol = kwargs.get('tol', 1e-2)
rho = kwargs.get('rho', None)
phase1 = kwargs.get('phase1', True)
if rho is not None:
lmb0, P0Q = map(np.asmatrix, LA.eigh(prob.f0.P.todense()))
lmb_min = np.min(lmb0)
if lmb_min + prob.m*rho < 0:
logging.error("rho parameter is too small, z-update not convex.")
logging.error("Minimum possible value of rho: %.3f\n", -lmb_min/prob.m)
logging.error("Given value of rho: %.3f\n", rho)
raise Exception("rho parameter is too small, need at least %.3f." % rho)
# TODO: find a reasonable auto parameter
if rho is None:
lmb0, P0Q = map(np.asmatrix, LA.eigh(prob.f0.P.todense()))
lmb_min = np.min(lmb0)
lmb_max = np.max(lmb0)
if lmb_min < 0: rho = 2.*(1.-lmb_min)/prob.m
else: rho = 1./prob.m
rho *= 50.
logging.warning("Automatically setting rho to %.3f", rho)
if phase1:
x1 = prob.better(x0, admm_phase1(x0, prob, tol, num_iters))
else:
x1 = x0
x2 = prob.better(x1, admm_phase2(x1, prob, rho, tol, num_iters, viol_lim))
return x2
评论列表
文章目录