MCPcopy Create free account
hub / github.com/TinyMPC/TinyMPC / predict_rho

Function predict_rho

src/tinympc/rho_benchmark.cpp:175–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173}
174
175tinytype 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
199void update_matrices_with_derivatives(TinyCache* cache, tinytype new_rho) {
200 tinytype delta_rho = new_rho - cache->rho;

Callers 1

benchmark_rho_adaptationFunction · 0.85

Calls 1

sqrtFunction · 0.50

Tested by

no test coverage detected