[SCIP] Number of heuristic's calls
André Filipe Lanca Serrano
andre.serrano at tuhh.de
Fri May 11 17:03:02 CEST 2018
Hi Gregor,
Yes the if statement was the last thing in the execution callback.
> When we write a heuristic, we generally try to make it return as
> fast as possible if some necessary preconditions are not satisfied,
> as it is in your case.
Oh I didn't know about that.
I did what you said and it worked just fine :) Thanks a lot!
Cheers,
André
Quoting Gregor Hendel <hendel at zib.de>:
> Hi Andre,
>
> Is the if-statement really the last thing in the execution callback?
> Then I am not surprised.
>
> When we write a heuristic, we generally try to make it return as
> fast as possible if some necessary preconditions are not satisfied,
> as it is in your case.
>
> I guess that you set the result pointer to
>
> *result = SCIP_DIDNOTFIND
>
> prior to your new if-statement?
> If so, this will still increase the run counter by 1 for the
> statistics. The correct result stages should be
>
> *result = SCIP_DIDNOTRUN
>
> if( ... )
> {
> return SCIP_OKAY;
> }
>
> // all conditions are satisfied, run the heuristic
>
> *result = SCIP_DIDNOTFIND;
>
> // ...
>
> if( foundsol )
> *result = SCIP_SUCCESS;
>
> Cheers,
> Gregor
>
>
> Am 11.05.2018 um 15:59 schrieb André Filipe Lanca Serrano:
>> Hi Gregor,
>>
>> Thanks for the tips.
>>
>>> Most likely, SCIP decides to restart the solution process, such
>>> that effectively not only 1, but 2 root nodes are evaluated. ->
>>> Exactly!
>>
>> I already verified the logs and SCIP is actually restarted.
>>
>> I included a statement into the end of heurExec callback to return
>> immediately if SCIPheurGetNCalls(heur) > 0 like this:
>>
>> /** execution method of primal heuristic */
>> static
>> SCIP_DECL_HEUREXEC(heurExecAtfmGA)
>> { /*lint --e{715}*/
>>
>> ...
>>
>> /* only call heuristic once at the root */
>> if (SCIPgetDepth(scip) <= 0 && SCIPheurGetNCalls(heur) > 0)
>> {
>> return SCIP_OKAY;
>> }
>> return SCIP_OKAY;
>> }
>>
>> It still runs my heuristic twice at the root node... What am I
>> doing wrong here?
>>
>>
>> Quoting Gregor Hendel <hendel at zib.de>:
>>
>>> Hi Andre,
>>>
>>> the properties look good for the purpose you describe, although I
>>> would suggest to use the letter 'M' to indicate a heuristic of
>>> that name :)
>>>
>>> Most likely, SCIP decides to restart the solution process, such
>>> that effectively not only 1, but 2 root nodes are evaluated. Can
>>> you verify whether SCIP actually restarted from some log file
>>> output?
>>>
>>> If you really want to run only once, you have to include a
>>> statement into the heurExec callback to return immediately if
>>> SCIPheurGetNCalls(heur) > 0.
>>>
>>> Hope this helps,
>>> Gregor
>>>
>>> Am 09.05.2018 um 16:33 schrieb André Filipe Lanca Serrano:
>>>> Hi to all,
>>>>
>>>> I created an heuristic and I would like to call it just once, in
>>>> the root node, as the first heuristic. I'm using the following
>>>> properties in my heuristic.
>>>>
>>>> #define HEUR_NAME "myheuristic"
>>>> #define HEUR_DESC "My heuristic"
>>>> #define HEUR_DISPCHAR 'g'
>>>> #define HEUR_PRIORITY 99999999
>>>> #define HEUR_FREQ 0
>>>> #define HEUR_FREQOFS 0
>>>> #define HEUR_MAXDEPTH -1
>>>> #define HEUR_TIMING SCIP_HEURTIMING_BEFORENODE
>>>> #define HEUR_USESSUBSCIP FALSE
>>>>
>>>> After running my project I get two calls from my heuristic using
>>>> the method SCIPheurGetNCalls(heur). What am I doing wrong here?
>>>> Am I missing smth? I followed all the instructions on how to add
>>>> primal heuristics and I guess it's smth to do with the
>>>> properties...
>>>>
>>>> Thank you in advance.
>>>>
>>>> Kind regards,
>>>> André Serrano
>>>>
>>>> _______________________________________________
>>>> Scip mailing list
>>>> Scip at zib.de
>>>> https://listserv.zib.de/mailman/listinfo/scip
>>>
>>> _______________________________________________
>>> Scip mailing list
>>> Scip at zib.de
>>> https://listserv.zib.de/mailman/listinfo/scip
>>
>>
>>
>> _______________________________________________
>> Scip mailing list
>> Scip at zib.de
>> https://listserv.zib.de/mailman/listinfo/scip
>
> _______________________________________________
> Scip mailing list
> Scip at zib.de
> https://listserv.zib.de/mailman/listinfo/scip
More information about the Scip
mailing list