[Scip] New Solution Callback
Jakob Breier
Jakob.Breier at rwth-aachen.de
Tue Jul 20 18:15:35 MEST 2010
Hi Stefan,
thank you, this is a very helpful example. Up until now I wasn't sure,
were to put the SCIPcatchEvent and SCIPdropEvent calls (I still don't
understand why they belong in SCIP_DECL_EVENTINIT and
SCIP_DECL_EVENTEXIT but I am happy to have the definite answer that they
do).
If you don't mind, I would like to ask you to make your example public
in the online documentation and put a link to it on the HOWTO-page (
http://scip.zib.de/doc/html/EVENT.html )
Regards,
Jakob Breier
On 07/18/2010 09:55 PM, Stefan Heinz wrote:
> Hi,
>
> I attached an event handler which checks for "best solution found". This one
> can be easily changed to "solution found" (Just replace
> SCIP_EVENTTYPE_BESTSOLFOUND with SCIP_EVENTTYPE_SOLFOUND).
>
> The only thing you have to do, is to initialize the even handler before you
> call SCIPsolve() with the call
> SCIP_CALL( SCIPcreateEventHdlrBestsol(scip) );
>
> The event handler is written in C which should be no problem with your C++
> project. You can also transform the C files into C++ file.
>
> Hope that helps
> Stefan
>
>
>
>
> Am Freitag 16 Juli 2010 22:28:19 schrieb Jakob Breier:
>
>> Hi,
>>
>> I am a student from the RWTH Aachen and I am working on a project using
>> scip. I am working with the C++ Interface and I want to write out the
>> currently best solutions every time a new solution is found, because the
>> process crashes quite often (out of memory, system reboot, etc.). I
>> believe the SOLFOUND event is the proper event to use (?). Unfortunately
>> the following code does not work:
>> =============SolFoundEventHandler.h=============
>> #include "scip/scip.h"
>> #include "objscip/objeventhdlr.h"
>>
>>
>> class SolFoundEventHandler : public scip::ObjEventhdlr
>> {
>>
>> private:
>>
>> public:
>> SolFoundEventHandler();
>> virtual SCIP_RETCODE scip_exec(
>> SCIP* scip,
>> SCIP_EVENTHDLR* eventhdlr,
>> SCIP_EVENT* event,
>> SCIP_EVENTDATA* eventdata
>> ) ;
>>
>>
>> };
>>
>> ============SolFoundEventHandler.cpp============
>> #include "SolFoundEventHandler.h"
>>
>>
>> SolFoundEventHandler::SolFoundEventHandler() :
>> ObjEventhdlr("SOLFOUND","desc")
>> // As far as I understand the interface the above line should tell
>> // scip that I want to catch the SOLFOUND event.
>> {
>>
>> }
>>
>>
>> SCIP_RETCODE SolFoundEventHandler::scip_exec(
>> SCIP* scip,
>> SCIP_EVENTHDLR* eventhdlr,
>> SCIP_EVENT* event,
>> SCIP_EVENTDATA* eventdata
>> )
>> {
>>
>> SCIPerrorMessage("This message will never be printed.");
>> SCIPABORT();
>>
>> return SCIP_OKAY;
>>
>>
>> }
>>
>> Also "SCIP_CALL_ABORT(SCIPincludeObjEventhdlr(scip_,
>> &solFoundEventHandler, false));" is called before the solving begins
>> (solFoundEventHandler is of course an object of type
>> SolFoundEventHandler). Yet SCIP_RETCODE SolFoundEventHandler::scip_exec
>> is never called.
>> Do you know what I do wrong?
>>
>> Regards,
>> Jakob Breier
>> _______________________________________________
>> Scip mailing list
>> Scip at zib.de
>> http://listserv.zib.de/mailman/listinfo/scip
>>
>>
>>
>>
>> _______________________________________________
>> Scip mailing list
>> Scip at zib.de
>> http://listserv.zib.de/mailman/listinfo/scip
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserv.zib.de/mailman/private/scip/attachments/20100720/b81d1aab/attachment.html
More information about the Scip
mailing list