| 173 | } |
| 174 | |
| 175 | tinytype predict_rho( |
| 176 | RhoAdapter* adapter, |
| 177 | tinytype pri_res, |
| 178 | tinytype dual_res, |
| 179 | tinytype pri_norm, |
| 180 | tinytype dual_norm, |
| 181 | tinytype current_rho |
| 182 | ) { |
| 183 | const tinytype eps = 1e-10; |
| 184 | |
| 185 | tinytype normalized_pri = pri_res / (pri_norm + eps); |
| 186 | tinytype normalized_dual = dual_res / (dual_norm + eps); |
| 187 | |
| 188 | tinytype ratio = normalized_pri / (normalized_dual + eps); |
| 189 | |
| 190 | tinytype new_rho = current_rho * std::sqrt(ratio); |
| 191 | |
| 192 | if (adapter->clip) { |
| 193 | new_rho = std::min(std::max(new_rho, adapter->rho_min), adapter->rho_max); |
| 194 | } |
| 195 | |
| 196 | return new_rho; |
| 197 | } |
| 198 | |
| 199 | void update_matrices_with_derivatives(TinyCache* cache, tinytype new_rho) { |
| 200 | tinytype delta_rho = new_rho - cache->rho; |
no test coverage detected