51 #include "scip/cons_linear.h"
54 #define READER_NAME "cbfreader"
55 #define READER_DESC "file reader and writer for MISDPs in cbf format"
56 #define READER_EXTENSION "cbf"
58 #define CBF_VERSION_NR 2
59 #define CBF_CHECK_NONNEG TRUE
66 #define MACRO_STR_EXPAND(tok) #tok
67 #define MACRO_STR(tok) MACRO_STR_EXPAND(tok)
68 #define CBF_NAME_FORMAT "%" MACRO_STR(CBF_MAX_NAME) "s"
69 #define CBF_MAX_LINE 512
70 #define CBF_MAX_NAME 512
78 SCIP_VAR** createdvars;
80 SCIP_CONS** createdconss;
86 SCIP_VAR*** sdpblockvars;
93 SCIP_Real*** valpointer;
94 int* sdpconstnblocknonz;
98 SCIP_Real** sdpconstval;
113 SCIP_Longint* linecount
116 assert( pFile != NULL );
117 assert( linecount != NULL );
128 return SCIP_READERROR;
136 SCIP_Longint* linecount
139 assert( scip != NULL );
140 assert( pfile != NULL );
141 assert( linecount != NULL );
143 SCIP_CALL(
CBFfgets(pfile, linecount) );
149 SCIP_CALL( SCIPsetObjsense(scip, SCIP_OBJSENSE_MINIMIZE) );
153 SCIP_CALL( SCIPsetObjsense(scip, SCIP_OBJSENSE_MAXIMIZE) );
157 SCIPerrorMessage(
"OBJSENSE should be either MIN or MAX.\n");
159 return SCIP_READERROR;
164 return SCIP_READERROR;
175 SCIP_Longint* linecount,
179 char varname[SCIP_MAXSTRLEN];
190 assert( scip != NULL );
191 assert( pfile != NULL );
192 assert( linecount != NULL );
193 assert( data != NULL );
195 SCIP_CALL(
CBFfgets(pfile, linecount) );
197 if ( sscanf(
CBF_LINE_BUFFER,
"%i %i", &(data->nvars), &nvartypes) != 2 )
198 return SCIP_READERROR;
201 if ( data->nvars < 0 )
203 SCIPerrorMessage(
"Number of variables %d should be non-negative!\n", data->nvars);
205 return SCIP_READERROR;
210 SCIPerrorMessage(
"Number of conic variable domains %d should be non-negative!\n", nvartypes);
212 return SCIP_READERROR;
214 assert( data->nvars >= 0 && nvartypes >= 0 );
218 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->createdvars), data->nvars) );
219 for (t = 0; t < nvartypes; t++)
221 SCIP_CALL(
CBFfgets(pfile, linecount) );
228 if ( nvartypevars <= 0 )
230 SCIPerrorMessage(
"Number of variables %d should be positive!\n", nvartypevars);
232 return SCIP_READERROR;
235 lb = -SCIPinfinity(scip);
236 ub = SCIPinfinity(scip);
248 SCIPerrorMessage(
"CBF-Reader of SCIP-SDP currently only supports non-negative, non-positive and free variables!\n");
250 return SCIP_READERROR;
254 for (v = 0; v < nvartypevars; v++)
257 snprintfreturn = SCIPsnprintf(varname, SCIP_MAXSTRLEN,
"x_%d", cnt);
258 assert( snprintfreturn < SCIP_MAXSTRLEN);
260 (void)SCIPsnprintf(varname, SCIP_MAXSTRLEN,
"x_%d", cnt);
263 SCIP_CALL( SCIPcreateVar(scip, &var, varname, lb, ub, 0.0, SCIP_VARTYPE_CONTINUOUS,
264 TRUE, FALSE, NULL, NULL, NULL, NULL, NULL));
266 SCIP_CALL( SCIPaddVar(scip, var) );
267 data->createdvars[cnt++] = var;
270 SCIP_CALL( SCIPreleaseVar(scip, &var) );
274 return SCIP_READERROR;
277 if ( cnt != data->nvars )
279 SCIPerrorMessage(
"Total number of variables for different cone types not equal to total number of variables!\n");
281 return SCIP_READERROR;
292 SCIP_Longint* linecount,
296 char consname[SCIP_MAXSTRLEN];
307 assert( scip != NULL );
308 assert( pfile != NULL );
309 assert( linecount != NULL );
310 assert( data != NULL );
312 SCIP_CALL(
CBFfgets(pfile, linecount) );
314 if ( sscanf(
CBF_LINE_BUFFER,
"%i %i", &(data->nconss), &nconstypes) != 2 )
315 return SCIP_READERROR;
318 if ( data->nconss < 0 )
320 SCIPerrorMessage(
"Number of scalar constraints %d should be non-negative!\n", data->nconss);
322 return SCIP_READERROR;
325 if ( nconstypes < 0 )
327 SCIPerrorMessage(
"Number of conic constraint domains %d should be non-negative!\n", nconstypes);
329 return SCIP_READERROR;
331 assert( data->nconss >= 0 && nconstypes >= 0 );
335 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->createdconss), data->nconss) );
336 for (t = 0; t < nconstypes; t++)
338 SCIP_CALL(
CBFfgets(pfile, linecount) );
345 if ( nconstypeconss <= 0 )
347 SCIPerrorMessage(
"Number of constraints %d should be positive!\n", nconstypeconss);
349 return SCIP_READERROR;
352 lhs = -SCIPinfinity(scip);
353 rhs = SCIPinfinity(scip);
370 SCIPerrorMessage(
"CBF-Reader of SCIP-SDP currently only supports linear greater or equal, less or equal and"
371 "equality constraints!\n");
373 return SCIP_READERROR;
377 for (c = 0; c < nconstypeconss; c++)
380 snprintfreturn = SCIPsnprintf(consname, SCIP_MAXSTRLEN,
"LP_%d", cnt);
381 assert( snprintfreturn < SCIP_MAXSTRLEN);
383 (void)SCIPsnprintf(consname, SCIP_MAXSTRLEN,
"linear_%d", cnt);
386 SCIP_CALL( SCIPcreateConsLinear(scip, &cons, consname, 0, NULL, NULL, lhs, rhs,
387 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE));
389 SCIP_CALL( SCIPaddCons(scip, cons) );
390 data->createdconss[cnt++] = cons;
393 SCIP_CALL( SCIPreleaseCons(scip, &cons) );
397 return SCIP_READERROR;
400 if ( cnt != data->nconss )
402 SCIPerrorMessage(
"Total number of constraints for different cone types not equal to total number of constraints!\n");
404 return SCIP_READERROR;
415 SCIP_Longint* linecount,
422 SCIP_Bool infeasible;
424 assert( scip != NULL );
425 assert( pfile != NULL );
426 assert( linecount != NULL );
427 assert( data != NULL );
429 if ( data->createdvars == NULL )
431 SCIPerrorMessage(
"Need to have 'VAR' section before 'INT' section!\n");
433 return SCIP_READERROR;
435 assert( data->nvars >= 0 );
437 SCIP_CALL(
CBFfgets(pfile, linecount) );
443 for (i = 0; i < nintvars; i++)
445 SCIP_CALL(
CBFfgets(pfile, linecount) );
448 SCIP_CALL( SCIPchgVarType(scip, data->createdvars[v], SCIP_VARTYPE_INTEGER, &infeasible) );
452 SCIPerrorMessage(
"Infeasibility detected because of integrality of variable %s!\n", SCIPvarGetName(data->createdvars[v]));
454 return SCIP_READERROR;
459 SCIPerrorMessage(
"Number of integrality constraints %d should be non-negative!\n", nintvars);
461 return SCIP_READERROR;
467 SCIPerrorMessage(
"Number of integrality constraints %d should be non-negative!\n", nintvars);
469 return SCIP_READERROR;
473 return SCIP_READERROR;
483 SCIP_Longint* linecount,
489 assert( scip != NULL );
490 assert( pfile != NULL );
491 assert( linecount != NULL );
492 assert( data != NULL );
494 SCIP_CALL(
CBFfgets(pfile, linecount) );
498 if ( data->nsdpblocks >= 0 )
500 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblocksizes), data->nsdpblocks) );
502 for (b = 0; b < data->nsdpblocks; b++)
504 SCIP_CALL(
CBFfgets(pfile, linecount) );
507 if ( data->sdpblocksizes[b] <= 0 )
509 SCIPerrorMessage(
"Size %d of SDP-block %d should be positive!\n", data->sdpblocksizes[b], b);
511 return SCIP_READERROR;
515 return SCIP_READERROR;
520 SCIPerrorMessage(
"Number of SDP-blocks %d should be non-negative!\n", data->nsdpblocks);
522 return SCIP_READERROR;
526 return SCIP_READERROR;
536 SCIP_Longint* linecount,
546 assert( scip != NULL );
547 assert( pfile != NULL );
548 assert( linecount != NULL );
549 assert( data != NULL );
551 if ( data->createdvars == NULL )
553 SCIPerrorMessage(
"Need to have 'VAR' section before 'OBJACOORD' section!\n");
555 return SCIP_READERROR;
557 assert( data->nvars >= 0 );
559 SCIP_CALL(
CBFfgets(pfile, linecount) );
563 if ( nobjcoefs >= 0 )
565 for (i = 0; i < nobjcoefs; i++)
567 SCIP_CALL(
CBFfgets(pfile, linecount) );
570 if ( v < 0 || v >= data->nvars )
572 SCIPerrorMessage(
"Given objective coefficient for variable %d which does not exist!\n", v);
574 return SCIP_READERROR;
577 if ( SCIPisZero(scip, val) )
583 SCIP_CALL( SCIPchgVarObj(scip, data->createdvars[v], val) );
587 return SCIP_READERROR;
592 SCIPerrorMessage(
"Number of objective coefficients %d should be non-negative!\n", nobjcoefs);
594 return SCIP_READERROR;
598 return SCIP_READERROR;
602 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
603 "OBJACOORD: Found %d coefficients with absolute value less than epsilon = %f.\n", nzerocoef, SCIPepsilon(scip));
614 SCIP_Longint* linecount,
625 assert( scip != NULL );
626 assert( pfile != NULL );
627 assert( linecount != NULL );
628 assert( data != NULL );
630 if ( data->createdvars == NULL )
632 SCIPerrorMessage(
"Need to have 'VAR' section before 'ACOORD' section!\n");
634 return SCIP_READERROR;
636 assert( data->nvars >= 0 );
638 if ( data->createdconss == NULL )
640 SCIPerrorMessage(
"Need to have 'CON' section before 'ACOORD' section!\n");
642 return SCIP_READERROR;
644 assert( data->nconss >= 0 );
646 SCIP_CALL(
CBFfgets(pfile, linecount) );
652 for (i = 0; i < ncoefs; i++)
654 SCIP_CALL(
CBFfgets(pfile, linecount) );
657 if ( c < 0 || c >= data->nconss )
659 SCIPerrorMessage(
"Given linear coefficient for constraint %d which does not exist!\n", c);
661 return SCIP_READERROR;
663 if ( v < 0 || v >= data->nvars )
665 SCIPerrorMessage(
"Given linear coefficient for variable %d which does not exist!\n", v);
667 return SCIP_READERROR;
669 if ( SCIPisZero(scip, val) )
675 SCIP_CALL( SCIPaddCoefLinear(scip, data->createdconss[c], data->createdvars[v], val) );
679 return SCIP_READERROR;
684 SCIPerrorMessage(
"Number of linear coefficients %d should be non-negative!\n", ncoefs);
686 return SCIP_READERROR;
690 return SCIP_READERROR;
694 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
695 "ACOORD: Found %d coefficients with absolute value less than epsilon = %f.\n", nzerocoef, SCIPepsilon(scip));
706 SCIP_Longint* linecount,
716 assert( scip != NULL );
717 assert( pfile != NULL );
718 assert( linecount != NULL );
719 assert( data != NULL );
721 if ( data->createdconss == NULL )
723 SCIPerrorMessage(
"Need to have 'CON' section before 'BCOORD' section!\n");
725 return SCIP_READERROR;
727 assert( data->nconss >= 0 );
729 SCIP_CALL(
CBFfgets(pfile, linecount) );
735 for (i = 0; i < nsides; i++)
737 SCIP_CALL(
CBFfgets(pfile, linecount) );
740 if ( c < 0 || c >= data->nconss )
742 SCIPerrorMessage(
"Given constant part for constraint %d which does not exist!\n", c);
744 return SCIP_READERROR;
747 if ( SCIPisZero(scip, val) )
754 if ( ! SCIPisInfinity(scip, -SCIPgetLhsLinear(scip, data->createdconss[c])) )
757 SCIP_CALL( SCIPchgLhsLinear(scip, data->createdconss[c], -val) );
760 if ( ! SCIPisInfinity(scip, SCIPgetRhsLinear(scip, data->createdconss[c]) ) )
763 SCIP_CALL( SCIPchgRhsLinear(scip, data->createdconss[c], -val) );
768 return SCIP_READERROR;
773 SCIPerrorMessage(
"Number of left- and right-hand sides %d should be non-negative!\n", nsides);
775 return SCIP_READERROR;
779 return SCIP_READERROR;
783 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
784 "BCOORD: Found %d coefficients with absolute value less than epsilon = %f.\n", nzerocoef, SCIPepsilon(scip));
795 SCIP_Longint* linecount,
811 assert( scip != NULL );
812 assert( pfile != NULL );
813 assert( linecount != NULL );
814 assert( data != NULL );
816 if ( data->nsdpblocks < 0 )
818 SCIPerrorMessage(
"Need to have 'PSDVAR' section before 'HCOORD' section!\n");
820 return SCIP_READERROR;
822 assert( data->nvars >= 0 );
824 if ( data->nvars < 0 )
826 SCIPerrorMessage(
"Need to have 'VAR' section before 'HCOORD' section!\n");
828 return SCIP_READERROR;
832 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpnblocknonz), data->nsdpblocks) );
833 for (b = 0; b < data->nsdpblocks; b++)
834 data->sdpnblocknonz[b] = 0;
836 SCIP_CALL(
CBFfgets(pfile, linecount) );
844 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &sdpvar, data->nsdpblocks) );
845 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdprow), data->nsdpblocks) );
846 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpcol), data->nsdpblocks) );
847 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpval), data->nsdpblocks) );
849 for (b = 0; b < data->nsdpblocks; b++)
851 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(sdpvar[b]), nnonz) );
852 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdprow[b]), nnonz) );
853 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpcol[b]), nnonz) );
854 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpval[b]), nnonz) );
857 for (i = 0; i < nnonz; i++)
859 SCIP_CALL(
CBFfgets(pfile, linecount) );
860 if ( sscanf(
CBF_LINE_BUFFER,
"%i %i %i %i %lf", &b, &v, &row, &col, &val) == 5 )
862 if ( b < 0 || b >= data->nsdpblocks )
864 SCIPerrorMessage(
"Given SDP-coefficient for SDP-constraint %d which does not exist!\n", b);
866 return SCIP_READERROR;
869 if ( v < 0 || v >= data->nvars )
871 SCIPerrorMessage(
"Given SDP-coefficient for variable %d which does not exist!\n", v);
873 return SCIP_READERROR;
876 if ( row < 0 || row >= data->sdpblocksizes[b] )
878 SCIPerrorMessage(
"Row index %d of given SDP coefficient is negative or larger than blocksize %d!\n",
879 row, data->sdpblocksizes[b]);
881 return SCIP_READERROR;
884 if ( col < 0 || col >= data->sdpblocksizes[b] )
886 SCIPerrorMessage(
"Column index %d of given SDP coefficient is negative or larger than blocksize %d!\n",
887 col, data->sdpblocksizes[b]);
889 return SCIP_READERROR;
892 if ( SCIPisZero(scip, val) )
898 sdpvar[b][data->sdpnblocknonz[b]] = v;
903 data->sdprow[b][data->sdpnblocknonz[b]] = col;
904 data->sdpcol[b][data->sdpnblocknonz[b]] = row;
908 data->sdprow[b][data->sdpnblocknonz[b]] = row;
909 data->sdpcol[b][data->sdpnblocknonz[b]] = col;
912 data->sdpval[b][data->sdpnblocknonz[b]] = val;
913 data->sdpnblocknonz[b]++;
917 return SCIP_READERROR;
921 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpnblockvars), data->nsdpblocks) );
922 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblockvars), data->nsdpblocks) );
923 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->nvarnonz), data->nsdpblocks) );
924 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->rowpointer), data->nsdpblocks) );
925 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->colpointer), data->nsdpblocks) );
926 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->valpointer), data->nsdpblocks) );
928 for (b = 0; b < data->nsdpblocks; b++)
931 SCIPsortIntIntIntReal(sdpvar[b], data->sdprow[b], data->sdpcol[b], data->sdpval[b], data->sdpnblocknonz[b]);
935 data->sdpnblockvars[b] = 0;
936 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpblockvars[b]), data->nvars) );
937 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->nvarnonz[b]), data->nvars) );
938 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->rowpointer[b]), data->nvars) );
939 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->colpointer[b]), data->nvars) );
940 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->valpointer[b]), data->nvars) );
942 for (v = 0; v < data->nvars; v++)
944 SCIP_Bool varused = FALSE;
946 firstindforvar = nextindaftervar;
947 data->nvarnonz[b][data->sdpnblockvars[b]] = 0;
949 while (nextindaftervar < data->sdpnblocknonz[b] && sdpvar[b][nextindaftervar] == v)
953 data->nvarnonz[b][data->sdpnblockvars[b]]++;
958 data->sdpblockvars[b][data->sdpnblockvars[b]] = data->createdvars[v];
959 data->rowpointer[b][data->sdpnblockvars[b]] = &(data->sdprow[b][firstindforvar]);
960 data->colpointer[b][data->sdpnblockvars[b]] = &(data->sdpcol[b][firstindforvar]);
961 data->valpointer[b][data->sdpnblockvars[b]] = &(data->sdpval[b][firstindforvar]);
962 data->sdpnblockvars[b]++;
966 assert( nextindaftervar == data->sdpnblocknonz[b] );
968 SCIPfreeBlockMemoryArray(scip, &(sdpvar[b]), nnonz);
972 SCIPfreeBlockMemoryArray(scip, &sdpvar, data->nsdpblocks);
976 SCIPerrorMessage(
"Number of nonzero coefficients of SDP-constraints %d should be non-negative!\n", nnonz);
978 return SCIP_READERROR;
982 return SCIP_READERROR;
986 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
987 "HCOORD: Found %d coefficients with absolute value less than epsilon = %f.\n", nzerocoef, SCIPepsilon(scip));
998 SCIP_Longint* linecount,
1010 assert( scip != NULL );
1011 assert( pfile != NULL );
1012 assert( linecount != NULL );
1013 assert( data != NULL );
1015 if ( data->nsdpblocks < 0 )
1017 SCIPerrorMessage(
"Need to have 'PSDVAR' section before 'DCOORD' section!\n");
1019 return SCIP_READERROR;
1022 if ( data->nvars < 0 )
1024 SCIPerrorMessage(
"Need to have 'VAR' section before 'DCOORD' section!\n");
1026 return SCIP_READERROR;
1029 SCIP_CALL(
CBFfgets(pfile, linecount) );
1033 if ( constnnonz < 0 )
1035 SCIPerrorMessage(
"Number of constant entries of SDP-constraints %d should be non-negative!\n", constnnonz);
1037 return SCIP_READERROR;
1040 data->constnnonz = constnnonz;
1041 if ( constnnonz > 1 )
1044 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstnblocknonz), data->nsdpblocks) );
1045 for (b = 0; b < data->nsdpblocks; b++)
1046 data->sdpconstnblocknonz[b] = 0;
1049 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstrow), data->nsdpblocks) );
1050 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstcol), data->nsdpblocks) );
1051 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstval), data->nsdpblocks) );
1053 for (b = 0; b < data->nsdpblocks; b++)
1055 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstrow[b]), constnnonz) );
1056 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstcol[b]), constnnonz) );
1057 SCIP_CALL( SCIPallocBlockMemoryArray(scip, &(data->sdpconstval[b]), constnnonz) );
1060 for (i = 0; i < constnnonz; i++)
1062 SCIP_CALL(
CBFfgets(pfile, linecount) );
1063 if ( sscanf(
CBF_LINE_BUFFER,
"%i %i %i %lf", &b, &row, &col, &val) == 4 )
1065 if ( b < 0 || b >= data->nsdpblocks )
1067 SCIPerrorMessage(
"Given constant entry for SDP-constraint %d which does not exist!\n", b);
1069 return SCIP_READERROR;
1072 if ( row < 0 || row >= data->sdpblocksizes[b] )
1074 SCIPerrorMessage(
"Row index %d of given constant SDP-entry is negative or larger than blocksize %d!\n",
1075 row, data->sdpblocksizes[b]);
1077 return SCIP_READERROR;
1080 if ( col < 0 || col >= data->sdpblocksizes[b] )
1082 SCIPerrorMessage(
"Column index %d of given constant SDP-entry is negative or larger than blocksize %d!\n",
1083 col, data->sdpblocksizes[b]);
1085 return SCIP_READERROR;
1088 if ( SCIPisZero(scip, val) )
1097 data->sdpconstrow[b][data->sdpconstnblocknonz[b]] = col;
1098 data->sdpconstcol[b][data->sdpconstnblocknonz[b]] = row;
1102 data->sdpconstrow[b][data->sdpconstnblocknonz[b]] = row;
1103 data->sdpconstcol[b][data->sdpconstnblocknonz[b]] = col;
1105 data->sdpconstval[b][data->sdpconstnblocknonz[b]] = -val;
1106 data->sdpconstnblocknonz[b]++;
1110 return SCIP_READERROR;
1115 return SCIP_READERROR;
1117 if ( nzerocoef > 0 )
1119 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
1120 "DCOORD: Found %d coefficients with absolute value less than epsilon = %f.\n", nzerocoef, SCIPepsilon(scip));
1133 SCIP_Bool allocated = FALSE;
1136 assert( scip != NULL );
1137 assert( data != NULL );
1141 while ( data->sdpconstnblocknonz != NULL && allocated == FALSE && b < data->nsdpblocks)
1143 if (data->sdpconstnblocknonz[b] > 0)
1150 for (b = 0; b < data->nsdpblocks; b++)
1152 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpconstval[b]), data->constnnonz);
1153 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpconstcol[b]), data->constnnonz);
1154 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpconstrow[b]), data->constnnonz);
1156 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpconstval, data->nsdpblocks);
1157 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpconstcol, data->nsdpblocks);
1158 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpconstrow, data->nsdpblocks);
1159 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpconstnblocknonz, data->nsdpblocks);
1164 while (allocated == FALSE && b < data->nsdpblocks)
1166 if (data->sdpnblocknonz[b] > 0)
1173 for (b = 0; b < data->nsdpblocks; b++)
1175 SCIPfreeBlockMemoryArrayNull(scip, &(data->valpointer[b]), data->nvars);
1176 SCIPfreeBlockMemoryArrayNull(scip, &(data->colpointer[b]), data->nvars);
1177 SCIPfreeBlockMemoryArrayNull(scip, &(data->rowpointer[b]), data->nvars);
1178 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpval[b]), data->nnonz);
1179 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpcol[b]), data->nnonz);
1180 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdprow[b]), data->nnonz);
1181 SCIPfreeBlockMemoryArrayNull(scip, &(data->sdpblockvars[b]), data->nvars);
1182 SCIPfreeBlockMemoryArrayNull(scip, &(data->nvarnonz[b]), data->nvars);
1184 SCIPfreeBlockMemoryArrayNull(scip, &data->valpointer, data->nsdpblocks);
1185 SCIPfreeBlockMemoryArrayNull(scip, &data->colpointer, data->nsdpblocks);
1186 SCIPfreeBlockMemoryArrayNull(scip, &data->rowpointer, data->nsdpblocks);
1187 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpval, data->nsdpblocks);
1188 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpcol, data->nsdpblocks);
1189 SCIPfreeBlockMemoryArrayNull(scip, &data->sdprow, data->nsdpblocks);
1190 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpblockvars, data->nsdpblocks);
1191 SCIPfreeBlockMemoryArrayNull(scip, &data->nvarnonz, data->nsdpblocks);
1192 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpnblockvars, data->nsdpblocks);
1193 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpnblocknonz, data->nsdpblocks);
1194 SCIPfreeBlockMemoryArrayNull(scip, &data->sdpblocksizes, data->nsdpblocks);
1197 if (data->nconss > 0)
1199 SCIPfreeBlockMemoryArrayNull(scip, &data->createdconss, data->nconss);
1201 SCIPfreeBlockMemoryArrayNull(scip, &data->createdvars, data->nvars);
1216 assert(scip != NULL);
1227 SCIP_FILE* scipfile;
1228 SCIP_Longint linecount = 0;
1229 SCIP_Bool versionread = FALSE;
1230 SCIP_Bool objread = FALSE;
1234 assert( result != NULL );
1236 *result = SCIP_DIDNOTRUN;
1238 SCIPdebugMsg(scip,
"Reading file %s ...\n", filename);
1240 scipfile = SCIPfopen(filename,
"r");
1243 return SCIP_READERROR;
1245 SCIP_CALL( SCIPallocBuffer(scip, &data) );
1246 data->nsdpblocks = -1;
1249 data->constnnonz = 0;
1252 data->sdpblocksizes = NULL;
1253 data->sdpnblocknonz = NULL;
1254 data->sdpnblockvars = NULL;
1255 data->sdpblockvars = NULL;
1256 data->sdprow = NULL;
1257 data->sdpcol = NULL;
1258 data->sdpval = NULL;
1259 data->sdpconstnblocknonz = NULL;
1260 data->sdpconstrow = NULL;
1261 data->sdpconstcol = NULL;
1262 data->sdpconstval = NULL;
1265 SCIP_CALL( SCIPcreateProb(scip, filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
1267 while(
CBFfgets(scipfile, &linecount) == SCIP_OKAY )
1273 if ( ! versionread )
1279 SCIP_CALL(
CBFfgets(scipfile, &linecount) );
1283 SCIPdebugMsg(scip,
"file version %d.\n", ver);
1286 SCIPerrorMessage(
"Strange version number %d; need at least version 1.\n", ver);
1288 return SCIP_READERROR;
1292 SCIPerrorMessage(
"Version %d too new; only supported up to version %d.\n",
CBF_VERSION_NR);
1294 return SCIP_READERROR;
1300 return SCIP_READERROR;
1304 SCIPerrorMessage(
"First keyword should be VER.\n");
1306 return SCIP_READERROR;
1313 SCIPdebugMsg(scip,
"Reading OBJSENSE\n");
1319 SCIPdebugMsg(scip,
"Reading VAR\n");
1320 SCIP_CALL(
CBFreadVar(scip, scipfile, &linecount, data) );
1324 SCIPdebugMsg(scip,
"Reading CON\n");
1325 SCIP_CALL(
CBFreadCon(scip, scipfile, &linecount, data) );
1329 SCIPdebugMsg(scip,
"Reading INT\n");
1330 SCIP_CALL(
CBFreadInt(scip, scipfile, &linecount, data) );
1334 SCIPdebugMsg(scip,
"Reading PSDCON\n");
1335 SCIP_CALL(
CBFreadPsdcon(scip, scipfile, &linecount, data) );
1342 SCIPerrorMessage(
"SDPs in primal form currently not supported, please use PSDCON!\n");
1344 return SCIP_READERROR;
1348 SCIPerrorMessage(
"SDPs in primal form currently not supported, please use PSDCON!\n");
1350 return SCIP_READERROR;
1354 SCIPdebugMsg(scip,
"Reading OBJACOORD\n");
1359 SCIPerrorMessage(
"constant part in objective value not supported by SCIP!\n");
1361 return SCIP_READERROR;
1365 SCIPerrorMessage(
"SDPs in primal form currently not supported, please use PSDCON!\n");
1367 return SCIP_READERROR;
1371 SCIPdebugMsg(scip,
"Reading ACOORD\n");
1372 SCIP_CALL(
CBFreadAcoord(scip, scipfile, &linecount, data) );
1376 SCIPdebugMsg(scip,
"Reading BCOORD\n");
1377 SCIP_CALL(
CBFreadBcoord(scip, scipfile, &linecount, data) );
1381 SCIPdebugMsg(scip,
"Reading HCOORD\n");
1382 SCIP_CALL(
CBFreadHcoord(scip, scipfile, &linecount, data) );
1386 SCIPdebugMsg(scip,
"Reading DCOORD\n");
1387 SCIP_CALL(
CBFreadDcoord(scip, scipfile, &linecount, data) );
1393 return SCIP_READERROR;
1401 SCIPerrorMessage(
"Keyword OBJSENSE is missing!\n");
1403 return SCIP_READERROR;
1407 if ( SCIPfclose(scipfile) )
1408 return SCIP_READERROR;
1410 #ifdef SCIP_MORE_DEBUG
1411 for (b = 0; b < SCIPgetNConss(scip); b++)
1413 SCIP_CALL( SCIPprintCons(scip, SCIPgetConss(scip)[b], NULL) );
1414 SCIPinfoMessage(scip, NULL,
"\n");
1419 for (b = 0; b < data->nsdpblocks; b++)
1422 char sdpconname[SCIP_MAXSTRLEN];
1427 assert( data->sdpblocksizes[b] > 0 );
1428 assert( (data->sdpnblockvars[b] > 0 && data->sdpnblocknonz[b] > 0) || (data->sdpconstnblocknonz[b] > 0) );
1431 snprintfreturn = SCIPsnprintf(sdpconname, SCIP_MAXSTRLEN,
"SDP_%d", b);
1432 assert( snprintfreturn < SCIP_MAXSTRLEN);
1434 (void) SCIPsnprintf(sdpconname, SCIP_MAXSTRLEN,
"SDP_%d", b);
1438 if ( data->sdpconstnblocknonz == NULL )
1440 SCIP_CALL(
SCIPcreateConsSdp(scip, &sdpcons, sdpconname, data->sdpnblockvars[b], data->sdpnblocknonz[b],
1441 data->sdpblocksizes[b], data->nvarnonz[b], data->colpointer[b], data->rowpointer[b], data->valpointer[b],
1442 data->sdpblockvars[b], 0, NULL, NULL, NULL) );
1446 SCIP_CALL(
SCIPcreateConsSdp(scip, &sdpcons, sdpconname, data->sdpnblockvars[b], data->sdpnblocknonz[b],
1447 data->sdpblocksizes[b], data->nvarnonz[b], data->colpointer[b], data->rowpointer[b], data->valpointer[b],
1448 data->sdpblockvars[b], data->sdpconstnblocknonz[b], data->sdpconstcol[b], data->sdpconstrow[b],
1449 data->sdpconstval[b]) );
1452 #ifdef SCIP_MORE_DEBUG
1453 SCIP_CALL( SCIPprintCons(scip, sdpcons, NULL) );
1456 SCIP_CALL( SCIPaddCons(scip, sdpcons) );
1458 SCIP_CALL( SCIPreleaseCons(scip, &sdpcons) );
1462 SCIPfreeBufferNull(scip, &data);
1464 *result = SCIP_SUCCESS;
1478 SCIP_Real* sdpconstval;
1492 int totalsdpconstnnonz;
1505 assert( scip != NULL );
1506 assert( result != NULL );
1508 SCIPdebugMsg(scip,
"Writing problem in CBF format to file.\n");
1509 *result = SCIP_DIDNOTRUN;
1513 SCIPerrorMessage(
"CBF reader currently only supports writing original problems!\n");
1515 return SCIP_READERROR;
1518 for (c = 0; c < nconss; c++)
1520 if ( (strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0)
1521 && (strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 ) )
1523 SCIPerrorMessage(
"CBF reader currently only supports linear and SDP constraints!\n");
1525 return SCIP_READERROR;
1530 for (v = 0; v < nvars; v++)
1532 assert( SCIPvarGetStatus(vars[v]) == SCIP_VARSTATUS_ORIGINAL );
1540 SCIPinfoMessage(scip, file,
"OBJSENSE\n%s\n\n", objsense == SCIP_OBJSENSE_MINIMIZE ?
"MIN" :
"MAX");
1543 SCIP_CALL( SCIPallocBufferArray(scip, &varsenses, nvars) );
1544 for (v = 0; v < nvars; v++)
1549 lb = SCIPvarGetLbOriginal(vars[v]);
1550 ub = SCIPvarGetUbOriginal(vars[v]);
1553 if ( SCIPisZero(scip, lb) )
1557 if ( ! SCIPisInfinity(scip, -lb) )
1559 SCIPerrorMessage(
"Can only handle variables with lower bound 0 or minus infinity.\n");
1561 return SCIP_READERROR;
1565 if ( SCIPisZero(scip, ub) )
1569 if ( ! SCIPisInfinity(scip, ub) )
1571 SCIPerrorMessage(
"Can only handle variables with upper bound 0 or infinity.\n");
1573 return SCIP_READERROR;
1579 SCIP_CALL( SCIPallocBufferArray(scip, &consssenses, nconss) );
1580 for (c = 0; c < nconss; c++)
1588 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1591 lhs = SCIPgetLhsLinear(scip, conss[c]);
1592 rhs = SCIPgetRhsLinear(scip, conss[c]);
1594 #ifdef CBF_CHECK_NONNEG
1596 if ( SCIPgetNVarsLinear(scip, conss[c]) == 1 && ! SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) )
1599 assert( ! SCIPisZero(scip, SCIPgetValsLinear(scip, conss[c])[0]) );
1600 assert( SCIPgetVarsLinear(scip, conss[c]) != NULL );
1602 v = SCIPvarGetProbindex(SCIPgetVarsLinear(scip, conss[c])[0]);
1603 assert( 0 <= v && v < nvars );
1605 if ( SCIPgetValsLinear(scip, conss[c])[0] > 0.0 )
1607 if ( SCIPisZero(scip, lhs) )
1612 else if ( SCIPisZero(scip, rhs) )
1620 if ( SCIPisZero(scip, lhs) )
1625 else if ( SCIPisZero(scip, rhs) )
1634 if ( SCIPisEQ(scip, lhs, rhs) )
1636 assert( ! SCIPisInfinity(scip, -lhs) );
1637 assert( ! SCIPisInfinity(scip, rhs) );
1642 if ( ! SCIPisInfinity(scip, -lhs) && ! SCIPisInfinity(scip, rhs) )
1644 SCIPerrorMessage(
"Cannot handle ranged rows.\n");
1646 return SCIP_READERROR;
1649 if ( ! SCIPisInfinity(scip, -lhs) )
1651 else if ( ! SCIPisInfinity(scip, rhs) )
1652 consssenses[c] = -1;
1659 for (v = 0; v < nvars; v++)
1661 if ( varsenses[v] != lastsense )
1664 lastsense = varsenses[v];
1669 SCIPinfoMessage(scip, file,
"VAR\n%d %d\n", nvars, nsenses);
1670 lastsense = varsenses[0];
1672 for (v = 1; v < nvars; v++)
1674 if ( varsenses[v] != lastsense )
1676 if ( lastsense == 0 )
1677 SCIPinfoMessage(scip, file,
"F %d\n", nsenses);
1678 else if ( lastsense == -1 )
1679 SCIPinfoMessage(scip, file,
"L- %d\n", nsenses);
1682 assert( lastsense == 1 );
1683 SCIPinfoMessage(scip, file,
"L+ %d\n", nsenses);
1686 lastsense = varsenses[v];
1690 if ( lastsense == 0 )
1691 SCIPinfoMessage(scip, file,
"F %d\n\n", nsenses);
1692 else if ( lastsense == -1 )
1693 SCIPinfoMessage(scip, file,
"L- %d\n\n", nsenses);
1696 assert( lastsense == 1 );
1697 SCIPinfoMessage(scip, file,
"L+ %d\n\n", nsenses);
1701 if ( nbinvars + nintvars > 0 )
1703 SCIPinfoMessage(scip, file,
"INT\n%d\n", nbinvars + nintvars);
1705 for (v = 0; v < nbinvars + nintvars; v++)
1707 assert( SCIPvarIsIntegral(vars[v]) );
1708 SCIPinfoMessage(scip, file,
"%d\n", v);
1710 SCIPinfoMessage(scip, file,
"\n");
1717 for (c = 0; c < nconss; c++)
1719 if ( consssenses[c] == 2 )
1723 if ( consssenses[c] != lastsense )
1726 lastsense = consssenses[c];
1731 SCIPinfoMessage(scip, file,
"CON\n%d %d\n", i, nsenses);
1732 nconsssenses = nsenses;
1734 while (c < nconss && consssenses[c] == 2)
1738 lastsense = consssenses[c];
1741 for (; c < nconss; ++c)
1743 if ( consssenses[c] == 2 )
1746 if ( consssenses[c] != lastsense )
1748 if ( lastsense == 0 )
1749 SCIPinfoMessage(scip, file,
"L= %d\n", nsenses);
1750 else if ( lastsense == -1 )
1751 SCIPinfoMessage(scip, file,
"L- %d\n", nsenses);
1754 assert( lastsense == 1 );
1755 SCIPinfoMessage(scip, file,
"L+ %d\n", nsenses);
1758 lastsense = consssenses[c];
1763 if ( lastsense == 0 )
1764 SCIPinfoMessage(scip, file,
"L= %d\n\n", nsenses);
1765 else if ( lastsense == -1 )
1766 SCIPinfoMessage(scip, file,
"L- %d\n\n", nsenses);
1769 assert( lastsense == 1 );
1770 SCIPinfoMessage(scip, file,
"L+ %d\n\n", nsenses);
1775 for (c = 0; c < nconss; c++)
1777 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") == 0 )
1782 SCIPinfoMessage(scip, file,
"PSDCON\n%d\n", nsdpconss);
1784 for (c = 0; c < nconss; c++)
1786 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 )
1792 SCIPinfoMessage(scip, file,
"\n");
1796 for (v = 0; v < nvars; v++)
1798 if ( ! SCIPisZero(scip, SCIPvarGetObj(vars[v])) )
1803 SCIPinfoMessage(scip, file,
"OBJACOORD\n%d\n", nobjnonz);
1805 for (v = 0; v < nvars; v++)
1809 obj = SCIPvarGetObj(vars[v]);
1810 if ( ! SCIPisZero(scip, obj) )
1812 SCIPinfoMessage(scip, file,
"%d %.9g\n", v, obj);
1815 SCIPinfoMessage(scip, file,
"\n");
1818 if ( nconsssenses > 0 )
1823 for (c = 0; c < nconss; c++)
1825 if ( consssenses[c] == -1 )
1827 assert( ! SCIPisInfinity(scip, SCIPgetRhsLinear(scip, conss[c])) );
1828 nnonz += SCIPgetNVarsLinear(scip, conss[c]);
1829 if ( ! SCIPisZero(scip, SCIPgetRhsLinear(scip, conss[c])) )
1832 else if ( consssenses[c] == 1 )
1834 assert( ! SCIPisInfinity(scip, -SCIPgetLhsLinear(scip, conss[c])) );
1835 nnonz += SCIPgetNVarsLinear(scip, conss[c]);
1836 if ( ! SCIPisZero(scip, SCIPgetLhsLinear(scip, conss[c])) )
1839 else if ( consssenses[c] == 0 )
1841 assert( SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) );
1842 nnonz += SCIPgetNVarsLinear(scip, conss[c]);
1843 if ( ! SCIPisZero(scip, SCIPgetLhsLinear(scip, conss[c])) )
1849 SCIPinfoMessage(scip, file,
"ACOORD\n%d\n", nnonz);
1851 for (c = 0; c < nconss; c++)
1853 if ( consssenses[c] == -1 || consssenses[c] == 0 || consssenses[c] == 1 )
1855 assert( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") == 0 );
1857 linvars = SCIPgetVarsLinear(scip, conss[c]);
1858 linvals = SCIPgetValsLinear(scip, conss[c]);
1860 for (v = 0; v < SCIPgetNVarsLinear(scip, conss[c]); v++)
1862 i = SCIPvarGetProbindex(linvars[v]);
1863 assert( 0 <= i && i < nvars );
1864 SCIPinfoMessage(scip, file,
"%d %d %.9g\n", consind, i, linvals[v]);
1869 SCIPinfoMessage(scip, file,
"\n");
1872 SCIPinfoMessage(scip, file,
"BCOORD\n%d\n", nbnonz);
1874 for (c = 0; c < nconss; c++)
1877 if ( consssenses[c] == -1 )
1879 val = SCIPgetRhsLinear(scip, conss[c]);
1880 if ( ! SCIPisZero(scip, val) )
1881 SCIPinfoMessage(scip, file,
"%d %.9g\n", consind, -val);
1884 else if ( consssenses[c] == 1 )
1886 val = SCIPgetLhsLinear(scip, conss[c]);
1887 if ( ! SCIPisZero(scip, val) )
1888 SCIPinfoMessage(scip, file,
"%d %.9g\n", consind, -val);
1891 else if ( consssenses[c] == 0 )
1893 val = SCIPgetLhsLinear(scip, conss[c]);
1894 if ( ! SCIPisZero(scip, val) )
1895 SCIPinfoMessage(scip, file,
"%d %.9g\n", consind, -val);
1899 SCIPinfoMessage(scip, file,
"\n");
1904 totalsdpconstnnonz = 0;
1905 for (c = 0; c < nconss; c++)
1907 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 )
1911 totalsdpnnonz += sdpnnonz;
1912 totalsdpconstnnonz += sdpconstnnonz;
1916 SCIP_CALL( SCIPallocBufferArray(scip, &sdpnvarnonz, nvars) );
1917 SCIP_CALL( SCIPallocBufferArray(scip, &sdpcol, totalsdpnnonz) );
1918 SCIP_CALL( SCIPallocBufferArray(scip, &sdprow, totalsdpnnonz) );
1919 SCIP_CALL( SCIPallocBufferArray(scip, &sdpval, totalsdpnnonz) );
1920 SCIP_CALL( SCIPallocBufferArray(scip, &sdpvars, nvars) );
1921 SCIP_CALL( SCIPallocBufferArray(scip, &sdpconstcol, totalsdpconstnnonz) );
1922 SCIP_CALL( SCIPallocBufferArray(scip, &sdpconstrow, totalsdpconstnnonz) );
1923 SCIP_CALL( SCIPallocBufferArray(scip, &sdpconstval, totalsdpconstnnonz) );
1925 sdparraylength = totalsdpnnonz;
1926 sdpconstnnonz = totalsdpconstnnonz;
1929 if ( totalsdpnnonz > 0 )
1931 SCIPinfoMessage(scip, file,
"HCOORD\n%d\n", totalsdpnnonz);
1933 for (c = 0; c < nconss; c++)
1935 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 )
1939 sdparraylength = totalsdpnnonz;
1940 sdpconstnnonz = totalsdpconstnnonz;
1942 SCIP_CALL(
SCIPconsSdpGetData(scip, conss[c], &sdpnvars, &sdpnnonz, &sdpblocksize, &sdparraylength, sdpnvarnonz,
1943 sdpcol, sdprow, sdpval, sdpvars, &sdpconstnnonz, sdpconstcol, sdpconstrow, sdpconstval) );
1945 assert( sdpconstnnonz <= totalsdpconstnnonz );
1946 assert( sdparraylength <= totalsdpnnonz);
1948 for (v = 0; v < sdpnvars; v++)
1950 for (i = 0; i < sdpnvarnonz[v]; i++)
1953 ind = SCIPvarGetProbindex(sdpvars[v]);
1954 assert( 0 <= ind && ind < nvars );
1955 SCIPinfoMessage(scip, file,
"%d %d %d %d %.9g\n", consind, ind, sdprow[v][i], sdpcol[v][i], sdpval[v][i]);
1960 SCIPinfoMessage(scip, file,
"\n");
1964 if ( totalsdpnnonz > 0 )
1966 SCIPinfoMessage(scip, file,
"DCOORD\n%d\n", totalsdpconstnnonz);
1968 for (c = 0; c < nconss; c++)
1970 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 )
1974 sdparraylength = totalsdpnnonz;
1975 sdpconstnnonz = totalsdpconstnnonz;
1977 SCIP_CALL(
SCIPconsSdpGetData(scip, conss[c], &sdpnvars, &sdpnnonz, &sdpblocksize, &sdparraylength, sdpnvarnonz,
1978 sdpcol, sdprow, sdpval, sdpvars, &sdpconstnnonz, sdpconstcol, sdpconstrow, sdpconstval) );
1980 assert( sdpconstnnonz <= totalsdpconstnnonz );
1981 assert( sdparraylength <= totalsdpnnonz);
1983 for (i = 0; i < sdpconstnnonz; i++)
1985 SCIPinfoMessage(scip, file,
"%d %d %d %.9g\n", consind, sdpconstrow[i], sdpconstcol[i], -sdpconstval[i]);
1991 SCIPfreeBufferArray(scip, &sdpconstval);
1992 SCIPfreeBufferArray(scip, &sdpconstrow);
1993 SCIPfreeBufferArray(scip, &sdpconstcol);
1994 SCIPfreeBufferArray(scip, &sdpvars);
1995 SCIPfreeBufferArray(scip, &sdpval);
1996 SCIPfreeBufferArray(scip, &sdprow);
1997 SCIPfreeBufferArray(scip, &sdpcol);
1998 SCIPfreeBufferArray(scip, &sdpnvarnonz);
1999 SCIPfreeBufferArray(scip, &consssenses);
2000 SCIPfreeBufferArray(scip, &varsenses);
2002 *result = SCIP_SUCCESS;
2017 SCIP_READERDATA* readerdata = NULL;
2018 SCIP_READER* reader;
2023 assert( reader != NULL );
2026 SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyCbf) );
2027 SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadCbf) );
2028 SCIP_CALL( SCIPsetReaderWrite(scip, reader, readerWriteCbf) );
static SCIP_RETCODE CBFfgets(SCIP_FILE *pFile, SCIP_Longint *linecount)
static SCIP_RETCODE CBFreadBcoord(SCIP *scip, SCIP_FILE *pfile, SCIP_Longint *linecount, CBF_DATA *data)
static SCIP_RETCODE CBFreadHcoord(SCIP *scip, SCIP_FILE *pfile, SCIP_Longint *linecount, CBF_DATA *data)
char CBF_LINE_BUFFER[CBF_MAX_LINE]
file reader for mixed-integer semidefinite programs in CBF format
static SCIP_DECL_READERCOPY(readerCopyCbf)
static SCIP_RETCODE CBFreadObjsense(SCIP *scip, SCIP_FILE *pfile, SCIP_Longint *linecount)
static SCIP_RETCODE CBFfreeData(SCIP *scip, CBF_DATA *data)
static SCIP_RETCODE CBFreadAcoord(SCIP *scip, SCIP_FILE *pfile, SCIP_Longint *linecount, CBF_DATA *data)
char CBF_NAME_BUFFER[CBF_MAX_NAME]
static SCIP_RETCODE CBFreadDcoord(SCIP *scip, SCIP_FILE *pfile, SCIP_Longint *linecount, CBF_DATA *data)
static SCIP_RETCODE CBFreadInt(SCIP *scip, SCIP_FILE *pfile, SCIP_Longint *linecount, CBF_DATA *data)
Constraint handler for SDP-constraints.
SCIP_RETCODE SCIPincludeReaderCbf(SCIP *scip)
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_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)
static SCIP_RETCODE CBFreadVar(SCIP *scip, SCIP_FILE *pfile, SCIP_Longint *linecount, CBF_DATA *data)
static SCIP_DECL_READERREAD(readerReadCbf)
static SCIP_RETCODE CBFreadCon(SCIP *scip, SCIP_FILE *pfile, SCIP_Longint *linecount, CBF_DATA *data)
int SCIPconsSdpGetBlocksize(SCIP *scip, SCIP_CONS *cons)
static SCIP_RETCODE CBFreadPsdcon(SCIP *scip, SCIP_FILE *pfile, SCIP_Longint *linecount, CBF_DATA *data)
static SCIP_RETCODE CBFreadObjacoord(SCIP *scip, SCIP_FILE *pfile, SCIP_Longint *linecount, CBF_DATA *data)
SCIP_RETCODE SCIPconsSdpGetNNonz(SCIP *scip, SCIP_CONS *cons, int *nnonz, int *constnnonz)
static SCIP_DECL_READERWRITE(readerWriteCbf)