@@ -96,18 +96,17 @@ struct QP
9696 preconditioner::RuizEquilibration<T, I> ruiz;
9797 /* !
9898 * Default constructor using the dimension of the matrices in entry.
99- * @param _dim primal variable dimension.
100- * @param _n_eq number of equality constraints.
101- * @param _n_in number of inequality constraints.
99+ * @param dim primal variable dimension.
100+ * @param n_eq number of equality constraints.
101+ * @param n_in number of inequality constraints.
102102 */
103- QP (isize _dim , isize _n_eq , isize _n_in )
104- : results(_dim, _n_eq, _n_in )
103+ QP (isize dim , isize n_eq , isize n_in )
104+ : results(dim, n_eq, n_in )
105105 , settings()
106- , model(_dim, _n_eq, _n_in )
106+ , model(dim, n_eq, n_in )
107107 , work()
108- , ruiz(_dim, _n_eq + _n_in , 1e-3 , 10 , preconditioner::Symmetry::UPPER)
108+ , ruiz(dim, n_eq + n_in , 1e-3 , 10 , preconditioner::Symmetry::UPPER)
109109 {
110-
111110 work.timer .stop ();
112111 work.internal .do_symbolic_fact = true ;
113112 }
@@ -328,27 +327,27 @@ struct QP
328327 * specified by the user. If matrices in entry are not null, the update is
329328 * effective only if the sparsity structure of entry is the same as the one
330329 * used for the initialization.
331- * @param H_ quadratic cost input defining the QP model.
332- * @param g_ linear cost input defining the QP model.
333- * @param A_ equality constraint matrix input defining the QP model.
334- * @param b_ equality constraint vector input defining the QP model.
335- * @param C_ inequality constraint matrix input defining the QP model.
336- * @param l_ lower inequality constraint vector input defining the QP model.
337- * @param u_ lower inequality constraint vector input defining the QP model.
338- * @param update_preconditioner_ bool parameter for updating or not the
330+ * @param H quadratic cost input defining the QP model.
331+ * @param g linear cost input defining the QP model.
332+ * @param A equality constraint matrix input defining the QP model.
333+ * @param b equality constraint vector input defining the QP model.
334+ * @param C inequality constraint matrix input defining the QP model.
335+ * @param l lower inequality constraint vector input defining the QP model.
336+ * @param u lower inequality constraint vector input defining the QP model.
337+ * @param update_preconditioner bool parameter for updating or not the
339338 * preconditioner and the associated scaled model.
340339 * @param rho proximal step size wrt primal variable.
341340 * @param mu_eq proximal step size wrt equality constrained multiplier.
342341 * @param mu_in proximal step size wrt inequality constrained multiplier.
343342 */
344- void update (const std::optional<SparseMat<T, I>> H_ ,
345- std::optional<VecRef<T>> g_ ,
346- const std::optional<SparseMat<T, I>> A_ ,
347- std::optional<VecRef<T>> b_ ,
348- const std::optional<SparseMat<T, I>> C_ ,
349- std::optional<VecRef<T>> l_ ,
350- std::optional<VecRef<T>> u_ ,
351- bool update_preconditioner_ = true ,
343+ void update (const std::optional<SparseMat<T, I>> H ,
344+ std::optional<VecRef<T>> g ,
345+ const std::optional<SparseMat<T, I>> A ,
346+ std::optional<VecRef<T>> b ,
347+ const std::optional<SparseMat<T, I>> C ,
348+ std::optional<VecRef<T>> l ,
349+ std::optional<VecRef<T>> u ,
350+ bool update_preconditioner = true ,
352351 std::optional<T> rho = std::nullopt ,
353352 std::optional<T> mu_eq = std::nullopt ,
354353 std::optional<T> mu_in = std::nullopt )
@@ -360,7 +359,7 @@ struct QP
360359 work.internal .dirty = false ;
361360 work.internal .proximal_parameter_update = false ;
362361 PreconditionerStatus preconditioner_status;
363- if (update_preconditioner_ ) {
362+ if (update_preconditioner ) {
364363 preconditioner_status = proxsuite::proxqp::PreconditionerStatus::EXECUTE;
365364 } else {
366365 preconditioner_status = proxsuite::proxqp::PreconditionerStatus::KEEP;
@@ -384,90 +383,90 @@ struct QP
384383 detail::middle_cols_mut (kkt_top_n_rows, n + n_eq, n_in, model.C_nnz );
385384
386385 // check the model is valid
387- if (g_ != std::nullopt ) {
388- PROXSUITE_CHECK_ARGUMENT_SIZE (g_ .value ().rows (),
386+ if (g != std::nullopt ) {
387+ PROXSUITE_CHECK_ARGUMENT_SIZE (g .value ().rows (),
389388 model.dim ,
390389 " the dimension wrt the primal variable x "
391390 " variable for updating g is not valid." );
392391 }
393- if (b_ != std::nullopt ) {
394- PROXSUITE_CHECK_ARGUMENT_SIZE (b_ .value ().rows (),
392+ if (b != std::nullopt ) {
393+ PROXSUITE_CHECK_ARGUMENT_SIZE (b .value ().rows (),
395394 model.n_eq ,
396395 " the dimension wrt equality constrained "
397396 " variables for updating b is not valid." );
398397 }
399- if (u_ != std::nullopt ) {
400- PROXSUITE_CHECK_ARGUMENT_SIZE (u_ .value ().rows (),
398+ if (u != std::nullopt ) {
399+ PROXSUITE_CHECK_ARGUMENT_SIZE (u .value ().rows (),
401400 model.n_in ,
402401 " the dimension wrt inequality constrained "
403402 " variables for updating u is not valid." );
404403 }
405- if (l_ != std::nullopt ) {
406- PROXSUITE_CHECK_ARGUMENT_SIZE (l_ .value ().rows (),
404+ if (l != std::nullopt ) {
405+ PROXSUITE_CHECK_ARGUMENT_SIZE (l .value ().rows (),
407406 model.n_in ,
408407 " the dimension wrt inequality constrained "
409408 " variables for updating l is not valid." );
410409 }
411- if (H_ != std::nullopt ) {
410+ if (H != std::nullopt ) {
412411 PROXSUITE_CHECK_ARGUMENT_SIZE (
413- H_ .value ().rows (),
412+ H .value ().rows (),
414413 model.dim ,
415414 " the row dimension for updating H is not valid." );
416415 PROXSUITE_CHECK_ARGUMENT_SIZE (
417- H_ .value ().cols (),
416+ H .value ().cols (),
418417 model.dim ,
419418 " the column dimension for updating H is not valid." );
420419 }
421- if (A_ != std::nullopt ) {
420+ if (A != std::nullopt ) {
422421 PROXSUITE_CHECK_ARGUMENT_SIZE (
423- A_ .value ().rows (),
422+ A .value ().rows (),
424423 model.n_eq ,
425424 " the row dimension for updating A is not valid." );
426425 PROXSUITE_CHECK_ARGUMENT_SIZE (
427- A_ .value ().cols (),
426+ A .value ().cols (),
428427 model.dim ,
429428 " the column dimension for updating A is not valid." );
430429 }
431- if (C_ != std::nullopt ) {
430+ if (C != std::nullopt ) {
432431 PROXSUITE_CHECK_ARGUMENT_SIZE (
433- C_ .value ().rows (),
432+ C .value ().rows (),
434433 model.n_in ,
435434 " the row dimension for updating C is not valid." );
436435 PROXSUITE_CHECK_ARGUMENT_SIZE (
437- C_ .value ().cols (),
436+ C .value ().cols (),
438437 model.dim ,
439438 " the column dimension for updating C is not valid." );
440439 }
441440
442441 // update the model
443442
444- if (g_ != std::nullopt ) {
445- model.g = g_ .value ();
443+ if (g != std::nullopt ) {
444+ model.g = g .value ();
446445 }
447- if (b_ != std::nullopt ) {
448- model.b = b_ .value ();
446+ if (b != std::nullopt ) {
447+ model.b = b .value ();
449448 }
450- if (u_ != std::nullopt ) {
451- model.u = u_ .value ();
449+ if (u != std::nullopt ) {
450+ model.u = u .value ();
452451 }
453- if (l_ != std::nullopt ) {
454- model.l = l_ .value ();
452+ if (l != std::nullopt ) {
453+ model.l = l .value ();
455454 }
456- if (H_ != std::nullopt ) {
455+ if (H != std::nullopt ) {
457456 SparseMat<T, I> H_triu =
458- H_ .value ().template triangularView <Eigen::Upper>();
459- if (A_ != std::nullopt ) {
460- if (C_ != std::nullopt ) {
457+ H .value ().template triangularView <Eigen::Upper>();
458+ if (A != std::nullopt ) {
459+ if (C != std::nullopt ) {
461460 bool res =
462461 have_same_structure (
463462 H_unscaled.as_const (),
464463 { proxsuite::linalg::sparse::from_eigen, H_triu }) &&
465464 have_same_structure (AT_unscaled.as_const (),
466465 { proxsuite::linalg::sparse::from_eigen,
467- SparseMat<T, I>(A_ .value ().transpose ()) }) &&
466+ SparseMat<T, I>(A .value ().transpose ()) }) &&
468467 have_same_structure (CT_unscaled.as_const (),
469468 { proxsuite::linalg::sparse::from_eigen,
470- SparseMat<T, I>(C_ .value ().transpose ()) });
469+ SparseMat<T, I>(C .value ().transpose ()) });
471470 /* TO PUT IN DEBUG MODE
472471 std::cout << "have same structure = " << res << std::endl;
473472 */
@@ -478,11 +477,11 @@ struct QP
478477 copy (
479478 AT_unscaled,
480479 { proxsuite::linalg::sparse::from_eigen,
481- SparseMat<T, I>(A_ .value ().transpose ()) }); // copy rhs into lhs
480+ SparseMat<T, I>(A .value ().transpose ()) }); // copy rhs into lhs
482481 copy (
483482 CT_unscaled,
484483 { proxsuite::linalg::sparse::from_eigen,
485- SparseMat<T, I>(C_ .value ().transpose ()) }); // copy rhs into lhs
484+ SparseMat<T, I>(C .value ().transpose ()) }); // copy rhs into lhs
486485 }
487486 } else {
488487 bool res =
@@ -491,7 +490,7 @@ struct QP
491490 { proxsuite::linalg::sparse::from_eigen, H_triu }) &&
492491 have_same_structure (AT_unscaled.as_const (),
493492 { proxsuite::linalg::sparse::from_eigen,
494- SparseMat<T, I>(A_ .value ().transpose ()) });
493+ SparseMat<T, I>(A .value ().transpose ()) });
495494 /* TO PUT IN DEBUG MODE
496495 std::cout << "have same structure = " << res << std::endl;
497496 */
@@ -502,28 +501,27 @@ struct QP
502501 copy (
503502 AT_unscaled,
504503 { proxsuite::linalg::sparse::from_eigen,
505- SparseMat<T, I>(A_ .value ().transpose ()) }); // copy rhs into lhs
504+ SparseMat<T, I>(A .value ().transpose ()) }); // copy rhs into lhs
506505 }
507506 }
508- } else if (C_ != std::nullopt ) {
507+ } else if (C != std::nullopt ) {
509508 bool res =
510509 have_same_structure (
511510 H_unscaled.as_const (),
512511 { proxsuite::linalg::sparse::from_eigen, H_triu }) &&
513512 have_same_structure (CT_unscaled.as_const (),
514513 { proxsuite::linalg::sparse::from_eigen,
515- SparseMat<T, I>(C_ .value ().transpose ()) });
514+ SparseMat<T, I>(C .value ().transpose ()) });
516515 /* TO PUT IN DEBUG MODE
517516 std::cout << "have same structure = " << res << std::endl;
518517 */
519518 if (res) {
520519 copy (H_unscaled,
521520 { proxsuite::linalg::sparse::from_eigen,
522521 H_triu }); // copy rhs into lhs
523- copy (
524- CT_unscaled,
525- { proxsuite::linalg::sparse::from_eigen,
526- SparseMat<T, I>(C_.value ().transpose ()) }); // copy rhs into lhs
522+ copy (CT_unscaled,
523+ { proxsuite::linalg::sparse::from_eigen,
524+ SparseMat<T, I>(C.value ().transpose ()) }); // copy rhs into lhs
527525 }
528526 } else {
529527
@@ -536,58 +534,55 @@ struct QP
536534 if (res) {
537535 copy (H_unscaled,
538536 { proxsuite::linalg::sparse::from_eigen,
539- H_ .value () }); // copy rhs into lhs
537+ H .value () }); // copy rhs into lhs
540538 }
541539 }
542- } else if (A_ != std::nullopt ) {
543- if (C_ != std::nullopt ) {
540+ } else if (A != std::nullopt ) {
541+ if (C != std::nullopt ) {
544542 bool res =
545543 have_same_structure (AT_unscaled.as_const (),
546544 { proxsuite::linalg::sparse::from_eigen,
547- SparseMat<T, I>(A_ .value ().transpose ()) }) &&
545+ SparseMat<T, I>(A .value ().transpose ()) }) &&
548546 have_same_structure (CT_unscaled.as_const (),
549547 { proxsuite::linalg::sparse::from_eigen,
550- SparseMat<T, I>(C_ .value ().transpose ()) });
548+ SparseMat<T, I>(C .value ().transpose ()) });
551549 /* TO PUT IN DEBUG MODE
552550 std::cout << "have same structure = " << res << std::endl;
553551 */
554552 if (res) {
555- copy (
556- AT_unscaled,
557- { proxsuite::linalg::sparse::from_eigen,
558- SparseMat<T, I>(A_.value ().transpose ()) }); // copy rhs into lhs
559- copy (
560- CT_unscaled,
561- { proxsuite::linalg::sparse::from_eigen,
562- SparseMat<T, I>(C_.value ().transpose ()) }); // copy rhs into lhs
553+ copy (AT_unscaled,
554+ { proxsuite::linalg::sparse::from_eigen,
555+ SparseMat<T, I>(A.value ().transpose ()) }); // copy rhs into lhs
556+ copy (CT_unscaled,
557+ { proxsuite::linalg::sparse::from_eigen,
558+ SparseMat<T, I>(C.value ().transpose ()) }); // copy rhs into lhs
563559 }
564560 } else {
565561 bool res =
566562 have_same_structure (AT_unscaled.as_const (),
567563 { proxsuite::linalg::sparse::from_eigen,
568- SparseMat<T, I>(A_ .value ().transpose ()) });
564+ SparseMat<T, I>(A .value ().transpose ()) });
569565 /* TO PUT IN DEBUG MODE
570566 std::cout << "have same structure = " << res << std::endl;
571567 */
572568 if (res) {
573- copy (
574- AT_unscaled,
575- { proxsuite::linalg::sparse::from_eigen,
576- SparseMat<T, I>(A_.value ().transpose ()) }); // copy rhs into lhs
569+ copy (AT_unscaled,
570+ { proxsuite::linalg::sparse::from_eigen,
571+ SparseMat<T, I>(A.value ().transpose ()) }); // copy rhs into lhs
577572 }
578573 }
579- } else if (C_ != std::nullopt ) {
574+ } else if (C != std::nullopt ) {
580575 bool res =
581576 have_same_structure (CT_unscaled.as_const (),
582577 { proxsuite::linalg::sparse::from_eigen,
583- SparseMat<T, I>(C_ .value ().transpose ()) });
578+ SparseMat<T, I>(C .value ().transpose ()) });
584579 /* TO PUT IN DEBUG MODE
585580 std::cout << "have same structure = " << res << std::endl;
586581 */
587582 if (res) {
588583 copy (CT_unscaled,
589584 { proxsuite::linalg::sparse::from_eigen,
590- SparseMat<T, I>(C_ .value ().transpose ()) }); // copy rhs into lhs
585+ SparseMat<T, I>(C .value ().transpose ()) }); // copy rhs into lhs
591586 }
592587 }
593588
0 commit comments