[Scip] some questions about the file readers in the coloring example

gamrath@zib.de gamrath at zib.de
Tue Dec 22 00:54:05 MET 2009


Dear Xiangyong,

you are right, "reader" and "filename" are not defined in
SCIP_DECL_READERREAD(readerReadCol), since they are parameters of the
method that is defined by this callback.

But this method is called nowhere in this file. In SCIPincludeReaderCol(),
the reader is included into the SCIP instance, and all the callback
methods of this reader that are defined in this file are given to SCIP in
this method, too.
So, SCIP knows the reader and the methods associated with it, and
everytime a file is read in, SCIP will check, whether the suffix of this
file equals the suffix this reader is related to and if that is the case,
SCIP will call the method readerReadCol() with all the parameters that are
defined in type_reader.h.

All these callback methods that you can or must define will only be called
by SCIP itself and never by the user. So you do not have to worry about
where to get the parameters from, you only have to know which parameters
you have, SCIP will do the rest ;-)

If you still have any questions, feel free to answer and pose them.

Best, Gerald



> Dear Gerald,
>
> Thanks.  I understand the definition of READERREAD.  If we look at the
> coloring example. The author did not define "reader" and "filename" either
> in SCIP_DECL_READERREAD(readerReadCol), or while calling it. So we need
> not define them before we call it.
>
> Please refer to function SCIP_DECL_READERREAD and
> SCIPincludeReaderCol(where the READERREAD is called)
>
> static SCIP_DECL_READERREAD(readerReadCol)
> {
>    assert(reader != NULL);
>    assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
>    assert(scip != NULL);
>    assert(result != NULL);
>
>    SCIP_CALL( readCol(scip, filename) );
>
>    *result = SCIP_SUCCESS;
>
>    return SCIP_OKAY;
> }
>
> SCIP_RETCODE SCIPincludeReaderCol(
>    SCIP*                 scip                /**< SCIP data structure */
>    )
> {
>   SCIP_READERDATA* readerdata;
>
>   /* create col reader data */
>   readerdata = NULL;
>
>   /* include col reader */
>   SCIP_CALL( SCIPincludeReader(scip, READER_NAME, READER_DESC,
> READER_EXTENSION,
>         readerFreeCol, readerReadCol, NULL, readerdata) );
>   return SCIP_OKAY;
> }
>
>
> Thanks.
>
>
> Xiangyong
>
>
>
>
> ÔÚ2009-12-21£¬gamrath at zib.de дµÀ£º
>>Hi Xiangyong,
>>
>>for each kind of plugin, you can look in the type_xyz.h file in the
>>src/scip/ directory in your SCIP folder in order to get the definitions
>> of
>>the callbacks for this plugin. For example, in the type_reader.h file,
>> you
>>will find the following line:
>>#define SCIP_DECL_READERREAD(x) SCIP_RETCODE x (SCIP* scip, SCIP_READER*
>>reader, const char* filename, SCIP_RESULT* result)
>>together with a description of the parameters and possible return values.
>>
>>So, the scip, reader, filename and result pointers are all parameters of
>>the method you defined.
>>
>>Best, Gerald
>>
>>> Dear all,
>>>
>>> I tried to understand the file reader "READERREAD" in the coloring
>>> example
>>> given below.
>>>
>>>
>>> /** problem reading method of reader */
>>> static
>>> SCIP_DECL_READERREAD(readerReadCol)
>>> {  /*lint --e{715}*/
>>>    assert(reader != NULL);
>>>    assert(strcmp(SCIPreaderGetName(reader), READER_NAME) == 0);
>>>    assert(scip != NULL);
>>>    assert(result != NULL);
>>>
>>>    SCIP_CALL( readCol(scip, filename) );
>>>
>>>    *result = SCIP_SUCCESS;
>>>
>>>    return SCIP_OKAY;
>>> }
>>>
>>> I have some questions:
>>> (1) in the aboer "READERREAD", are reader and result the reserverd
>>> words
>>> in SCIP system?  If not, why we can use them without definition.
>>> (2) in the calling of subroutine "readCol", where the filename is
>>> defined?
>>>
>>>
>>> Thanks for your help.
>>>
>>> Xiangyong
>>> _______________________________________________
>>> Scip mailing list
>>> Scip at zib.de
>>> http://listserv.zib.de/mailman/listinfo/scip
>>>
>>
>



More information about the Scip mailing list