コード例 #1
0
ファイル: reader_dec.c プロジェクト: aimanqais/gerardus
/* reads problem from file */
SCIP_RETCODE SCIPreadDec(
    SCIP*                 scip,               /**< SCIP data structure */
    const char*           filename,           /**< full path and name of file to read, or NULL if stdin should be used */
    SCIP_RESULT*          result              /**< pointer to store the result of the file reading call */
)
{
    SCIP_READER* reader;
    DECINPUT decinput;
    int i;

    if( SCIPgetStage(scip) < SCIP_STAGE_TRANSFORMED )
        SCIP_CALL( SCIPtransformProb(scip) );

    reader = SCIPfindReader(scip, READER_NAME);
    assert(reader != NULL);

    /* initialize DEC input data */
    decinput.file = NULL;
    decinput.linebuf[0] = '\0';
    SCIP_CALL( SCIPallocMemoryArray(scip, &decinput.token, DEC_MAX_LINELEN) ); /*lint !e506*/
    decinput.token[0] = '\0';
    SCIP_CALL( SCIPallocMemoryArray(scip, &decinput.tokenbuf, DEC_MAX_LINELEN) ); /*lint !e506*/
    decinput.tokenbuf[0] = '\0';
    for( i = 0; i < DEC_MAX_PUSHEDTOKENS; ++ i )
    {
        SCIP_CALL( SCIPallocMemoryArray(scip, &decinput.pushedtokens[i], DEC_MAX_LINELEN) ); /*lint !e506 !e866*/
    }

    decinput.npushedtokens = 0;
    decinput.linenumber = 0;
    decinput.linepos = 0;
    decinput.section = DEC_START;
    decinput.presolved = FALSE;
    decinput.haspresolvesection = FALSE;
    decinput.nblocks = NOVALUE;
    decinput.blocknr = - 2;
    decinput.haserror = FALSE;

    /* read the file */
    SCIP_CALL( readDECFile(scip, reader, &decinput, filename) );

    /* free dynamically allocated memory */
    SCIPfreeMemoryArray(scip, &decinput.token);
    SCIPfreeMemoryArray(scip, &decinput.tokenbuf);
    for( i = 0; i < DEC_MAX_PUSHEDTOKENS; ++ i )
    {
        SCIPfreeMemoryArray(scip, &decinput.pushedtokens[i]);
    }

    /* evaluate the result */
    if( decinput.haserror )
        return SCIP_READERROR;
    else
    {
        *result = SCIP_SUCCESS;
    }

    return SCIP_OKAY;
}
コード例 #2
0
ファイル: reader_blk.c プロジェクト: aimanqais/gerardus
/* reads problem from file */
SCIP_RETCODE SCIPreadBlk(
    SCIP*                 scip,               /**< SCIP data structure */
    const char*           filename,           /**< full path and name of file to read, or NULL if stdin should be used */
    SCIP_RESULT*          result              /**< pointer to store the result of the file reading call */
)
{
    SCIP_READER* reader;
    BLKINPUT blkinput;
    int i;

    reader = SCIPfindReader(scip, READER_NAME);
    assert(reader != NULL);

    /* initialize BLK input data */
    blkinput.file = NULL;
    blkinput.linebuf[0] = '\0';
    SCIP_CALL( SCIPallocMemoryArray(scip, &blkinput.token, BLK_MAX_LINELEN) ); /*lint !e506*/
    blkinput.token[0] = '\0';
    SCIP_CALL( SCIPallocMemoryArray(scip, &blkinput.tokenbuf, BLK_MAX_LINELEN) ); /*lint !e506*/
    blkinput.tokenbuf[0] = '\0';
    for( i = 0; i < BLK_MAX_PUSHEDTOKENS; ++i )
    {
        SCIP_CALL( SCIPallocMemoryArray(scip, &blkinput.pushedtokens[i], BLK_MAX_LINELEN) ); /*lint !e506 !e866*/
    }

    blkinput.npushedtokens = 0;
    blkinput.linenumber = 0;
    blkinput.linepos = 0;
    blkinput.section = BLK_START;
    blkinput.presolved = FALSE;
    blkinput.haspresolvesection = FALSE;
    blkinput.nblocks = -1;
    blkinput.blocknr = -2;
    blkinput.haserror = FALSE;

    /* read the file */
    SCIP_CALL( readBLKFile(scip, reader, &blkinput, filename) );

    /* free dynamically allocated memory */
    SCIPfreeMemoryArray(scip, &blkinput.token);
    SCIPfreeMemoryArray(scip, &blkinput.tokenbuf);
    for( i = 0; i < BLK_MAX_PUSHEDTOKENS; ++i )
    {
        SCIPfreeMemoryArray(scip, &blkinput.pushedtokens[i]);
    }

    /* evaluate the result */
    if( blkinput.haserror )
        return SCIP_READERROR;
    else
    {
        *result = SCIP_SUCCESS;
    }

    return SCIP_OKAY;
}
コード例 #3
0
/** returns the reader object of the given name, or 0 if not existing */
scip::ObjReader* SCIPfindObjReader(
   SCIP*                 scip,               /**< SCIP data structure */
   const char*           name                /**< name of file reader */
   )
{
   SCIP_READER* reader;
   SCIP_READERDATA* readerdata;

   reader = SCIPfindReader(scip, name);
   if( reader == NULL )
      return 0;

   readerdata = SCIPreaderGetData(reader);
   assert(readerdata != NULL);

   return readerdata->objreader;
}