Skip to content

Commit 4aeee22

Browse files
committed
working on maros
1 parent 2700f84 commit 4aeee22

File tree

4 files changed

+144
-59
lines changed

4 files changed

+144
-59
lines changed

include/proxsuite/osqp/dense/solver.hpp

+57-6
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,8 @@ polish(const Settings<T>& qpsettings,
629629
const HessianType hessian_type)
630630
{
631631

632+
std::cout << "check 01" << std::endl;
633+
632634
// Find the upper and lower active constraints
633635
qpwork.active_set_up_eq.array() = (qpresults.y.array() > 0);
634636
qpwork.active_set_low_eq.array() = (qpresults.y.array() < 0);
@@ -638,6 +640,8 @@ polish(const Settings<T>& qpsettings,
638640
isize numactive_constraints_eq_up = qpwork.active_set_up_eq.count();
639641
isize numactive_constraints_eq_low = qpwork.active_set_low_eq.count();
640642

643+
std::cout << "check 02" << std::endl;
644+
641645
qpwork.active_set_up_ineq = qpwork.active_set_up;
642646
qpwork.active_set_low_ineq = qpwork.active_set_low;
643647
qpwork.active_constraints_ineq =
@@ -646,6 +650,8 @@ polish(const Settings<T>& qpsettings,
646650
isize numactive_constraints_ineq_up = qpwork.active_set_up_ineq.count();
647651
isize numactive_constraints_ineq_low = qpwork.active_set_low_ineq.count();
648652

653+
std::cout << "check 03" << std::endl;
654+
649655
isize numactive_constraints =
650656
numactive_constraints_eq + numactive_constraints_ineq;
651657

@@ -682,6 +688,8 @@ polish(const Settings<T>& qpsettings,
682688
}
683689
}
684690

691+
std::cout << "check 04" << std::endl;
692+
685693
Mat<T> A_low(numactive_constraints_eq_low, qpmodel.dim);
686694
Mat<T> A_up(numactive_constraints_eq_up, qpmodel.dim);
687695

@@ -698,6 +706,8 @@ polish(const Settings<T>& qpsettings,
698706
}
699707
}
700708

709+
std::cout << "check 05" << std::endl;
710+
701711
// Construction and factorization of K + Delta_K
702712
isize row;
703713
isize column;
@@ -706,12 +716,17 @@ polish(const Settings<T>& qpsettings,
706716
proxsuite::linalg::veg::from_slice_mut, qpwork.ldl_stack.as_mut()
707717
};
708718

719+
std::cout << "check 06" << std::endl;
720+
709721
switch (dense_backend) {
710722
case DenseBackend::PrimalDualLDLT:
711723

712724
// Top left corner of K for H
713725
qpwork.k_polish.resize(qpmodel.dim + numactive_constraints,
714726
qpmodel.dim + numactive_constraints);
727+
728+
std::cout << "check 07" << std::endl;
729+
715730
switch (hessian_type) {
716731
case HessianType::Dense:
717732
qpwork.k_polish.topLeftCorner(qpmodel.dim, qpmodel.dim) =
@@ -726,55 +741,72 @@ polish(const Settings<T>& qpsettings,
726741
break;
727742
}
728743

744+
std::cout << "check 08" << std::endl;
745+
729746
// Add the rows/columns for the constraints
730747
row = qpmodel.dim;
748+
std::cout << "check 081" << std::endl;
731749
column = qpmodel.dim;
750+
std::cout << "check 082" << std::endl;
732751
qpwork.k_polish.block(
733752
0, column, qpmodel.dim, numactive_constraints_eq_low) =
734753
A_low.transpose();
754+
std::cout << "check 083" << std::endl;
735755
column += numactive_constraints_eq_low;
736756
qpwork.k_polish.block(
737757
0, column, qpmodel.dim, numactive_constraints_ineq_low) =
738758
C_low.transpose();
759+
std::cout << "check 084" << std::endl;
739760
column += numactive_constraints_ineq_low;
740761
qpwork.k_polish.block(
741762
0, column, qpmodel.dim, numactive_constraints_eq_up) = A_up.transpose();
742763
column += numactive_constraints_eq_up;
764+
std::cout << "check 085" << std::endl;
743765
qpwork.k_polish.block(
744766
0, column, qpmodel.dim, numactive_constraints_ineq_up) =
745767
C_up.transpose();
746768
qpwork.k_polish.block(row, 0, numactive_constraints_eq_low, qpmodel.dim) =
747769
A_low;
770+
std::cout << "check 086" << std::endl;
748771
row += numactive_constraints_eq_low;
749772
qpwork.k_polish.block(
750773
row, 0, numactive_constraints_ineq_low, qpmodel.dim) = C_low;
751774
row += numactive_constraints_ineq_low;
775+
std::cout << "check 087" << std::endl;
752776
qpwork.k_polish.block(row, 0, numactive_constraints_eq_up, qpmodel.dim) =
753777
A_up;
754778
row += numactive_constraints_eq_up;
779+
// std::cout << "check 088" << std::endl;
755780
qpwork.k_polish.block(
756781
row, 0, numactive_constraints_ineq_up, qpmodel.dim) = C_up;
782+
// std::cout << "check 089" << std::endl;
757783
qpwork.k_polish
758784
.bottomRightCorner(numactive_constraints, numactive_constraints)
759785
.setZero();
760786

761-
std::cout << "check 1" << std::endl;
762-
std::cout << "checkout 1" << std::endl;
787+
std::cout << "check 09" << std::endl;
788+
789+
// std::cout << "check 1" << std::endl;
790+
// std::cout << "checkout 1" << std::endl;
763791
// Construction and factorization of K + Delta_K
764792
qpwork.k_plus_delta_k_polish =
765793
qpwork.k_polish; // error: malloc(): invalid size (unsorted), malloc():
766794
// unaligned tcache chunk detected
767795
// errors here in test cvxpy, but also maros meszaros for some problems
768-
std::cout << "check 2" << std::endl;
769-
std::cout << "checkout 2" << std::endl;
796+
// std::cout << "check 2" << std::endl;
797+
// std::cout << "checkout 2" << std::endl;
798+
std::cout << "check 091" << std::endl;
770799
qpwork.k_plus_delta_k_polish.topLeftCorner(qpmodel.dim, qpmodel.dim)
771800
.diagonal()
772801
.array() += qpsettings.delta_osqp;
802+
std::cout << "check 092" << std::endl;
773803
qpwork.k_plus_delta_k_polish
774804
.bottomRightCorner(numactive_constraints, numactive_constraints)
775805
.diagonal()
776806
.array() -= qpsettings.delta_osqp;
777807

808+
std::cout << "check 010" << std::endl;
809+
778810
qpwork.ldl.factorize(qpwork.k_plus_delta_k_polish.transpose(), stack);
779811

780812
break;
@@ -807,6 +839,8 @@ polish(const Settings<T>& qpsettings,
807839
break;
808840
}
809841

842+
std::cout << "check 011" << std::endl;
843+
810844
// Construction of the l_low, u_up, etc to build the rhs for the linear
811845
// systems (iterative refinement)
812846
isize l_low_index = 0;
@@ -832,6 +866,8 @@ polish(const Settings<T>& qpsettings,
832866
}
833867
}
834868

869+
std::cout << "check 012" << std::endl;
870+
835871
isize b_low_index = 0;
836872
isize b_up_index = 0;
837873
Vec<T> b_low(numactive_constraints_eq_low);
@@ -847,6 +883,8 @@ polish(const Settings<T>& qpsettings,
847883
}
848884
}
849885

886+
std::cout << "check 013" << std::endl;
887+
850888
// Iterative refinement
851889
Vec<T> g_polish_rhs;
852890
isize line;
@@ -867,6 +905,8 @@ polish(const Settings<T>& qpsettings,
867905
Vec<T> hat_y_up;
868906
Vec<T> hat_z_up;
869907

908+
std::cout << "check 014" << std::endl;
909+
870910
switch (dense_backend) {
871911
case DenseBackend::PrimalDualLDLT:
872912

@@ -884,11 +924,13 @@ polish(const Settings<T>& qpsettings,
884924

885925
inner_pb_dim = qpmodel.dim + numactive_constraints;
886926

887-
std::cout << "check 3" << std::endl;
927+
// std::cout << "check 3" << std::endl;
928+
std::cout << "check 015" << std::endl;
888929
hat_t = g_polish_rhs; // 2 times Fatal glibc error: malloc.c:4376
889930
// (_int_malloc): assertion failed: (unsigned long)
890931
// (size) >= (unsigned long) (nb)
891-
std::cout << "check 4" << std::endl;
932+
// std::cout << "check 4" << std::endl;
933+
std::cout << "check 016" << std::endl;
892934

893935
solve_linear_system(hat_t,
894936
qpmodel,
@@ -900,6 +942,8 @@ polish(const Settings<T>& qpsettings,
900942
inner_pb_dim,
901943
stack);
902944

945+
std::cout << "check 017" << std::endl;
946+
903947
// Iterative refinement
904948
for (i64 iter = 0; iter < qpsettings.nb_polish_iter; ++iter) {
905949
rhs_polish = g_polish_rhs - qpwork.k_polish * hat_t;
@@ -916,6 +960,8 @@ polish(const Settings<T>& qpsettings,
916960
hat_t = hat_t + delta_hat_t;
917961
}
918962

963+
std::cout << "check 018" << std::endl;
964+
919965
break;
920966
case DenseBackend::PrimalLDLT:
921967

@@ -1002,6 +1048,7 @@ polish(const Settings<T>& qpsettings,
10021048

10031049
// Update of the primal and dual variables
10041050
qpresults.x = hat_t.head(qpmodel.dim);
1051+
std::cout << "check 019" << std::endl;
10051052

10061053
y_low_index = 0;
10071054
z_low_index = 0;
@@ -1019,6 +1066,8 @@ polish(const Settings<T>& qpsettings,
10191066
}
10201067
}
10211068

1069+
std::cout << "check 020" << std::endl;
1070+
10221071
for (isize i = 0; i < n_constraints; ++i) {
10231072
if (qpwork.active_set_low_ineq(i)) {
10241073
qpresults.z(i) =
@@ -1032,6 +1081,8 @@ polish(const Settings<T>& qpsettings,
10321081
++z_up_index;
10331082
}
10341083
}
1084+
1085+
std::cout << "check 021" << std::endl;
10351086
}
10361087
/*!
10371088
* Executes the OSQP algorithm.

include/proxsuite/proxqp/settings.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,10 @@ struct Settings
234234

235235
Settings(
236236
DenseBackend dense_backend = DenseBackend::PrimalDualLDLT,
237-
T default_mu_eq = 1.E-3,
238-
T default_mu_in = 1.E-1,
237+
// T default_mu_eq = 1.E-3, // proxqp
238+
// T default_mu_in = 1.E-1, // proxqp
239+
T default_mu_eq = 1.E-3, // osqp
240+
T default_mu_in = 1.E-1, // osqp
239241
T alpha_bcl = 0.1,
240242
T beta_bcl = 0.9,
241243
T alpha_osqp = 1.6,

test/src/dense_maros_meszaros.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,21 @@ char const* files[] = {
2020
// MAROS_MESZAROS_DIR "CONT-101.mat", MAROS_MESZAROS_DIR "CONT-200.mat",
2121
// MAROS_MESZAROS_DIR "CONT-201.mat", MAROS_MESZAROS_DIR "CONT-300.mat",
2222
// MAROS_MESZAROS_DIR "CVXQP1_L.mat", MAROS_MESZAROS_DIR "CVXQP1_M.mat",
23-
MAROS_MESZAROS_DIR "CVXQP1_S.mat",
24-
MAROS_MESZAROS_DIR "CVXQP2_L.mat",
25-
// MAROS_MESZAROS_DIR "CVXQP2_M.mat", MAROS_MESZAROS_DIR "CVXQP2_S.mat",
23+
// MAROS_MESZAROS_DIR "CVXQP1_S.mat",
24+
// MAROS_MESZAROS_DIR "CVXQP2_L.mat",
25+
// MAROS_MESZAROS_DIR "CVXQP2_M.mat",
26+
// MAROS_MESZAROS_DIR "CVXQP2_S.mat",
2627
// MAROS_MESZAROS_DIR "CVXQP3_L.mat", MAROS_MESZAROS_DIR "CVXQP3_M.mat",
2728
// MAROS_MESZAROS_DIR "CVXQP3_S.mat", MAROS_MESZAROS_DIR "DPKLO1.mat",
2829
// MAROS_MESZAROS_DIR "DTOC3.mat", MAROS_MESZAROS_DIR "DUAL1.mat",
2930
// MAROS_MESZAROS_DIR "DUAL2.mat", MAROS_MESZAROS_DIR "DUAL3.mat",
30-
// MAROS_MESZAROS_DIR "DUAL4.mat", MAROS_MESZAROS_DIR "DUALC1.mat",
31+
// MAROS_MESZAROS_DIR "DUAL4.mat",
32+
// MAROS_MESZAROS_DIR "DUALC1.mat",
3133
// MAROS_MESZAROS_DIR "DUALC2.mat", MAROS_MESZAROS_DIR "DUALC5.mat",
3234
// MAROS_MESZAROS_DIR "DUALC8.mat", MAROS_MESZAROS_DIR "EXDATA.mat",
3335
// MAROS_MESZAROS_DIR "GENHS28.mat", MAROS_MESZAROS_DIR "GOULDQP2.mat",
3436
// MAROS_MESZAROS_DIR "GOULDQP3.mat", MAROS_MESZAROS_DIR "HS118.mat",
35-
// MAROS_MESZAROS_DIR "HS21.mat", MAROS_MESZAROS_DIR "HS268.mat",
37+
MAROS_MESZAROS_DIR "HS21.mat", // MAROS_MESZAROS_DIR "HS268.mat",
3638
// MAROS_MESZAROS_DIR "HS35.mat", MAROS_MESZAROS_DIR "HS35MOD.mat",
3739
// MAROS_MESZAROS_DIR "HS51.mat", MAROS_MESZAROS_DIR "HS52.mat",
3840
// MAROS_MESZAROS_DIR "HS53.mat", MAROS_MESZAROS_DIR "HS76.mat",
@@ -131,7 +133,8 @@ TEST_CASE("dense maros meszaros using the api")
131133
qp.settings.eps_dual_inf = 1e-12;
132134
auto& eps = qp.settings.eps_abs;
133135

134-
for (size_t it = 0; it < 2; ++it) {
136+
// for (size_t it = 0; it < 2; ++it) {
137+
for (size_t it = 0; it < 1; ++it) {
135138
if (it > 0)
136139
qp.settings.initial_guess = proxsuite::proxqp::InitialGuessStatus::
137140
WARM_START_WITH_PREVIOUS_RESULT;
@@ -165,6 +168,9 @@ TEST_CASE("dense maros meszaros using the api")
165168
timer.stop();
166169
elapsed_time += timer.elapsed().user;
167170
}
171+
std::cout << " n: " << n << " n_eq+n_in: " << n_eq_in << std::endl;
172+
// std::cout << "now we do the warm start with previous result" <<
173+
// std::endl;
168174
}
169175
std::cout << "timings total : \t" << elapsed_time * 1e-3 << "ms" << std::endl;
170176
}

0 commit comments

Comments
 (0)