44 #define BMS_CALL(x) do \
48 SCIPerrorMessage("No memory in function call.\n"); \
49 return SCIP_NOMEMORY; \
66 int* sdpconstnblocknonz,
70 SCIP_Real** sdpconstval,
72 int** sdpnblockvarnonz,
104 assert( bufmem != NULL );
105 assert( lb != NULL );
106 assert( ub != NULL );
107 assert( nsdpblocks >= 0 );
108 assert( nsdpblocks == 0 || sdpblocksizes != NULL );
109 assert( nsdpblocks == 0 || sdpnblockvars != NULL );
110 assert( sdpconstnnonz >= 0 );
111 assert( nsdpblocks == 0 || sdpconstnnonz == 0 || sdpconstnblocknonz != NULL );
112 assert( nsdpblocks == 0 || sdpconstnnonz == 0 || sdpconstrow != NULL );
113 assert( nsdpblocks == 0 || sdpconstnnonz == 0 || sdpconstcol != NULL );
114 assert( nsdpblocks == 0 || sdpconstnnonz == 0 || sdpconstval != NULL );
115 assert( sdpnnonz >= 0 );
116 assert( nsdpblocks == 0 || sdpnblockvarnonz != NULL );
117 assert( nsdpblocks == 0 || sdpvar != NULL );
118 assert( nsdpblocks == 0 || sdprow != NULL );
119 assert( nsdpblocks == 0 || sdpcol != NULL );
120 assert( nsdpblocks == 0 || sdpval != NULL );
121 assert( nsdpblocks == 0 || indchanges != NULL );
122 assert( nsdpblocks == 0 || nremovedinds != NULL );
123 assert( nsdpblocks == 0 || blockindchanges != NULL );
124 assert( nlpcons >= 0 );
125 assert( noldlpcons >= nlpcons );
126 assert( nlpcons == 0 || lplhs != NULL );
127 assert( nlpcons == 0 || lprhs != NULL );
128 assert( nlpcons == 0 || rownactivevars != NULL );
129 assert( lpnnonz >= 0 );
130 assert( nlpcons == 0 || lprow != NULL );
131 assert( nlpcons == 0 || lpcol != NULL );
132 assert( nlpcons == 0 || lpval != NULL );
133 assert( solvector != NULL );
134 assert( feastol >= 0 );
135 assert( infeasible != NULL );
138 for (i = 0; i < nvars; i++)
140 if ( solvector[i] < lb[i] - feastol || solvector[i] > ub[i] + feastol )
142 SCIPdebugMessage(
"solution found infeasible (feastol=%f) for variable bounds: x[%d] = %f <|= [%f, %f]\n",
143 feastol, i, solvector[i], lb[i], ub[i]);
152 SCIP_Real* lpconsvals;
154 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &lpconsvals, noldlpcons) );
157 for (i = 0; i < noldlpcons; i++)
161 for (i = 0; i < lpnnonz; i++)
163 if ( lb[lpcol[i]] < ub[lpcol[i]] - epsilon )
164 lpconsvals[lprow[i]] += solvector[lpcol[i]] * lpval[i];
169 for (i = 0; i < noldlpcons; i++)
171 if ( rownactivevars[i] > 1 )
173 if ( lpconsvals[i] < lplhs[ind] - feastol || lpconsvals[i] > lprhs[ind] + feastol)
175 SCIPdebugMessage(
"solution found infeasible (feastol=%f) for lp constraint: LP-%d = %f <|= [%f,%f]\n",
176 feastol, i, lpconsvals[i], lplhs[ind], lprhs[ind]);
177 BMSfreeBufferMemoryArray(bufmem, &lpconsvals);
185 BMSfreeBufferMemoryArray(bufmem, &lpconsvals);
189 if ( nsdpblocks > 0 )
191 SCIP_Real* fullsdpmatrix;
192 SCIP_Real eigenvalue;
193 int maxblocksize = 0;
196 if ( nsdpblocks == 1 )
197 maxblocksize = sdpblocksizes[0] - nremovedinds[0];
201 for (b = 0; b < nsdpblocks; b++)
203 maxblocksize = ((sdpblocksizes[b] - nremovedinds[b]) > maxblocksize) ? sdpblocksizes[b] - nremovedinds[b] : maxblocksize;
207 BMS_CALL( BMSallocBufferMemoryArray(bufmem, &fullsdpmatrix, maxblocksize * maxblocksize) );
209 for (b = 0; b < nsdpblocks; b++)
211 if ( blockindchanges[b] > -1 )
214 for (i = 0; i < sdpblocksizes[b] - nremovedinds[b]; i++)
216 for (j = 0; j <= i; j++)
218 fullsdpmatrix[i * (sdpblocksizes[b] - nremovedinds[b]) + j] = 0.0;
223 for (v = 0; v < sdpnblockvars[b]; v++)
225 if ( lb[sdpvar[b][v]] < ub[sdpvar[b][v]] - epsilon )
227 for (i = 0; i < sdpnblockvarnonz[b][v]; i++)
229 fullsdpmatrix[((sdprow[b][v][i] - indchanges[b][sdprow[b][v][i]]) * (sdpblocksizes[b] - nremovedinds[b])) +
230 sdpcol[b][v][i] - indchanges[b][sdpcol[b][v][i]]] += solvector[sdpvar[b][v]] * sdpval[b][v][i];
236 for (i = 0; i < sdpconstnblocknonz[b]; i++)
238 fullsdpmatrix[((sdpconstrow[b][i] - indchanges[b][sdpconstrow[b][i]]) * (sdpblocksizes[b] - nremovedinds[b])) +
239 sdpconstcol[b][i] - indchanges[b][sdpconstcol[b][i]]] -= sdpconstval[b][i];
243 for (i = 0; i < sdpblocksizes[b] - nremovedinds[b]; i++)
245 for (j = 0; j < i; j++)
247 fullsdpmatrix[j * (sdpblocksizes[b] - nremovedinds[b]) + i] = fullsdpmatrix[i * (sdpblocksizes[b] - nremovedinds[b]) + j];
254 if ( eigenvalue < - feastol )
256 SCIPdebugMessage(
"solution found infeasible (feastol=%.10f) for sdp constraint %d, smallest eigenvector %.10f\n",
257 feastol, b, eigenvalue);
258 BMSfreeBufferMemoryArray(bufmem, &fullsdpmatrix);
265 BMSfreeBufferMemoryArray(bufmem, &fullsdpmatrix);
EXTERN 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 different versions of L...