<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def update_rho(self, k, r, s):
 """Automatic rho adjustment."""


        if self.opt['AutoRho', 'Enabled']:
            tau = self.rho_tau
            mu = self.rho_mu
            xi = self.rho_xi
            if k != 0 and np.mod(k + 1, self.opt['AutoRho', 'Period']) == 0:
                if self.opt['AutoRho', 'AutoScaling']:
                    if s == 0.0 or r == 0.0:
                        rhomlt = tau
                    else:
                        rhomlt = np.sqrt(r / (s * xi) if r > s * xi else
                                         (s * xi) / r)
                        if rhomlt > tau:
                            rhomlt = tau
                else:
                    rhomlt = tau
                rsf = 1.0
                if r > xi * mu * s:
                    rsf = rhomlt
                elif s > (mu / xi) * r:
                    rsf = 1.0 / rhomlt
                self.rho *= self.dtype.type(rsf)
                self.U /= rsf
                if rsf != 1.0:
                    self.rhochange()