42 #include "scip/pub_message.h" 45 #define BMS_CALL(x) do \ 49 SCIPerrorMessage("No memory in function call.\n"); \ 50 return SCIP_NOMEMORY; \ 67 int* sdpconstnblocknonz,
71 SCIP_Real** sdpconstval,
73 int** sdpnblockvarnonz,
105 assert( bufmem != NULL );
106 assert( lb != NULL );
107 assert( ub != NULL );
108 assert( nsdpblocks >= 0 );
109 assert( nsdpblocks == 0 || sdpblocksizes != NULL );
110 assert( nsdpblocks == 0 || sdpnblockvars != NULL );
111 assert( sdpconstnnonz >= 0 );
112 assert( nsdpblocks == 0 || sdpconstnnonz == 0 || sdpconstnblocknonz != NULL );
113 assert( nsdpblocks == 0 || sdpconstnnonz == 0 || sdpconstrow != NULL );
114 assert( nsdpblocks == 0 || sdpconstnnonz == 0 || sdpconstcol != NULL );
115 assert( nsdpblocks == 0 || sdpconstnnonz == 0 || sdpconstval != NULL );
116 assert( sdpnnonz >= 0 );
117 assert( nsdpblocks == 0 || sdpnblockvarnonz != NULL );
118 assert( nsdpblocks == 0 || sdpvar != NULL );
119 assert( nsdpblocks == 0 || sdprow != NULL );
120 assert( nsdpblocks == 0 || sdpcol != NULL );
121 assert( nsdpblocks == 0 || sdpval != NULL );
122 assert( nsdpblocks == 0 || indchanges != NULL );
123 assert( nsdpblocks == 0 || nremovedinds != NULL );
124 assert( nsdpblocks == 0 || blockindchanges != NULL );
125 assert( nlpcons >= 0 );
126 assert( noldlpcons >= nlpcons );
127 assert( nlpcons == 0 || lplhs != NULL );
128 assert( nlpcons == 0 || lprhs != NULL );
129 assert( nlpcons == 0 || rownactivevars != NULL );
130 assert( lpnnonz >= 0 );
131 assert( nlpcons == 0 || lprow != NULL );
132 assert( nlpcons == 0 || lpcol != NULL );
133 assert( nlpcons == 0 || lpval != NULL );
134 assert( solvector != NULL );
135 assert( feastol >= 0 );
136 assert( infeasible != NULL );
139 for (i = 0; i < nvars; i++)
141 if ( solvector[i] < lb[i] - feastol || solvector[i] > ub[i] + feastol )
143 SCIPdebugMessage(
"solution found infeasible (feastol=%f) for variable bounds: x[%d] = %f <|= [%f, %f]\n",
144 feastol, i, solvector[i], lb[i], ub[i]);
153 SCIP_Real* lpconsvals;
155 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &lpconsvals, noldlpcons) );
158 for (i = 0; i < noldlpcons; i++)
162 for (i = 0; i < lpnnonz; i++)
164 if ( lb[lpcol[i]] < ub[lpcol[i]] - epsilon )
165 lpconsvals[lprow[i]] += solvector[lpcol[i]] * lpval[i];
170 for (i = 0; i < noldlpcons; i++)
172 if ( rownactivevars[i] > 1 )
174 if ( lpconsvals[i] < lplhs[ind] - feastol || lpconsvals[i] > lprhs[ind] + feastol)
176 SCIPdebugMessage(
"solution found infeasible (feastol=%f) for lp constraint: LP-%d = %f <|= [%f,%f]\n",
177 feastol, i, lpconsvals[i], lplhs[ind], lprhs[ind]);
178 BMSfreeBufferMemoryArray(bufmem, &lpconsvals);
186 BMSfreeBufferMemoryArray(bufmem, &lpconsvals);
190 if ( nsdpblocks > 0 )
192 SCIP_Real* fullsdpmatrix;
193 SCIP_Real eigenvalue;
194 int maxblocksize = 0;
197 if ( nsdpblocks == 1 )
198 maxblocksize = sdpblocksizes[0] - nremovedinds[0];
202 for (b = 0; b < nsdpblocks; b++)
204 maxblocksize = ((sdpblocksizes[b] - nremovedinds[b]) > maxblocksize) ? sdpblocksizes[b] - nremovedinds[b] : maxblocksize;
208 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &fullsdpmatrix, maxblocksize * maxblocksize) );
210 for (b = 0; b < nsdpblocks; b++)
212 if ( blockindchanges[b] > -1 )
215 for (i = 0; i < sdpblocksizes[b] - nremovedinds[b]; i++)
217 for (j = 0; j <= i; j++)
219 fullsdpmatrix[i * (sdpblocksizes[b] - nremovedinds[b]) + j] = 0.0;
224 for (v = 0; v < sdpnblockvars[b]; v++)
226 if ( lb[sdpvar[b][v]] < ub[sdpvar[b][v]] - epsilon )
228 for (i = 0; i < sdpnblockvarnonz[b][v]; i++)
230 fullsdpmatrix[((sdprow[b][v][i] - indchanges[b][sdprow[b][v][i]]) * (sdpblocksizes[b] - nremovedinds[b])) +
231 sdpcol[b][v][i] - indchanges[b][sdpcol[b][v][i]]] += solvector[sdpvar[b][v]] * sdpval[b][v][i];
237 for (i = 0; i < sdpconstnblocknonz[b]; i++)
239 fullsdpmatrix[((sdpconstrow[b][i] - indchanges[b][sdpconstrow[b][i]]) * (sdpblocksizes[b] - nremovedinds[b])) +
240 sdpconstcol[b][i] - indchanges[b][sdpconstcol[b][i]]] -= sdpconstval[b][i];
244 for (i = 0; i < sdpblocksizes[b] - nremovedinds[b]; i++)
246 for (j = 0; j < i; j++)
248 fullsdpmatrix[j * (sdpblocksizes[b] - nremovedinds[b]) + i] = fullsdpmatrix[i * (sdpblocksizes[b] - nremovedinds[b]) + j];
255 if ( eigenvalue < - feastol )
257 SCIPdebugMessage(
"solution found infeasible (feastol=%.10f) for sdp constraint %d, smallest eigenvector %.10f\n",
258 feastol, b, eigenvalue);
259 BMSfreeBufferMemoryArray(bufmem, &fullsdpmatrix);
266 BMSfreeBufferMemoryArray(bufmem, &fullsdpmatrix);
SCIP_EXPORT SCIP_RETCODE SCIPlapackComputeIthEigenvalue(BMS_BUFMEM *bufmem, SCIP_Bool geteigenvectors, int n, SCIP_Real *A, int i, SCIP_Real *eigenvalue, SCIP_Real *eigenvector)
SCIP_RETCODE SCIPsdpSolcheckerCheck(BMS_BUFMEM *bufmem, int nvars, SCIP_Real *lb, SCIP_Real *ub, int nsdpblocks, int *sdpblocksizes, int *sdpnblockvars, int sdpconstnnonz, int *sdpconstnblocknonz, int **sdpconstrow, int **sdpconstcol, SCIP_Real **sdpconstval, int sdpnnonz, int **sdpnblockvarnonz, int **sdpvar, int ***sdprow, int ***sdpcol, SCIP_Real ***sdpval, int **indchanges, int *nremovedinds, int *blockindchanges, int nlpcons, int noldlpcons, SCIP_Real *lplhs, SCIP_Real *lprhs, int *rownactivevars, int lpnnonz, int *lprow, int *lpcol, SCIP_Real *lpval, SCIP_Real *solvector, SCIP_Real feastol, SCIP_Real epsilon, SCIP_Bool *infeasible)
checks a given SDP solution for feasibility
interface methods for eigenvector computation and matrix multiplication using openblas ...