@@ -3319,7 +3319,7 @@ def test_case_update_A_for_different_initial_guess(self):
33193319 "---testing sparse random strongly convex qp with equality and inequality constraints: test update A for different initial guess---"
33203320 )
33213321 n = 10
3322- H , g , A_old , b , C , u , l = generate_mixed_qp (n )
3322+ H , g , A_old , b_old , C , u , l = generate_mixed_qp (n )
33233323 n_eq = A_old .shape [0 ]
33243324 n_in = C .shape [0 ]
33253325 qp = proxsuite .proxqp .dense .QP (n , n_eq , n_in )
@@ -3330,42 +3330,40 @@ def test_case_update_A_for_different_initial_guess(self):
33303330 H ,
33313331 np .asfortranarray (g ),
33323332 A_old ,
3333- np .asfortranarray (b ),
3333+ np .asfortranarray (b_old ),
33343334 C ,
33353335 np .asfortranarray (l ),
33363336 np .asfortranarray (u ),
33373337 True ,
33383338 )
33393339 qp .solve ()
3340- A = spa .random (
3341- n_eq , n , density = 0.15 , data_rvs = np .random .randn , format = "csc"
3342- ).toarray ()
3340+ _ , _ , A_new , b_new , _ , _ , _ = generate_mixed_qp (n , seed = 2 )
33433341 dua_res = normInf (
33443342 H @ qp .results .x
33453343 + g
33463344 + A_old .transpose () @ qp .results .y
33473345 + C .transpose () @ qp .results .z
33483346 )
33493347 pri_res = max (
3350- normInf (A_old @ qp .results .x - b ),
3348+ normInf (A_old @ qp .results .x - b_old ),
33513349 normInf (
33523350 np .maximum (C @ qp .results .x - u , 0 )
33533351 + np .minimum (C @ qp .results .x - l , 0 )
33543352 ),
33553353 )
33563354 assert dua_res <= 1e-9
33573355 assert pri_res <= 1e-9
3358- qp .update (A = A )
3359- assert normInf (qp .model .A - A ) <= 1.0e-9
3356+ qp .update (A = A_new , b = b_new )
3357+ assert normInf (qp .model .A - A_new ) <= 1.0e-9
33603358 qp .solve ()
33613359 dua_res = normInf (
33623360 H @ qp .results .x
33633361 + g
3364- + A .transpose () @ qp .results .y
3362+ + A_new .transpose () @ qp .results .y
33653363 + C .transpose () @ qp .results .z
33663364 )
33673365 pri_res = max (
3368- normInf (A @ qp .results .x - b ),
3366+ normInf (A_new @ qp .results .x - b_new ),
33693367 normInf (
33703368 np .maximum (C @ qp .results .x - u , 0 )
33713369 + np .minimum (C @ qp .results .x - l , 0 )
@@ -3392,7 +3390,7 @@ def test_case_update_A_for_different_initial_guess(self):
33923390 H ,
33933391 np .asfortranarray (g ),
33943392 A_old ,
3395- np .asfortranarray (b ),
3393+ np .asfortranarray (b_old ),
33963394 C ,
33973395 np .asfortranarray (l ),
33983396 np .asfortranarray (u ),
@@ -3406,25 +3404,25 @@ def test_case_update_A_for_different_initial_guess(self):
34063404 + C .transpose () @ qp2 .results .z
34073405 )
34083406 pri_res = max (
3409- normInf (A_old @ qp2 .results .x - b ),
3407+ normInf (A_old @ qp2 .results .x - b_old ),
34103408 normInf (
34113409 np .maximum (C @ qp2 .results .x - u , 0 )
34123410 + np .minimum (C @ qp2 .results .x - l , 0 )
34133411 ),
34143412 )
34153413 assert dua_res <= 1e-9
34163414 assert pri_res <= 1e-9
3417- qp2 .update (A = A )
3418- assert normInf (qp .model .A - A ) <= 1.0e-9
3415+ qp2 .update (A = A_new , b = b_new )
3416+ assert normInf (qp .model .A - A_new ) <= 1.0e-9
34193417 qp2 .solve ()
34203418 dua_res = normInf (
34213419 H @ qp2 .results .x
34223420 + g
3423- + A .transpose () @ qp2 .results .y
3421+ + A_new .transpose () @ qp2 .results .y
34243422 + C .transpose () @ qp2 .results .z
34253423 )
34263424 pri_res = max (
3427- normInf (A @ qp2 .results .x - b ),
3425+ normInf (A_new @ qp2 .results .x - b_new ),
34283426 normInf (
34293427 np .maximum (C @ qp2 .results .x - u , 0 )
34303428 + np .minimum (C @ qp2 .results .x - l , 0 )
@@ -3451,7 +3449,7 @@ def test_case_update_A_for_different_initial_guess(self):
34513449 H ,
34523450 np .asfortranarray (g ),
34533451 A_old ,
3454- np .asfortranarray (b ),
3452+ np .asfortranarray (b_old ),
34553453 C ,
34563454 np .asfortranarray (l ),
34573455 np .asfortranarray (u ),
@@ -3465,25 +3463,25 @@ def test_case_update_A_for_different_initial_guess(self):
34653463 + C .transpose () @ qp3 .results .z
34663464 )
34673465 pri_res = max (
3468- normInf (A_old @ qp3 .results .x - b ),
3466+ normInf (A_old @ qp3 .results .x - b_old ),
34693467 normInf (
34703468 np .maximum (C @ qp3 .results .x - u , 0 )
34713469 + np .minimum (C @ qp3 .results .x - l , 0 )
34723470 ),
34733471 )
34743472 assert dua_res <= 1e-9
34753473 assert pri_res <= 1e-9
3476- qp3 .update (A = A )
3477- assert normInf (qp .model .A - A ) <= 1.0e-9
3474+ qp3 .update (A = A_new , b = b_new )
3475+ assert normInf (qp .model .A - A_new ) <= 1.0e-9
34783476 qp3 .solve ()
34793477 dua_res = normInf (
34803478 H @ qp3 .results .x
34813479 + g
3482- + A .transpose () @ qp3 .results .y
3480+ + A_new .transpose () @ qp3 .results .y
34833481 + C .transpose () @ qp3 .results .z
34843482 )
34853483 pri_res = max (
3486- normInf (A @ qp3 .results .x - b ),
3484+ normInf (A_new @ qp3 .results .x - b_new ),
34873485 normInf (
34883486 np .maximum (C @ qp3 .results .x - u , 0 )
34893487 + np .minimum (C @ qp3 .results .x - l , 0 )
@@ -3510,7 +3508,7 @@ def test_case_update_A_for_different_initial_guess(self):
35103508 H ,
35113509 np .asfortranarray (g ),
35123510 A_old ,
3513- np .asfortranarray (b ),
3511+ np .asfortranarray (b_old ),
35143512 C ,
35153513 np .asfortranarray (l ),
35163514 np .asfortranarray (u ),
@@ -3524,25 +3522,25 @@ def test_case_update_A_for_different_initial_guess(self):
35243522 + C .transpose () @ qp4 .results .z
35253523 )
35263524 pri_res = max (
3527- normInf (A_old @ qp4 .results .x - b ),
3525+ normInf (A_old @ qp4 .results .x - b_old ),
35283526 normInf (
35293527 np .maximum (C @ qp4 .results .x - u , 0 )
35303528 + np .minimum (C @ qp4 .results .x - l , 0 )
35313529 ),
35323530 )
35333531 assert dua_res <= 1e-9
35343532 assert pri_res <= 1e-9
3535- qp4 .update (A = A )
3536- assert normInf (qp .model .A - A ) <= 1.0e-9
3533+ qp4 .update (A = A_new , b = b_new )
3534+ assert normInf (qp .model .A - A_new ) <= 1.0e-9
35373535 qp4 .solve ()
35383536 dua_res = normInf (
35393537 H @ qp4 .results .x
35403538 + g
3541- + A .transpose () @ qp4 .results .y
3539+ + A_new .transpose () @ qp4 .results .y
35423540 + C .transpose () @ qp4 .results .z
35433541 )
35443542 pri_res = max (
3545- normInf (A @ qp4 .results .x - b ),
3543+ normInf (A_new @ qp4 .results .x - b_new ),
35463544 normInf (
35473545 np .maximum (C @ qp4 .results .x - u , 0 )
35483546 + np .minimum (C @ qp4 .results .x - l , 0 )
@@ -3567,7 +3565,7 @@ def test_case_update_A_for_different_initial_guess(self):
35673565 H ,
35683566 np .asfortranarray (g ),
35693567 A_old ,
3570- np .asfortranarray (b ),
3568+ np .asfortranarray (b_old ),
35713569 C ,
35723570 np .asfortranarray (l ),
35733571 np .asfortranarray (u ),
@@ -3581,25 +3579,25 @@ def test_case_update_A_for_different_initial_guess(self):
35813579 + C .transpose () @ qp5 .results .z
35823580 )
35833581 pri_res = max (
3584- normInf (A_old @ qp5 .results .x - b ),
3582+ normInf (A_old @ qp5 .results .x - b_old ),
35853583 normInf (
35863584 np .maximum (C @ qp5 .results .x - u , 0 )
35873585 + np .minimum (C @ qp5 .results .x - l , 0 )
35883586 ),
35893587 )
35903588 assert dua_res <= 1e-9
35913589 assert pri_res <= 1e-9
3592- qp5 .update (A = A )
3593- assert normInf (qp .model .A - A ) <= 1.0e-9
3590+ qp5 .update (A = A_new , b = b_new )
3591+ assert normInf (qp .model .A - A_new ) <= 1.0e-9
35943592 qp5 .solve ()
35953593 dua_res = normInf (
35963594 H @ qp5 .results .x
35973595 + g
3598- + A .transpose () @ qp5 .results .y
3596+ + A_new .transpose () @ qp5 .results .y
35993597 + C .transpose () @ qp5 .results .z
36003598 )
36013599 pri_res = max (
3602- normInf (A @ qp5 .results .x - b ),
3600+ normInf (A_new @ qp5 .results .x - b_new ),
36033601 normInf (
36043602 np .maximum (C @ qp5 .results .x - u , 0 )
36053603 + np .minimum (C @ qp5 .results .x - l , 0 )
0 commit comments