@@ -96,6 +96,10 @@ static const char delimchars[] = " \f\n\r\t\v";
96
96
static const char tokenchars [] = "-+:<>=" ;
97
97
static const char commentchars [] = "\\" ;
98
98
99
+ struct SCIP_ReaderData
100
+ {
101
+ DECDECOMP * decdecomp ;
102
+ };
99
103
100
104
101
105
@@ -822,55 +826,32 @@ SCIP_RETCODE readREFFile(
822
826
823
827
/** writes a BLK file */
824
828
static
825
- SCIP_RETCODE writeBLKFile (
829
+ SCIP_RETCODE writeREFFile (
826
830
SCIP * scip , /**< SCIP data structure */
827
- REFINPUT * refinput /**< REF reading data */
831
+ SCIP_READER * reader ,
832
+ FILE * file
833
+
828
834
)
829
835
{
830
- char filename [SCIP_MAXSTRLEN ];
831
- FILE * outfile ;
832
- SCIP_VAR * * vars ;
833
- SCIP_VARDATA * vardata ;
834
- int nvars ;
835
-
836
- int i ;
837
- int v ;
838
-
839
- SCIPsnprintf (filename , SCIP_MAXSTRLEN , "%s.blk" , SCIPgetProbName (scip ));
840
- outfile = fopen (filename , "w" );
841
-
842
- SCIP_CALL ( SCIPgetVarsData (scip , & vars , & nvars , NULL , NULL , NULL , NULL ) );
836
+ SCIP_READERDATA * readerdata ;
843
837
844
- SCIPinfoMessage ( scip , outfile , "NBlocks\n" ) ;
845
- SCIPinfoMessage ( scip , outfile , "%d\n" , refinput -> nblocks ) ;
838
+ int nvars ;
839
+ int nconss ;
846
840
847
- for ( i = 0 ; i < refinput -> nblocks ; i ++ )
848
- {
849
- SCIPinfoMessage (scip , outfile , "Block %d\n" , i + 1 );
841
+ assert (scip != NULL );
842
+ assert (reader != NULL );
843
+ assert (file != NULL );
844
+ assert (result != NULL );
850
845
851
- for ( v = 0 ; v < nvars ; v ++ )
852
- {
853
- vardata = SCIPvarGetData (vars [v ]);
854
- if ( vardata -> blocknr == i )
855
- {
856
- SCIPinfoMessage (scip , outfile , "%s\n" , SCIPvarGetName (vars [v ]));
857
- }
858
- }
859
- }
846
+ readerdata = SCIPreaderGetData (reader );
847
+ assert (readerdata != NULL );
860
848
861
- if ( refinput -> nmarkedmasterconss > 0 )
849
+ if (readerdata -> decdecomp == NULL )
862
850
{
863
- SCIPinfoMessage (scip , outfile , "Masterconss\n" );
864
- for ( i = 0 ; i < refinput -> nmarkedmasterconss ; i ++ )
865
- {
866
- SCIPinfoMessage (scip , outfile , "%s\n" , SCIPconsGetName (refinput -> markedmasterconss [i ]));
867
- }
851
+ SCIPerrorMessage ("No reformulation exists, cannot write reformulation file!\n" );
852
+ return SCIP_INVALIDCALL ;
868
853
}
869
854
870
- SCIPinfoMessage (scip , outfile , "END\n" );
871
-
872
- fclose (outfile );
873
-
874
855
return SCIP_OKAY ;
875
856
}
876
857
@@ -880,7 +861,20 @@ SCIP_RETCODE writeBLKFile(
880
861
*/
881
862
882
863
/** destructor of reader to free user data (called when SCIP is exiting) */
883
- #define readerFreeRef NULL
864
+ SCIP_DECL_READERFREE (readerFreeRef )
865
+ {
866
+ SCIP_READERDATA * readerdata ;
867
+ assert (scip != NULL );
868
+ assert (reader != NULL );
869
+
870
+ assert (strcmp (SCIPreaderGetName (reader ), READER_NAME ) == 0 );
871
+ readerdata = SCIPreaderGetData (reader );
872
+ assert (readerdata != NULL );
873
+
874
+ SCIPfreeMemory (scip , & readerdata );
875
+
876
+ return SCIP_OKAY ;
877
+ }
884
878
885
879
886
880
/** problem reading method of reader */
@@ -897,6 +891,8 @@ SCIP_DECL_READERREAD(readerReadRef)
897
891
static
898
892
SCIP_DECL_READERWRITE (readerWriteRef )
899
893
{
894
+ SCIP_CALL (writeREFFile (scip , reader , file ));
895
+ * result = SCIP_SUCCESS ;
900
896
return SCIP_OKAY ;
901
897
}
902
898
@@ -912,7 +908,7 @@ SCIP_RETCODE SCIPincludeReaderRef(
912
908
SCIP_READERDATA * readerdata ;
913
909
914
910
/* create blk reader data */
915
- readerdata = NULL ;
911
+ SCIP_CALL ( SCIPallocMemory ( scip , readerdata )) ;
916
912
917
913
/* include lp reader */
918
914
SCIP_CALL ( SCIPincludeReader (scip , READER_NAME , READER_DESC , READER_EXTENSION ,
@@ -1007,3 +1003,28 @@ SCIP_RETCODE SCIPreadRef(
1007
1003
1008
1004
return SCIP_OKAY ;
1009
1005
}
1006
+
1007
+ /** set the decomp structure */
1008
+ extern
1009
+ SCIP_RETCODE SCIPReaderREFSetDecomp (
1010
+ SCIP * scip , /**< SCIP data structure */
1011
+ SCIP_READER * reader , /**< Reader data structure */
1012
+ DECDECOMP * decdecomp /**< DECOMP data structure */
1013
+
1014
+ )
1015
+ {
1016
+
1017
+ SCIP_READERDATA * readerdata ;
1018
+ assert (scip != NULL );
1019
+ assert (decdecomp != NULL );
1020
+ assert (reader != NULL );
1021
+
1022
+ assert (strcmp (SCIPreaderGetName (reader ), READER_NAME ) == 0 );
1023
+ readerdata = SCIPreaderGetData (reader );
1024
+
1025
+ assert (readerdata != NULL );
1026
+
1027
+ readerdata -> decdecomp = decdecomp ;
1028
+
1029
+ return SCIP_OKAY ;
1030
+ }
0 commit comments