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]);
64 constraints.
init( 0 );
68 cyclingManager.init( 0,0 );
87 constraints.init( _nC );
94 cyclingManager.init( _nV,_nC );
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 )
325 char messageString[80];
330 for( l=0; l<
nWSR; ++l )
337 sprintf( messageString,
"%d ...",l );
358 delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub,
359 Delta_bC_isZero, Delta_bB_isZero );
369 delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub,
370 Delta_bC_isZero, Delta_bB_isZero,
371 delta_xFX,delta_xFR,delta_yAC,delta_yFX
382 delta_lbA,delta_ubA,delta_lb,delta_ub,
383 delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax,
384 BC_idx,BC_status,BC_isBound
395 delta_g,delta_lbA,delta_ubA,delta_lb,delta_ub,
396 delta_xFX,delta_xFR,delta_yAC,delta_yFX,delta_Ax,
397 BC_idx,BC_status,BC_isBound
463 sprintf( messageString,
"(nWSR = %d)",nWSR );
472 return returnvalueKKTcheck;
535 for( i=0; i<nC; ++i )
546 for( i=0; i<nC; ++i )
559 for( i=0; i<nC; ++i )
600 for( i=0; i<nV; ++i )
601 for( j=0; j<nV; ++j )
608 for( i=0; i<nV; ++i )
624 for ( i=0; i<nFR; ++i )
628 for ( j=0; j<nZ; ++j )
631 for ( k=0; k<nFR; ++k )
636 HZ[i *
NVMAX + j] = sum;
641 for ( i=0; i<nZ; ++i )
642 for ( j=0; j<nZ; ++j )
645 for ( k=0; k<nFR; ++k )
650 ZHZ[i *
NVMAX + j] = sum;
656 for( i=0; i<nZ; ++i )
659 sum = ZHZ[i*
NVMAX + i];
661 for( k=(i-1); k>=0; --k )
667 inv = 1.0 /
R[i *
NVMAX + i];
675 for( j=(i+1); j<nZ; ++j )
677 sum = ZHZ[j*
NVMAX + i];
679 for( k=(i-1); k>=0; --k )
682 R[i*
NVMAX + j] = sum * inv;
690 for (j = 0; j < nZ; ++j)
693 for (i = 0; i <
NVMAX; ++i)
694 ZHZ[i] =
Q[i * NVMAX + j];
697 for (i = 0; i < nFR; ++i)
702 for (k = 0; k < nFR; ++k)
705 sum +=
H[ii * NVMAX + kk] * ZHZ[kk];
711 for (i = j; i < nZ; ++i)
714 for (k = 0; k < nFR; ++k)
718 for (i = j; i < nZ; ++i)
720 ZHZ[i] +=
Q[kk * NVMAX + i] * q;
728 for (k = (j - 1); k >= 0; --k)
729 sum -=
R[k * NVMAX + j] *
R[k * NVMAX + j];
733 R[j * NVMAX + j] =
sqrt(sum);
734 inv = 1.0 /
R[j * NVMAX + j];
742 for (i = (j + 1); i < nZ; ++i)
746 for (k = (j - 1); k >= 0; --k)
747 sum -=
R[k * NVMAX + j] *
R[k * NVMAX + i];
749 R[j * NVMAX + i] = sum * inv;
774 for( i=0; i<nV; ++i )
775 for( j=0; j<nV; ++j )
778 for( i=0; i<nFR; ++i )
785 for( i=0; i<
sizeT; ++i )
786 for( j=0; j<
sizeT; ++j )
845 static Bounds auxiliaryBounds;
847 auxiliaryBounds.
init( nV );
851 auxiliaryConstraints.
init( nC );
888 for( i=0; i<nV; ++i )
890 g_original[i] =
g[i];
891 lb_original[i] =
lb[i];
892 ub_original[i] =
ub[i];
895 for( i=0; i<nC; ++i )
897 lbA_original[i] =
lbA[i];
898 ubA_original[i] =
ubA[i];
955 if ( ( auxiliaryBounds == 0 ) || ( auxiliaryBounds == guessedBounds ) )
958 if ( ( auxiliaryConstraints == 0 ) || ( auxiliaryConstraints == guessedConstraints ) )
969 if ( guessedConstraints != 0 )
973 for( i=0; i<nC; ++i )
975 guessedStatus = guessedConstraints->
getStatus( i );
992 if ( (
xOpt != 0 ) && ( yOpt == 0 ) )
994 for( i=0; i<nC; ++i )
1025 if ( (
xOpt == 0 ) && ( yOpt != 0 ) )
1027 for( i=0; i<nC; ++i )
1029 if ( yOpt[nV+i] >
ZERO )
1036 if ( yOpt[nV+i] < -
ZERO )
1060 if ( (
xOpt == 0 ) && ( yOpt == 0 ) )
1062 for( i=0; i<nC; ++i )
1097 if ( auxiliaryBounds != 0 )
1099 for( i=0; i<nV; ++i )
1108 if ( auxiliaryConstraints != 0 )
1110 for( i=0; i<nC; ++i )
1135 for( i=0; i<nC; ++i )
1148 for( i=0; i<nV; ++i )
1164 for( i=0; i<nV; ++i )
1179 for( i=0; i<nC; ++i )
1217 for( i=0; i<nV; ++i )
1220 for ( j=0; j<nC; ++j )
1224 for( i=0; i<nV; ++i )
1230 for( i=0; i<nV; ++i )
1233 for ( j=0; j<nC; ++j )
1240 for( i=0; i<nV+nC; ++i )
1245 for( i=0; i<nV+nC; ++i )
1264 for ( i=0; i<nV; ++i )
1270 for ( j=0; j<nC; ++j )
1274 for ( j=0; j<nV; ++j )
1296 for ( i=0; i<nV; ++i )
1301 if ( useRelaxation ==
BT_TRUE )
1334 if ( useRelaxation ==
BT_TRUE )
1347 if ( useRelaxation ==
BT_TRUE )
1358 for ( i=0; i<nC; ++i )
1363 if ( useRelaxation ==
BT_TRUE )
1396 if ( useRelaxation ==
BT_TRUE )
1409 if ( useRelaxation ==
BT_TRUE )
1451 if ( updateCholesky ==
BT_TRUE )
1455 switch ( ensureLIreturnvalue )
1479 int tcol =
sizeT - nAC;
1488 for( i=0; i<nZ; ++i )
1494 for( i=0; i<nFR; ++i )
1497 aFR[i] =
A[number*
NVMAX + ii];
1501 for( i=0; i<nFR; ++i )
1504 for( j=0; j<nZ; ++j )
1505 wZ[j] += aFR[i] *
Q[ii*
NVMAX + j];
1511 for( j=0; j<nAC; ++j )
1512 T[nAC*
NVMAX + tcol+j] = 0.0;
1513 for( i=0; i<nFR; ++i )
1516 for( j=0; j<nAC; ++j )
1529 for( j=0; j<nZ-1; ++j )
1533 for( i=0; i<nFR; ++i )
1541 for( i=0; i<=j+1; ++i )
1546 T[nAC*
NVMAX + tcol-1] = wZ[nZ-1];
1553 for( i=0; i<nZ-1; ++i )
1557 for( j=(1+i); j<(nZ-1); ++j )
1561 for( i=0; i<nZ; ++i )
1594 for( i=0; i<nZ; ++i )
1597 for( j=0; j<nFR; ++j )
1656 for( i=0; i<nAC; ++i )
1659 for( j=0; j<nFR; ++j )
1662 xiC_TMP[i] +=
Q[jj*
NVMAX + nZ+i] *
A[number*
NVMAX + jj];
1668 for( i=0; i<nAC; ++i )
1671 for( j=0; j<nFR; ++j )
1674 xiC_TMP[i] -=
Q[jj*
NVMAX + nZ+i] *
A[number*
NVMAX + jj];
1690 for( i=0; i<nFX; ++i )
1693 xiB[i] =
A[number*
NVMAX + ii];
1695 for( j=0; j<nAC; ++j )
1698 xiB[i] -=
A[jj*
NVMAX + ii] * xiC[j];
1704 for( i=0; i<nFX; ++i )
1707 xiB[i] = -
A[number*
NVMAX + ii];
1709 for( j=0; j<nAC; ++j )
1712 xiB[i] -=
A[jj*
NVMAX + ii] * xiC[j];
1720 int y_min_number = -1;
1724 for( i=0; i<nAC; ++i )
1730 if ( ( xiC[i] >
ZERO ) && (
y[nV+ii] >= 0.0 ) )
1732 if (
y[nV+ii]/xiC[i] < y_min )
1734 y_min =
y[nV+ii]/xiC[i];
1741 if ( ( xiC[i] < -
ZERO ) && (
y[nV+ii] <= 0.0 ) )
1743 if (
y[nV+ii]/xiC[i] < y_min )
1745 y_min =
y[nV+ii]/xiC[i];
1753 for( i=0; i<nFX; ++i )
1759 if ( ( xiB[i] >
ZERO ) && (
y[ii] >= 0.0 ) )
1761 if (
y[ii]/xiB[i] < y_min )
1763 y_min =
y[ii]/xiB[i];
1771 if ( ( xiB[i] < -
ZERO ) && (
y[ii] <= 0.0 ) )
1773 if (
y[ii]/xiB[i] < y_min )
1775 y_min =
y[ii]/xiB[i];
1785 char messageString[80];
1796 if ( y_min_number >= 0 )
1815 for( i=0; i<nAC; ++i )
1818 y[nV+ii] -= y_min * xiC[i];
1820 for( i=0; i<nFX; ++i )
1823 y[ii] -= y_min * xiB[i];
1828 y[nV+number] = y_min;
1830 y[nV+number] = -y_min;
1833 if ( y_min_isBound ==
BT_TRUE )
1836 sprintf( messageString,
"bound no. %d.",y_min_number );
1843 y[y_min_number] = 0.0;
1848 sprintf( messageString,
"constraint no. %d.",y_min_number );
1855 y[nV+y_min_number] = 0.0;
1899 if ( updateCholesky ==
BT_TRUE )
1903 switch ( ensureLIreturnvalue )
1928 int tcol =
sizeT - nAC;
1934 if ( lastfreenumber != number )
1948 for( i=0; i<nFR; ++i )
1949 w[i] =
Q[FR_idx[nFR-1]*
NVMAX + i];
1956 for( j=0; j<nZ-1; ++j )
1960 for( i=0; i<nFR; ++i )
1968 for( i=0; i<=j+1; ++i )
1978 for( i=0; i<nAC; ++i )
1986 for( i=0; i<nFR; ++i )
1995 for( j=nZ; j<nFR-1; ++j )
1999 for( i=0; i<nFR; ++i )
2005 for( i=(nFR-2-j); i<nAC; ++i )
2016 for( i=0; i<nZ-1; ++i )
2020 for( j=(1+i); j<nZ-1; ++j )
2024 for( i=0; i<nZ; ++i )
2049 for( i=0; i<nZ; ++i )
2104 for( i=0; i<nAC; ++i )
2105 xiC_TMP[i] =
Q[number*
NVMAX + nZ+i];
2109 for( i=0; i<nAC; ++i )
2110 xiC_TMP[i] = -
Q[number*
NVMAX + nZ+i];
2118 for( i=0; i<nFX; ++i )
2123 for( j=0; j<nAC; ++j )
2126 xiB[i] -=
A[jj*
NVMAX + ii] * xiC[j];
2133 int y_min_number = -1;
2137 for( i=0; i<nAC; ++i )
2143 if ( ( xiC[i] >
ZERO ) && (
y[nV+ii] >= 0.0 ) )
2145 if (
y[nV+ii]/xiC[i] < y_min )
2147 y_min =
y[nV+ii]/xiC[i];
2154 if ( ( xiC[i] < -
ZERO ) && (
y[nV+ii] <= 0.0 ) )
2156 if (
y[nV+ii]/xiC[i] < y_min )
2158 y_min =
y[nV+ii]/xiC[i];
2166 for( i=0; i<nFX; ++i )
2172 if ( ( xiB[i] >
ZERO ) && (
y[ii] >= 0.0 ) )
2174 if (
y[ii]/xiB[i] < y_min )
2176 y_min =
y[ii]/xiB[i];
2184 if ( ( xiB[i] < -
ZERO ) && (
y[ii] <= 0.0 ) )
2186 if (
y[ii]/xiB[i] < y_min )
2188 y_min =
y[ii]/xiB[i];
2198 char messageString[80];
2209 if ( y_min_number >= 0 )
2229 for( i=0; i<nAC; ++i )
2232 y[nV+ii] -= y_min * xiC[i];
2234 for( i=0; i<nFX; ++i )
2237 y[ii] -= y_min * xiB[i];
2247 if ( y_min_isBound ==
BT_TRUE )
2250 sprintf( messageString,
"bound no. %d.",y_min_number );
2257 y[y_min_number] = 0.0;
2262 sprintf( messageString,
"constraint no. %d.",y_min_number );
2269 y[nV+y_min_number] = 0.0;
2308 int tcol =
sizeT - nAC;
2316 if ( ( number_idx < 0 ) || ( number_idx >= nAC ) )
2328 if ( number_idx < nAC-1 )
2330 for( i=(number_idx+1); i<nAC; ++i )
2331 for( j=(nAC-i-1); j<nAC; ++j )
2334 for( j=0; j<nAC; ++j )
2335 T[(nAC-1)*
NVMAX + tcol+j] = 0.0;
2343 for( j=(nAC-2-number_idx); j>=0; --j )
2347 for( i=(nAC-j-1); i<(nAC-1); ++i )
2350 for( i=0; i<nFR; ++i )
2360 for( j=0; j<nAC; ++j )
2361 T[(nAC-1)*
NVMAX + tcol+j] = 0.0;
2371 for ( i=0; i<nFR; ++i )
2377 for( j=0; j<nFR; ++j )
2380 for( i=0; i<nFR; ++i )
2387 for ( i=0; i<nZ; ++i )
2392 for( j=0; j<nFR; ++j )
2396 for( i=0; i<nZ; ++i )
2397 ZHz[i] +=
Q[jj*
NVMAX + i] * Hz[j];
2406 for( i=0; i<nZ; ++i )
2413 for( j=0; j<nFR; ++j )
2414 rho2 +=
Q[FR_idx[j]*
NVMAX + nZ] * Hz[j];
2461 int tcol =
sizeT - nAC;
2474 int nnFRp1 = FR_idx[nFR];
2475 for( i=0; i<nFR; ++i )
2479 Q[nnFRp1*
NVMAX + i] = 0.0;
2481 Q[nnFRp1*
NVMAX + nFR] = 1.0;
2491 for( i=0; i<nAC; ++i )
2494 tmp[i] =
A[ii*
NVMAX + number];
2503 for( j=(nAC-1); j>=0; --j )
2507 for( i=(nAC-j); i<nAC; ++i )
2510 for( i=0; i<=nFR; ++i )
2531 for( i=0; i<nFR; ++i )
2535 for( j=0; j<nFR; ++j )
2538 for( i=0; i<nFR; ++i )
2550 for( i=0; i<nZ; ++i )
2554 for( j=0; j<nFR; ++j )
2557 for( i=0; i<nZ; ++i )
2559 rhs[i] +=
Q[jj*
NVMAX + i] * ( Hz[j] + z2 *
H[nnFRp1*
NVMAX + jj] );
2568 for( i=0; i<nZ; ++i )
2575 for( j=0; j<nFR; ++j )
2579 rho2 +=
Q[jj*
NVMAX + nZ] * ( Hz[j] + 2.0*z2*
H[nnFRp1*
NVMAX + jj] );
2624 if ( removingBound ==
BT_TRUE )
2636 for( i=(nR-1); i>=0; --i )
2639 for( j=(i+1); j<nR; ++j )
2640 sum -=
R[i*
NVMAX + j] * a[j];
2643 a[i] = sum /
R[i*
NVMAX + i];
2651 for( i=0; i<nR; ++i )
2655 for( j=0; j<i; ++j )
2656 sum -=
R[j*
NVMAX + i] * a[j];
2659 a[i] = sum /
R[i*
NVMAX + i];
2677 int tcol =
sizeT - nT;
2690 for( i=0; i<nT; ++i )
2693 for( j=0; j<i; ++j )
2705 for( i=0; i<nT; ++i )
2708 for( j=0; j<i; ++j )
2709 sum -=
T[(nT-1-j)*
NVMAX + tcol+i] * a[nT-1-j];
2712 a[nT-1-i] = sum /
T[(nT-1-i)*
NVMAX + tcol+i];
2745 for( i=0; i<nC; ++i )
2751 delta_lbA[i] = -
INFTY - lbA[i];
2754 for( i=0; i<nC; ++i )
2760 delta_ubA[i] =
INFTY - ubA[i];
2766 for ( i=0; i<nAC; ++i )
2785 const real_t*
const delta_g,
const real_t*
const delta_lbA,
const real_t*
const delta_ubA,
2786 const real_t*
const delta_lb,
const real_t*
const delta_ub,
2803 for( i=0; i<nFR; ++i )
2806 HMX_delta_xFX[i] = 0.0;
2807 YFR_delta_xFRy[i] = 0.0;
2808 ZFR_delta_xFRz[i] = 0.0;
2809 HFR_YFR_delta_xFRy[i] = 0.0;
2814 for( i=0; i<nZ; ++i )
2815 delta_xFRz[i] = 0.0;
2821 for( i=0; i<nFX; ++i )
2826 delta_xFX[i] = delta_lb[ii];
2828 delta_xFX[i] = delta_ub[ii];
2838 if ( ( Delta_bC_isZero ==
BT_TRUE ) && ( Delta_bB_isZero ==
BT_TRUE ) )
2840 for( i=0; i<nAC; ++i )
2841 delta_xFRy[i] = 0.0;
2843 for( i=0; i<nFR; ++i )
2851 for( i=0; i<nAC; ++i )
2856 delta_xFRy_TMP[i] = delta_lbA[ii];
2858 delta_xFRy_TMP[i] = delta_ubA[ii];
2862 for( j=0; j<nFX; ++j )
2865 delta_xFRy_TMP[i] -=
A[ii*
NVMAX + jj] * delta_xFX[j];
2873 for( i=0; i<nFR; ++i )
2876 for( j=0; j<nAC; ++j )
2877 YFR_delta_xFRy[i] +=
Q[ii*
NVMAX + nZ+j] * delta_xFRy[j];
2880 delta_xFR[i] = YFR_delta_xFRy[i];
2888 for( j=0; j<nFR; ++j )
2891 for( i=0; i<nZ; ++i )
2892 delta_xFRz[i] -=
Q[jj*
NVMAX + i] * delta_g[jj];
2897 for( i=0; i<nFR; ++i )
2900 for( j=0; j<nZ; ++j )
2901 ZFR_delta_xFRz[i] +=
Q[ii*
NVMAX + j] * delta_xFRz[j];
2903 delta_xFR[i] += ZFR_delta_xFRz[i];
2911 for( i=0; i<nFR; ++i )
2914 for( j=0; j<nFX; ++j )
2917 HMX_delta_xFX[i] +=
H[ii*
NVMAX + jj] * delta_xFX[j];
2926 for( i=0; i<nFR; ++i )
2929 for( j=0; j<nFR; ++j )
2932 HFR_YFR_delta_xFRy[i] +=
H[ii*
NVMAX + jj] * YFR_delta_xFRy[j];
2946 if ( ( nAC > 0 ) && ( nFX > 0 ) && ( Delta_bB_isZero ==
BT_FALSE ) )
2948 for( j=0; j<nFR; ++j )
2951 delta_xFRz_RHS[j] = delta_g[jj] + HFR_YFR_delta_xFRy[j] + HMX_delta_xFX[j];
2956 if ( ( nAC == 0 ) && ( Delta_bB_isZero ==
BT_TRUE ) )
2958 for( j=0; j<nFR; ++j )
2961 delta_xFRz_RHS[j] = delta_g[jj];
2968 for( j=0; j<nFR; ++j )
2971 delta_xFRz_RHS[j] = delta_g[jj] + HFR_YFR_delta_xFRy[j];
2976 for( j=0; j<nFR; ++j )
2979 delta_xFRz_RHS[j] = delta_g[jj] + HMX_delta_xFX[j];
2985 for( j=0; j<nFR; ++j )
2988 for( i=0; i<nZ; ++i )
2989 delta_xFRz[i] -=
Q[jj*
NVMAX + i] * delta_xFRz_RHS[j];
3000 for( i=0; i<nFR; ++i )
3003 for( j=0; j<nZ; ++j )
3004 ZFR_delta_xFRz[i] +=
Q[ii*
NVMAX + j] * delta_xFRz[j];
3006 delta_xFR[i] += ZFR_delta_xFRz[i];
3017 for( i=0; i<nAC; ++i )
3018 delta_yAC_TMP[i] = 0.0;
3020 for( i=0; i<nFR; ++i )
3021 delta_yAC_RHS[i] = 0.0;
3026 for( j=0; j<nAC; ++j )
3028 for( i=0; i<nFR; ++i )
3031 delta_yAC_TMP[j] +=
Q[ii*
NVMAX + nZ+j] * delta_g[ii];
3034 delta_yAC_TMP[j] += delta_xFRy[j];
3039 if ( ( Delta_bC_isZero ==
BT_TRUE ) && ( Delta_bB_isZero ==
BT_TRUE ) )
3041 for( i=0; i<nFR; ++i )
3044 delta_yAC_RHS[i] = delta_g[ii];
3049 for( i=0; i<nFR; ++i )
3052 delta_yAC_RHS[i] = HFR_YFR_delta_xFRy[i] + delta_g[ii];
3058 for( i=0; i<nFR; ++i )
3061 for( j=0; j<nFR; ++j )
3064 delta_yAC_RHS[i] +=
H[ii*
NVMAX + jj] * ZFR_delta_xFRz[j];
3073 for( i=0; i<nFR; ++i )
3074 delta_yAC_RHS[i] += HMX_delta_xFX[i];
3078 for( i=0; i<nAC; ++i)
3080 for( j=0; j<nFR; ++j )
3083 delta_yAC_TMP[i] +=
Q[jj*
NVMAX + nZ+i] * delta_yAC_RHS[j];
3096 for( i=0; i<nFX; ++i )
3100 delta_yFX[i] = delta_g[ii];
3102 for( j=0; j<nAC; ++j )
3105 delta_yFX[i] -=
A[jj*
NVMAX + ii] * delta_yAC[j];
3110 delta_yFX[i] += delta_xFX[i];
3114 for( j=0; j<nFR; ++j )
3117 delta_yFX[i] +=
H[ii*
NVMAX + jj] * delta_xFR[j];
3122 for( j=0; j<nFX; ++j )
3125 delta_yFX[i] +=
H[ii*
NVMAX + jj] * delta_xFX[j];
3140 const real_t*
const delta_lbA,
const real_t*
const delta_ubA,
3141 const real_t*
const delta_lb,
const real_t*
const delta_ub,
3142 const real_t*
const delta_xFX,
const real_t*
const delta_xFR,
3143 const real_t*
const delta_yAC,
const real_t*
const delta_yFX,
3157 for ( i=0; i<2*(nV+nC); ++i )
3158 maxStepLength[i] = 1.0;
3164 for( i=0; i<nAC; ++i )
3173 if ( delta_yAC[i] < -
ZERO )
3175 if (
y[nV+ii] > 0.0 )
3176 maxStepLength[nV+ii] =
y[nV+ii] / ( -delta_yAC[i] );
3178 maxStepLength[nV+ii] = 0.0;
3184 if ( delta_yAC[i] >
ZERO )
3186 if (
y[nV+ii] < 0.0 )
3187 maxStepLength[nV+ii] =
y[nV+ii] / ( -delta_yAC[i] );
3189 maxStepLength[nV+ii] = 0.0;
3197 for( i=0; i<nFX; ++i )
3206 if ( delta_yFX[i] < -
ZERO )
3209 maxStepLength[ii] =
y[ii] / ( -delta_yFX[i] );
3211 maxStepLength[ii] = 0.0;
3217 if ( delta_yFX[i] >
ZERO )
3220 maxStepLength[ii] =
y[ii] / ( -delta_yFX[i] );
3222 maxStepLength[ii] = 0.0;
3233 for( j=0; j<nFR; ++j )
3236 delta_x[jj] = delta_xFR[j];
3238 for( j=0; j<nFX; ++j )
3241 delta_x[jj] = delta_xFX[j];
3244 for( i=0; i<nIAC; ++i )
3251 for( j=0; j<nV; ++j )
3252 delta_Ax[ii] +=
A[ii*
NVMAX + j] * delta_x[j];
3257 if ( delta_lbA[ii] > delta_Ax[ii] )
3259 if (
Ax[ii] >
lbA[ii] )
3260 maxStepLength[nV+ii] = (
Ax[ii] -
lbA[ii] ) / ( delta_lbA[ii] - delta_Ax[ii] );
3262 maxStepLength[nV+ii] = 0.0;
3269 if ( delta_ubA[ii] < delta_Ax[ii] )
3271 if (
Ax[ii] <
ubA[ii] )
3272 maxStepLength[nV+nC+nV+ii] = (
Ax[ii] -
ubA[ii] ) / ( delta_ubA[ii] - delta_Ax[ii] );
3274 maxStepLength[nV+nC+nV+ii] = 0.0;
3286 for( i=0; i<nFR; ++i )
3290 if ( delta_lb[ii] > delta_xFR[i] )
3292 if (
x[ii] >
lb[ii] )
3293 maxStepLength[ii] = (
x[ii] -
lb[ii] ) / ( delta_lb[ii] - delta_xFR[i] );
3295 maxStepLength[ii] = 0.0;
3303 for( i=0; i<nFR; ++i )
3307 if ( delta_ub[ii] < delta_xFR[i] )
3309 if (
x[ii] <
ub[ii] )
3310 maxStepLength[nV+nC+ii] = (
x[ii] -
ub[ii] ) / ( delta_ub[ii] - delta_xFR[i] );
3312 maxStepLength[nV+nC+ii] = 0.0;
3325 for ( i=0; i<nV; ++i )
3328 if ( maxStepLength[i] < tau_new )
3330 tau_new = maxStepLength[i];
3340 if ( maxStepLength[nV+nC+i] < tau_new )
3342 tau_new = maxStepLength[nV+nC+i];
3349 for ( i=nV; i<nV+nC; ++i )
3352 if ( maxStepLength[i] < tau_new )
3354 tau_new = maxStepLength[i];
3364 if ( maxStepLength[nV+nC+i] < tau_new )
3366 tau_new = maxStepLength[nV+nC+i];
3376 if ( tau_new >
EPS )
3387 char messageString[80];
3390 sprintf( messageString,
"Stepsize is %.6e!",
tau );
3392 sprintf( messageString,
"Stepsize is %.6e! (BC_idx = %d, BC_isBound = %d, BC_status = %d)",
tau,BC_idx,BC_isBound,BC_status );
3406 const real_t*
const delta_g,
const real_t*
const delta_lbA,
const real_t*
const delta_ubA,
3407 const real_t*
const delta_lb,
const real_t*
const delta_ub,
3408 const real_t*
const delta_xFX,
const real_t*
const delta_xFR,
3409 const real_t*
const delta_yAC,
const real_t*
const delta_yFX,
3436 for( i=0; i<nFR; ++i )
3439 x[ii] +=
tau*delta_xFR[i];
3442 for( i=0; i<nFX; ++i )
3445 x[ii] +=
tau*delta_xFX[i];
3446 y[ii] +=
tau*delta_yFX[i];
3449 for( i=0; i<nAC; ++i )
3452 y[nV+ii] +=
tau*delta_yAC[i];
3456 for( i=0; i<nIAC; ++i )
3460 Ax[ii] +=
tau*delta_Ax[ii];
3462 for( i=0; i<nAC; ++i )
3467 for( j=0; j<nV; ++j )
3472 for( i=0; i<nV; ++i )
3474 g[i] +=
tau*delta_g[i];
3475 lb[i] +=
tau*delta_lb[i];
3476 ub[i] +=
tau*delta_ub[i];
3479 for( i=0; i<nC; ++i )
3481 lbA[i] +=
tau*delta_lbA[i];
3482 ubA[i] +=
tau*delta_ubA[i];
3489 char messageString[80];
3490 sprintf( messageString,
"Stepsize is %.6e",
tau );
3498 char messageString[80];
3509 switch ( BC_status )
3521 sprintf( messageString,
"bound no. %d.", BC_idx );
3533 sprintf( messageString,
"constraint no. %d.", BC_idx );
3551 sprintf( messageString,
"lower bound no. %d.", BC_idx );
3553 sprintf( messageString,
"upper bound no. %d.", BC_idx );
3564 sprintf( messageString,
"lower constraint's bound no. %d.", BC_idx );
3566 sprintf( messageString,
"upper constraint's bound no. %d.", BC_idx );
3584 const real_t*
const delta_lbA,
const real_t*
const delta_ubA
3596 for( i=0; i<
getNC( ); ++i )
3622 if ( ( nC > 0 ) && ( _A == 0 ) )
3627 for( i=0; i<nC; ++i )
3628 for( j=0; j<nV; ++j )
3629 A[i*
NVMAX + j] = _A[i*nV + j];
3634 for( i=0; i<nC; ++i )
3640 for( i=0; i<nC; ++i )
3647 for( i=0; i<nC; ++i )
3653 for( i=0; i<nC; ++i )
3677 char myPrintfString[160];
3680 if ( iteration < 0 )
3689 if ( iteration == 0 )
3691 sprintf( myPrintfString,
"\n############## qpOASES -- QP NO.%4.1d ###############\n",
count );
3694 sprintf( myPrintfString,
" Iter | StepLength | Info | nFX | nAC \n" );
3701 sprintf( myPrintfString,
" %4.1d | %1.5e | QP SOLVED | %4.1d | %4.1d \n", iteration,
tau,
getNFX( ),
getNAC( ) );
3709 sprintf( info,
"REM " );
3711 sprintf( info,
"ADD " );
3714 sprintf( &(info[4]),
"BND" );
3716 sprintf( &(info[4]),
"CON" );
3718 sprintf( myPrintfString,
" %4.1d | %1.5e | %s%4.1d | %4.1d | %4.1d \n", iteration,
tau,info,BC_idx,
getNFX( ),
getNAC( ) );
3745 #ifdef __PERFORM_KKT_TEST__ 3753 real_t maxKKTviolation = 0.0;
3759 for( i=0; i<nV; ++i )
3763 for( j=0; j<nV; ++j )
3769 for( j=0; j<nAC; ++j )
3772 tmp -=
A[jj*
NVMAX + i] *
y[nV+jj];
3775 if (
getAbs( tmp ) > maxKKTviolation )
3776 maxKKTviolation =
getAbs( tmp );
3781 for( i=0; i<nC; ++i )
3783 if (
lbA[i] -
Ax[i] > maxKKTviolation )
3784 maxKKTviolation =
lbA[i] -
Ax[i];
3786 if ( Ax[i] -
ubA[i] > maxKKTviolation )
3787 maxKKTviolation = Ax[i] -
ubA[i];
3791 for( i=0; i<nV; ++i )
3793 if (
lb[i] -
x[i] > maxKKTviolation )
3794 maxKKTviolation =
lb[i] -
x[i];
3796 if ( x[i] -
ub[i] > maxKKTviolation )
3797 maxKKTviolation = x[i] -
ub[i];
3802 for( i=0; i<nV; ++i )
3807 if ( -
y[i] > maxKKTviolation )
3808 maxKKTviolation = -
y[i];
3809 if (
getAbs(
x[i] -
lb[i] ) > maxKKTviolation )
3810 maxKKTviolation =
getAbs(
x[i] -
lb[i] );
3814 if (
y[i] > maxKKTviolation )
3815 maxKKTviolation =
y[i];
3816 if (
getAbs(
ub[i] -
x[i] ) > maxKKTviolation )
3817 maxKKTviolation =
getAbs(
ub[i] -
x[i] );
3821 if (
getAbs(
y[i] ) > maxKKTviolation )
3822 maxKKTviolation =
getAbs(
y[i] );
3828 for( i=0; i<nC; ++i )
3833 if ( -
y[nV+i] > maxKKTviolation )
3834 maxKKTviolation = -
y[nV+i];
3840 if (
y[nV+i] > maxKKTviolation )
3841 maxKKTviolation =
y[nV+i];
3847 if (
getAbs(
y[nV+i] ) > maxKKTviolation )
3848 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)
USING_NAMESPACE_ACADO typedef TaylorVariable< Interval > T
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 init(const real_t *const _H, const real_t *const _g, const real_t *const _lb, const real_t *const _ub, int &nWSR, const real_t *const yOpt=0, real_t *const cputime=0)
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)
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