/** problem reading method of reader */ static SCIP_DECL_READERREAD(readerReadFix) { /*lint --e{715}*/ assert(reader != NULL); assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0); assert(result != NULL); *result = SCIP_DIDNOTRUN; if( SCIPgetStage(scip) < SCIP_STAGE_PROBLEM ) { SCIPerrorMessage("reading of fixing file is only possible after a problem was created\n"); return SCIP_READERROR; } /* free transformed problem, s.t. fixings are applied to the original problem */ SCIP_CALL( SCIPfreeTransform(scip) ); /* read (partial) solution from fixing file */ SCIP_CALL( readSol(scip, filename) ); *result = SCIP_SUCCESS; return SCIP_OKAY; }
/** problem reading method of reader * * In order to determine the type of the file, we have to open it. Thus, it has to be opened * twice. This might be removed, but is likely to not hurt the performance too much. */ static SCIP_DECL_READERREAD(readerReadSol) { /*lint --e{715}*/ SCIP_FILE* file; char buffer[SCIP_MAXSTRLEN]; char *s; assert(reader != NULL); assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0); assert(result != NULL); *result = SCIP_DIDNOTRUN; if( SCIPgetStage(scip) < SCIP_STAGE_PROBLEM ) { SCIPerrorMessage("reading of solution file is only possible after a problem was created\n"); return SCIP_READERROR; } if( SCIPgetStage(scip) == SCIP_STAGE_SOLVED ) { SCIPverbMessage(scip, SCIP_VERBLEVEL_NORMAL, NULL, "primal solution from solution file <%s> was ignored - problem is already solved to optimality\n", filename); *result = SCIP_SUCCESS; return SCIP_OKAY; } /* open input file in order to determine type */ file = SCIPfopen(filename, "r"); if( file == NULL ) { SCIPerrorMessage("cannot open file <%s> for reading\n", filename); SCIPprintSysError(filename); return SCIP_NOFILE; } /* get next line */ if( SCIPfgets(buffer, (int) sizeof(buffer), file) == NULL ) { SCIPerrorMessage("cannot parse file.\n"); return SCIP_READERROR; } /* close file */ SCIPfclose(file); /* decide whether it is xml */ s = buffer; /* skip spaces */ while( isspace((unsigned char)*s) ) ++s; if( s[0] == '<' && s[1] == '?' && s[2] == 'x' && s[3] == 'm' && s[4] == 'l' ) { /* read XML solution and add it to the solution pool */ SCIP_CALL( readXMLSol(scip, filename) ); } else { /* read the solution and add it to the solution pool */ SCIP_CALL( readSol(scip, filename) ); } *result = SCIP_SUCCESS; return SCIP_OKAY; }