77 #include "scip/cons_linear.h" 80 #define READER_NAME "cbfreader" 81 #define READER_DESC "file reader and writer for MISDPs in cbf format" 82 #define READER_EXTENSION "cbf" 84 #define CBF_VERSION_NR 3 85 #define CBF_CHECK_NONNEG TRUE 92 #define CBF_MAX_LINE 512 93 #define CBF_MAX_NAME 512 96 #define MACRO_STR_EXPAND(tok) #tok 97 #define MACRO_STR(tok) MACRO_STR_EXPAND(tok) 98 #define CBF_NAME_FORMAT "%" MACRO_STR(CBF_MAX_NAME) "s" 104 SCIP_Bool* psdvarrank1;
105 SCIP_VAR**** createdpsdvars;
106 SCIP_Bool noorigsdpcons;
107 SCIP_Bool* sdpblockrank1;
111 SCIP_VAR** createdvars;
113 SCIP_CONS** createdconss;
120 SCIP_VAR*** sdpblockvars;
127 SCIP_Real*** valpointer;
128 int* sdpconstnblocknonz;
132 SCIP_Real** sdpconstval;
138 typedef struct CBF_Data CBF_DATA;
157 assert( scip != NULL );
158 assert( data != NULL );
161 if ( data->constnnonz > 0 )
163 for (b = 0; b < data->nsdpblocks; b++)
165 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpconstval[b]), data->constnnonz);
166 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpconstcol[b]), data->constnnonz);
167 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpconstrow[b]), data->constnnonz);
169 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpconstval, data->nsdpblocks);
170 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpconstcol, data->nsdpblocks);
171 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpconstrow, data->nsdpblocks);
172 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpconstnblocknonz, data->nsdpblocks);
176 if ( data->nnonz > 0 )
180 if ( data->npsdvars > 0 )
181 ncbfsdpblocks = data->nsdpblocks - data->npsdvars;
183 ncbfsdpblocks = data->nsdpblocks;
185 if ( data->noorigsdpcons )
188 assert( ncbfsdpblocks == 0 );
190 for (b = 0; b < data->nsdpblocks; b++)
192 SCIPfreeBlockMemoryArrayNull(scip, &(data->valpointer[b]), data->sdpnblocknonz[b]);
193 SCIPfreeBlockMemoryArrayNull(scip, &(data->colpointer[b]), data->sdpnblocknonz[b]);
194 SCIPfreeBlockMemoryArrayNull(scip, &(data->rowpointer[b]), data->sdpnblocknonz[b]);
195 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpval[b]), data->sdpnblocknonz[b]);
196 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpcol[b]), data->sdpnblocknonz[b]);
197 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdprow[b]), data->sdpnblocknonz[b]);
198 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpblockvars[b]), data->sdpnblocknonz[b]);
199 SCIPfreeBlockMemoryArrayNull(scip, &(data->nvarnonz[b]), data->sdpnblocknonz[b]);
202 SCIPfreeBlockMemoryArrayNull(scip, &data->valpointer, data->nsdpblocks);
203 SCIPfreeBlockMemoryArrayNull(scip, &data->colpointer, data->nsdpblocks);
204 SCIPfreeBlockMemoryArrayNull(scip, &data->rowpointer, data->nsdpblocks);
205 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpval, data->nsdpblocks);
206 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpcol, data->nsdpblocks);
207 SCIPfreeBlockMemoryArrayNull(scip, &data->sdprow, data->nsdpblocks);
208 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpblockvars, data->nsdpblocks);
209 SCIPfreeBlockMemoryArrayNull(scip, &data->nvarnonz, data->nsdpblocks);
210 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpnblockvars, data->nsdpblocks);
211 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpnblocknonz, data->nsdpblocks);
212 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpblockrank1, data->nsdpblocks);
213 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpblocksizes, data->nsdpblocks);
218 assert( ncbfsdpblocks > 0 );
220 for (b = 0; b < ncbfsdpblocks; b++)
222 if ( data->sdpnblockvars != NULL )
224 SCIPfreeBlockMemoryArrayNull(scip, &(data->valpointer[b]), data->nvars);
225 SCIPfreeBlockMemoryArrayNull(scip, &(data->colpointer[b]), data->nvars);
226 SCIPfreeBlockMemoryArrayNull(scip, &(data->rowpointer[b]), data->nvars);
227 SCIPfreeBlockMemoryArrayNull(scip, &(data->nvarnonz[b]), data->nvars);
228 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpblockvars[b]), data->nvars);
230 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpval[b]), data->nnonz);
231 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpcol[b]), data->nnonz);
232 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdprow[b]), data->nnonz);
235 if ( data->npsdvars > 0 )
237 for (b = ncbfsdpblocks; b < data->nsdpblocks; b++)
239 if ( data->sdpnblockvars != NULL )
241 SCIPfreeBlockMemoryArrayNull(scip, &(data->valpointer[b]), data->sdpnblocknonz[b]);
242 SCIPfreeBlockMemoryArrayNull(scip, &(data->colpointer[b]), data->sdpnblocknonz[b]);
243 SCIPfreeBlockMemoryArrayNull(scip, &(data->rowpointer[b]), data->sdpnblocknonz[b]);
244 SCIPfreeBlockMemoryArrayNull(scip, &(data->nvarnonz[b]), data->sdpnblocknonz[b]);
245 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpblockvars[b]), data->sdpnblocknonz[b]);
247 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpval[b]), data->nnonz);
248 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpcol[b]), data->nnonz);
249 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdprow[b]), data->nnonz);
253 if ( data->sdpnblockvars != NULL )
255 SCIPfreeBlockMemoryArrayNull(scip, &data->valpointer, data->nsdpblocks);
256 SCIPfreeBlockMemoryArrayNull(scip, &data->colpointer, data->nsdpblocks);
257 SCIPfreeBlockMemoryArrayNull(scip, &data->rowpointer, data->nsdpblocks);
258 SCIPfreeBlockMemoryArrayNull(scip, &data->nvarnonz, data->nsdpblocks);
259 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpblockvars, data->nsdpblocks);
260 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpnblockvars, data->nsdpblocks);
262 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpval, data->nsdpblocks);
263 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpcol, data->nsdpblocks);
264 SCIPfreeBlockMemoryArrayNull(scip, &data->sdprow, data->nsdpblocks);
265 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpnblocknonz, data->nsdpblocks);
266 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpblockrank1, data->nsdpblocks);
267 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpblocksizes, data->nsdpblocks);
270 else if ( data->nsdpblocks > 0 )
272 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpblockrank1, data->nsdpblocks);
273 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpblocksizes, data->nsdpblocks);
276 if (data->nconss > 0)
278 SCIPfreeBlockMemoryArrayNull(scip, &data->createdconss, data->nconss);
282 SCIPfreeBlockMemoryArrayNull(scip, &data->createdvars, data->nvars);
284 if ( data->npsdvars > 0 && data->psdvarsizes != NULL )
286 assert( data->createdpsdvars != NULL );
287 assert( data->psdvarrank1 != NULL );
289 for (t = 0; t < data->npsdvars; t++)
291 if ( data->psdvarsizes[t] > 0 )
293 for (i = 0; i < data->psdvarsizes[t]; ++i)
294 SCIPfreeBlockMemoryArrayNull(scip, &(data->createdpsdvars[t][i]), i+1);
295 SCIPfreeBlockMemoryArrayNull(scip, &(data->createdpsdvars[t]), data->psdvarsizes[t]);
299 SCIPfreeBlockMemoryArrayNull(scip, &(data->psdvarrank1), data->npsdvars);
300 SCIPfreeBlockMemoryArrayNull(scip, &(data->psdvarsizes), data->npsdvars);
301 SCIPfreeBlockMemoryArrayNull(scip, &(data->createdpsdvars), data->npsdvars);
304 SCIPfreeBlockMemoryArrayNull(scip, &data->namebuffer,
CBF_MAX_NAME);
305 SCIPfreeBlockMemoryArrayNull(scip, &data->linebuffer,
CBF_MAX_LINE);
307 SCIPfreeBufferNull(scip, &data);
308 assert( data == NULL );
311 if ( SCIPfclose(file) )
312 return SCIP_READERROR;
323 SCIP_Longint* linecount,
327 assert( data != NULL );
328 assert( pFile != NULL );
329 assert( linecount != NULL );
332 while ( SCIPfgets(data->linebuffer,
CBF_MAX_LINE, pFile) != NULL )
336 if ( data->linebuffer[0] !=
'#' )
342 SCIPerrorMessage(
"Could not read content of line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
345 return SCIP_READERROR;
354 SCIP_Longint* linecount
357 assert( scip != NULL );
358 assert( data != NULL );
359 assert( pfile != NULL );
360 assert( linecount != NULL );
362 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
364 if ( sscanf(data->linebuffer,
CBF_NAME_FORMAT, data->namebuffer) != 1 )
366 SCIPerrorMessage(
"Could not read OBJSENSE in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
368 return SCIP_READERROR;
371 if ( strcmp(data->namebuffer,
"MIN") == 0 )
373 SCIP_CALL( SCIPsetObjsense(scip, SCIP_OBJSENSE_MINIMIZE) );
375 else if ( strcmp(data->namebuffer,
"MAX") == 0 )
377 SCIP_CALL( SCIPsetObjsense(scip, SCIP_OBJSENSE_MAXIMIZE) );
381 SCIPerrorMessage(
"OBJSENSE in line %" SCIP_LONGINT_FORMAT
" should be either MIN or MAX.\n", *linecount);
383 return SCIP_READERROR;
395 SCIP_Longint* linecount
398 char varname[SCIP_MAXSTRLEN];
409 assert( scip != NULL );
410 assert( data != NULL );
411 assert( pfile != NULL );
412 assert( linecount != NULL );
414 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
416 if ( sscanf(data->linebuffer,
"%i %i", &(data->nvars), &nvartypes) != 2 )
418 SCIPerrorMessage(
"Could not read number of scalar variables and conic domains in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
420 return SCIP_READERROR;
423 if ( data->nvars < 0 )
425 SCIPerrorMessage(
"Number of scalar variables %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", data->nvars, *linecount);
427 return SCIP_READERROR;
432 SCIPerrorMessage(
"Number of conic variable domains %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", nvartypes, *linecount);
434 return SCIP_READERROR;
437 assert( data->nvars >= 0 && nvartypes >= 0 );
438 assert( data->nvars > 0 || nvartypes == 0 );
439 assert( data->nvars == 0 || nvartypes > 0 );
442 if ( data->nvars == 0 )
446 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->createdvars), data->nvars) );
447 for (t = 0; t < nvartypes; t++)
452 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
454 if ( sscanf(data->linebuffer,
CBF_NAME_FORMAT" %i", data->namebuffer, &nvartypevars) != 2 )
456 SCIPerrorMessage(
"Could not read conic domain and number of corresponding scalar variables in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
458 return SCIP_READERROR;
461 if ( nvartypevars <= 0 )
463 SCIPerrorMessage(
"Number of scalar variables %d in line %" SCIP_LONGINT_FORMAT
" should be positive!\n", nvartypevars, *linecount);
465 return SCIP_READERROR;
468 lb = -SCIPinfinity(scip);
469 ub = SCIPinfinity(scip);
471 if ( strcmp(data->namebuffer,
"L+") == 0 )
475 else if ( strcmp(data->namebuffer,
"L-") == 0 )
479 else if ( strcmp(data->namebuffer,
"F") != 0 )
481 SCIPerrorMessage(
"CBF-Reader of SCIP-SDP currently only supports non-negative, non-positive and free variables!\n");
483 return SCIP_READERROR;
487 for (v = 0; v < nvartypevars; v++)
490 snprintfreturn = SCIPsnprintf(varname, SCIP_MAXSTRLEN,
"x_%d", cnt);
491 assert( snprintfreturn < SCIP_MAXSTRLEN);
493 (void)SCIPsnprintf(varname, SCIP_MAXSTRLEN,
"x_%d", cnt);
496 SCIP_CALL( SCIPcreateVar(scip, &var, varname, lb, ub, 0.0, SCIP_VARTYPE_CONTINUOUS,
497 TRUE, FALSE, NULL, NULL, NULL, NULL, NULL));
499 SCIP_CALL( SCIPaddVar(scip, var) );
500 data->createdvars[cnt++] = var;
503 SCIP_CALL( SCIPreleaseVar(scip, &var) );
507 if ( cnt != data->nvars )
509 SCIPerrorMessage(
"Total number of scalar variables for different cone types not equal to total number of scalar variables!\n");
511 return SCIP_READERROR;
523 SCIP_Longint* linecount
526 char varname[SCIP_MAXSTRLEN];
535 assert( scip != NULL );
536 assert( data != NULL );
537 assert( pfile != NULL );
538 assert( linecount != NULL );
540 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
542 if ( sscanf(data->linebuffer,
"%i", &(data->npsdvars)) != 1 )
544 SCIPerrorMessage(
"Could not read number of psd variables in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
546 return SCIP_READERROR;
549 if ( data->npsdvars < 0 )
551 SCIPerrorMessage(
"Number of psd variables %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", data->npsdvars, *linecount);
553 return SCIP_READERROR;
557 if ( data->npsdvars == 0 )
561 if ( data->nsdpblocks > -1 )
563 SCIPerrorMessage(
"Need to have 'PSDVAR' section before 'PSDCON' section!\n");
565 return SCIP_READERROR;
568 assert( data->npsdvars > 0 );
571 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->createdpsdvars), data->npsdvars) );
572 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->psdvarsizes), data->npsdvars) );
573 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->psdvarrank1), data->npsdvars) );
575 for (t = 0; t < data->npsdvars; t++)
583 data->psdvarsizes[t] = -1;
585 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
587 if ( sscanf(data->linebuffer,
"%i", &sizepsdvar) != 1 )
589 SCIPerrorMessage(
"Could not read the size of psd variable %d in line %" SCIP_LONGINT_FORMAT
".\n", t, *linecount);
591 return SCIP_READERROR;
594 if ( sizepsdvar <= 0 )
596 SCIPerrorMessage(
"Size %d of psd variable %d in line %" SCIP_LONGINT_FORMAT
" should be positive!\n", sizepsdvar, t, *linecount);
598 return SCIP_READERROR;
602 data->psdvarsizes[t] = sizepsdvar;
605 data->psdvarrank1[t] = FALSE;
607 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->createdpsdvars[t]), sizepsdvar) );
609 lb = -SCIPinfinity(scip);
610 ub = SCIPinfinity(scip);
612 for (i = 0; i < sizepsdvar; ++i)
614 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->createdpsdvars[t][i]), i+1) );
615 for (j = 0; j <= i; ++j)
618 snprintfreturn = SCIPsnprintf(varname, SCIP_MAXSTRLEN,
"y_%d%d%d", t, i, j);
619 assert( snprintfreturn < SCIP_MAXSTRLEN);
621 (void)SCIPsnprintf(varname, SCIP_MAXSTRLEN,
"y_%d%d%d", t, i, j);
624 SCIP_CALL( SCIPcreateVar(scip, &var, varname, lb, ub, 0.0, SCIP_VARTYPE_CONTINUOUS,
625 TRUE, FALSE, NULL, NULL, NULL, NULL, NULL));
627 SCIP_CALL( SCIPaddVar(scip, var) );
628 data->createdpsdvars[t][i][j] = var;
632 SCIP_CALL( SCIPreleaseVar(scip, &var) );
635 assert( cnt == sizepsdvar * (sizepsdvar + 1) / 2 );
647 SCIP_Longint* linecount
654 assert( scip != NULL );
655 assert( data != NULL );
656 assert( pfile != NULL );
657 assert( linecount != NULL );
659 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
661 if ( sscanf(data->linebuffer,
"%i", &(nrank1psdvars)) != 1 )
663 SCIPerrorMessage(
"Could not read number of psd variables with a rank-1 constraint in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
665 return SCIP_READERROR;
668 if ( nrank1psdvars == 0 )
672 if ( data->npsdvars < 0 )
674 SCIPerrorMessage(
"Need to have 'PSDVAR' section before 'PSDVARRANK1' section!\n");
676 return SCIP_READERROR;
679 if ( nrank1psdvars < 0 )
681 SCIPerrorMessage(
"Number of psd variables with a rank-1 constraint %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", nrank1psdvars, *linecount);
683 return SCIP_READERROR;
686 assert( data->npsdvars >= 0 );
687 assert( nrank1psdvars >= 0 );
688 assert( data->nsdpblocksrank1 >= 0 );
690 data->nsdpblocksrank1 += nrank1psdvars;
692 for (i = 0; i < nrank1psdvars; i++)
694 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
696 if ( sscanf(data->linebuffer,
"%i", &v) != 1 )
698 SCIPerrorMessage(
"Could not read index of psd variable with a rank-1 constraint in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
700 return SCIP_READERROR;
703 if ( v < 0 || v >= data->npsdvars )
705 SCIPerrorMessage(
"Given rank-1 constraint in line %" SCIP_LONGINT_FORMAT
" for matrix variable %d which does not exist!\n", *linecount, v);
707 return SCIP_READERROR;
710 data->psdvarrank1[v] = TRUE;
722 SCIP_Longint* linecount
725 char consname[SCIP_MAXSTRLEN];
736 assert( scip != NULL );
737 assert( data != NULL );
738 assert( pfile != NULL );
739 assert( linecount != NULL );
741 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
743 if ( sscanf(data->linebuffer,
"%i %i", &(data->nconss), &nconstypes) != 2 )
745 SCIPerrorMessage(
"Could not read number of scalar constraints and conic domains in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
747 return SCIP_READERROR;
750 if ( data->nconss < 0 )
752 SCIPerrorMessage(
"Number of scalar constraints %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", data->nconss, *linecount);
754 return SCIP_READERROR;
757 if ( nconstypes < 0 )
759 SCIPerrorMessage(
"Number of conic constraint domains %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", nconstypes, *linecount);
761 return SCIP_READERROR;
763 assert( data->nconss >= 0 && nconstypes >= 0 );
764 assert( data->nconss > 0 || nconstypes == 0 );
765 assert( data->nconss == 0 || nconstypes > 0 );
768 if ( data->nconss == 0 )
772 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->createdconss), data->nconss) );
773 for (t = 0; t < nconstypes; t++)
778 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
780 if ( sscanf(data->linebuffer,
CBF_NAME_FORMAT" %i", data->namebuffer, &nconstypeconss) != 2 )
782 SCIPerrorMessage(
"Could not read conic domain and number of corresponding scalar constraints in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
784 return SCIP_READERROR;
787 if ( nconstypeconss <= 0 )
789 SCIPerrorMessage(
"Number of constraints %d in line %" SCIP_LONGINT_FORMAT
" should be positive!\n", nconstypeconss, *linecount);
791 return SCIP_READERROR;
794 lhs = -SCIPinfinity(scip);
795 rhs = SCIPinfinity(scip);
797 if ( strcmp(data->namebuffer,
"L+") == 0 )
801 else if ( strcmp(data->namebuffer,
"L-") == 0 )
805 else if ( strcmp(data->namebuffer,
"L=") == 0 )
812 SCIPerrorMessage(
"CBF-Reader of SCIP-SDP currently only supports linear greater or equal, less or equal and" 813 " equality constraints!\n");
815 return SCIP_READERROR;
819 for (c = 0; c < nconstypeconss; c++)
822 snprintfreturn = SCIPsnprintf(consname, SCIP_MAXSTRLEN,
"LP_%d", cnt);
823 assert( snprintfreturn < SCIP_MAXSTRLEN);
825 (void)SCIPsnprintf(consname, SCIP_MAXSTRLEN,
"linear_%d", cnt);
828 SCIP_CALL( SCIPcreateConsLinear(scip, &cons, consname, 0, NULL, NULL, lhs, rhs,
829 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE));
831 SCIP_CALL( SCIPaddCons(scip, cons) );
832 data->createdconss[cnt++] = cons;
835 SCIP_CALL( SCIPreleaseCons(scip, &cons) );
839 if ( cnt != data->nconss )
841 SCIPerrorMessage(
"Total number of constraints for different cone types not equal to total number of constraints!\n");
843 return SCIP_READERROR;
855 SCIP_Longint* linecount
861 SCIP_Bool infeasible;
863 assert( scip != NULL );
864 assert( data != NULL );
865 assert( pfile != NULL );
866 assert( linecount != NULL );
868 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
870 if ( sscanf(data->linebuffer,
"%i", &nintvars) != 1 )
872 SCIPerrorMessage(
"Could not read number of integer variables in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
874 return SCIP_READERROR;
882 SCIPerrorMessage(
"Number of integrality constraints %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative.\n", nintvars, *linecount);
884 return SCIP_READERROR;
887 if ( data->createdvars == NULL )
889 SCIPerrorMessage(
"Need to have 'VAR' section before 'INT' section!\n");
891 return SCIP_READERROR;
893 assert( data->nvars >= 0 );
895 for (i = 0; i < nintvars; i++)
897 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
899 if ( sscanf(data->linebuffer,
"%i", &v) != 1 )
901 SCIPerrorMessage(
"Could not read variable index in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
903 return SCIP_READERROR;
906 if ( v < 0 || v >= data->nvars )
908 SCIPerrorMessage(
"Given integrality contraint in line %" SCIP_LONGINT_FORMAT
" for variable %d which does not exist!\n", *linecount, v);
910 return SCIP_READERROR;
913 SCIP_CALL( SCIPchgVarType(scip, data->createdvars[v], SCIP_VARTYPE_INTEGER, &infeasible) );
917 SCIPerrorMessage(
"Infeasibility detected because of integrality of variable %s!\n", SCIPvarGetName(data->createdvars[v]));
919 return SCIP_READERROR;
932 SCIP_Longint* linecount
938 assert( scip != NULL );
939 assert( data != NULL );
940 assert( pfile != NULL );
941 assert( linecount != NULL );
943 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
945 if ( sscanf(data->linebuffer,
"%i", &ncbfsdpblocks) != 1 )
947 SCIPerrorMessage(
"Could not read number of psd constraints in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
949 return SCIP_READERROR;
952 if ( ncbfsdpblocks < 0 )
954 SCIPerrorMessage(
"Number of SDP-blocks %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", ncbfsdpblocks, *linecount);
956 return SCIP_READERROR;
960 if ( ncbfsdpblocks == 0 )
962 data->noorigsdpcons = TRUE;
963 data->nsdpblocks = 0;
966 assert( ncbfsdpblocks > 0 );
970 if ( data->npsdvars > 0 )
971 data->nsdpblocks = ncbfsdpblocks + data->npsdvars;
973 data->nsdpblocks = ncbfsdpblocks;
975 assert( data->nsdpblocks > 0 );
977 data->noorigsdpcons = FALSE;
978 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblocksizes), data->nsdpblocks) );
979 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblockrank1), data->nsdpblocks) );
981 for (b = 0; b < ncbfsdpblocks; b++)
983 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
984 if ( sscanf(data->linebuffer,
"%i", &(data->sdpblocksizes[b])) != 1 )
986 SCIPerrorMessage(
"Could not read size of psd constraint %d in line %" SCIP_LONGINT_FORMAT
".\n", b, *linecount);
988 return SCIP_READERROR;
991 if ( data->sdpblocksizes[b] <= 0 )
993 SCIPerrorMessage(
"Size %d of SDP-block %d in line %" SCIP_LONGINT_FORMAT
" should be positive!\n", data->sdpblocksizes[b], b, *linecount);
995 return SCIP_READERROR;
999 data->sdpblockrank1[b] = FALSE;
1002 for (b = 0; b < data->npsdvars; b++)
1006 data->sdpblocksizes[ncbfsdpblocks + b] = data->psdvarsizes[b];
1007 data->sdpblockrank1[ncbfsdpblocks + b] = data->psdvarrank1[b];
1019 SCIP_Longint* linecount
1024 int nrank1sdpblocks;
1027 assert( scip != NULL );
1028 assert( data != NULL );
1029 assert( pfile != NULL );
1030 assert( linecount != NULL );
1032 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1034 if ( sscanf(data->linebuffer,
"%i", &(nrank1sdpblocks)) != 1 )
1036 SCIPerrorMessage(
"Could not read number of psd constraints with a rank-1 constraint in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1038 return SCIP_READERROR;
1041 if ( nrank1sdpblocks == 0 )
1045 if ( data->nsdpblocks < 0 )
1047 SCIPerrorMessage(
"Need to have 'PSDCON' section before 'PSDCONRANK1' section!\n");
1049 return SCIP_READERROR;
1052 if ( nrank1sdpblocks < 0 )
1054 SCIPerrorMessage(
"Number of psd constraints with a rank-1 constraint %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", nrank1sdpblocks, *linecount);
1056 return SCIP_READERROR;
1059 assert( data->nsdpblocks >= 0 );
1060 assert( nrank1sdpblocks >= 0 );
1061 assert( data->nsdpblocksrank1 >= 0 );
1063 data->nsdpblocksrank1 += nrank1sdpblocks;
1065 if ( data->npsdvars > 0 )
1066 ncbfsdpblocks = data->nsdpblocks - data->npsdvars;
1068 ncbfsdpblocks = data->nsdpblocks;
1070 for (i = 0; i < nrank1sdpblocks; i++)
1072 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1073 if ( sscanf(data->linebuffer,
"%i", &c) != 1 )
1075 SCIPerrorMessage(
"Could not read index of psd constraint with a rank-1 constraint in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1077 return SCIP_READERROR;
1080 if ( c < 0 || c >= ncbfsdpblocks )
1082 SCIPerrorMessage(
"Given rank-1 constraint in line %" SCIP_LONGINT_FORMAT
" for sdp constraint %d which does not exist!\n", *linecount, c);
1084 return SCIP_READERROR;
1087 data->sdpblockrank1[c] = TRUE;
1099 SCIP_Longint* linecount
1110 assert( scip != NULL );
1111 assert( data != NULL );
1112 assert( pfile != NULL );
1113 assert( linecount != NULL );
1115 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1117 if ( sscanf(data->linebuffer,
"%i", &nobjcoefs) != 1 )
1119 SCIPerrorMessage(
"Could not read number of objective coefficients for matrix variables in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1121 return SCIP_READERROR;
1124 if ( nobjcoefs < 0 )
1126 SCIPerrorMessage(
"Number of objective coefficients for matrix variables %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", nobjcoefs, *linecount);
1128 return SCIP_READERROR;
1131 if ( nobjcoefs == 0 )
1134 if ( data->createdpsdvars == NULL )
1136 SCIPerrorMessage(
"Need to have 'PSDVAR' section before 'OBJFCOORD' section!\n");
1138 return SCIP_READERROR;
1140 assert( data->npsdvars >= 0 );
1142 for (i = 0; i < nobjcoefs; i++)
1144 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1146 if ( sscanf(data->linebuffer,
"%i %i %i %lf", &v, &row, &col, &val) != 4 )
1148 SCIPerrorMessage(
"Could not read entry of OBJFCOORD in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1150 return SCIP_READERROR;
1153 if ( v < 0 || v >= data->npsdvars )
1155 SCIPerrorMessage(
"Given objective coefficient in line %" SCIP_LONGINT_FORMAT
" for matrix variable %d which does not exist!\n", *linecount, v);
1157 return SCIP_READERROR;
1160 if ( row < 0 || row >= data->psdvarsizes[v] )
1162 SCIPerrorMessage(
"Row index %d of given coefficient in line %" SCIP_LONGINT_FORMAT
" for matrix variable %d in objective function is negative or larger than varsize %d!\n",
1163 row, *linecount, v, data->psdvarsizes[v]);
1165 return SCIP_READERROR;
1168 if ( col < 0 || col >= data->psdvarsizes[v] )
1170 SCIPerrorMessage(
"Column index %d of given coefficient in line %" SCIP_LONGINT_FORMAT
" for matrix variable %d in objective function is negative or larger than varsize %d!\n",
1171 col, *linecount, v, data->psdvarsizes[v]);
1173 return SCIP_READERROR;
1176 if ( SCIPisInfinity(scip, val) || SCIPisInfinity(scip, -val) )
1178 SCIPerrorMessage(
"Given objective coefficient in line %" SCIP_LONGINT_FORMAT
" for matrix variable %d is infinity, which is not allowed.\n",
1181 return SCIP_READERROR;
1184 if ( SCIPisZero(scip, val) )
1193 SCIP_CALL( SCIPchgVarObj(scip, data->createdpsdvars[v][col][row], 2*val) );
1195 else if ( row == col )
1197 SCIP_CALL( SCIPchgVarObj(scip, data->createdpsdvars[v][col][row], val) );
1201 SCIP_CALL( SCIPchgVarObj(scip, data->createdpsdvars[v][row][col], 2*val) );
1206 if ( nzerocoef > 0 )
1208 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
1209 "OBJFCOORD: Found %d coefficients with absolute value less than epsilon = %g.\n", nzerocoef, SCIPepsilon(scip));
1221 SCIP_Longint* linecount
1230 assert( scip != NULL );
1231 assert( data != NULL );
1232 assert( pfile != NULL );
1233 assert( linecount != NULL );
1235 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1237 if ( sscanf(data->linebuffer,
"%i", &nobjcoefs) != 1 )
1239 SCIPerrorMessage(
"Could not read number of objective coefficients for scalar variables in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1241 return SCIP_READERROR;
1244 if ( nobjcoefs < 0 )
1246 SCIPerrorMessage(
"Number of objective coefficients for scalar variables %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", nobjcoefs, *linecount);
1248 return SCIP_READERROR;
1251 if ( nobjcoefs == 0 )
1254 if ( data->createdvars == NULL )
1256 SCIPerrorMessage(
"Need to have 'VAR' section before 'OBJACOORD' section!\n");
1258 return SCIP_READERROR;
1260 assert( data->nvars >= 0 );
1262 for (i = 0; i < nobjcoefs; i++)
1264 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1265 if ( sscanf(data->linebuffer,
"%i %lf", &v, &val) != 2 )
1267 SCIPerrorMessage(
"Could not read entry of OBJACOORD in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1269 return SCIP_READERROR;
1272 if ( v < 0 || v >= data->nvars )
1274 SCIPerrorMessage(
"Given objective coefficient in line %" SCIP_LONGINT_FORMAT
" for scalar variable %d which does not exist!\n", *linecount, v);
1276 return SCIP_READERROR;
1279 if ( SCIPisInfinity(scip, val) || SCIPisInfinity(scip, -val) )
1281 SCIPerrorMessage(
"Given objective coefficient in line %" SCIP_LONGINT_FORMAT
" for scalar variable %d is infinity, which is not allowed.\n",
1284 return SCIP_READERROR;
1287 if ( SCIPisZero(scip, val) )
1293 SCIP_CALL( SCIPchgVarObj(scip, data->createdvars[v], val) );
1297 if ( nzerocoef > 0 )
1299 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
1300 "OBJACOORD: Found %d coefficients with absolute value less than epsilon = %g.\n", nzerocoef, SCIPepsilon(scip));
1312 SCIP_Longint* linecount
1324 assert( scip != NULL );
1325 assert( data != NULL );
1326 assert( pfile != NULL );
1327 assert( linecount != NULL );
1329 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1331 if ( sscanf(data->linebuffer,
"%i", &ncoefs) != 1 )
1333 SCIPerrorMessage(
"Could not read number of coefficients for psd variables in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1335 return SCIP_READERROR;
1340 SCIPerrorMessage(
"Number of matrix variable coefficients %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", ncoefs, *linecount);
1342 return SCIP_READERROR;
1348 if ( data->createdpsdvars == NULL )
1350 SCIPerrorMessage(
"Need to have 'PSDVAR' section before 'FCOORD' section!\n");
1352 return SCIP_READERROR;
1354 assert( data->npsdvars >= 0 );
1356 if ( data->createdconss == NULL )
1358 SCIPerrorMessage(
"Need to have 'CON' section before 'FCOORD' section!\n");
1360 return SCIP_READERROR;
1362 assert( data->nconss >= 0 );
1364 for (i = 0; i < ncoefs; i++)
1366 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1368 if ( sscanf(data->linebuffer,
"%i %i %i %i %lf", &c, &v, &row, &col, &val) != 5 )
1370 SCIPerrorMessage(
"Could not read entry of FCOORD in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1372 return SCIP_READERROR;
1375 if ( c < 0 || c >= data->nconss )
1377 SCIPerrorMessage(
"Given matrix variable coefficient in line %" SCIP_LONGINT_FORMAT
" for constraint %d which does not exist!\n", *linecount, c);
1379 return SCIP_READERROR;
1382 if ( v < 0 || v >= data->npsdvars )
1384 SCIPerrorMessage(
"Given coefficient in line %" SCIP_LONGINT_FORMAT
" for matrix variable %d which does not exist!\n", *linecount, v);
1386 return SCIP_READERROR;
1389 if ( row < 0 || row >= data->psdvarsizes[v] )
1391 SCIPerrorMessage(
"Row index %d of given coefficient in line %" SCIP_LONGINT_FORMAT
" for matrix variable %d in scalar constraint %d is negative or larger than varsize %d!\n",
1392 row, *linecount, v, c, data->psdvarsizes[v]);
1394 return SCIP_READERROR;
1397 if ( col < 0 || col >= data->psdvarsizes[v] )
1399 SCIPerrorMessage(
"Column index %d of given coefficient in line %" SCIP_LONGINT_FORMAT
" for matrix variable %d in scalar constraint %d is negative or larger than varsize %d!\n",
1400 col, *linecount, v, c, data->psdvarsizes[v]);
1402 return SCIP_READERROR;
1405 if ( SCIPisInfinity(scip, val) || SCIPisInfinity(scip, -val) )
1407 SCIPerrorMessage(
"Given coefficient in line %" SCIP_LONGINT_FORMAT
" for matrix variable %d is infinity, which is not allowed.\n",
1410 return SCIP_READERROR;
1413 if ( SCIPisZero(scip, val) )
1422 SCIP_CALL( SCIPaddCoefLinear(scip, data->createdconss[c], data->createdpsdvars[v][col][row], 2*val) );
1424 else if ( row == col )
1425 SCIP_CALL( SCIPaddCoefLinear(scip, data->createdconss[c], data->createdpsdvars[v][row][col], val) );
1428 SCIP_CALL( SCIPaddCoefLinear(scip, data->createdconss[c], data->createdpsdvars[v][row][col], 2*val) );
1433 if ( nzerocoef > 0 )
1435 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
1436 "FCOORD: Found %d coefficients with absolute value less than epsilon = %g.\n", nzerocoef, SCIPepsilon(scip));
1448 SCIP_Longint* linecount
1458 assert( scip != NULL );
1459 assert( data != NULL );
1460 assert( pfile != NULL );
1461 assert( linecount != NULL );
1463 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1465 if ( sscanf(data->linebuffer,
"%i", &ncoefs) != 1 )
1467 SCIPerrorMessage(
"Could not read number of linear coefficients in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1469 return SCIP_READERROR;
1474 SCIPerrorMessage(
"Number of linear coefficients %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", ncoefs, *linecount);
1476 return SCIP_READERROR;
1482 if ( data->createdvars == NULL )
1484 SCIPerrorMessage(
"Need to have 'VAR' section before 'ACOORD' section!\n");
1486 return SCIP_READERROR;
1488 assert( data->nvars >= 0 );
1490 if ( data->createdconss == NULL )
1492 SCIPerrorMessage(
"Need to have 'CON' section before 'ACOORD' section!\n");
1494 return SCIP_READERROR;
1496 assert( data->nconss >= 0 );
1498 for (i = 0; i < ncoefs; i++)
1500 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1501 if ( sscanf(data->linebuffer,
"%i %i %lf", &c, &v, &val) != 3 )
1503 SCIPerrorMessage(
"Could not read entry of ACOORD in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1505 return SCIP_READERROR;
1508 if ( c < 0 || c >= data->nconss )
1510 SCIPerrorMessage(
"Given linear coefficient in line %" SCIP_LONGINT_FORMAT
" for constraint %d which does not exist!\n", *linecount, c);
1512 return SCIP_READERROR;
1515 if ( v < 0 || v >= data->nvars )
1517 SCIPerrorMessage(
"Given linear coefficient in line %" SCIP_LONGINT_FORMAT
" for variable %d which does not exist!\n", *linecount, v);
1519 return SCIP_READERROR;
1522 if ( SCIPisInfinity(scip, val) || SCIPisInfinity(scip, -val) )
1524 SCIPerrorMessage(
"Given linear coefficient in line %" SCIP_LONGINT_FORMAT
" for variable %d is infinity, which is not allowed.\n",
1527 return SCIP_READERROR;
1530 if ( SCIPisZero(scip, val) )
1536 SCIP_CALL( SCIPaddCoefLinear(scip, data->createdconss[c], data->createdvars[v], val) );
1540 if ( nzerocoef > 0 )
1542 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
1543 "ACOORD: Found %d coefficients with absolute value less than epsilon = %g.\n", nzerocoef, SCIPepsilon(scip));
1555 SCIP_Longint* linecount
1564 assert( scip != NULL );
1565 assert( data != NULL );
1566 assert( pfile != NULL );
1567 assert( linecount != NULL );
1569 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1571 if ( sscanf(data->linebuffer,
"%i", &nsides) != 1 )
1573 SCIPerrorMessage(
"Could not read number of constant parts in scalar constraints in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1575 return SCIP_READERROR;
1580 SCIPerrorMessage(
"Number of constant parts %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", nsides, *linecount);
1582 return SCIP_READERROR;
1588 if ( data->createdconss == NULL )
1590 SCIPerrorMessage(
"Need to have 'CON' section before 'BCOORD' section!\n");
1592 return SCIP_READERROR;
1594 assert( data->nconss >= 0 );
1596 for (i = 0; i < nsides; i++)
1598 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1600 if ( sscanf(data->linebuffer,
"%i %lf", &c, &val) != 2 )
1602 SCIPerrorMessage(
"Could not read entry of BCOORD in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1604 return SCIP_READERROR;
1607 if ( c < 0 || c >= data->nconss )
1609 SCIPerrorMessage(
"Given constant part in line %" SCIP_LONGINT_FORMAT
" for scalar constraint %d which does not exist!\n", *linecount, c);
1611 return SCIP_READERROR;
1614 if ( SCIPisInfinity(scip, val) || SCIPisInfinity(scip, -val) )
1616 SCIPerrorMessage(
"Given constant part in line %" SCIP_LONGINT_FORMAT
" of scalar constraint %d is infinity, which is not allowed.\n",
1619 return SCIP_READERROR;
1622 if ( SCIPisZero(scip, val) )
1629 if ( ! SCIPisInfinity(scip, -SCIPgetLhsLinear(scip, data->createdconss[c])) )
1632 SCIP_CALL( SCIPchgLhsLinear(scip, data->createdconss[c], -val) );
1635 if ( ! SCIPisInfinity(scip, SCIPgetRhsLinear(scip, data->createdconss[c]) ) )
1638 SCIP_CALL( SCIPchgRhsLinear(scip, data->createdconss[c], -val) );
1643 if ( nzerocoef > 0 )
1645 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
1646 "BCOORD: Found %d coefficients with absolute value less than epsilon = %g.\n", nzerocoef, SCIPepsilon(scip));
1658 SCIP_Longint* linecount
1670 int nextindaftervar;
1676 assert( scip != NULL );
1677 assert( data != NULL );
1678 assert( pfile != NULL );
1679 assert( linecount != NULL );
1681 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1683 if ( sscanf(data->linebuffer,
"%i", &nnonz) != 1 )
1685 SCIPerrorMessage(
"Could not read number of nonzero coefficients of SDP-constraints in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1687 return SCIP_READERROR;
1692 SCIPerrorMessage(
"Number of nonzero coefficients of SDP-constraints %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", nnonz, *linecount);
1694 return SCIP_READERROR;
1700 if ( data->nsdpblocks < 0 )
1702 SCIPerrorMessage(
"Need to have 'PSDCON' section before 'HCOORD' section!\n");
1704 return SCIP_READERROR;
1706 assert( data->nsdpblocks >= 0 );
1708 if ( data->nvars < 0 )
1710 SCIPerrorMessage(
"Need to have 'VAR' section before 'HCOORD' section!\n");
1712 return SCIP_READERROR;
1714 assert( data->nvars >= 0 );
1718 if ( data->npsdvars > 0 )
1720 ncbfsdpblocks = data->nsdpblocks - data->npsdvars;
1721 for (i = 0; i < data->npsdvars; i++)
1722 nauxnonz += data->psdvarsizes[i] * (data->psdvarsizes[i] + 1) / 2;
1726 ncbfsdpblocks = data->nsdpblocks;
1729 assert( ncbfsdpblocks >= 0 );
1732 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpnblocknonz), data->nsdpblocks) );
1733 for (b = 0; b < data->nsdpblocks; b++)
1734 data->sdpnblocknonz[b] = 0;
1736 data->nnonz = nnonz + nauxnonz;
1739 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &sdpvar, data->nsdpblocks) );
1740 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdprow), data->nsdpblocks) );
1741 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpcol), data->nsdpblocks) );
1742 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpval), data->nsdpblocks) );
1744 for (b = 0; b < data->nsdpblocks; b++)
1746 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(sdpvar[b]), data->nnonz) );
1747 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdprow[b]), data->nnonz) );
1748 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpcol[b]), data->nnonz) );
1749 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpval[b]), data->nnonz) );
1752 for (i = 0; i < nnonz; i++)
1754 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1756 if ( sscanf(data->linebuffer,
"%i %i %i %i %lf", &b, &v, &row, &col, &val) != 5 )
1758 SCIPerrorMessage(
"Could not read entry of HCOORD in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1762 if ( b < 0 || b >= ncbfsdpblocks )
1764 SCIPerrorMessage(
"Given SDP-coefficient in line %" SCIP_LONGINT_FORMAT
" for SDP-constraint %d which does not exist!\n", *linecount, b);
1768 if ( v < 0 || v >= data->nvars )
1770 SCIPerrorMessage(
"Given SDP-coefficient in line %" SCIP_LONGINT_FORMAT
" for variable %d which does not exist!\n", *linecount, v);
1774 if ( row < 0 || row >= data->sdpblocksizes[b] )
1776 SCIPerrorMessage(
"Row index %d of given SDP coefficient in line %" SCIP_LONGINT_FORMAT
" is negative or larger than blocksize %d!\n",
1777 row, *linecount, data->sdpblocksizes[b]);
1781 if ( col < 0 || col >= data->sdpblocksizes[b] )
1783 SCIPerrorMessage(
"Column index %d of given SDP coefficient in line %" SCIP_LONGINT_FORMAT
" is negative or larger than blocksize %d!\n",
1784 col, *linecount, data->sdpblocksizes[b]);
1788 if ( SCIPisInfinity(scip, val) || SCIPisInfinity(scip, -val) )
1790 SCIPerrorMessage(
"Given SDP-coefficient in line %" SCIP_LONGINT_FORMAT
" for variable %d is infinity, which is not allowed.\n",
1795 if ( SCIPisZero(scip, val) )
1801 sdpvar[b][data->sdpnblocknonz[b]] = v;
1806 data->sdprow[b][data->sdpnblocknonz[b]] = col;
1807 data->sdpcol[b][data->sdpnblocknonz[b]] = row;
1811 data->sdprow[b][data->sdpnblocknonz[b]] = row;
1812 data->sdpcol[b][data->sdpnblocknonz[b]] = col;
1815 data->sdpval[b][data->sdpnblocknonz[b]] = val;
1816 data->sdpnblocknonz[b]++;
1821 if ( data->npsdvars > 0 )
1824 for (v = 0; v < data->npsdvars; v++)
1826 b = ncbfsdpblocks + v;
1827 for (row = 0; row < data->psdvarsizes[v]; row++)
1829 for (col = 0; col <= row; col++)
1831 sdpvar[b][data->sdpnblocknonz[b]] = data->nvars + 1;
1832 data->sdprow[b][data->sdpnblocknonz[b]] = row;
1833 data->sdpcol[b][data->sdpnblocknonz[b]] = col;
1834 data->sdpval[b][data->sdpnblocknonz[b]] = val;
1835 data->sdpnblocknonz[b]++;
1838 assert( data->sdpnblocknonz[b] == data->psdvarsizes[v] * (data->psdvarsizes[v] + 1) / 2 );
1839 assert( b == data->nsdpblocks - 1 );
1844 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpnblockvars), data->nsdpblocks) );
1845 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblockvars), data->nsdpblocks) );
1846 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->nvarnonz), data->nsdpblocks) );
1847 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->rowpointer), data->nsdpblocks) );
1848 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->colpointer), data->nsdpblocks) );
1849 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->valpointer), data->nsdpblocks) );
1852 for (b = 0; b < ncbfsdpblocks; b++)
1855 SCIPsortIntIntIntReal(sdpvar[b], data->sdprow[b], data->sdpcol[b], data->sdpval[b], data->sdpnblocknonz[b]);
1858 nextindaftervar = 0;
1859 data->sdpnblockvars[b] = 0;
1860 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblockvars[b]), data->nvars) );
1861 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->nvarnonz[b]), data->nvars) );
1862 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->rowpointer[b]), data->nvars) );
1863 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->colpointer[b]), data->nvars) );
1864 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->valpointer[b]), data->nvars) );
1866 for (v = 0; v < data->nvars; v++)
1868 SCIP_Bool varused = FALSE;
1870 firstindforvar = nextindaftervar;
1871 data->nvarnonz[b][data->sdpnblockvars[b]] = 0;
1873 while (nextindaftervar < data->sdpnblocknonz[b] && sdpvar[b][nextindaftervar] == v)
1877 data->nvarnonz[b][data->sdpnblockvars[b]]++;
1882 data->sdpblockvars[b][data->sdpnblockvars[b]] = data->createdvars[v];
1883 data->rowpointer[b][data->sdpnblockvars[b]] = &(data->sdprow[b][firstindforvar]);
1884 data->colpointer[b][data->sdpnblockvars[b]] = &(data->sdpcol[b][firstindforvar]);
1885 data->valpointer[b][data->sdpnblockvars[b]] = &(data->sdpval[b][firstindforvar]);
1886 data->sdpnblockvars[b]++;
1890 assert( nextindaftervar == data->sdpnblocknonz[b] );
1894 if ( data->npsdvars > 0 )
1896 assert( data->nsdpblocks == ncbfsdpblocks + data->npsdvars );
1897 for (v = 0; v < data->npsdvars; v++)
1902 b = ncbfsdpblocks + v;
1904 data->sdpnblockvars[b] = data->sdpnblocknonz[b];
1906 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblockvars[b]), data->sdpnblocknonz[b]) );
1907 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->nvarnonz[b]), data->sdpnblocknonz[b]) );
1908 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->rowpointer[b]), data->sdpnblocknonz[b]) );
1909 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->colpointer[b]), data->sdpnblocknonz[b]) );
1910 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->valpointer[b]), data->sdpnblocknonz[b]) );
1912 for (row = 0; row < data->psdvarsizes[v]; row++)
1914 for (col = 0; col <= row; col++)
1916 data->nvarnonz[b][varidx] = 1;
1917 data->sdpblockvars[b][varidx] = data->createdpsdvars[v][row][col];
1918 data->rowpointer[b][varidx] = &(data->sdprow[b][varidx]);
1919 data->colpointer[b][varidx] = &(data->sdpcol[b][varidx]);
1920 data->valpointer[b][varidx] = &(data->sdpval[b][varidx]);
1924 assert( varidx == data->sdpnblocknonz[b] );
1928 for (b = 0; b < data->nsdpblocks; b++)
1929 SCIPfreeBlockMemoryArray(scip, &(sdpvar[b]), data->nnonz);
1931 SCIPfreeBlockMemoryArray(scip, &sdpvar, data->nsdpblocks);
1933 if ( nzerocoef > 0 )
1935 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
1936 "HCOORD: Found %d coefficients with absolute value less than epsilon = %g.\n", nzerocoef, SCIPepsilon(scip));
1943 for (b = 0; b < data->nsdpblocks; b++)
1944 SCIPfreeBlockMemoryArray(scip, &(sdpvar[b]), data->nnonz);
1946 SCIPfreeBlockMemoryArray(scip, &sdpvar, data->nsdpblocks);
1949 return SCIP_READERROR;
1958 SCIP_Longint* linecount
1969 assert( scip != NULL );
1970 assert( data != NULL );
1971 assert( pfile != NULL );
1972 assert( linecount != NULL );
1974 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
1976 if ( sscanf(data->linebuffer,
"%i", &constnnonz) != 1 )
1978 SCIPerrorMessage(
"Could not read number of constant entries of SDP-constraints in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
1980 return SCIP_READERROR;
1983 if ( constnnonz < 0 )
1985 SCIPerrorMessage(
"Number of constant entries of SDP-constraints %d in line %" SCIP_LONGINT_FORMAT
" should be non-negative!\n", constnnonz, *linecount);
1987 return SCIP_READERROR;
1990 if ( constnnonz == 0 )
1993 if ( data->nsdpblocks < 0 )
1995 SCIPerrorMessage(
"Need to have 'PSDCON' section before 'DCOORD' section!\n");
1997 return SCIP_READERROR;
2007 data->constnnonz = constnnonz;
2008 assert( constnnonz > 0 );
2011 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstnblocknonz), data->nsdpblocks) );
2012 for (b = 0; b < data->nsdpblocks; b++)
2013 data->sdpconstnblocknonz[b] = 0;
2016 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstrow), data->nsdpblocks) );
2017 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstcol), data->nsdpblocks) );
2018 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstval), data->nsdpblocks) );
2020 for (b = 0; b < data->nsdpblocks; b++)
2022 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstrow[b]), constnnonz) );
2023 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstcol[b]), constnnonz) );
2024 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstval[b]), constnnonz) );
2027 for (i = 0; i < constnnonz; i++)
2029 SCIP_CALL(
CBFfgets(scip, data, pfile, linecount, TRUE) );
2030 if ( sscanf(data->linebuffer,
"%i %i %i %lf", &b, &row, &col, &val) != 4 )
2032 SCIPerrorMessage(
"Could not read entry of DCOORD in line %" SCIP_LONGINT_FORMAT
".\n", *linecount);
2034 return SCIP_READERROR;
2037 if ( b < 0 || b >= data->nsdpblocks )
2039 SCIPerrorMessage(
"Given constant entry in line %" SCIP_LONGINT_FORMAT
" for SDP-constraint %d which does not exist!\n", *linecount, b);
2041 return SCIP_READERROR;
2044 if ( row < 0 || row >= data->sdpblocksizes[b] )
2046 SCIPerrorMessage(
"Row index %d of given constant SDP-entry in line %" SCIP_LONGINT_FORMAT
" is negative or larger than blocksize %d!\n",
2047 row, *linecount, data->sdpblocksizes[b]);
2049 return SCIP_READERROR;
2052 if ( col < 0 || col >= data->sdpblocksizes[b] )
2054 SCIPerrorMessage(
"Column index %d of given constant SDP-entry in line %" SCIP_LONGINT_FORMAT
" is negative or larger than blocksize %d!\n",
2055 col, *linecount, data->sdpblocksizes[b]);
2057 return SCIP_READERROR;
2060 if ( SCIPisInfinity(scip, val) || SCIPisInfinity(scip, -val) )
2062 SCIPerrorMessage(
"Given constant entry in line %" SCIP_LONGINT_FORMAT
" for SDP constraint %d is infinity, which is not allowed.\n",
2065 return SCIP_READERROR;
2068 if ( SCIPisZero(scip, val) )
2077 data->sdpconstrow[b][data->sdpconstnblocknonz[b]] = col;
2078 data->sdpconstcol[b][data->sdpconstnblocknonz[b]] = row;
2082 data->sdpconstrow[b][data->sdpconstnblocknonz[b]] = row;
2083 data->sdpconstcol[b][data->sdpconstnblocknonz[b]] = col;
2085 data->sdpconstval[b][data->sdpconstnblocknonz[b]] = -val;
2086 data->sdpconstnblocknonz[b]++;
2090 if ( nzerocoef > 0 )
2092 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
2093 "DCOORD: Found %d coefficients with absolute value less than epsilon = %g.\n", nzerocoef, SCIPepsilon(scip));
2109 assert(scip != NULL);
2120 SCIP_FILE* scipfile;
2121 SCIP_Longint linecount = 0;
2122 SCIP_Bool versionread = FALSE;
2123 SCIP_Bool objread = FALSE;
2127 assert( result != NULL );
2129 *result = SCIP_DIDNOTRUN;
2131 SCIPdebugMsg(scip,
"Reading file %s ...\n", filename);
2133 scipfile = SCIPfopen(filename,
"r");
2136 return SCIP_READERROR;
2138 SCIP_CALL( SCIPallocBuffer(scip, &data) );
2139 data->nsdpblocks = -1;
2140 data->nsdpblocksrank1 = 0;
2143 data->npsdvars = -1;
2144 data->constnnonz = 0;
2146 data->noorigsdpcons= FALSE;
2148 data->createdvars = NULL;
2149 data->createdconss = NULL;
2150 data->createdpsdvars = NULL;
2151 data->psdvarsizes = NULL;
2152 data->psdvarrank1 = NULL;
2153 data->sdpblockrank1 = NULL;
2154 data->sdpblocksizes = NULL;
2155 data->sdpnblocknonz = NULL;
2156 data->sdpnblockvars = NULL;
2157 data->nvarnonz = NULL;
2158 data->sdpblockvars = NULL;
2159 data->sdprow = NULL;
2160 data->sdpcol = NULL;
2161 data->sdpval = NULL;
2162 data->rowpointer = NULL;
2163 data->colpointer = NULL;
2164 data->valpointer = NULL;
2165 data->sdpconstnblocknonz = NULL;
2166 data->sdpconstrow = NULL;
2167 data->sdpconstcol = NULL;
2168 data->sdpconstval = NULL;
2170 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &data->linebuffer,
CBF_MAX_LINE) );
2171 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &data->namebuffer,
CBF_MAX_NAME) );
2174 SCIP_CALL( SCIPcreateProb(scip, filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
2176 while(
CBFfgets(scip, data, scipfile, &linecount, FALSE) == SCIP_OKAY )
2179 if ( sscanf(data->linebuffer,
CBF_NAME_FORMAT, data->namebuffer) == 1 )
2182 if ( ! versionread )
2184 if ( strcmp(data->namebuffer,
"VER") == 0 )
2188 SCIP_CALL(
CBFfgets(scip, data, scipfile, &linecount, TRUE) );
2190 if ( sscanf(data->linebuffer,
"%i", &ver) == 1 )
2192 SCIPdebugMsg(scip,
"file version %d.\n", ver);
2195 SCIPerrorMessage(
"Strange version number %d; need at least version 1.\n", ver);
2197 return SCIP_READERROR;
2201 SCIPerrorMessage(
"Version %d too new; only supported up to version %d.\n", ver,
CBF_VERSION_NR);
2203 return SCIP_READERROR;
2210 SCIPerrorMessage(
"Could not read version number in line %" SCIP_LONGINT_FORMAT
".\n", linecount);
2212 return SCIP_READERROR;
2217 SCIPerrorMessage(
"First keyword should be VER.\n");
2219 return SCIP_READERROR;
2224 if ( strcmp(data->namebuffer,
"OBJSENSE") == 0 )
2226 SCIPdebugMsg(scip,
"Reading OBJSENSE\n");
2230 else if ( strcmp(data->namebuffer,
"VAR") == 0 )
2232 SCIPdebugMsg(scip,
"Reading VAR\n");
2233 SCIP_CALL(
CBFreadVar(scip, data, scipfile, &linecount) );
2235 else if ( strcmp(data->namebuffer,
"CON") == 0 )
2237 SCIPdebugMsg(scip,
"Reading CON\n");
2238 SCIP_CALL(
CBFreadCon(scip, data, scipfile, &linecount) );
2240 else if ( strcmp(data->namebuffer,
"INT") == 0 )
2242 SCIPdebugMsg(scip,
"Reading INT\n");
2243 SCIP_CALL(
CBFreadInt(scip, data, scipfile, &linecount) );
2245 else if ( strcmp(data->namebuffer,
"PSDCON") == 0 )
2247 SCIPdebugMsg(scip,
"Reading PSDCON\n");
2248 SCIP_CALL(
CBFreadPsdCon(scip, data, scipfile, &linecount) );
2250 else if ( strcmp(data->namebuffer,
"PSDVAR") == 0 )
2252 SCIPdebugMsg(scip,
"Reading PSDVAR\n");
2253 SCIP_CALL(
CBFreadPsdVar(scip, data, scipfile, &linecount) );
2255 else if ( strcmp(data->namebuffer,
"PSDCONRANK1") == 0 )
2257 SCIPdebugMsg(scip,
"Reading PSDCONRANK1\n");
2260 else if ( strcmp(data->namebuffer,
"PSDVARRANK1") == 0 )
2262 SCIPdebugMsg(scip,
"Reading PSDVARRANK1\n");
2265 else if ( strcmp(data->namebuffer,
"OBJFCOORD") == 0 )
2267 SCIPdebugMsg(scip,
"Reading OBJFCOORD\n");
2270 else if ( strcmp(data->namebuffer,
"OBJACOORD") == 0 )
2272 SCIPdebugMsg(scip,
"Reading OBJACOORD\n");
2275 else if ( strcmp(data->namebuffer,
"OBJBCOORD") == 0 )
2277 SCIPerrorMessage(
"constant part in objective value not supported by SCIP!\n");
2279 return SCIP_READERROR;
2281 else if ( strcmp(data->namebuffer,
"FCOORD") == 0 )
2283 SCIPdebugMsg(scip,
"Reading FCOORD\n");
2284 SCIP_CALL(
CBFreadFcoord(scip, data, scipfile, &linecount) );
2286 else if ( strcmp(data->namebuffer,
"ACOORD") == 0 )
2288 SCIPdebugMsg(scip,
"Reading ACOORD\n");
2289 SCIP_CALL(
CBFreadAcoord(scip, data, scipfile, &linecount) );
2291 else if ( strcmp(data->namebuffer,
"BCOORD") == 0 )
2293 SCIPdebugMsg(scip,
"Reading BCOORD\n");
2294 SCIP_CALL(
CBFreadBcoord(scip, data, scipfile, &linecount) );
2296 else if ( strcmp(data->namebuffer,
"HCOORD") == 0 )
2298 SCIPdebugMsg(scip,
"Reading HCOORD\n");
2299 SCIP_CALL(
CBFreadHcoord(scip, data, scipfile, &linecount) );
2301 else if ( strcmp(data->namebuffer,
"DCOORD") == 0 )
2303 SCIPdebugMsg(scip,
"Reading DCOORD\n");
2304 SCIP_CALL(
CBFreadDcoord(scip, data, scipfile, &linecount) );
2308 SCIPerrorMessage(
"Keyword %s in line %" SCIP_LONGINT_FORMAT
" not recognized!\n", data->namebuffer, linecount);
2310 return SCIP_READERROR;
2317 if ( data->nsdpblocks < 0 )
2318 data->nsdpblocks = 0;
2320 if ( data->npsdvars < 0 )
2326 if ( data->npsdvars > data->nsdpblocks )
2334 assert( data->nsdpblocks == 0 );
2335 assert( data->createdpsdvars != NULL );
2336 assert( data->psdvarrank1 != NULL );
2337 assert( data->npsdvars > 0 );
2339 data->noorigsdpcons = TRUE;
2341 data->nsdpblocks = data->npsdvars;
2345 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblocksizes), data->nsdpblocks) );
2346 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblockrank1), data->nsdpblocks) );
2347 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpnblocknonz), data->nsdpblocks) );
2348 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpnblockvars), data->nsdpblocks) );
2349 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->nvarnonz), data->nsdpblocks) );
2350 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblockvars), data->nsdpblocks) );
2351 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdprow), data->nsdpblocks) );
2352 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpcol), data->nsdpblocks) );
2353 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpval), data->nsdpblocks) );
2354 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->rowpointer), data->nsdpblocks) );
2355 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->colpointer), data->nsdpblocks) );
2356 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->valpointer), data->nsdpblocks) );
2358 for (b = 0; b < data->nsdpblocks; b++)
2360 nauxvars = data->psdvarsizes[b] * (data->psdvarsizes[b] + 1) / 2;
2361 data->nnonz += nauxvars;
2364 data->sdpblocksizes[b] = data->psdvarsizes[b];
2365 data->sdpblockrank1[b] = data->psdvarrank1[b];
2366 data->sdpnblocknonz[b] = nauxvars;
2367 data->sdpnblockvars[b] = nauxvars;
2369 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->nvarnonz[b]), nauxvars) );
2370 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblockvars[b]), nauxvars) );
2371 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdprow[b]), nauxvars) );
2372 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpcol[b]), nauxvars) );
2373 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpval[b]), nauxvars) );
2374 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->rowpointer[b]), nauxvars) );
2375 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->colpointer[b]), nauxvars) );
2376 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->valpointer[b]), nauxvars) );
2379 for (row = 0; row < data->psdvarsizes[b]; row++)
2381 for (col = 0; col <= row; col++)
2383 data->sdprow[b][varidx] = row;
2384 data->sdpcol[b][varidx] = col;
2385 data->sdpval[b][varidx] = val;
2387 data->nvarnonz[b][varidx] = 1;
2388 data->sdpblockvars[b][varidx] = data->createdpsdvars[b][row][col];
2389 data->rowpointer[b][varidx] = &(data->sdprow[b][varidx]);
2390 data->colpointer[b][varidx] = &(data->sdpcol[b][varidx]);
2391 data->valpointer[b][varidx] = &(data->sdpval[b][varidx]);
2395 assert( varidx == nauxvars );
2399 assert( data->npsdvars == data->nsdpblocks || ! data->noorigsdpcons );
2403 SCIPerrorMessage(
"Keyword OBJSENSE is missing!\n");
2405 return SCIP_READERROR;
2408 #ifdef SCIP_MORE_DEBUG 2409 for (b = 0; b < SCIPgetNConss(scip); b++)
2411 SCIP_CALL( SCIPprintCons(scip, SCIPgetConss(scip)[b], NULL) );
2412 SCIPinfoMessage(scip, NULL,
"\n");
2417 if ( data->sdpnblocknonz == NULL && data->nsdpblocks > 0 )
2419 SCIPerrorMessage(
"No nonconstant nonzeros have been specified for any SDP block, please remove all SDP blocks!\n");
2421 return SCIP_READERROR;
2425 for (b = 0; b < data->nsdpblocks; b++)
2428 char sdpconname[SCIP_MAXSTRLEN];
2434 if ( data->sdpnblockvars[b] == 0 || data->sdpnblocknonz[b] == 0 )
2436 SCIPerrorMessage(
"SDP block %d has no nonzeros or only constant nonzeros, please remove this SDP block!\n", b);
2438 return SCIP_READERROR;
2441 assert( data->sdpblocksizes[b] > 0 );
2442 assert( (data->sdpnblockvars[b] > 0 && data->sdpnblocknonz[b] > 0) || (data->sdpconstnblocknonz[b] > 0) );
2445 snprintfreturn = SCIPsnprintf(sdpconname, SCIP_MAXSTRLEN,
"SDP_%d", b);
2446 assert( snprintfreturn < SCIP_MAXSTRLEN);
2448 (void) SCIPsnprintf(sdpconname, SCIP_MAXSTRLEN,
"SDP_%d", b);
2452 if ( data->sdpconstnblocknonz == NULL )
2454 if ( ! data->sdpblockrank1[b] )
2456 SCIP_CALL(
SCIPcreateConsSdp(scip, &sdpcons, sdpconname, data->sdpnblockvars[b], data->sdpnblocknonz[b],
2457 data->sdpblocksizes[b], data->nvarnonz[b], data->colpointer[b], data->rowpointer[b], data->valpointer[b],
2458 data->sdpblockvars[b], 0, NULL, NULL, NULL, TRUE) );
2462 SCIP_CALL(
SCIPcreateConsSdpRank1(scip, &sdpcons, sdpconname, data->sdpnblockvars[b], data->sdpnblocknonz[b],
2463 data->sdpblocksizes[b], data->nvarnonz[b], data->colpointer[b], data->rowpointer[b], data->valpointer[b],
2464 data->sdpblockvars[b], 0, NULL, NULL, NULL, TRUE) );
2469 if ( ! data->sdpblockrank1[b] )
2471 SCIP_CALL(
SCIPcreateConsSdp(scip, &sdpcons, sdpconname, data->sdpnblockvars[b], data->sdpnblocknonz[b],
2472 data->sdpblocksizes[b], data->nvarnonz[b], data->colpointer[b], data->rowpointer[b], data->valpointer[b],
2473 data->sdpblockvars[b], data->sdpconstnblocknonz[b], data->sdpconstcol[b], data->sdpconstrow[b],
2474 data->sdpconstval[b], TRUE) );
2478 SCIP_CALL(
SCIPcreateConsSdpRank1(scip, &sdpcons, sdpconname, data->sdpnblockvars[b], data->sdpnblocknonz[b],
2479 data->sdpblocksizes[b], data->nvarnonz[b], data->colpointer[b], data->rowpointer[b], data->valpointer[b],
2480 data->sdpblockvars[b], data->sdpconstnblocknonz[b], data->sdpconstcol[b], data->sdpconstrow[b],
2481 data->sdpconstval[b], TRUE) );
2485 #ifdef SCIP_MORE_DEBUG 2486 SCIP_CALL( SCIPprintCons(scip, sdpcons, NULL) );
2489 SCIP_CALL( SCIPaddCons(scip, sdpcons) );
2491 SCIP_CALL( SCIPreleaseCons(scip, &sdpcons) );
2496 *result = SCIP_SUCCESS;
2510 SCIP_Real* sdpconstval;
2524 int totalsdpconstnnonz;
2536 int nrank1sdpblocks;
2538 assert( scip != NULL );
2539 assert( result != NULL );
2541 SCIPdebugMsg(scip,
"Writing problem in CBF format to file.\n");
2542 *result = SCIP_DIDNOTRUN;
2546 SCIPerrorMessage(
"CBF reader currently only supports writing original problems!\n");
2547 return SCIP_READERROR;
2550 for (c = 0; c < nconss; c++)
2552 if ( (strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0)
2553 && (strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 )
2554 && (strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDPrank1") != 0 ) )
2556 SCIPerrorMessage(
"CBF reader currently only supports linear and SDP constraints!\n");
2557 return SCIP_READERROR;
2562 for (v = 0; v < nvars; v++)
2564 assert( SCIPvarGetStatus(vars[v]) == SCIP_VARSTATUS_ORIGINAL );
2572 SCIPinfoMessage(scip, file,
"OBJSENSE\n%s\n\n", objsense == SCIP_OBJSENSE_MINIMIZE ?
"MIN" :
"MAX");
2575 SCIP_CALL( SCIPallocBufferArray(scip, &varsenses, nvars) );
2576 for (v = 0; v < nvars; v++)
2581 lb = SCIPvarGetLbOriginal(vars[v]);
2582 ub = SCIPvarGetUbOriginal(vars[v]);
2585 if ( SCIPisZero(scip, lb) )
2589 if ( ! SCIPisInfinity(scip, -lb) )
2591 SCIPerrorMessage(
"Can only handle variables with lower bound 0 or minus infinity.\n");
2592 SCIPfreeBufferArray(scip, &varsenses);
2593 return SCIP_READERROR;
2597 if ( SCIPisZero(scip, ub) )
2601 if ( ! SCIPisInfinity(scip, ub) )
2603 SCIPerrorMessage(
"Can only handle variables with upper bound 0 or infinity.\n");
2604 SCIPfreeBufferArray(scip, &varsenses);
2605 return SCIP_READERROR;
2611 SCIP_CALL( SCIPallocBufferArray(scip, &consssenses, nconss) );
2612 for (c = 0; c < nconss; c++)
2620 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
2623 lhs = SCIPgetLhsLinear(scip, conss[c]);
2624 rhs = SCIPgetRhsLinear(scip, conss[c]);
2626 #ifdef CBF_CHECK_NONNEG 2628 if ( SCIPgetNVarsLinear(scip, conss[c]) == 1 && ! SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) )
2631 assert( ! SCIPisZero(scip, SCIPgetValsLinear(scip, conss[c])[0]) );
2632 assert( SCIPgetVarsLinear(scip, conss[c]) != NULL );
2634 v = SCIPvarGetProbindex(SCIPgetVarsLinear(scip, conss[c])[0]);
2635 assert( 0 <= v && v < nvars );
2637 if ( SCIPgetValsLinear(scip, conss[c])[0] > 0.0 )
2639 if ( SCIPisZero(scip, lhs) )
2644 else if ( SCIPisZero(scip, rhs) )
2652 if ( SCIPisZero(scip, lhs) )
2657 else if ( SCIPisZero(scip, rhs) )
2666 if ( SCIPisEQ(scip, lhs, rhs) )
2668 assert( ! SCIPisInfinity(scip, -lhs) );
2669 assert( ! SCIPisInfinity(scip, rhs) );
2674 if ( ! SCIPisInfinity(scip, -lhs) && ! SCIPisInfinity(scip, rhs) )
2676 SCIPerrorMessage(
"Cannot handle ranged rows.\n");
2677 SCIPfreeBufferArray(scip, &varsenses);
2678 SCIPfreeBufferArray(scip, &consssenses);
2679 return SCIP_READERROR;
2682 if ( ! SCIPisInfinity(scip, -lhs) )
2684 else if ( ! SCIPisInfinity(scip, rhs) )
2685 consssenses[c] = -1;
2692 for (v = 0; v < nvars; v++)
2694 if ( varsenses[v] != lastsense )
2697 lastsense = varsenses[v];
2702 SCIPinfoMessage(scip, file,
"VAR\n%d %d\n", nvars, nsenses);
2703 lastsense = varsenses[0];
2705 for (v = 1; v < nvars; v++)
2707 if ( varsenses[v] != lastsense )
2709 if ( lastsense == 0 )
2710 SCIPinfoMessage(scip, file,
"F %d\n", nsenses);
2711 else if ( lastsense == -1 )
2712 SCIPinfoMessage(scip, file,
"L- %d\n", nsenses);
2715 assert( lastsense == 1 );
2716 SCIPinfoMessage(scip, file,
"L+ %d\n", nsenses);
2719 lastsense = varsenses[v];
2723 if ( lastsense == 0 )
2724 SCIPinfoMessage(scip, file,
"F %d\n\n", nsenses);
2725 else if ( lastsense == -1 )
2726 SCIPinfoMessage(scip, file,
"L- %d\n\n", nsenses);
2729 assert( lastsense == 1 );
2730 SCIPinfoMessage(scip, file,
"L+ %d\n\n", nsenses);
2734 if ( nbinvars + nintvars > 0 )
2736 SCIPinfoMessage(scip, file,
"INT\n%d\n", nbinvars + nintvars);
2738 for (v = 0; v < nbinvars + nintvars; v++)
2740 assert( SCIPvarIsIntegral(vars[v]) );
2741 SCIPinfoMessage(scip, file,
"%d\n", v);
2743 SCIPinfoMessage(scip, file,
"\n");
2750 for (c = 0; c < nconss; c++)
2752 if ( consssenses[c] == 2 )
2756 if ( consssenses[c] != lastsense )
2759 lastsense = consssenses[c];
2763 assert( nsenses == 0 || i > 0 );
2764 assert( nsenses > 0 || i == 0 );
2769 SCIPinfoMessage(scip, file,
"CON\n%d %d\n", i, nsenses);
2770 nconsssenses = nsenses;
2772 while (c < nconss && consssenses[c] == 2)
2776 lastsense = consssenses[c];
2779 for (; c < nconss; ++c)
2781 if ( consssenses[c] == 2 )
2784 if ( consssenses[c] != lastsense )
2786 if ( lastsense == 0 )
2787 SCIPinfoMessage(scip, file,
"L= %d\n", nsenses);
2788 else if ( lastsense == -1 )
2789 SCIPinfoMessage(scip, file,
"L- %d\n", nsenses);
2792 assert( lastsense == 1 );
2793 SCIPinfoMessage(scip, file,
"L+ %d\n", nsenses);
2796 lastsense = consssenses[c];
2801 if ( lastsense == 0 )
2802 SCIPinfoMessage(scip, file,
"L= %d\n\n", nsenses);
2803 else if ( lastsense == -1 )
2804 SCIPinfoMessage(scip, file,
"L- %d\n\n", nsenses);
2807 assert( lastsense == 1 );
2808 SCIPinfoMessage(scip, file,
"L+ %d\n\n", nsenses);
2818 for (c = 0; c < nconss; c++)
2820 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") == 0 || strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDPrank1") == 0 )
2825 if ( nsdpconss > 0 )
2827 SCIPinfoMessage(scip, file,
"PSDCON\n%d\n", nsdpconss);
2829 for (c = 0; c < nconss; c++)
2831 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 && strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDPrank1") != 0 )
2837 SCIPinfoMessage(scip, file,
"\n");
2841 nrank1sdpblocks = 0;
2842 for (c = 0; c < nconss; c++)
2844 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDPrank1") == 0 )
2849 if ( nrank1sdpblocks > 0 )
2851 SCIPinfoMessage(scip, file,
"PSDCONRANK1\n%d\n", nrank1sdpblocks);
2854 for (c = 0; c < nconss; c++)
2856 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDPrank1") != 0 )
2860 SCIPinfoMessage(scip, file,
"%d\n", consind);
2864 SCIPinfoMessage(scip, file,
"\n");
2869 for (v = 0; v < nvars; v++)
2871 if ( ! SCIPisZero(scip, SCIPvarGetObj(vars[v])) )
2876 SCIPinfoMessage(scip, file,
"OBJACOORD\n%d\n", nobjnonz);
2878 for (v = 0; v < nvars; v++)
2882 obj = SCIPvarGetObj(vars[v]);
2883 if ( ! SCIPisZero(scip, obj) )
2885 SCIPinfoMessage(scip, file,
"%d %.15g\n", v, obj);
2888 SCIPinfoMessage(scip, file,
"\n");
2891 if ( nconsssenses > 0 )
2896 for (c = 0; c < nconss; c++)
2898 if ( consssenses[c] == -1 )
2900 assert( ! SCIPisInfinity(scip, SCIPgetRhsLinear(scip, conss[c])) );
2901 nnonz += SCIPgetNVarsLinear(scip, conss[c]);
2902 if ( ! SCIPisZero(scip, SCIPgetRhsLinear(scip, conss[c])) )
2905 else if ( consssenses[c] == 1 )
2907 assert( ! SCIPisInfinity(scip, -SCIPgetLhsLinear(scip, conss[c])) );
2908 nnonz += SCIPgetNVarsLinear(scip, conss[c]);
2909 if ( ! SCIPisZero(scip, SCIPgetLhsLinear(scip, conss[c])) )
2912 else if ( consssenses[c] == 0 )
2914 assert( SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) );
2915 nnonz += SCIPgetNVarsLinear(scip, conss[c]);
2916 if ( ! SCIPisZero(scip, SCIPgetLhsLinear(scip, conss[c])) )
2922 SCIPinfoMessage(scip, file,
"ACOORD\n%d\n", nnonz);
2924 for (c = 0; c < nconss; c++)
2926 if ( consssenses[c] == -1 || consssenses[c] == 0 || consssenses[c] == 1 )
2928 assert( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") == 0 );
2930 linvars = SCIPgetVarsLinear(scip, conss[c]);
2931 linvals = SCIPgetValsLinear(scip, conss[c]);
2933 for (v = 0; v < SCIPgetNVarsLinear(scip, conss[c]); v++)
2935 i = SCIPvarGetProbindex(linvars[v]);
2936 assert( 0 <= i && i < nvars );
2937 SCIPinfoMessage(scip, file,
"%d %d %.15g\n", consind, i, linvals[v]);
2942 SCIPinfoMessage(scip, file,
"\n");
2945 SCIPinfoMessage(scip, file,
"BCOORD\n%d\n", nbnonz);
2947 for (c = 0; c < nconss; c++)
2950 if ( consssenses[c] == -1 )
2952 val = SCIPgetRhsLinear(scip, conss[c]);
2953 if ( ! SCIPisZero(scip, val) )
2954 SCIPinfoMessage(scip, file,
"%d %.15g\n", consind, -val);
2957 else if ( consssenses[c] == 1 )
2959 val = SCIPgetLhsLinear(scip, conss[c]);
2960 if ( ! SCIPisZero(scip, val) )
2961 SCIPinfoMessage(scip, file,
"%d %.15g\n", consind, -val);
2964 else if ( consssenses[c] == 0 )
2966 val = SCIPgetLhsLinear(scip, conss[c]);
2967 if ( ! SCIPisZero(scip, val) )
2968 SCIPinfoMessage(scip, file,
"%d %.15g\n", consind, -val);
2972 SCIPinfoMessage(scip, file,
"\n");
2977 totalsdpconstnnonz = 0;
2978 for (c = 0; c < nconss; c++)
2980 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 && strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDPrank1") != 0 )
2984 totalsdpnnonz += sdpnnonz;
2985 totalsdpconstnnonz += sdpconstnnonz;
2989 SCIP_CALL( SCIPallocBufferArray(scip, &sdpnvarnonz, nvars) );
2990 SCIP_CALL( SCIPallocBufferArray(scip, &sdpcol, totalsdpnnonz) );
2991 SCIP_CALL( SCIPallocBufferArray(scip, &sdprow, totalsdpnnonz) );
2992 SCIP_CALL( SCIPallocBufferArray(scip, &sdpval, totalsdpnnonz) );
2993 SCIP_CALL( SCIPallocBufferArray(scip, &sdpvars, nvars) );
2994 SCIP_CALL( SCIPallocBufferArray(scip, &sdpconstcol, totalsdpconstnnonz) );
2995 SCIP_CALL( SCIPallocBufferArray(scip, &sdpconstrow, totalsdpconstnnonz) );
2996 SCIP_CALL( SCIPallocBufferArray(scip, &sdpconstval, totalsdpconstnnonz) );
2998 sdparraylength = totalsdpnnonz;
2999 sdpconstnnonz = totalsdpconstnnonz;
3002 if ( totalsdpnnonz > 0 )
3004 SCIPinfoMessage(scip, file,
"HCOORD\n%d\n", totalsdpnnonz);
3006 for (c = 0; c < nconss; c++)
3008 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 && strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDPrank1") != 0 )
3012 sdparraylength = totalsdpnnonz;
3013 sdpconstnnonz = totalsdpconstnnonz;
3015 SCIP_CALL(
SCIPconsSdpGetData(scip, conss[c], &sdpnvars, &sdpnnonz, &sdpblocksize, &sdparraylength, sdpnvarnonz,
3016 sdpcol, sdprow, sdpval, sdpvars, &sdpconstnnonz, sdpconstcol, sdpconstrow, sdpconstval, NULL, NULL, NULL) );
3018 assert( sdpconstnnonz <= totalsdpconstnnonz );
3019 assert( sdparraylength <= totalsdpnnonz);
3021 for (v = 0; v < sdpnvars; v++)
3023 for (i = 0; i < sdpnvarnonz[v]; i++)
3026 ind = SCIPvarGetProbindex(sdpvars[v]);
3027 assert( 0 <= ind && ind < nvars );
3028 SCIPinfoMessage(scip, file,
"%d %d %d %d %.15g\n", consind, ind, sdprow[v][i], sdpcol[v][i], sdpval[v][i]);
3033 SCIPinfoMessage(scip, file,
"\n");
3037 if ( totalsdpnnonz > 0 )
3039 SCIPinfoMessage(scip, file,
"DCOORD\n%d\n", totalsdpconstnnonz);
3041 for (c = 0; c < nconss; c++)
3043 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 && strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDPrank1") != 0 )
3047 sdparraylength = totalsdpnnonz;
3048 sdpconstnnonz = totalsdpconstnnonz;
3050 SCIP_CALL(
SCIPconsSdpGetData(scip, conss[c], &sdpnvars, &sdpnnonz, &sdpblocksize, &sdparraylength, sdpnvarnonz,
3051 sdpcol, sdprow, sdpval, sdpvars, &sdpconstnnonz, sdpconstcol, sdpconstrow, sdpconstval, NULL, NULL, NULL) );
3053 assert( sdpconstnnonz <= totalsdpconstnnonz );
3054 assert( sdparraylength <= totalsdpnnonz);
3056 for (i = 0; i < sdpconstnnonz; i++)
3058 SCIPinfoMessage(scip, file,
"%d %d %d %.15g\n", consind, sdpconstrow[i], sdpconstcol[i], -sdpconstval[i]);
3064 SCIPfreeBufferArray(scip, &sdpconstval);
3065 SCIPfreeBufferArray(scip, &sdpconstrow);
3066 SCIPfreeBufferArray(scip, &sdpconstcol);
3067 SCIPfreeBufferArray(scip, &sdpvars);
3068 SCIPfreeBufferArray(scip, &sdpval);
3069 SCIPfreeBufferArray(scip, &sdprow);
3070 SCIPfreeBufferArray(scip, &sdpcol);
3071 SCIPfreeBufferArray(scip, &sdpnvarnonz);
3072 SCIPfreeBufferArray(scip, &consssenses);
3073 SCIPfreeBufferArray(scip, &varsenses);
3075 *result = SCIP_SUCCESS;
3090 SCIP_READERDATA* readerdata = NULL;
3091 SCIP_READER* reader;
3096 assert( reader != NULL );
3099 SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyCbf) );
3100 SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadCbf) );
3101 SCIP_CALL( SCIPsetReaderWrite(scip, reader, readerWriteCbf) );
static SCIP_RETCODE CBFreadPsdConRank1(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_RETCODE CBFreadBcoord(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_RETCODE CBFreadPsdVar(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_RETCODE CBFreadAcoord(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_RETCODE CBFreadObjFcoord(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_RETCODE CBFreadObjsense(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_RETCODE CBFreadVar(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
file reader for mixed-integer semidefinite programs in CBF format
SCIP_RETCODE SCIPcreateConsSdpRank1(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, int nnonz, int blocksize, int *nvarnonz, int **col, int **row, SCIP_Real **val, SCIP_VAR **vars, int constnnonz, int *constcol, int *constrow, SCIP_Real *constval, SCIP_Bool removeduplicates)
static SCIP_RETCODE CBFreadFcoord(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_DECL_READERCOPY(readerCopyCbf)
static SCIP_RETCODE CBFfreeData(SCIP *scip, SCIP_FILE *file, CBF_DATA *data)
SCIP_RETCODE SCIPcreateConsSdp(SCIP *scip, SCIP_CONS **cons, const char *name, int nvars, int nnonz, int blocksize, int *nvarnonz, int **col, int **row, SCIP_Real **val, SCIP_VAR **vars, int constnnonz, int *constcol, int *constrow, SCIP_Real *constval, SCIP_Bool removeduplicates)
static SCIP_RETCODE CBFreadObjAcoord(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
Constraint handler for SDP-constraints.
SCIP_RETCODE SCIPincludeReaderCbf(SCIP *scip)
static SCIP_RETCODE CBFreadPsdCon(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_RETCODE CBFreadPsdVarRank1(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
SCIP_RETCODE SCIPconsSdpGetData(SCIP *scip, SCIP_CONS *cons, int *nvars, int *nnonz, int *blocksize, int *arraylength, int *nvarnonz, int **col, int **row, SCIP_Real **val, SCIP_VAR **vars, int *constnnonz, int *constcol, int *constrow, SCIP_Real *constval, SCIP_Bool *rankone, int **maxevsubmat, SCIP_Bool *addedquadcons)
SCIP_Bool SCIPconsSdpShouldBeRankOne(SCIP_CONS *cons)
static SCIP_RETCODE CBFreadHcoord(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_DECL_READERREAD(readerReadCbf)
static SCIP_RETCODE CBFfgets(SCIP *scip, CBF_DATA *data, SCIP_FILE *pFile, SCIP_Longint *linecount, SCIP_Bool printerror)
static SCIP_RETCODE CBFreadInt(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_RETCODE CBFreadDcoord(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
int SCIPconsSdpGetBlocksize(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPconsSdpGetNNonz(SCIP *scip, SCIP_CONS *cons, int *nnonz, int *constnnonz)
static SCIP_RETCODE CBFreadCon(SCIP *scip, CBF_DATA *data, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_DECL_READERWRITE(readerWriteCbf)