35 #include <QProblem.hpp> 42 printf(
"%s = [...\n", name);
43 for (i = 0; i < m; i++) {
44 for (j = 0; j < n; j++)
45 printf(
" % 9.4f", A[i*n+j]);
108 for( i=0; i<_nC; ++i )
109 for( j=0; j<_nV; ++j )
112 for( i=0; i<_nC; ++i )
115 for( i=0; i<_nC; ++i )
120 for( i=0; i<(_nV+_nC); ++i )
126 for( i=0; i<
sizeT; ++i )
127 for( j=0; j<
sizeT; ++j )
130 for( i=0; i<_nV; ++i )
131 for( j=0; j<_nV; ++j )
134 for( i=0; i<_nC; ++i )
164 for( i=0; i<_nC; ++i )
165 for( j=0; j<_nV; ++j )
168 for( i=0; i<_nC; ++i )
171 for( i=0; i<_nC; ++i )
176 for( i=0; i<(_nV+_nC); ++i )
182 for( i=0; i<
sizeT; ++i )
183 for( j=0; j<
sizeT; ++j )
186 for( i=0; i<_nV; ++i )
187 for( j=0; j<_nV; ++j )
190 for( i=0; i<_nC; ++i )
218 for( i=0; i<
sizeT; ++i )
219 for( j=0; j<
sizeT; ++j )
222 for( i=0; i<nV; ++i )
223 for( j=0; j<nV; ++j )
311 char messageString[80];
316 for( l=0; l<
nWSR; ++l )
323 sprintf( messageString,
"%d ...",l );
343 g_new,lbA_new,ubA_new,lb_new,ub_new,
344 delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub,
345 Delta_bC_isZero, Delta_bB_isZero );
355 delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub,
356 Delta_bC_isZero, Delta_bB_isZero,
357 delta_xFX,delta_xFR,delta_yAC,delta_yFX
368 delta_lbA,delta_ubA,delta_lb,delta_ub,
369 delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax,
370 BC_idx,BC_status,BC_isBound
381 delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub,
382 delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax,
383 BC_idx,BC_status,BC_isBound
449 sprintf( messageString,
"(nWSR = %d)",nWSR );
458 return returnvalueKKTcheck;
521 for( i=0; i<nC; ++i )
532 for( i=0; i<nC; ++i )
545 for( i=0; i<nC; ++i )
586 for( i=0; i<nV; ++i )
587 for( j=0; j<nV; ++j )
594 for( i=0; i<nV; ++i )
614 for ( i=0; i<nFR; ++i )
618 for ( j=0; j<nZ; ++j )
620 HZ[i*
NVMAX + j] = 0.0;
621 for ( k=0; k<nFR; ++k )
630 for ( i=0; i<nZ; ++i )
631 for ( j=0; j<nZ; ++j )
633 ZHZ[i*
NVMAX + j] = 0.0;
634 for ( k=0; k<nFR; ++k )
644 for( i=0; i<nZ; ++i )
647 sum = ZHZ[i*
NVMAX + i];
649 for( k=(i-1); k>=0; --k )
660 for( j=(i+1); j<nZ; ++j )
662 sum = ZHZ[j*
NVMAX + i];
664 for( k=(i-1); k>=0; --k )
691 for( i=0; i<nV; ++i )
692 for( j=0; j<nV; ++j )
695 for( i=0; i<nFR; ++i )
702 for( i=0; i<
sizeT; ++i )
703 for( j=0; j<
sizeT; ++j )
762 static Bounds auxiliaryBounds;
764 auxiliaryBounds.
init( nV );
768 auxiliaryConstraints.
init( nC );
801 for( i=0; i<nV; ++i )
803 g_original[i] =
g[i];
804 lb_original[i] =
lb[i];
805 ub_original[i] =
ub[i];
808 for( i=0; i<nC; ++i )
810 lbA_original[i] =
lbA[i];
811 ubA_original[i] =
ubA[i];
827 returnValue returnvalue =
hotstart( g_original,lb_original,ub_original,lbA_original,ubA_original, nWSR,0 );
868 if ( ( auxiliaryBounds == 0 ) || ( auxiliaryBounds == guessedBounds ) )
871 if ( ( auxiliaryConstraints == 0 ) || ( auxiliaryConstraints == guessedConstraints ) )
882 if ( guessedConstraints != 0 )
886 for( i=0; i<nC; ++i )
888 guessedStatus = guessedConstraints->
getStatus( i );
905 if ( ( xOpt != 0 ) && ( yOpt == 0 ) )
907 for( i=0; i<nC; ++i )
938 if ( ( xOpt == 0 ) && ( yOpt != 0 ) )
940 for( i=0; i<nC; ++i )
942 if ( yOpt[nV+i] >
ZERO )
949 if ( yOpt[nV+i] < -
ZERO )
973 if ( ( xOpt == 0 ) && ( yOpt == 0 ) )
975 for( i=0; i<nC; ++i )
1010 if ( auxiliaryBounds != 0 )
1012 for( i=0; i<nV; ++i )
1021 if ( auxiliaryConstraints != 0 )
1023 for( i=0; i<nC; ++i )
1048 for( i=0; i<nC; ++i )
1061 for( i=0; i<nV; ++i )
1077 for( i=0; i<nV; ++i )
1092 for( i=0; i<nC; ++i )
1130 for( i=0; i<nV; ++i )
1133 for ( j=0; j<nC; ++j )
1137 for( i=0; i<nV; ++i )
1143 for( i=0; i<nV; ++i )
1146 for ( j=0; j<nC; ++j )
1153 for( i=0; i<nV+nC; ++i )
1158 for( i=0; i<nV+nC; ++i )
1177 for ( i=0; i<nV; ++i )
1183 for ( j=0; j<nC; ++j )
1187 for ( j=0; j<nV; ++j )
1209 for ( i=0; i<nV; ++i )
1214 if ( useRelaxation ==
BT_TRUE )
1247 if ( useRelaxation ==
BT_TRUE )
1260 if ( useRelaxation ==
BT_TRUE )
1271 for ( i=0; i<nC; ++i )
1276 if ( useRelaxation ==
BT_TRUE )
1309 if ( useRelaxation ==
BT_TRUE )
1322 if ( useRelaxation ==
BT_TRUE )
1364 if ( updateCholesky ==
BT_TRUE )
1368 switch ( ensureLIreturnvalue )
1392 int tcol =
sizeT - nAC;
1401 for( i=0; i<nZ; ++i )
1407 for( i=0; i<nFR; ++i )
1410 aFR[i] =
A[number*
NVMAX + ii];
1414 for( i=0; i<nFR; ++i )
1417 for( j=0; j<nZ; ++j )
1418 wZ[j] += aFR[i] *
Q[ii*
NVMAX + j];
1424 for( j=0; j<nAC; ++j )
1425 T[nAC*
NVMAX + tcol+j] = 0.0;
1426 for( i=0; i<nFR; ++i )
1429 for( j=0; j<nAC; ++j )
1442 for( j=0; j<nZ-1; ++j )
1446 for( i=0; i<nFR; ++i )
1454 for( i=0; i<=j+1; ++i )
1459 T[nAC*
NVMAX + tcol-1] = wZ[nZ-1];
1466 for( i=0; i<nZ-1; ++i )
1470 for( j=(1+i); j<(nZ-1); ++j )
1474 for( i=0; i<nZ; ++i )
1507 for( i=0; i<nZ; ++i )
1510 for( j=0; j<nFR; ++j )
1569 for( i=0; i<nAC; ++i )
1572 for( j=0; j<nFR; ++j )
1575 xiC_TMP[i] +=
Q[jj*
NVMAX + nZ+i] *
A[number*
NVMAX + jj];
1581 for( i=0; i<nAC; ++i )
1584 for( j=0; j<nFR; ++j )
1587 xiC_TMP[i] -=
Q[jj*
NVMAX + nZ+i] *
A[number*
NVMAX + jj];
1603 for( i=0; i<nFX; ++i )
1606 xiB[i] =
A[number*
NVMAX + ii];
1608 for( j=0; j<nAC; ++j )
1611 xiB[i] -=
A[jj*
NVMAX + ii] * xiC[j];
1617 for( i=0; i<nFX; ++i )
1620 xiB[i] = -
A[number*
NVMAX + ii];
1622 for( j=0; j<nAC; ++j )
1625 xiB[i] -=
A[jj*
NVMAX + ii] * xiC[j];
1633 int y_min_number = -1;
1637 for( i=0; i<nAC; ++i )
1643 if ( ( xiC[i] >
ZERO ) && (
y[nV+ii] >= 0.0 ) )
1645 if (
y[nV+ii]/xiC[i] < y_min )
1647 y_min =
y[nV+ii]/xiC[i];
1654 if ( ( xiC[i] < -
ZERO ) && (
y[nV+ii] <= 0.0 ) )
1656 if (
y[nV+ii]/xiC[i] < y_min )
1658 y_min =
y[nV+ii]/xiC[i];
1666 for( i=0; i<nFX; ++i )
1672 if ( ( xiB[i] >
ZERO ) && (
y[ii] >= 0.0 ) )
1674 if (
y[ii]/xiB[i] < y_min )
1676 y_min =
y[ii]/xiB[i];
1684 if ( ( xiB[i] < -
ZERO ) && (
y[ii] <= 0.0 ) )
1686 if (
y[ii]/xiB[i] < y_min )
1688 y_min =
y[ii]/xiB[i];
1698 char messageString[80];
1709 if ( y_min_number >= 0 )
1728 for( i=0; i<nAC; ++i )
1731 y[nV+ii] -= y_min * xiC[i];
1733 for( i=0; i<nFX; ++i )
1736 y[ii] -= y_min * xiB[i];
1741 y[nV+number] = y_min;
1743 y[nV+number] = -y_min;
1746 if ( y_min_isBound ==
BT_TRUE )
1749 sprintf( messageString,
"bound no. %d.",y_min_number );
1756 y[y_min_number] = 0.0;
1761 sprintf( messageString,
"constraint no. %d.",y_min_number );
1768 y[nV+y_min_number] = 0.0;
1812 if ( updateCholesky ==
BT_TRUE )
1816 switch ( ensureLIreturnvalue )
1841 int tcol =
sizeT - nAC;
1847 if ( lastfreenumber != number )
1861 for( i=0; i<nFR; ++i )
1862 w[i] =
Q[FR_idx[nFR-1]*
NVMAX + i];
1869 for( j=0; j<nZ-1; ++j )
1873 for( i=0; i<nFR; ++i )
1881 for( i=0; i<=j+1; ++i )
1891 for( i=0; i<nAC; ++i )
1899 for( i=0; i<nFR; ++i )
1908 for( j=nZ; j<nFR-1; ++j )
1912 for( i=0; i<nFR; ++i )
1918 for( i=(nFR-2-j); i<nAC; ++i )
1929 for( i=0; i<nZ-1; ++i )
1933 for( j=(1+i); j<nZ-1; ++j )
1937 for( i=0; i<nZ; ++i )
1962 for( i=0; i<nZ; ++i )
2017 for( i=0; i<nAC; ++i )
2018 xiC_TMP[i] =
Q[number*
NVMAX + nZ+i];
2022 for( i=0; i<nAC; ++i )
2023 xiC_TMP[i] = -
Q[number*
NVMAX + nZ+i];
2031 for( i=0; i<nFX; ++i )
2036 for( j=0; j<nAC; ++j )
2039 xiB[i] -=
A[jj*
NVMAX + ii] * xiC[j];
2046 int y_min_number = -1;
2050 for( i=0; i<nAC; ++i )
2056 if ( ( xiC[i] >
ZERO ) && (
y[nV+ii] >= 0.0 ) )
2058 if (
y[nV+ii]/xiC[i] < y_min )
2060 y_min =
y[nV+ii]/xiC[i];
2067 if ( ( xiC[i] < -
ZERO ) && (
y[nV+ii] <= 0.0 ) )
2069 if (
y[nV+ii]/xiC[i] < y_min )
2071 y_min =
y[nV+ii]/xiC[i];
2079 for( i=0; i<nFX; ++i )
2085 if ( ( xiB[i] >
ZERO ) && (
y[ii] >= 0.0 ) )
2087 if (
y[ii]/xiB[i] < y_min )
2089 y_min =
y[ii]/xiB[i];
2097 if ( ( xiB[i] < -
ZERO ) && (
y[ii] <= 0.0 ) )
2099 if (
y[ii]/xiB[i] < y_min )
2101 y_min =
y[ii]/xiB[i];
2111 char messageString[80];
2122 if ( y_min_number >= 0 )
2142 for( i=0; i<nAC; ++i )
2145 y[nV+ii] -= y_min * xiC[i];
2147 for( i=0; i<nFX; ++i )
2150 y[ii] -= y_min * xiB[i];
2160 if ( y_min_isBound ==
BT_TRUE )
2163 sprintf( messageString,
"bound no. %d.",y_min_number );
2170 y[y_min_number] = 0.0;
2175 sprintf( messageString,
"constraint no. %d.",y_min_number );
2182 y[nV+y_min_number] = 0.0;
2221 int tcol =
sizeT - nAC;
2229 if ( ( number_idx < 0 ) || ( number_idx >= nAC ) )
2241 if ( number_idx < nAC-1 )
2243 for( i=(number_idx+1); i<nAC; ++i )
2244 for( j=(nAC-i-1); j<nAC; ++j )
2247 for( j=0; j<nAC; ++j )
2248 T[(nAC-1)*
NVMAX + tcol+j] = 0.0;
2256 for( j=(nAC-2-number_idx); j>=0; --j )
2260 for( i=(nAC-j-1); i<(nAC-1); ++i )
2263 for( i=0; i<nFR; ++i )
2273 for( j=0; j<nAC; ++j )
2274 T[(nAC-1)*
NVMAX + tcol+j] = 0.0;
2284 for ( i=0; i<nFR; ++i )
2290 for( j=0; j<nFR; ++j )
2293 for( i=0; i<nFR; ++i )
2300 for ( i=0; i<nZ; ++i )
2305 for( j=0; j<nFR; ++j )
2309 for( i=0; i<nZ; ++i )
2310 ZHz[i] +=
Q[jj*
NVMAX + i] * Hz[j];
2319 for( i=0; i<nZ; ++i )
2326 for( j=0; j<nFR; ++j )
2327 rho2 +=
Q[FR_idx[j]*
NVMAX + nZ] * Hz[j];
2374 int tcol =
sizeT - nAC;
2387 int nnFRp1 = FR_idx[nFR];
2388 for( i=0; i<nFR; ++i )
2392 Q[nnFRp1*
NVMAX + i] = 0.0;
2394 Q[nnFRp1*
NVMAX + nFR] = 1.0;
2404 for( i=0; i<nAC; ++i )
2407 tmp[i] =
A[ii*
NVMAX + number];
2416 for( j=(nAC-1); j>=0; --j )
2420 for( i=(nAC-j); i<nAC; ++i )
2423 for( i=0; i<=nFR; ++i )
2444 for( i=0; i<nFR; ++i )
2448 for( j=0; j<nFR; ++j )
2451 for( i=0; i<nFR; ++i )
2463 for( i=0; i<nZ; ++i )
2467 for( j=0; j<nFR; ++j )
2470 for( i=0; i<nZ; ++i )
2472 rhs[i] +=
Q[jj*
NVMAX + i] * ( Hz[j] + z2 *
H[nnFRp1*
NVMAX + jj] );
2481 for( i=0; i<nZ; ++i )
2488 for( j=0; j<nFR; ++j )
2492 rho2 +=
Q[jj*
NVMAX + nZ] * ( Hz[j] + 2.0*z2*
H[nnFRp1*
NVMAX + jj] );
2537 if ( removingBound ==
BT_TRUE )
2549 for( i=(nR-1); i>=0; --i )
2552 for( j=(i+1); j<nR; ++j )
2553 sum -=
R[i*
NVMAX + j] * a[j];
2556 a[i] = sum /
R[i*
NVMAX + i];
2564 for( i=0; i<nR; ++i )
2568 for( j=0; j<i; ++j )
2569 sum -=
R[j*
NVMAX + i] * a[j];
2572 a[i] = sum /
R[i*
NVMAX + i];
2590 int tcol =
sizeT - nT;
2603 for( i=0; i<nT; ++i )
2606 for( j=0; j<i; ++j )
2618 for( i=0; i<nT; ++i )
2621 for( j=0; j<i; ++j )
2622 sum -=
T[(nT-1-j)*
NVMAX + tcol+i] * a[nT-1-j];
2625 a[nT-1-i] = sum /
T[(nT-1-i)*
NVMAX + tcol+i];
2658 for( i=0; i<nC; ++i )
2662 delta_lbA[i] = lbA_new[i] -
lbA[i];
2664 delta_lbA[i] = -
INFTY - lbA[i];
2667 for( i=0; i<nC; ++i )
2671 delta_ubA[i] = ubA_new[i] -
ubA[i];
2673 delta_ubA[i] =
INFTY - ubA[i];
2679 for ( i=0; i<nAC; ++i )
2698 const real_t*
const delta_g,
const real_t*
const delta_lbA,
const real_t*
const delta_ubA,
2699 const real_t*
const delta_lb,
const real_t*
const delta_ub,
2716 for( i=0; i<nFR; ++i )
2719 HMX_delta_xFX[i] = 0.0;
2720 YFR_delta_xFRy[i] = 0.0;
2721 ZFR_delta_xFRz[i] = 0.0;
2722 HFR_YFR_delta_xFRy[i] = 0.0;
2727 for( i=0; i<nZ; ++i )
2728 delta_xFRz[i] = 0.0;
2734 for( i=0; i<nFX; ++i )
2739 delta_xFX[i] = delta_lb[ii];
2741 delta_xFX[i] = delta_ub[ii];
2751 if ( ( Delta_bC_isZero ==
BT_TRUE ) && ( Delta_bB_isZero ==
BT_TRUE ) )
2753 for( i=0; i<nAC; ++i )
2754 delta_xFRy[i] = 0.0;
2756 for( i=0; i<nFR; ++i )
2764 for( i=0; i<nAC; ++i )
2769 delta_xFRy_TMP[i] = delta_lbA[ii];
2771 delta_xFRy_TMP[i] = delta_ubA[ii];
2775 for( j=0; j<nFX; ++j )
2778 delta_xFRy_TMP[i] -=
A[ii*
NVMAX + jj] * delta_xFX[j];
2786 for( i=0; i<nFR; ++i )
2789 for( j=0; j<nAC; ++j )
2790 YFR_delta_xFRy[i] +=
Q[ii*
NVMAX + nZ+j] * delta_xFRy[j];
2793 delta_xFR[i] = YFR_delta_xFRy[i];
2801 for( j=0; j<nFR; ++j )
2804 for( i=0; i<nZ; ++i )
2805 delta_xFRz[i] -=
Q[jj*
NVMAX + i] * delta_g[jj];
2810 for( i=0; i<nFR; ++i )
2813 for( j=0; j<nZ; ++j )
2814 ZFR_delta_xFRz[i] +=
Q[ii*
NVMAX + j] * delta_xFRz[j];
2816 delta_xFR[i] += ZFR_delta_xFRz[i];
2824 for( i=0; i<nFR; ++i )
2827 for( j=0; j<nFX; ++j )
2830 HMX_delta_xFX[i] +=
H[ii*
NVMAX + jj] * delta_xFX[j];
2839 for( i=0; i<nFR; ++i )
2842 for( j=0; j<nFR; ++j )
2845 HFR_YFR_delta_xFRy[i] +=
H[ii*
NVMAX + jj] * YFR_delta_xFRy[j];
2859 if ( ( nAC > 0 ) && ( nFX > 0 ) && ( Delta_bB_isZero ==
BT_FALSE ) )
2861 for( j=0; j<nFR; ++j )
2864 delta_xFRz_RHS[j] = delta_g[jj] + HFR_YFR_delta_xFRy[j] + HMX_delta_xFX[j];
2869 if ( ( nAC == 0 ) && ( Delta_bB_isZero ==
BT_TRUE ) )
2871 for( j=0; j<nFR; ++j )
2874 delta_xFRz_RHS[j] = delta_g[jj];
2881 for( j=0; j<nFR; ++j )
2884 delta_xFRz_RHS[j] = delta_g[jj] + HFR_YFR_delta_xFRy[j];
2889 for( j=0; j<nFR; ++j )
2892 delta_xFRz_RHS[j] = delta_g[jj] + HMX_delta_xFX[j];
2898 for( j=0; j<nFR; ++j )
2901 for( i=0; i<nZ; ++i )
2902 delta_xFRz[i] -=
Q[jj*
NVMAX + i] * delta_xFRz_RHS[j];
2913 for( i=0; i<nFR; ++i )
2916 for( j=0; j<nZ; ++j )
2917 ZFR_delta_xFRz[i] +=
Q[ii*
NVMAX + j] * delta_xFRz[j];
2919 delta_xFR[i] += ZFR_delta_xFRz[i];
2930 for( i=0; i<nAC; ++i )
2931 delta_yAC_TMP[i] = 0.0;
2933 for( i=0; i<nFR; ++i )
2934 delta_yAC_RHS[i] = 0.0;
2939 for( j=0; j<nAC; ++j )
2941 for( i=0; i<nFR; ++i )
2944 delta_yAC_TMP[j] +=
Q[ii*
NVMAX + nZ+j] * delta_g[ii];
2947 delta_yAC_TMP[j] += delta_xFRy[j];
2952 if ( ( Delta_bC_isZero ==
BT_TRUE ) && ( Delta_bB_isZero ==
BT_TRUE ) )
2954 for( i=0; i<nFR; ++i )
2957 delta_yAC_RHS[i] = delta_g[ii];
2962 for( i=0; i<nFR; ++i )
2965 delta_yAC_RHS[i] = HFR_YFR_delta_xFRy[i] + delta_g[ii];
2971 for( i=0; i<nFR; ++i )
2974 for( j=0; j<nFR; ++j )
2977 delta_yAC_RHS[i] +=
H[ii*
NVMAX + jj] * ZFR_delta_xFRz[j];
2986 for( i=0; i<nFR; ++i )
2987 delta_yAC_RHS[i] += HMX_delta_xFX[i];
2991 for( i=0; i<nAC; ++i)
2993 for( j=0; j<nFR; ++j )
2996 delta_yAC_TMP[i] +=
Q[jj*
NVMAX + nZ+i] * delta_yAC_RHS[j];
3009 for( i=0; i<nFX; ++i )
3013 delta_yFX[i] = delta_g[ii];
3015 for( j=0; j<nAC; ++j )
3018 delta_yFX[i] -=
A[jj*
NVMAX + ii] * delta_yAC[j];
3023 delta_yFX[i] += delta_xFX[i];
3027 for( j=0; j<nFR; ++j )
3030 delta_yFX[i] +=
H[ii*
NVMAX + jj] * delta_xFR[j];
3035 for( j=0; j<nFX; ++j )
3038 delta_yFX[i] +=
H[ii*
NVMAX + jj] * delta_xFX[j];
3053 const real_t*
const delta_lbA,
const real_t*
const delta_ubA,
3054 const real_t*
const delta_lb,
const real_t*
const delta_ub,
3055 const real_t*
const delta_xFX,
const real_t*
const delta_xFR,
3056 const real_t*
const delta_yAC,
const real_t*
const delta_yFX,
3070 for ( i=0; i<2*(nV+nC); ++i )
3071 maxStepLength[i] = 1.0;
3077 for( i=0; i<nAC; ++i )
3086 if ( delta_yAC[i] < -
ZERO )
3088 if (
y[nV+ii] > 0.0 )
3089 maxStepLength[nV+ii] =
y[nV+ii] / ( -delta_yAC[i] );
3091 maxStepLength[nV+ii] = 0.0;
3097 if ( delta_yAC[i] >
ZERO )
3099 if (
y[nV+ii] < 0.0 )
3100 maxStepLength[nV+ii] =
y[nV+ii] / ( -delta_yAC[i] );
3102 maxStepLength[nV+ii] = 0.0;
3110 for( i=0; i<nFX; ++i )
3119 if ( delta_yFX[i] < -
ZERO )
3122 maxStepLength[ii] =
y[ii] / ( -delta_yFX[i] );
3124 maxStepLength[ii] = 0.0;
3130 if ( delta_yFX[i] >
ZERO )
3133 maxStepLength[ii] =
y[ii] / ( -delta_yFX[i] );
3135 maxStepLength[ii] = 0.0;
3146 for( j=0; j<nFR; ++j )
3149 delta_x[jj] = delta_xFR[j];
3151 for( j=0; j<nFX; ++j )
3154 delta_x[jj] = delta_xFX[j];
3157 for( i=0; i<nIAC; ++i )
3164 for( j=0; j<nV; ++j )
3165 delta_Ax[ii] +=
A[ii*
NVMAX + j] * delta_x[j];
3170 if ( delta_lbA[ii] > delta_Ax[ii] )
3172 if (
Ax[ii] >
lbA[ii] )
3173 maxStepLength[nV+ii] = (
Ax[ii] -
lbA[ii] ) / ( delta_lbA[ii] - delta_Ax[ii] );
3175 maxStepLength[nV+ii] = 0.0;
3182 if ( delta_ubA[ii] < delta_Ax[ii] )
3184 if (
Ax[ii] <
ubA[ii] )
3185 maxStepLength[nV+nC+nV+ii] = (
Ax[ii] -
ubA[ii] ) / ( delta_ubA[ii] - delta_Ax[ii] );
3187 maxStepLength[nV+nC+nV+ii] = 0.0;
3199 for( i=0; i<nFR; ++i )
3203 if ( delta_lb[ii] > delta_xFR[i] )
3205 if (
x[ii] >
lb[ii] )
3206 maxStepLength[ii] = (
x[ii] -
lb[ii] ) / ( delta_lb[ii] - delta_xFR[i] );
3208 maxStepLength[ii] = 0.0;
3216 for( i=0; i<nFR; ++i )
3220 if ( delta_ub[ii] < delta_xFR[i] )
3222 if (
x[ii] <
ub[ii] )
3223 maxStepLength[nV+nC+ii] = (
x[ii] -
ub[ii] ) / ( delta_ub[ii] - delta_xFR[i] );
3225 maxStepLength[nV+nC+ii] = 0.0;
3238 for ( i=0; i<nV; ++i )
3241 if ( maxStepLength[i] < tau_new )
3243 tau_new = maxStepLength[i];
3253 if ( maxStepLength[nV+nC+i] < tau_new )
3255 tau_new = maxStepLength[nV+nC+i];
3262 for ( i=nV; i<nV+nC; ++i )
3265 if ( maxStepLength[i] < tau_new )
3267 tau_new = maxStepLength[i];
3277 if ( maxStepLength[nV+nC+i] < tau_new )
3279 tau_new = maxStepLength[nV+nC+i];
3289 if ( tau_new >
EPS )
3300 char messageString[80];
3303 sprintf( messageString,
"Stepsize is %.6e!",
tau );
3305 sprintf( messageString,
"Stepsize is %.6e! (BC_idx = %d, BC_isBound = %d, BC_status = %d)",
tau,BC_idx,BC_isBound,BC_status );
3319 const real_t*
const delta_g,
const real_t*
const delta_lbA,
const real_t*
const delta_ubA,
3320 const real_t*
const delta_lb,
const real_t*
const delta_ub,
3321 const real_t*
const delta_xFX,
const real_t*
const delta_xFR,
3322 const real_t*
const delta_yAC,
const real_t*
const delta_yFX,
3349 for( i=0; i<nFR; ++i )
3352 x[ii] +=
tau*delta_xFR[i];
3355 for( i=0; i<nFX; ++i )
3358 x[ii] +=
tau*delta_xFX[i];
3359 y[ii] +=
tau*delta_yFX[i];
3362 for( i=0; i<nAC; ++i )
3365 y[nV+ii] +=
tau*delta_yAC[i];
3369 for( i=0; i<nIAC; ++i )
3373 Ax[ii] +=
tau*delta_Ax[ii];
3375 for( i=0; i<nAC; ++i )
3380 for( j=0; j<nV; ++j )
3385 for( i=0; i<nV; ++i )
3387 g[i] +=
tau*delta_g[i];
3388 lb[i] +=
tau*delta_lb[i];
3389 ub[i] +=
tau*delta_ub[i];
3392 for( i=0; i<nC; ++i )
3394 lbA[i] +=
tau*delta_lbA[i];
3395 ubA[i] +=
tau*delta_ubA[i];
3402 char messageString[80];
3403 sprintf( messageString,
"Stepsize is %.6e",
tau );
3411 char messageString[80];
3422 switch ( BC_status )
3434 sprintf( messageString,
"bound no. %d.", BC_idx );
3446 sprintf( messageString,
"constraint no. %d.", BC_idx );
3464 sprintf( messageString,
"lower bound no. %d.", BC_idx );
3466 sprintf( messageString,
"upper bound no. %d.", BC_idx );
3477 sprintf( messageString,
"lower constraint's bound no. %d.", BC_idx );
3479 sprintf( messageString,
"upper constraint's bound no. %d.", BC_idx );
3497 const real_t*
const delta_lbA,
const real_t*
const delta_ubA
3509 for( i=0; i<
getNC( ); ++i )
3535 if ( ( nC > 0 ) && ( _A == 0 ) )
3540 for( i=0; i<nC; ++i )
3541 for( j=0; j<nV; ++j )
3542 A[i*
NVMAX + j] = _A[i*nV + j];
3547 for( i=0; i<nC; ++i )
3553 for( i=0; i<nC; ++i )
3560 for( i=0; i<nC; ++i )
3566 for( i=0; i<nC; ++i )
3590 char myPrintfString[160];
3593 if ( iteration < 0 )
3602 if ( iteration == 0 )
3604 sprintf( myPrintfString,
"\n############## qpOASES -- QP NO.%4.1d ###############\n",
count );
3607 sprintf( myPrintfString,
" Iter | StepLength | Info | nFX | nAC \n" );
3614 sprintf( myPrintfString,
" %4.1d | %1.5e | QP SOLVED | %4.1d | %4.1d \n", iteration,
tau,
getNFX( ),
getNAC( ) );
3622 sprintf( info,
"REM " );
3624 sprintf( info,
"ADD " );
3627 sprintf( &(info[4]),
"BND" );
3629 sprintf( &(info[4]),
"CON" );
3631 sprintf( myPrintfString,
" %4.1d | %1.5e | %s%4.1d | %4.1d | %4.1d \n", iteration,
tau,info,BC_idx,
getNFX( ),
getNAC( ) );
3658 #ifdef __PERFORM_KKT_TEST__ 3666 real_t maxKKTviolation = 0.0;
3672 for( i=0; i<nV; ++i )
3676 for( j=0; j<nV; ++j )
3682 for( j=0; j<nAC; ++j )
3685 tmp -=
A[jj*
NVMAX + i] *
y[nV+jj];
3688 if (
getAbs( tmp ) > maxKKTviolation )
3689 maxKKTviolation =
getAbs( tmp );
3694 for( i=0; i<nC; ++i )
3696 if (
lbA[i] -
Ax[i] > maxKKTviolation )
3697 maxKKTviolation =
lbA[i] -
Ax[i];
3699 if ( Ax[i] -
ubA[i] > maxKKTviolation )
3700 maxKKTviolation = Ax[i] -
ubA[i];
3704 for( i=0; i<nV; ++i )
3706 if (
lb[i] -
x[i] > maxKKTviolation )
3707 maxKKTviolation =
lb[i] -
x[i];
3709 if ( x[i] -
ub[i] > maxKKTviolation )
3710 maxKKTviolation = x[i] -
ub[i];
3715 for( i=0; i<nV; ++i )
3720 if ( -
y[i] > maxKKTviolation )
3721 maxKKTviolation = -
y[i];
3722 if (
getAbs(
x[i] -
lb[i] ) > maxKKTviolation )
3723 maxKKTviolation =
getAbs(
x[i] -
lb[i] );
3727 if (
y[i] > maxKKTviolation )
3728 maxKKTviolation =
y[i];
3729 if (
getAbs(
ub[i] -
x[i] ) > maxKKTviolation )
3730 maxKKTviolation =
getAbs(
ub[i] -
x[i] );
3734 if (
getAbs(
y[i] ) > maxKKTviolation )
3735 maxKKTviolation =
getAbs(
y[i] );
3741 for( i=0; i<nC; ++i )
3746 if ( -
y[nV+i] > maxKKTviolation )
3747 maxKKTviolation = -
y[nV+i];
3753 if (
y[nV+i] > maxKKTviolation )
3754 maxKKTviolation =
y[nV+i];
3760 if (
getAbs(
y[nV+i] ) > maxKKTviolation )
3761 maxKKTviolation =
getAbs(
y[nV+i] );
BooleanType areBoundsConsistent(const real_t *const delta_lb, const real_t *const delta_ub, const real_t *const delta_lbA, const real_t *const delta_ubA) const
returnValue addConstraint_ensureLI(int number, SubjectToStatus C_status)
returnValue setupCholeskyDecomposition()
void setNoLower(BooleanType _status)
returnValue addBound_ensureLI(int number, SubjectToStatus B_status)
returnValue setType(int i, SubjectToType value)
returnValue init(const real_t *const _H, const real_t *const _g, const real_t *const _A, const real_t *const _lb, const real_t *const _ub, const real_t *const _lbA, const real_t *const _ubA, int &nWSR, const real_t *const yOpt=0, real_t *const cputime=0)
IntermediateState sqrt(const Expression &arg)
BooleanType isInfeasible() const
returnValue hotstart_determineStepDirection(const int *const FR_idx, const int *const FX_idx, const int *const AC_idx, const real_t *const delta_g, const real_t *const delta_lbA, const real_t *const delta_ubA, const real_t *const delta_lb, const real_t *const delta_ub, BooleanType Delta_bC_isZero, BooleanType Delta_bB_isZero, real_t *const delta_xFX, real_t *const delta_xFR, real_t *const delta_yAC, real_t *const delta_yFX)
Manages working sets of constraints.
returnValue swapFree(int number1, int number2)
returnValue addConstraint_checkLI(int number)
returnValue removeConstraint(int number, BooleanType updateCholesky)
returnValue moveInactiveToActive(int _number, SubjectToStatus _status)
returnValue hotstart_determineDataShift(const int *const FX_idx, const int *const AC_idx, const real_t *const g_new, const real_t *const lbA_new, const real_t *const ubA_new, const real_t *const lb_new, const real_t *const ub_new, real_t *const delta_g, real_t *const delta_lbA, real_t *const delta_ubA, real_t *const delta_lb, real_t *const delta_ub, BooleanType &Delta_bC_isZero, BooleanType &Delta_bB_isZero)
BooleanType isNoLower() const
returnValue setNEC(int n)
Implements the online active set strategy for box-constrained QPs.
returnValue setupAuxiliaryQPgradient()
returnValue getNumberArray(int *const numberarray) const
returnValue moveFixedToFree(int _number)
int getLastNumber() const
BooleanType isUnbounded() const
returnValue setupAuxiliaryQPsolution(const real_t *const xOpt, const real_t *const yOpt)
returnValue hotstart_determineStepLength(const int *const FR_idx, const int *const FX_idx, const int *const AC_idx, const int *const IAC_idx, const real_t *const delta_lbA, const real_t *const delta_ubA, const real_t *const delta_lb, const real_t *const delta_ub, const real_t *const delta_xFX, const real_t *const delta_xFR, const real_t *const delta_yAC, const real_t *const delta_yFX, real_t *const delta_Ax, int &BC_idx, SubjectToStatus &BC_status, BooleanType &BC_isBound)
returnValue checkForIdentityHessian()
void computeGivens(real_t xold, real_t yold, real_t &xnew, real_t &ynew, real_t &c, real_t &s) const
BEGIN_NAMESPACE_ACADO const double EPS
returnValue setNIC(int n)
#define THROWINFO(retval)
returnValue obtainAuxiliaryWorkingSet(const real_t *const xOpt, const real_t *const yOpt, const Bounds *const guessedBounds, Bounds *auxiliaryBounds) const
returnValue throwInfo(returnValue Inumber, const char *additionaltext, const char *functionname, const char *filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus)
const real_t CRITICALACCURACY
Allows to pass back messages to the calling function.
#define THROWERROR(retval)
Indexlist * getInactive()
returnValue hotstart(const real_t *const g_new, const real_t *const lb_new, const real_t *const ub_new, const real_t *const lbA_new, const real_t *const ubA_new, int &nWSR, real_t *const cputime)
CyclingManager cyclingManager
returnValue throwWarning(returnValue Wnumber, const char *additionaltext, const char *functionname, const char *filename, const unsigned long linenumber, VisibilityStatus localVisibilityStatus)
returnValue setupAllInactive()
returnValue myPrintf(const char *s)
returnValue obtainAuxiliaryWorkingSet(const real_t *const xOpt, const real_t *const yOpt, const Bounds *const guessedBounds, const Constraints *const guessedConstraints, Bounds *auxiliaryBounds, Constraints *auxiliaryConstraints) const
returnValue solveInitialQP(const real_t *const xOpt, const real_t *const yOpt, const Bounds *const guessedBounds, const Constraints *const guessedConstraints, int &nWSR, real_t *const cputime)
returnValue setupCholeskyDecompositionProjected()
returnValue setupQPdata(const real_t *const _H, const real_t *const _g, const real_t *const _A, const real_t *const _lb, const real_t *const _ub, const real_t *const _lbA, const real_t *const _ubA)
returnValue backsolveT(const real_t *const b, BooleanType transposed, real_t *const a)
returnValue setupSubjectToType()
SubjectToStatus getStatus(int i) const
returnValue hotstart_performStep(const int *const FR_idx, const int *const FX_idx, const int *const AC_idx, const int *const IAC_idx, const real_t *const delta_g, const real_t *const delta_lbA, const real_t *const delta_ubA, const real_t *const delta_lb, const real_t *const delta_ub, const real_t *const delta_xFX, const real_t *const delta_xFR, const real_t *const delta_yAC, const real_t *const delta_yFX, const real_t *const delta_Ax, int BC_idx, SubjectToStatus BC_status, BooleanType BC_isBound)
returnValue setupQPdata(const real_t *const _H, const real_t *const _g, const real_t *const _lb, const real_t *const _ub)
returnValue setupAuxiliaryQPbounds(const Bounds *const auxiliaryBounds, const Constraints *const auxiliaryConstraints, BooleanType useRelaxation)
returnValue setupSubjectToType()
returnValue setupAllFree()
returnValue setupConstraint(int _number, SubjectToStatus _status)
real_t A[NCMAX_ALLOC *NVMAX]
CyclingStatus getCyclingStatus(int number, BooleanType isBound) const
BooleanType areBoundsConsistent(const real_t *const delta_lb, const real_t *const delta_ub) const
void printmatrix2(char *name, double *A, int m, int n)
returnValue checkKKTconditions()
void rhs(const real_t *x, real_t *f)
returnValue addBound(int number, SubjectToStatus B_status, BooleanType updateCholesky)
SubjectToType getType(int i) const
BooleanType isNoUpper() const
QProblemStatus getStatus() const
returnValue removeBound(int number, BooleanType updateCholesky)
returnValue moveActiveToInactive(int _number)
const real_t DESIREDACCURACY
returnValue hotstart_determineDataShift(const int *const FX_idx, const real_t *const g_new, const real_t *const lb_new, const real_t *const ub_new, real_t *const delta_g, real_t *const delta_lb, real_t *const delta_ub, BooleanType &Delta_bB_isZero)
returnValue setNUC(int n)
void setNoUpper(BooleanType _status)
QProblemB & operator=(const QProblemB &rhs)
returnValue init(int _nV, int _nC)
int getIndex(int givennumber) const
Manages working sets of bounds (= box constraints).
returnValue backsolveR(const real_t *const b, BooleanType transposed, real_t *const a)
returnValue setCyclingStatus(int number, BooleanType isBound, CyclingStatus _status)
returnValue printIteration(int iteration, int BC_idx, SubjectToStatus BC_status, BooleanType BC_isBound)
Implements the online active set strategy for QPs with general constraints.
returnValue setupAuxiliaryWorkingSet(const Bounds *const auxiliaryBounds, const Constraints *const auxiliaryConstraints, BooleanType setupAfresh)
returnValue clearCyclingData()
void applyGivens(real_t c, real_t s, real_t xold, real_t yold, real_t &xnew, real_t &ynew) const
QProblem & operator=(const QProblem &rhs)
MessageHandling * getGlobalMessageHandler()
returnValue addBound_checkLI(int number)
returnValue setupTQfactorisation()
const double BOUNDRELAXATION
returnValue addConstraint(int number, SubjectToStatus C_status, BooleanType updateCholesky)
returnValue moveFreeToFixed(int _number, SubjectToStatus _status)
returnValue getDualSolution(real_t *const yOpt) const