Skip to content

Commit a7fb45c

Browse files
committed
dense: simplify and remove useless signature
1 parent 2a4b492 commit a7fb45c

File tree

1 file changed

+22
-123
lines changed

1 file changed

+22
-123
lines changed

include/proxsuite/proxqp/dense/wrapper.hpp

Lines changed: 22 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -260,11 +260,11 @@ struct QP
260260
* @param mu_eq proximal step size wrt equality constrained multiplier.
261261
* @param mu_in proximal step size wrt inequality constrained multiplier.
262262
*/
263-
void update(const optional<MatRef<T>> H,
263+
void update(optional<MatRef<T>> H,
264264
optional<VecRef<T>> g,
265-
const optional<MatRef<T>> A,
265+
optional<MatRef<T>> A,
266266
optional<VecRef<T>> b,
267-
const optional<MatRef<T>> C,
267+
optional<MatRef<T>> C,
268268
optional<VecRef<T>> l,
269269
optional<VecRef<T>> u,
270270
bool update_preconditioner = true,
@@ -293,130 +293,29 @@ struct QP
293293
}
294294
proxsuite::proxqp::dense::update_proximal_parameters(
295295
settings, results, work, rho, mu_eq, mu_in);
296-
proxsuite::proxqp::dense::setup(
297-
optional<MatRef<T>>(dense::MatRef<T>(model.H)),
298-
optional<VecRef<T>>(dense::VecRef<T>(model.g)),
299-
optional<MatRef<T>>(dense::MatRef<T>(model.A)),
300-
optional<VecRef<T>>(dense::VecRef<T>(model.b)),
301-
optional<MatRef<T>>(dense::MatRef<T>(model.C)),
302-
optional<VecRef<T>>(dense::VecRef<T>(model.l)),
303-
optional<VecRef<T>>(dense::VecRef<T>(model.u)),
304-
settings,
305-
model,
306-
work,
307-
results,
308-
ruiz,
309-
preconditioner_status);
310-
if (settings.compute_timings) {
311-
results.info.setup_time = work.timer.elapsed().user; // in microseconds
312-
}
313-
};
314-
/*!
315-
* Updates the QP model vectors only (to avoid ambiguity through overloading)
316-
* and equilibrates it if specified by the user.
317-
* @param H quadratic cost input defingit reset --soft HEAD~ing the QP model.
318-
* @param g linear cost input defining the QP model.
319-
* @param A equality constraint matrix input defining the QP model.
320-
* @param b equality constraint vector input defining the QP model.
321-
* @param C inequality constraint matrix input defining the QP model.
322-
* @param l lower inequality constraint vector input defining the QP model.
323-
* @param u upper inequality constraint vector input defining the QP model.
324-
* @param update_preconditioner bool parameter for executing or not the
325-
* preconditioner.
326-
* @param rho proximal step size wrt primal variable.
327-
* @param mu_eq proximal step size wrt equality constrained multiplier.
328-
* @param mu_in proximal step size wrt inequality constrained multiplier.
329-
*/
330-
void update(PROXSUITE_MAYBE_UNUSED const nullopt_t H,
331-
optional<VecRef<T>> g,
332-
PROXSUITE_MAYBE_UNUSED const nullopt_t A,
333-
optional<VecRef<T>> b,
334-
PROXSUITE_MAYBE_UNUSED const nullopt_t C,
335-
optional<VecRef<T>> l,
336-
optional<VecRef<T>> u,
337-
bool update_preconditioner = true,
338-
optional<T> rho = nullopt,
339-
optional<T> mu_eq = nullopt,
340-
optional<T> mu_in = nullopt)
341-
{
342-
work.refactorize = false;
343-
work.proximal_parameter_update = false;
344-
// treat the case when H, A and C are nullopt, in order to avoid ambiguity
345-
// through overloading
346-
if (settings.compute_timings) {
347-
work.timer.stop();
348-
work.timer.start();
349-
}
350-
PreconditionerStatus preconditioner_status;
351-
if (update_preconditioner) {
352-
preconditioner_status = proxsuite::proxqp::PreconditionerStatus::EXECUTE;
353-
} else {
354-
preconditioner_status = proxsuite::proxqp::PreconditionerStatus::KEEP;
355-
}
356-
bool real_update =
357-
!(g == nullopt && b == nullopt && u == nullopt && l == nullopt);
358-
if (real_update) {
359-
// check the model is valid
360-
if (g != nullopt) {
361-
PROXSUITE_CHECK_ARGUMENT_SIZE(g.value().rows(),
362-
model.dim,
363-
"the dimension wrt primal variable x "
364-
"variable for updating g is not valid.");
365-
}
366-
if (b != nullopt) {
367-
PROXSUITE_CHECK_ARGUMENT_SIZE(b.value().rows(),
368-
model.n_eq,
369-
"the dimension wrt equality constrained "
370-
"variables for updating b is not valid.");
371-
}
372-
if (u != nullopt) {
373-
PROXSUITE_CHECK_ARGUMENT_SIZE(
374-
u.value().rows(),
375-
model.n_in,
376-
"the dimension wrt inequality constrained variables for updating u "
377-
"is not valid.");
378-
}
379-
if (l != nullopt) {
380-
PROXSUITE_CHECK_ARGUMENT_SIZE(
381-
l.value().rows(),
382-
model.n_in,
383-
"the dimension wrt inequality constrained variables for updating l "
384-
"is not valid.");
385-
}
386-
// update the model
387-
if (g != nullopt) {
388-
model.g = g.value().eval();
389-
}
390-
if (b != nullopt) {
391-
model.b = b.value().eval();
392-
}
393-
if (u != nullopt) {
394-
model.u = u.value().eval();
395-
}
396-
if (l != nullopt) {
397-
model.l = l.value().eval();
398-
}
399-
}
400-
proxsuite::proxqp::dense::update_proximal_parameters(
401-
settings, results, work, rho, mu_eq, mu_in);
402-
proxsuite::proxqp::dense::setup(
403-
optional<MatRef<T>>(dense::MatRef<T>(model.H)),
404-
optional<VecRef<T>>(dense::VecRef<T>(model.g)),
405-
optional<MatRef<T>>(dense::MatRef<T>(model.A)),
406-
optional<VecRef<T>>(dense::VecRef<T>(model.b)),
407-
optional<MatRef<T>>(dense::MatRef<T>(model.C)),
408-
optional<VecRef<T>>(dense::VecRef<T>(model.l)),
409-
optional<VecRef<T>>(dense::VecRef<T>(model.u)),
410-
settings,
411-
model,
412-
work,
413-
results,
414-
ruiz,
415-
preconditioner_status);
296+
297+
typedef optional<MatRef<T>> optional_MatRef;
298+
typedef optional<VecRef<T>> optional_VecRef;
299+
proxsuite::proxqp::dense::setup(/* avoid double assignation */
300+
optional_MatRef(nullopt),
301+
optional_VecRef(nullopt),
302+
optional_MatRef(nullopt),
303+
optional_VecRef(nullopt),
304+
optional_MatRef(nullopt),
305+
optional_VecRef(nullopt),
306+
optional_VecRef(nullopt),
307+
settings,
308+
model,
309+
work,
310+
results,
311+
ruiz,
312+
preconditioner_status);
313+
416314
if (settings.compute_timings) {
417315
results.info.setup_time = work.timer.elapsed().user; // in microseconds
418316
}
419317
};
318+
420319
/*!
421320
* Solves the QP problem using PRXOQP algorithm.
422321
*/

0 commit comments

Comments
 (0)