@@ -77,28 +77,33 @@ def PALM(H, proxf, proxg, x0, y0, gammaf=1., gammag=1.,
7777 'Proximal operator (g): %s\n '
7878 'gammaf = %10e\t gammaf = %10e\t niter = %d\n ' %
7979 (type (H ), type (proxf ), type (proxg ), gammaf , gammag , niter ))
80- head = ' Itn x[0] y[0] f g H'
80+ head = ' Itn x[0] y[0] f g H ck dk '
8181 print (head )
8282
8383 x , y = x0 .copy (), y0 .copy ()
8484 for iiter in range (niter ):
8585 ck = gammaf * H .ly (y )
8686 x = x - (1 / ck ) * H .gradx (x .ravel ())
87- x = proxf .prox (x , ck )
87+ if proxf is not None :
88+ x = proxf .prox (x , ck )
8889 H .updatex (x .copy ())
8990 dk = gammag * H .lx (x )
9091 y = y - (1 / dk ) * H .grady (y .ravel ())
91- y = proxg .prox (y , dk )
92+ if proxg is not None :
93+ y = proxg .prox (y , dk )
9294 H .updatey (y .copy ())
9395
9496 # run callback
9597 if callback is not None :
9698 callback (x , y )
9799
98100 if show :
101+ pf = proxf (x ) if proxf is not None else 0.
102+ pg = proxg (y ) if proxg is not None else 0.
99103 if iiter < 10 or niter - iiter < 10 or iiter % (niter // 10 ) == 0 :
100- msg = '%6g %5.5e %5.2e %5.2e %5.2e %5.2e' % \
101- (iiter + 1 , x [0 ], y [0 ], proxf (x ), proxg (y ), H (x , y ))
104+ msg = '%6g %5.5e %5.2e %5.2e %5.2e %5.2e %5.2e %5.2e' % \
105+ (iiter + 1 , x [0 ], y [0 ], pf if pf is not None else 0. ,
106+ pg if pg is not None else 0. , H (x , y ), ck , dk )
102107 print (msg )
103108 if show :
104109 print ('\n Total time (s) = %.2f' % (time .time () - tstart ))
0 commit comments