[Scip] New Solution Callback
Stefan Heinz
heinz at zib.de
Sun Jul 18 21:55:07 MEST 2010
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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: event_bestsol.c
Type: text/x-csrc
Size: 3390 bytes
Desc: not available
Url : http://listserv.zib.de/mailman/private/scip/attachments/20100718/6a086c16/event_bestsol.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: event_bestsol.h
Type: text/x-chdr
Size: 541 bytes
Desc: not available
Url : http://listserv.zib.de/mailman/private/scip/attachments/20100718/6a086c16/event_bestsol-0001.bin
More information about the Scip
mailing list