50 #include "scip/cons_linear.h"
53 #define READER_NAME "cbfreader"
54 #define READER_DESC "file reader and writer for MISDPs in cbf format"
55 #define READER_EXTENSION "cbf"
57 #define CBF_VERSION_NR 1
58 #define CBF_CHECK_NONNEG TRUE
65 #define MACRO_STR_EXPAND(tok) #tok
66 #define MACRO_STR(tok) MACRO_STR_EXPAND(tok)
67 #define CBF_NAME_FORMAT "%" MACRO_STR(CBF_MAX_NAME) "s"
68 #define CBF_MAX_LINE 512
69 #define CBF_MAX_NAME 512
82 SCIP_VAR** createdvars;
89 SCIP_CONS** createdconss;
95 SCIP_VAR*** sdpblockvars;
101 SCIP_Real*** valpointer;
102 int* sdpconstnblocknonz;
106 SCIP_Real** sdpconstval;
120 long long int * linecount
123 assert( pFile != NULL );
124 assert( linecount != NULL );
135 return SCIP_READERROR;
143 long long int * linecount
146 assert( scip != NULL );
147 assert( pfile != NULL );
148 assert( linecount != NULL );
150 SCIP_CALL(
CBFfgets(pfile, linecount) );
156 SCIP_CALL( SCIPsetObjsense(scip, SCIP_OBJSENSE_MINIMIZE) );
160 SCIP_CALL( SCIPsetObjsense(scip, SCIP_OBJSENSE_MAXIMIZE) );
164 SCIPerrorMessage(
"OBJSENSE should be either MIN or MAX.\n");
170 return SCIP_READERROR;
181 long long int * linecount,
192 char varname[SCIP_MAXSTRLEN];
198 assert( scip != NULL );
199 assert( pfile != NULL );
200 assert( linecount != NULL );
201 assert( data != NULL );
203 SCIP_CALL(
CBFfgets(pfile, linecount) );
205 if ( sscanf(
CBF_LINE_BUFFER,
"%i %i", &(data->nvars), &nvartypes) != 2 )
206 return SCIP_READERROR;
209 assert( data->nvars >= 0 );
210 assert( data->nvars == 0 || ((1 <= nvartypes) && (nvartypes <= 3)) );
212 SCIP_CALL( SCIPallocBufferArray(scip, &(data->createdvars), data->nvars) );
213 for (v = 0; v < data->nvars; v++)
216 snprintfreturn = SCIPsnprintf(varname, SCIP_MAXSTRLEN,
"x_%d", v);
217 assert( snprintfreturn < SCIP_MAXSTRLEN);
219 (void)SCIPsnprintf(varname, SCIP_MAXSTRLEN,
"x_%d", v);
222 SCIP_CALL( SCIPcreateVar(scip, &var, varname, -SCIPinfinity(scip), SCIPinfinity(scip), 0.0,
223 SCIP_VARTYPE_CONTINUOUS, TRUE, FALSE, NULL, NULL, NULL, NULL, NULL));
225 SCIP_CALL( SCIPaddVar(scip, var) );
226 data->createdvars[v] = var;
229 SCIP_CALL( SCIPreleaseVar(scip, &var) );
238 for (t = 0; t < nvartypes; t++)
240 SCIP_CALL(
CBFfgets(pfile, linecount) );
246 if ( nvartypevars >= 0 )
247 nposorthvars = nvartypevars;
250 SCIPerrorMessage(
"Number of non-negative variables %d should be non-negative!\n", nvartypevars);
256 if ( nvartypevars >= 0 )
257 nnegorthvars = nvartypevars;
260 SCIPerrorMessage(
"Number of non-positive variables %d should be non-negative!\n", nvartypevars);
267 if ( nvartypevars >= 0 )
268 nfreevars = nvartypevars;
271 SCIPerrorMessage(
"Number of free variables %d should be non-negative!\n", nvartypevars);
278 SCIPerrorMessage(
"CBF-Reader of SCIP-SDP currently only supports non-negative, non-positive and free variables!\n");
283 return SCIP_READERROR;
287 data->firstnegorthvar = nposorthvars;
288 for (v = 0; v < nposorthvars; v++)
290 SCIP_CALL( SCIPchgVarLbGlobal(scip, data->createdvars[v], 0.0) );
294 data->firstfreevar = data->firstnegorthvar + nnegorthvars;
295 for (v = data->firstnegorthvar; v < data->firstfreevar; v++)
297 SCIP_CALL( SCIPchgVarUbGlobal(scip, data->createdvars[v], 0.0) );
300 assert( data->firstfreevar + nfreevars == data->nvars );
310 long long int * linecount,
321 char consname[SCIP_MAXSTRLEN];
327 assert( scip != NULL );
328 assert( pfile != NULL );
329 assert( linecount != NULL );
330 assert( data != NULL );
332 SCIP_CALL(
CBFfgets(pfile, linecount) );
334 if ( sscanf(
CBF_LINE_BUFFER,
"%i %i", &(data->nconss), &nconstypes) != 2 )
335 return SCIP_READERROR;
338 assert( data->nconss >= 0 );
339 assert( data->nconss == 0 || ((1 <= nconstypes) && (nconstypes <= 3)) );
341 SCIP_CALL( SCIPallocBufferArray(scip, &(data->createdconss), data->nconss) );
342 for (c = 0; c < data->nconss; c++)
345 snprintfreturn = SCIPsnprintf(consname, SCIP_MAXSTRLEN,
"LP_%d", c);
346 assert( snprintfreturn < SCIP_MAXSTRLEN);
348 (void)SCIPsnprintf(consname, SCIP_MAXSTRLEN,
"linear_%d", c);
351 SCIP_CALL( SCIPcreateConsLinear(scip, &cons, consname, 0, NULL, NULL, -SCIPinfinity(scip), SCIPinfinity(scip),
352 TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE));
354 SCIP_CALL( SCIPaddCons(scip, cons) );
355 data->createdconss[c] = cons;
358 SCIP_CALL( SCIPreleaseCons(scip, &cons) );
368 for (t = 0; t < nconstypes; t++)
370 SCIP_CALL(
CBFfgets(pfile, linecount) );
376 if ( nconstypeconss >= 0 )
377 ngeqconss = nconstypeconss;
380 SCIPerrorMessage(
"Number of greater or equal constraints %d should be non-negative!\n", nconstypeconss);
386 if ( nconstypeconss >= 0 )
387 nleqconss = nconstypeconss;
390 SCIPerrorMessage(
"Number of less or equal constraints %d should be non-negative!\n", nconstypeconss);
397 if ( nconstypeconss >= 0 )
398 neqconss = nconstypeconss;
401 SCIPerrorMessage(
"Number of equality constraints %d should be non-negative!\n", nconstypeconss);
408 SCIPerrorMessage(
"CBF-Reader of SCIP-SDP currently only supports linear greater or equal, less or equal and"
409 "equality constraints!\n");
414 return SCIP_READERROR;
418 data->firstleqcons = ngeqconss;
419 for (c = 0; c < ngeqconss; c++)
421 SCIP_CALL( SCIPchgLhsLinear(scip, data->createdconss[c], 0.0) );
425 data->firsteqcons = data->firstleqcons + nleqconss;
426 for (c = data->firstleqcons; c < data->firsteqcons; c++)
428 SCIP_CALL( SCIPchgRhsLinear(scip, data->createdconss[c], 0.0) );
431 assert( data->firsteqcons + neqconss == data->nconss );
441 long long int * linecount,
448 SCIP_Bool infeasible;
450 assert( scip != NULL );
451 assert( pfile != NULL );
452 assert( linecount != NULL );
453 assert( data != NULL );
455 SCIP_CALL(
CBFfgets(pfile, linecount) );
461 for (i = 0; i < nintvars; i++)
463 SCIP_CALL(
CBFfgets(pfile, linecount) );
466 SCIP_CALL( SCIPchgVarType(scip, data->createdvars[v], SCIP_VARTYPE_INTEGER, &infeasible) );
470 SCIPinfoMessage(scip, NULL,
"Infeasibility detected because of integrality of variable %s\n",
471 SCIPvarGetName(data->createdvars[v]));
476 SCIPerrorMessage(
"Number of integrality constraints %d should be non-negative!\n", nintvars);
483 SCIPerrorMessage(
"Number of integrality constraints %d should be non-negative!\n", nintvars);
488 return SCIP_READERROR;
498 long long int * linecount,
504 assert( scip != NULL );
505 assert( pfile != NULL );
506 assert( linecount != NULL );
507 assert( data != NULL );
509 SCIP_CALL(
CBFfgets(pfile, linecount) );
513 if ( data->nsdpblocks >= 0 )
515 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpblocksizes), data->nsdpblocks) );
517 for (b = 0; b < data->nsdpblocks; b++)
519 SCIP_CALL(
CBFfgets(pfile, linecount) );
522 if ( data->sdpblocksizes[b] <= 0 )
524 SCIPerrorMessage(
"Size %d of SDP-block %d should be positive!\n", data->sdpblocksizes[b], b);
529 return SCIP_READERROR;
534 SCIPerrorMessage(
"Number of SDP-blocks %d should be non-negative!\n", data->nsdpblocks);
539 return SCIP_READERROR;
549 long long int * linecount,
558 assert( scip != NULL );
559 assert( pfile != NULL );
560 assert( linecount != NULL );
561 assert( data != NULL );
563 SCIP_CALL(
CBFfgets(pfile, linecount) );
567 if ( nobjcoefs >= 0 )
569 for (i = 0; i < nobjcoefs; i++)
571 SCIP_CALL(
CBFfgets(pfile, linecount) );
574 if ( v < 0 || v >= data->nvars )
576 SCIPerrorMessage(
"Given objective coefficient for variable %d which does not exist!\n", v);
580 if ( SCIPisZero(scip, val) )
582 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
"Ignored objective coefficient of variable %d; value"
583 "%f is smaller than epsilon = %f.\n", v, val, SCIPepsilon(scip));
587 SCIP_CALL( SCIPchgVarObj(scip, data->createdvars[v], val) );
591 return SCIP_READERROR;
596 SCIPerrorMessage(
"Number of objective coefficients %d should be non-negative!\n", nobjcoefs);
601 return SCIP_READERROR;
611 long long int * linecount,
621 assert( scip != NULL );
622 assert( pfile != NULL );
623 assert( linecount != NULL );
624 assert( data != NULL );
626 SCIP_CALL(
CBFfgets(pfile, linecount) );
632 for (i = 0; i < ncoefs; i++)
634 SCIP_CALL(
CBFfgets(pfile, linecount) );
637 if ( c < 0 || c >= data->nconss )
639 SCIPerrorMessage(
"Given linear coefficient for constraint %d which does not exist!\n", c);
642 if ( v < 0 || v >= data->nvars )
644 SCIPerrorMessage(
"Given linear coefficient for variable %d which does not exist!\n", v);
647 if ( SCIPisZero(scip, val) )
649 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
"Ignored linear coefficient of constraint %d, variable "
650 "%d; value %.9f is smaller than epsilon = %f.\n", c, v, val, SCIPepsilon(scip));
654 SCIP_CALL( SCIPaddCoefLinear(scip, data->createdconss[c], data->createdvars[v], val) );
658 return SCIP_READERROR;
663 SCIPerrorMessage(
"Number of linear coefficients %d should be non-negative!\n", ncoefs);
668 return SCIP_READERROR;
678 long long int * linecount,
687 assert( scip != NULL );
688 assert( pfile != NULL );
689 assert( linecount != NULL );
690 assert( data != NULL );
692 SCIP_CALL(
CBFfgets(pfile, linecount) );
698 for (i = 0; i < nsides; i++)
700 SCIP_CALL(
CBFfgets(pfile, linecount) );
703 if ( c < 0 || c >= data->nconss )
705 SCIPerrorMessage(
"Given constant part for constraint %d which does not exist!\n", c);
708 if ( SCIPisZero(scip, val) )
710 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
"Ignored constant part of constraint %d; value %.9f is "
711 "smaller than epsilon = %f.\n", c, val, SCIPepsilon(scip));
715 if ( c < data->firstleqcons )
718 SCIP_CALL( SCIPchgLhsLinear(scip, data->createdconss[c], -val) );
720 else if ( c < data->firsteqcons )
723 SCIP_CALL( SCIPchgRhsLinear(scip, data->createdconss[c], -val) );
728 SCIP_CALL( SCIPchgLhsLinear(scip, data->createdconss[c], -val) );
729 SCIP_CALL( SCIPchgRhsLinear(scip, data->createdconss[c], -val) );
734 return SCIP_READERROR;
739 SCIPerrorMessage(
"Number of left- and right-hand sides %d should be non-negative!\n", nsides);
744 return SCIP_READERROR;
754 long long int * linecount,
770 assert( scip != NULL );
771 assert( pfile != NULL );
772 assert( linecount != NULL );
773 assert( data != NULL );
776 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpnblocknonz), data->nsdpblocks) );
777 for (b = 0; b < data->nsdpblocks; b++)
778 data->sdpnblocknonz[b] = 0;
780 SCIP_CALL(
CBFfgets(pfile, linecount) );
787 SCIP_CALL( SCIPallocBufferArray(scip, &sdpvar, data->nsdpblocks) );
788 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdprow), data->nsdpblocks) );
789 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpcol), data->nsdpblocks) );
790 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpval), data->nsdpblocks) );
791 for (b = 0; b < data->nsdpblocks; b++)
793 SCIP_CALL( SCIPallocBufferArray(scip, &(sdpvar[b]), nnonz) );
794 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdprow[b]), nnonz) );
795 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpcol[b]), nnonz) );
796 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpval[b]), nnonz) );
799 for (i = 0; i < nnonz; i++)
801 SCIP_CALL(
CBFfgets(pfile, linecount) );
802 if ( sscanf(
CBF_LINE_BUFFER,
"%i %i %i %i %lf", &b, &v, &row, &col, &val) == 5 )
804 if ( b < 0 || b >= data->nsdpblocks )
806 SCIPerrorMessage(
"Given SDP-coefficient for SDP-constraint %d which does not exist!\n", b);
809 if ( v < 0 || v >= data->nvars )
811 SCIPerrorMessage(
"Given SDP-coefficient for variable %d which does not exist!\n", v);
814 if ( row < 0 || row >= data->sdpblocksizes[b] )
816 SCIPerrorMessage(
"Row index %d of given SDP coefficient is negative or larger than blocksize %d!\n",
817 row, data->sdpblocksizes[b]);
820 if ( col < 0 || col >= data->sdpblocksizes[b] )
822 SCIPerrorMessage(
"Column index %d of given SDP coefficient is negative or larger than blocksize %d!\n",
823 col, data->sdpblocksizes[b]);
826 if ( SCIPisZero(scip, val) )
828 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
"Ignored SDP-coefficient of SDP-constraint %d, variable "
829 "%d, row %d, col %d; value %.9f is smaller than epsilon = %f.\n", b, v, row, col, val, SCIPepsilon(scip));
833 sdpvar[b][data->sdpnblocknonz[b]] = v;
834 data->sdprow[b][data->sdpnblocknonz[b]] = row;
835 data->sdpcol[b][data->sdpnblocknonz[b]] = col;
836 data->sdpval[b][data->sdpnblocknonz[b]] = val;
837 data->sdpnblocknonz[b]++;
841 return SCIP_READERROR;
845 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpnblockvars), data->nsdpblocks) );
846 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpblockvars), data->nsdpblocks) );
847 SCIP_CALL( SCIPallocBufferArray(scip, &(data->nvarnonz), data->nsdpblocks) );
848 SCIP_CALL( SCIPallocBufferArray(scip, &(data->rowpointer), data->nsdpblocks) );
849 SCIP_CALL( SCIPallocBufferArray(scip, &(data->colpointer), data->nsdpblocks) );
850 SCIP_CALL( SCIPallocBufferArray(scip, &(data->valpointer), data->nsdpblocks) );
851 for (b = 0; b < data->nsdpblocks; b++)
854 SCIPsortIntIntIntReal(sdpvar[b], data->sdprow[b], data->sdpcol[b], data->sdpval[b], data->sdpnblocknonz[b]);
858 data->sdpnblockvars[b] = 0;
859 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpblockvars[b]), data->nvars) );
860 SCIP_CALL( SCIPallocBufferArray(scip, &(data->nvarnonz[b]), data->nvars) );
861 SCIP_CALL( SCIPallocBufferArray(scip, &(data->rowpointer[b]), data->nvars) );
862 SCIP_CALL( SCIPallocBufferArray(scip, &(data->colpointer[b]), data->nvars) );
863 SCIP_CALL( SCIPallocBufferArray(scip, &(data->valpointer[b]), data->nvars) );
865 for (v = 0; v < data->nvars; v++)
868 firstindforvar = nextindaftervar;
869 data->nvarnonz[b][data->sdpnblockvars[b]] = 0;
870 while (nextindaftervar < data->sdpnblocknonz[b] && sdpvar[b][nextindaftervar] == v)
874 data->nvarnonz[b][data->sdpnblockvars[b]]++;
878 data->sdpblockvars[b][data->sdpnblockvars[b]] = data->createdvars[v];
879 data->rowpointer[b][data->sdpnblockvars[b]] = &(data->sdprow[b][firstindforvar]);
880 data->colpointer[b][data->sdpnblockvars[b]] = &(data->sdpcol[b][firstindforvar]);
881 data->valpointer[b][data->sdpnblockvars[b]] = &(data->sdpval[b][firstindforvar]);
882 data->sdpnblockvars[b]++;
886 assert (nextindaftervar == data->sdpnblocknonz[b]);
887 #ifdef SCIP_DISABLED_CODE
889 SCIP_CALL( SCIPreallocBufferArray(scip, &(data->rowpointer[b]), data->sdpnblocknonz[b]) );
890 SCIP_CALL( SCIPreallocBufferArray(scip, &(data->colpointer[b]), data->sdpnblocknonz[b]) );
891 SCIP_CALL( SCIPreallocBufferArray(scip, &(data->valpointer[b]), data->sdpnblocknonz[b]) );
893 SCIPfreeBufferArray(scip, &(sdpvar[b]));
897 SCIPfreeBufferArray(scip, &sdpvar);
901 SCIPerrorMessage(
"Number of nonzero coefficients of SDP-constraints %d should be non-negative!\n", nnonz);
906 return SCIP_READERROR;
916 long long int * linecount,
927 assert( scip != NULL );
928 assert( pfile != NULL );
929 assert( linecount != NULL );
930 assert( data != NULL );
933 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpconstnblocknonz), data->nsdpblocks) );
934 for (b = 0; b < data->nsdpblocks; b++)
935 data->sdpconstnblocknonz[b] = 0;
937 SCIP_CALL(
CBFfgets(pfile, linecount) );
941 if ( constnnonz >= 0 )
944 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpconstrow), data->nsdpblocks) );
945 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpconstcol), data->nsdpblocks) );
946 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpconstval), data->nsdpblocks) );
947 for (b = 0; b < data->nsdpblocks; b++)
949 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpconstrow[b]), constnnonz) );
950 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpconstcol[b]), constnnonz) );
951 SCIP_CALL( SCIPallocBufferArray(scip, &(data->sdpconstval[b]), constnnonz) );
954 for (i = 0; i < constnnonz; i++)
956 SCIP_CALL(
CBFfgets(pfile, linecount) );
957 if ( sscanf(
CBF_LINE_BUFFER,
"%i %i %i %lf", &b, &row, &col, &val) == 4 )
959 if ( b < 0 || b >= data->nsdpblocks )
961 SCIPerrorMessage(
"Given constant entry for SDP-constraint %d which does not exist!\n", b);
964 if ( row < 0 || row >= data->sdpblocksizes[b] )
966 SCIPerrorMessage(
"Row index %d of given constant SDP-entry is negative or larger than blocksize %d!\n",
967 row, data->sdpblocksizes[b]);
970 if ( col < 0 || col >= data->sdpblocksizes[b] )
972 SCIPerrorMessage(
"Column index %d of given constant SDP-entry is negative or larger than blocksize %d!\n",
973 col, data->sdpblocksizes[b]);
976 if ( SCIPisZero(scip, val) )
978 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL,
"Ignored constant entry of SDP-constraint %d, row %d,"
979 " col %d; value %.9f is smaller than epsilon = %f.\n", b, row, col, val, SCIPepsilon(scip));
983 data->sdpconstrow[b][data->sdpconstnblocknonz[b]] = row;
984 data->sdpconstcol[b][data->sdpconstnblocknonz[b]] = col;
985 data->sdpconstval[b][data->sdpconstnblocknonz[b]] = -val;
986 data->sdpconstnblocknonz[b]++;
990 return SCIP_READERROR;
992 #ifdef SCIP_DISABLED_CODE
993 for (b = 0; b < data->nsdpblocks; b++)
996 SCIP_CALL( SCIPreallocBufferArray(scip, &(data->sdpconstrow[b]), data->sdpconstnblocknonz[b]) );
997 SCIP_CALL( SCIPreallocBufferArray(scip, &(data->sdpconstcol[b]), data->sdpconstnblocknonz[b]) );
998 SCIP_CALL( SCIPreallocBufferArray(scip, &(data->sdpconstval[b]), data->sdpconstnblocknonz[b]) );
1004 SCIPerrorMessage(
"Number of constant entries of SDP-constraints %d should be non-negative!\n", constnnonz);
1009 return SCIP_READERROR;
1023 assert( scip != NULL );
1024 assert( data != NULL );
1026 for (b = 0; b < data->nsdpblocks; b++)
1028 SCIPfreeBufferArrayNull(scip, &(data->sdpconstval[b]));
1029 SCIPfreeBufferArrayNull(scip, &(data->sdpconstcol[b]));
1030 SCIPfreeBufferArrayNull(scip, &(data->sdpconstrow[b]));
1031 SCIPfreeBufferArrayNull(scip, &(data->valpointer[b]));
1032 SCIPfreeBufferArrayNull(scip, &(data->colpointer[b]));
1033 SCIPfreeBufferArrayNull(scip, &(data->rowpointer[b]));
1034 SCIPfreeBufferArrayNull(scip, &(data->sdpval[b]));
1035 SCIPfreeBufferArrayNull(scip, &(data->sdpcol[b]));
1036 SCIPfreeBufferArrayNull(scip, &(data->sdprow[b]));
1037 SCIPfreeBufferArrayNull(scip, &(data->sdpblockvars[b]));
1038 SCIPfreeBufferArrayNull(scip, &(data->nvarnonz[b]));
1040 SCIPfreeBufferArrayNull(scip, &data->sdpconstval);
1041 SCIPfreeBufferArrayNull(scip, &data->sdpconstcol);
1042 SCIPfreeBufferArrayNull(scip, &data->sdpconstrow);
1043 SCIPfreeBufferArrayNull(scip, &data->sdpconstnblocknonz);
1044 SCIPfreeBufferArrayNull(scip, &data->valpointer);
1045 SCIPfreeBufferArrayNull(scip, &data->colpointer);
1046 SCIPfreeBufferArrayNull(scip, &data->rowpointer);
1047 SCIPfreeBufferArrayNull(scip, &data->sdpval);
1048 SCIPfreeBufferArrayNull(scip, &data->sdpcol);
1049 SCIPfreeBufferArrayNull(scip, &data->sdprow);
1050 SCIPfreeBufferArrayNull(scip, &data->sdpblockvars);
1051 SCIPfreeBufferArrayNull(scip, &data->nvarnonz);
1052 SCIPfreeBufferArrayNull(scip, &data->sdpnblockvars);
1053 SCIPfreeBufferArrayNull(scip, &data->sdpnblocknonz);
1054 SCIPfreeBufferArrayNull(scip, &data->sdpblocksizes);
1055 SCIPfreeBufferArrayNull(scip, &data->createdconss);
1056 SCIPfreeBufferArrayNull(scip, &data->createdvars);
1071 assert(scip != NULL);
1082 SCIP_FILE* scipfile;
1083 long long int linecount;
1084 SCIP_Bool versionread;
1089 *result = SCIP_DIDNOTRUN;
1091 versionread = FALSE;
1094 SCIPdebugMsg(scip,
"Reading file %s\n", filename);
1096 scipfile = SCIPfopen(filename,
"r");
1099 return SCIP_READERROR;
1101 SCIP_CALL( SCIPallocBuffer(scip, &data) );
1102 data->nsdpblocks = 0;
1105 SCIP_CALL( SCIPcreateProb(scip, filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL) );
1107 while(
CBFfgets(scipfile, &linecount) == SCIP_OKAY )
1113 if ( ! versionread )
1119 SCIP_CALL(
CBFfgets(scipfile, &linecount) );
1123 SCIPdebugMsg(scip,
"file version %d\n", ver);
1126 SCIPerrorMessage(
"Only version number %d is supported!\n",
CBF_VERSION_NR);
1133 return SCIP_READERROR;
1137 SCIPerrorMessage(
"First keyword should be VER.\n");
1145 SCIPdebugMsg(scip,
"Reading OBJSENSE\n");
1151 SCIPdebugMsg(scip,
"Reading VAR\n");
1152 SCIP_CALL(
CBFreadVar(scip, scipfile, &linecount, data) );
1156 SCIPdebugMsg(scip,
"Reading CON\n");
1157 SCIP_CALL(
CBFreadCon(scip, scipfile, &linecount, data) );
1161 SCIPdebugMsg(scip,
"Reading INT\n");
1162 SCIP_CALL(
CBFreadInt(scip, scipfile, &linecount, data) );
1166 SCIPdebugMsg(scip,
"Reading PSDCON\n");
1167 SCIP_CALL(
CBFreadPsdcon(scip, scipfile, &linecount, data) );
1174 SCIPerrorMessage(
"SDPs in primal form currently not supported, please use PSDCON!\n");
1179 SCIPerrorMessage(
"SDPs in primal form currently not supported, please use PSDCON!\n");
1184 SCIPdebugMsg(scip,
"Reading OBJACOORD\n");
1189 SCIPerrorMessage(
"constant part in objective value not supported by SCIP!\n");
1194 SCIPerrorMessage(
"SDPs in primal form currently not supported, please use PSDCON!\n");
1199 SCIPdebugMsg(scip,
"Reading ACOORD\n");
1200 SCIP_CALL(
CBFreadAcoord(scip, scipfile, &linecount, data) );
1204 SCIPdebugMsg(scip,
"Reading BCOORD\n");
1205 SCIP_CALL(
CBFreadBcoord(scip, scipfile, &linecount, data) );
1209 SCIPdebugMsg(scip,
"Reading HCOORD\n");
1210 SCIP_CALL(
CBFreadHcoord(scip, scipfile, &linecount, data) );
1214 SCIPdebugMsg(scip,
"Reading DCOORD\n");
1215 SCIP_CALL(
CBFreadDcoord(scip, scipfile, &linecount, data) );
1228 SCIPerrorMessage(
"Keyword OBJSENSE is missing!\n");
1233 if ( SCIPfclose(scipfile) )
1234 return SCIP_READERROR;
1236 #ifdef SCIP_MORE_DEBUG
1237 for (b = 0; b < SCIPgetNConss(scip); b++)
1239 SCIP_CALL( SCIPprintCons(scip, SCIPgetConss(scip)[b], NULL) );
1244 for (b = 0; b < data->nsdpblocks; b++)
1247 char sdpconname[SCIP_MAXSTRLEN];
1252 assert( data->sdpblocksizes[b] > 0 );
1253 assert( ((data->sdpnblockvars[b] > 0) && data->sdpnblocknonz[b] > 0) || (data->sdpconstnblocknonz[b] > 0) );
1256 snprintfreturn = SCIPsnprintf(sdpconname, SCIP_MAXSTRLEN,
"SDP_%d", b);
1257 assert( snprintfreturn < SCIP_MAXSTRLEN);
1259 (void) SCIPsnprintf(sdpconname, SCIP_MAXSTRLEN,
"SDP_%d", b);
1261 SCIP_CALL(
SCIPcreateConsSdp(scip, &sdpcons, sdpconname, data->sdpnblockvars[b], data->sdpnblocknonz[b],
1262 data->sdpblocksizes[b], data->nvarnonz[b], data->colpointer[b], data->rowpointer[b], data->valpointer[b],
1263 data->sdpblockvars[b], data->sdpconstnblocknonz[b], data->sdpconstcol[b], data->sdpconstrow[b],
1264 data->sdpconstval[b]) );
1266 #ifdef SCIP_MORE_DEBUG
1267 SCIP_CALL( SCIPprintCons(scip, sdpcons, NULL) );
1270 SCIP_CALL( SCIPaddCons(scip, sdpcons) );
1272 SCIP_CALL( SCIPreleaseCons(scip, &sdpcons) );
1276 SCIPfreeBufferNull(scip, &data);
1278 *result = SCIP_SUCCESS;
1302 int totalsdpconstnnonz;
1306 SCIP_Real* sdpconstval;
1317 #ifdef CBF_CHECK_NONNEG
1318 SCIP_Bool* consdisabled;
1325 assert( scip != NULL );
1327 SCIPdebugMsg(scip,
"Writing problem in CBF format to %s\n", file);
1328 *result = SCIP_DIDNOTRUN;
1332 SCIPerrorMessage(
"CBF reader currently only supports writing original problems!\n");
1336 for (c = 0; c < nconss; c++)
1338 if ( (strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0)
1339 && (strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 ) )
1341 SCIPerrorMessage(
"CBF reader currently only supports linear and SDP constraints!\n");
1347 for (v = 0; v < nvars; v++)
1349 assert( SCIPvarGetStatus(vars[v]) == SCIP_VARSTATUS_ORIGINAL );
1357 SCIPinfoMessage(scip, file,
"OBJSENSE\n%s\n\n", objsense == SCIP_OBJSENSE_MINIMIZE ?
"MIN" :
"MAX");
1359 #ifdef CBF_CHECK_NONNEG
1363 SCIP_CALL( SCIPallocBufferArray(scip, &consdisabled, nconss) );
1364 SCIP_CALL( SCIPallocBufferArray(scip, &posorth, nvars) );
1365 SCIP_CALL( SCIPallocBufferArray(scip, &negorth, nvars) );
1367 for (v = 0; v < nvars; v++)
1375 for (c = 0; c < nconss; c++)
1377 consdisabled[c] = 0;
1380 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1384 if ( SCIPgetNVarsLinear(scip, conss[c]) != 1 )
1388 assert( ! SCIPisZero(scip, SCIPgetValsLinear(scip, conss[c])[0]) );
1391 assert( SCIPisLT(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) );
1393 if ( SCIPgetValsLinear(scip, conss[c])[0] > 0.0 )
1395 if ( SCIPisZero(scip, SCIPgetLhsLinear(scip, conss[c])) )
1397 consdisabled[c] = 1;
1401 if ( ! SCIPisInfinity(scip, SCIPgetRhsLinear(scip, conss[c])) )
1403 SCIPerrorMessage(
"Detection of non-negativity constraints currently not supported for ranged rows!\n");
1407 else if ( SCIPisZero(scip, SCIPgetRhsLinear(scip, conss[c])) )
1409 consdisabled[c] = 1;
1416 if ( SCIPisZero(scip, SCIPgetLhsLinear(scip, conss[c])) )
1418 consdisabled[c] = 1;
1422 else if ( SCIPisZero(scip, SCIPgetRhsLinear(scip, conss[c])) )
1424 consdisabled[c] = 1;
1431 assert( (0 <= nposorth) && (0 <= nnegorth) && (nposorth + nnegorth <= nvars) );
1438 for (v = 0; v < nvars; v++)
1445 for (v = 0; v < nvars; v++)
1452 for (v = 0; v < nvars; v++)
1454 if ( ( ! posorth[v] ) && ( ! negorth[v] ) )
1461 if ( (nposorth == 0) && (nnegorth == 0) )
1462 SCIPinfoMessage(scip, file,
"VAR\n%d 1\nF %d\n\n", nvars, nvars);
1463 else if ( (nposorth > 0) && (nnegorth == 0) && (nposorth < nvars) )
1464 SCIPinfoMessage(scip, file,
"VAR\n%d 2\nL+ %d\nF %d\n\n", nvars, nposorth, nvars - nposorth);
1465 else if ( (nposorth == 0) && (nnegorth > 0) && (nnegorth < nvars) )
1466 SCIPinfoMessage(scip, file,
"VAR\n%d 2\nL- %d\nF %d\n\n", nvars, nposorth, nvars - nnegorth);
1467 else if ( nposorth + nnegorth < nvars )
1468 SCIPinfoMessage(scip, file,
"VAR\n%d 3\nL+ %d\nL- %d\nF %d\n\n", nvars, nposorth, nnegorth, nvars - nposorth - nnegorth);
1469 else if ( (nposorth > 0) && (nnegorth == 0) )
1470 SCIPinfoMessage(scip, file,
"VAR\n%d 1\nL+ %d\n\n", nvars, nposorth);
1471 else if ( (nposorth == 0) && (nnegorth > 0) )
1472 SCIPinfoMessage(scip, file,
"VAR\n%d 1\nL- %d\n\n", nvars, nnegorth);
1474 SCIPinfoMessage(scip, file,
"VAR\n%d 2\nL+ %d\nL- %d\n\n", nvars, nposorth, nnegorth);
1482 SCIPinfoMessage(scip, file,
"VAR\n%d 1\nF %d\n\n", nvars, nvars);
1486 if ( nbinvars + nintvars > 0 )
1488 SCIPinfoMessage(scip, file,
"INT\n%d\n", nbinvars + nintvars);
1490 for (v = 0; v < nbinvars + nintvars; v++)
1492 assert( SCIPvarIsIntegral(vars[v]) );
1496 SCIPinfoMessage(scip, file,
"\n");
1503 for (c = 0; c < nconss; c++)
1506 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1509 #ifdef CBF_CHECK_NONNEG
1510 if ( consdisabled[c] )
1514 if ( ( ! SCIPisInfinity(scip, -1 * SCIPgetLhsLinear(scip, conss[c]))) &&
1515 ( ! SCIPisInfinity(scip, SCIPgetRhsLinear(scip, conss[c])) ) &&
1516 SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) )
1520 if ( ! SCIPisInfinity(scip, -1 * SCIPgetLhsLinear(scip, conss[c])) )
1522 if ( ! SCIPisInfinity(scip, SCIPgetRhsLinear(scip, conss[c])) )
1528 if ( neqconss + ngeqconss + nleqconss > 0 )
1530 if ( ((neqconss > 0) && (ngeqconss == 0) && (nleqconss == 0))
1531 || ((neqconss == 0) && (ngeqconss > 0) && (nleqconss == 0))
1532 || ((neqconss == 0) && (ngeqconss == 0) && (nleqconss > 0)) )
1533 SCIPinfoMessage(scip, file,
"CON\n%d 1\n", neqconss + ngeqconss + nleqconss);
1534 else if ( ((neqconss > 0) && (ngeqconss > 0) && (nleqconss == 0))
1535 || ((neqconss > 0) && (ngeqconss == 0) && (nleqconss > 0))
1536 || ((neqconss == 0) && (ngeqconss > 0) && (nleqconss > 0)) )
1537 SCIPinfoMessage(scip, file,
"CON\n%d 2\n", neqconss + ngeqconss + nleqconss);
1540 assert( (neqconss > 0) && (ngeqconss > 0) && (nleqconss > 0) );
1541 SCIPinfoMessage(scip, file,
"CON\n%d 3\n", neqconss + ngeqconss + nleqconss);
1544 if ( ngeqconss > 0 )
1545 SCIPinfoMessage(scip, file,
"L+ %d", ngeqconss);
1546 if ( nleqconss > 0 )
1547 SCIPinfoMessage(scip, file,
"L- %d", nleqconss);
1549 SCIPinfoMessage(scip, file,
"L= %d", neqconss);
1551 SCIPinfoMessage(scip, file,
"\n\n");
1556 for (c = 0; c < nconss; c++)
1558 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") == 0 )
1563 SCIPinfoMessage(scip, file,
"PSDCON\n%d\n", nsdpconss);
1565 for (c = 0; c < nconss; c++)
1567 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 )
1573 SCIPinfoMessage(scip, file,
"\n");
1577 for (v = 0; v < nvars; v++)
1579 if ( ! SCIPisZero(scip, SCIPvarGetObj(vars[v])) )
1584 SCIPinfoMessage(scip, file,
"OBJACOORD\n%d\n", nobjnonz);
1586 for (v = 0; v < nvars; v++)
1588 if ( ! SCIPisZero(scip, SCIPvarGetObj(vars[v])) )
1594 SCIPinfoMessage(scip, file,
"\n");
1596 if ( neqconss + ngeqconss + nleqconss > 0 )
1603 for (c = 0; c < nconss; c++)
1605 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1608 if ( SCIPisInfinity(scip, -1 * SCIPgetLhsLinear(scip, conss[c]))
1609 || SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) )
1611 #ifdef CBF_CHECK_NONNEG
1612 if ( consdisabled[c] )
1616 nnonz += SCIPgetNVarsLinear(scip, conss[c]);
1617 nbnonz += ( ! SCIPisZero(scip, SCIPgetLhsLinear(scip, conss[c])));
1620 for (c = 0; c < nconss; c++)
1622 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1625 if ( SCIPisInfinity(scip, SCIPgetRhsLinear(scip, conss[c]))
1626 || SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) )
1628 #ifdef CBF_CHECK_NONNEG
1629 if ( consdisabled[c] )
1633 nnonz += SCIPgetNVarsLinear(scip, conss[c]);
1634 nbnonz += ( ! SCIPisZero(scip, SCIPgetRhsLinear(scip, conss[c])));
1637 for (c = 0; c < nconss; c++)
1639 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1642 if ( SCIPisInfinity(scip, -1 * SCIPgetLhsLinear(scip, conss[c]))
1643 || SCIPisInfinity(scip, SCIPgetRhsLinear(scip, conss[c]))
1644 || ( ! SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c]))) )
1646 #ifdef CBF_CHECK_NONNEG
1647 if ( consdisabled[c] )
1651 nnonz += SCIPgetNVarsLinear(scip, conss[c]);
1652 nbnonz += ( ! SCIPisZero(scip, SCIPgetLhsLinear(scip, conss[c])));
1656 SCIPinfoMessage(scip, file,
"ACOORD\n%d\n", nnonz);
1660 for (c = 0; c < nconss; c++)
1662 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1665 if ( SCIPisInfinity(scip, -1 * SCIPgetLhsLinear(scip, conss[c]))
1666 || SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) )
1668 #ifdef CBF_CHECK_NONNEG
1669 if ( consdisabled[c] )
1673 linvars = SCIPgetVarsLinear(scip, conss[c]);
1674 linvals = SCIPgetValsLinear(scip, conss[c]);
1676 for (v = 0; v < SCIPgetNVarsLinear(scip, conss[c]); v++)
1683 for (c = 0; c < nconss; c++)
1685 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1688 if ( SCIPisInfinity(scip, SCIPgetRhsLinear(scip, conss[c]))
1689 || SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) )
1691 #ifdef CBF_CHECK_NONNEG
1692 if ( consdisabled[c] )
1696 linvars = SCIPgetVarsLinear(scip, conss[c]);
1697 linvals = SCIPgetValsLinear(scip, conss[c]);
1699 for (v = 0; v < SCIPgetNVarsLinear(scip, conss[c]); v++)
1706 for (c = 0; c < nconss; c++)
1708 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1711 if ( SCIPisInfinity(scip, -1 * SCIPgetLhsLinear(scip, conss[c]))
1712 || SCIPisInfinity(scip, SCIPgetRhsLinear(scip, conss[c]))
1713 || ( ! SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c]))) )
1715 #ifdef CBF_CHECK_NONNEG
1716 if ( consdisabled[c] )
1720 linvars = SCIPgetVarsLinear(scip, conss[c]);
1721 linvals = SCIPgetValsLinear(scip, conss[c]);
1723 for (v = 0; v < SCIPgetNVarsLinear(scip, conss[c]); v++)
1730 SCIPinfoMessage(scip, file,
"\n");
1733 SCIPinfoMessage(scip, file,
"BCOORD\n%d\n", nbnonz);
1737 for (c = 0; c < nconss; c++)
1739 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1742 if ( SCIPisInfinity(scip, -1 * SCIPgetLhsLinear(scip, conss[c]))
1743 || SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) )
1745 #ifdef CBF_CHECK_NONNEG
1746 if ( consdisabled[c] )
1751 if ( ! SCIPisZero(scip, SCIPgetLhsLinear(scip, conss[c])) )
1753 SCIPinfoMessage(scip, file,
"%d %.9f\n", consind, -1 * SCIPgetLhsLinear(scip, conss[c]));
1758 for (c = 0; c < nconss; c++)
1760 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1763 if ( SCIPisInfinity(scip, SCIPgetRhsLinear(scip, conss[c]))
1764 || SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c])) )
1766 #ifdef CBF_CHECK_NONNEG
1767 if ( consdisabled[c] )
1772 if ( ! SCIPisZero(scip, SCIPgetRhsLinear(scip, conss[c])) )
1774 SCIPinfoMessage(scip, file,
"%d %.9f\n", consind, -1 * SCIPgetRhsLinear(scip, conss[c]));
1779 for (c = 0; c < nconss; c++)
1781 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"linear") != 0 )
1784 if ( SCIPisInfinity(scip, -1 * SCIPgetLhsLinear(scip, conss[c]))
1785 || SCIPisInfinity(scip, SCIPgetRhsLinear(scip, conss[c]))
1786 || ( ! SCIPisEQ(scip, SCIPgetLhsLinear(scip, conss[c]), SCIPgetRhsLinear(scip, conss[c]))) )
1788 #ifdef CBF_CHECK_NONNEG
1789 if ( consdisabled[c] )
1794 if ( ! SCIPisZero(scip, SCIPgetLhsLinear(scip, conss[c])) )
1796 SCIPinfoMessage(scip, file,
"%d %.9f\n", consind, -1 * SCIPgetLhsLinear(scip, conss[c]));
1800 SCIPinfoMessage(scip, file,
"\n");
1805 totalsdpconstnnonz = 0;
1806 for (c = 0; c < nconss; c++)
1808 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 )
1812 totalsdpnnonz += sdpnnonz;
1813 totalsdpconstnnonz += sdpconstnnonz;
1817 SCIP_CALL( SCIPallocBufferArray(scip, &sdpnvarnonz, nvars) );
1818 SCIP_CALL( SCIPallocBufferArray(scip, &sdpcol, totalsdpnnonz) );
1819 SCIP_CALL( SCIPallocBufferArray(scip, &sdprow, totalsdpnnonz) );
1820 SCIP_CALL( SCIPallocBufferArray(scip, &sdpval, totalsdpnnonz) );
1821 SCIP_CALL( SCIPallocBufferArray(scip, &sdpvars, nvars) );
1822 SCIP_CALL( SCIPallocBufferArray(scip, &sdpconstcol, totalsdpconstnnonz) );
1823 SCIP_CALL( SCIPallocBufferArray(scip, &sdpconstrow, totalsdpconstnnonz) );
1824 SCIP_CALL( SCIPallocBufferArray(scip, &sdpconstval, totalsdpconstnnonz) );
1826 sdparraylength = totalsdpnnonz;
1827 sdpconstnnonz = totalsdpconstnnonz;
1830 SCIPinfoMessage(scip, file,
"HCOORD\n%d\n", totalsdpnnonz);
1832 for (c = 0; c < nconss; c++)
1834 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 )
1838 sdparraylength = totalsdpnnonz;
1839 sdpconstnnonz = totalsdpconstnnonz;
1841 SCIP_CALL(
SCIPconsSdpGetData(scip, conss[c], &sdpnvars, &sdpnnonz, &sdpblocksize, &sdparraylength, sdpnvarnonz,
1842 sdpcol, sdprow, sdpval, sdpvars, &sdpconstnnonz, sdpconstcol, sdpconstrow, sdpconstval) );
1844 assert( sdpconstnnonz <= totalsdpconstnnonz );
1845 assert( sdparraylength <= totalsdpnnonz);
1847 for (v = 0; v < sdpnvars; v++)
1849 for (i = 0; i < sdpnvarnonz[v]; i++)
1852 sdprow[v][i], sdpcol[v][i], sdpval[v][i]);
1857 SCIPinfoMessage(scip, file,
"\n");
1860 SCIPinfoMessage(scip, file,
"DCOORD\n%d\n", totalsdpconstnnonz);
1862 for (c = 0; c < nconss; c++)
1864 if ( strcmp(SCIPconshdlrGetName(SCIPconsGetHdlr(conss[c])),
"SDP") != 0 )
1868 sdparraylength = totalsdpnnonz;
1869 sdpconstnnonz = totalsdpconstnnonz;
1871 SCIP_CALL(
SCIPconsSdpGetData(scip, conss[c], &sdpnvars, &sdpnnonz, &sdpblocksize, &sdparraylength, sdpnvarnonz,
1872 sdpcol, sdprow, sdpval, sdpvars, &sdpconstnnonz, sdpconstcol, sdpconstrow, sdpconstval) );
1874 assert( sdpconstnnonz <= totalsdpconstnnonz );
1875 assert( sdparraylength <= totalsdpnnonz);
1877 for (i = 0; i < sdpconstnnonz; i++)
1879 SCIPinfoMessage(scip, file,
"%d %d %d %.9f\n", consind, sdpconstrow[i], sdpconstcol[i], -1* sdpconstval[i]);
1884 SCIPfreeBufferArray(scip, &sdpconstval);
1885 SCIPfreeBufferArray(scip, &sdpconstrow);
1886 SCIPfreeBufferArray(scip, &sdpconstcol);
1887 SCIPfreeBufferArray(scip, &sdpvars);
1888 SCIPfreeBufferArray(scip, &sdpval);
1889 SCIPfreeBufferArray(scip, &sdprow);
1890 SCIPfreeBufferArray(scip, &sdpcol);
1891 SCIPfreeBufferArray(scip, &sdpnvarnonz);
1893 #ifdef CBF_CHECK_NONNEG
1894 SCIPfreeBufferArray(scip, &negorth);
1895 SCIPfreeBufferArray(scip, &posorth);
1896 SCIPfreeBufferArray(scip, &consdisabled);
1899 *result = SCIP_SUCCESS;
1914 SCIP_READERDATA* readerdata;
1915 SCIP_READER* reader;
1923 assert(reader != NULL);
1926 SCIP_CALL( SCIPsetReaderCopy(scip, reader, readerCopyCbf) );
1927 SCIP_CALL( SCIPsetReaderRead(scip, reader, readerReadCbf) );
1928 SCIP_CALL( SCIPsetReaderWrite(scip, reader, readerWriteCbf) );
static SCIP_RETCODE CBFreadCon(SCIP *scip, SCIP_FILE *pfile, long long int *linecount, CBF_DATA *data)
static SCIP_RETCODE CBFreadDcoord(SCIP *scip, SCIP_FILE *pfile, long long int *linecount, CBF_DATA *data)
SCIP_RETCODE SCIPsdpVarmapperAddVars(SCIP *scip, SdpVarmapper *varmapper, int nvars, SCIP_VAR **vars)
char CBF_LINE_BUFFER[CBF_MAX_LINE]
static SCIP_RETCODE CBFreadHcoord(SCIP *scip, SCIP_FILE *pfile, long long int *linecount, CBF_DATA *data)
file reader for mixed-integer semidefinite programs in CBF format
static SCIP_RETCODE CBFfgets(SCIP_FILE *pFile, long long int *linecount)
static SCIP_DECL_READERCOPY(readerCopyCbf)
static SCIP_RETCODE CBFreadAcoord(SCIP *scip, SCIP_FILE *pfile, long long int *linecount, CBF_DATA *data)
static SCIP_RETCODE CBFfreeData(SCIP *scip, CBF_DATA *data)
char CBF_NAME_BUFFER[CBF_MAX_NAME]
SCIP_RETCODE SCIPsdpVarmapperCreate(SCIP *scip, SdpVarmapper **varmapper, int size)
struct Sdpvarmapper SdpVarmapper
int SCIPsdpVarmapperGetSdpIndex(SdpVarmapper *varmapper, SCIP_VAR *var)
Constraint handler for SDP-constraints.
SCIP_RETCODE SCIPincludeReaderCbf(SCIP *scip)
class that maps SCIP variables to SDP indices (the SCIP variables are given SDP indices in the order ...
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 CBFreadPsdcon(SCIP *scip, SCIP_FILE *pfile, long long int *linecount, CBF_DATA *data)
static SCIP_RETCODE CBFreadVar(SCIP *scip, SCIP_FILE *pfile, long long int *linecount, CBF_DATA *data)
static SCIP_DECL_READERREAD(readerReadCbf)
int SCIPconsSdpGetBlocksize(SCIP *scip, SCIP_CONS *cons)
SCIP_RETCODE SCIPsdpVarmapperFree(SCIP *scip, SdpVarmapper **varmapper)
static SCIP_RETCODE CBFreadObjacoord(SCIP *scip, SCIP_FILE *pfile, long long int *linecount, CBF_DATA *data)
static SCIP_RETCODE CBFreadBcoord(SCIP *scip, SCIP_FILE *pfile, long long int *linecount, CBF_DATA *data)
SCIP_RETCODE SCIPconsSdpGetNNonz(SCIP *scip, SCIP_CONS *cons, int *nnonz, int *constnnonz)
static SCIP_RETCODE CBFreadInt(SCIP *scip, SCIP_FILE *pfile, long long int *linecount, CBF_DATA *data)
static SCIP_RETCODE CBFreadObjsense(SCIP *scip, SCIP_FILE *pfile, long long int *linecount)
static SCIP_DECL_READERWRITE(readerWriteCbf)