Scippy

SCIP

Solving Constraint Integer Programs

nlhdlr.c
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* SCIP --- Solving Constraint Integer Programs */
5/* */
6/* Copyright (c) 2002-2024 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file nlhdlr.c
26 * @ingroup OTHER_CFILES
27 * @brief functions for nonlinearity handlers of nonlinear constraint handler
28 * @author Ksenia Bestuzheva
29 * @author Benjamin Mueller
30 * @author Felipe Serrano
31 * @author Stefan Vigerske
32 */
33
34#include <assert.h>
35#include <string.h>
36
37#include "scip/pub_nlhdlr.h"
38#include "scip/nlhdlr.h"
39#include "scip/struct_nlhdlr.h"
40#include "scip/scip_timing.h"
41#include "scip/scip_mem.h"
42#include "scip/scip_param.h"
43#include "scip/scip_message.h"
44#include "scip/pub_message.h"
45#include "scip/pub_misc.h"
46
47/**@addtogroup PublicNlhdlrInterfaceMethods
48 * @{
49 */
50
51#ifdef NDEBUG
52/* Undo the defines from pub_nlhdlr.h, which exist if NDEBUG is defined. */
53#undef SCIPnlhdlrSetCopyHdlr
54#undef SCIPnlhdlrSetFreeHdlrData
55#undef SCIPnlhdlrSetFreeExprData
56#undef SCIPnlhdlrSetInitExit
57#undef SCIPnlhdlrSetProp
58#undef SCIPnlhdlrSetSepa
59#undef SCIPnlhdlrSetSollinearize
60#undef SCIPnlhdlrGetName
61#undef SCIPnlhdlrGetDesc
62#undef SCIPnlhdlrGetDetectPriority
63#undef SCIPnlhdlrGetEnfoPriority
64#undef SCIPnlhdlrIsEnabled
65#undef SCIPnlhdlrGetData
66#undef SCIPnlhdlrHasIntEval
67#undef SCIPnlhdlrHasReverseProp
68#undef SCIPnlhdlrHasInitSepa
69#undef SCIPnlhdlrHasExitSepa
70#undef SCIPnlhdlrHasEnfo
71#undef SCIPnlhdlrHasEstimate
72#undef SCIPnlhdlrHasSollinearize
73#endif
74
75/** sets the copy handler callback of a nonlinear handler */
77 SCIP_NLHDLR* nlhdlr, /**< nonlinear handler */
78 SCIP_DECL_NLHDLRCOPYHDLR((*copy)) /**< copy callback (can be NULL) */
79 )
80{
81 assert(nlhdlr != NULL);
82
83 nlhdlr->copyhdlr = copy;
84}
85
86/** sets the nonlinear handler callback to free the nonlinear handler data */
88 SCIP_NLHDLR* nlhdlr, /**< nonlinear handler */
89 SCIP_DECL_NLHDLRFREEHDLRDATA((*freehdlrdata)) /**< handler free callback (can be NULL) */
90 )
91{
92 assert(nlhdlr != NULL);
93
94 nlhdlr->freehdlrdata = freehdlrdata;
95}
96
97/** sets the nonlinear handler callback to free expression specific data of nonlinear handler */
99 SCIP_NLHDLR* nlhdlr, /**< nonlinear handler */
100 SCIP_DECL_NLHDLRFREEEXPRDATA((*freeexprdata)) /**< nonlinear handler expression data free callback
101 * (can be NULL if data does not need to be freed) */
102 )
103{
104 assert(nlhdlr != NULL);
105
106 nlhdlr->freeexprdata = freeexprdata;
107}
108
109/** sets the initialization and deinitialization callback of a nonlinear handler */
111 SCIP_NLHDLR* nlhdlr, /**< nonlinear handler */
112 SCIP_DECL_NLHDLRINIT((*init)), /**< initialization callback (can be NULL) */
113 SCIP_DECL_NLHDLREXIT((*exit_)) /**< deinitialization callback (can be NULL) */
114 )
115{
116 assert(nlhdlr != NULL);
117
118 nlhdlr->init = init;
119 nlhdlr->exit = exit_;
120}
121
122/** sets the propagation callbacks of a nonlinear handler */
124 SCIP_NLHDLR* nlhdlr, /**< nonlinear handler */
125 SCIP_DECL_NLHDLRINTEVAL((*inteval)), /**< interval evaluation callback (can be NULL) */
126 SCIP_DECL_NLHDLRREVERSEPROP((*reverseprop)) /**< reverse propagation callback (can be NULL) */
127 )
128{
129 assert(nlhdlr != NULL);
130
131 nlhdlr->inteval = inteval;
132 nlhdlr->reverseprop = reverseprop;
133}
134
135/** sets the enforcement callbacks of a nonlinear handler */
137 SCIP_NLHDLR* nlhdlr, /**< nonlinear handler */
138 SCIP_DECL_NLHDLRINITSEPA((*initsepa)), /**< separation initialization callback (can be NULL) */
139 SCIP_DECL_NLHDLRENFO((*enfo)), /**< enforcement callback (can be NULL if estimate is not NULL) */
140 SCIP_DECL_NLHDLRESTIMATE((*estimate)), /**< estimation callback (can be NULL if sepa is not NULL) */
141 SCIP_DECL_NLHDLREXITSEPA((*exitsepa)) /**< separation deinitialization callback (can be NULL) */
142 )
143{
144 assert(nlhdlr != NULL);
145 assert(enfo != NULL || estimate != NULL);
146
147 nlhdlr->initsepa = initsepa;
148 nlhdlr->enfo = enfo;
149 nlhdlr->estimate = estimate;
150 nlhdlr->exitsepa = exitsepa;
151}
152
153/** sets the solution linearization callback of a nonlinear handler */
155 SCIP_NLHDLR* nlhdlr, /**< nonlinear handler */
156 SCIP_DECL_NLHDLRSOLLINEARIZE((*sollinearize)) /**< solution linearization callback */
157 )
158{
159 assert(nlhdlr != NULL);
160 assert(sollinearize != NULL);
161
162 nlhdlr->sollinearize = sollinearize;
163}
164
165/** gives name of nonlinear handler */
167 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
168 )
169{
170 assert(nlhdlr != NULL);
171
172 return nlhdlr->name;
173}
174
175/** gives description of nonlinear handler, can be NULL */
177 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
178 )
179{
180 assert(nlhdlr != NULL);
181
182 return nlhdlr->desc;
183}
184
185/** gives detection priority of nonlinear handler */
187 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
188 )
189{
190 assert(nlhdlr != NULL);
191
192 return nlhdlr->detectpriority;
193}
194
195/** gives enforcement priority of nonlinear handler */
197 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
198 )
199{
200 assert(nlhdlr != NULL);
201
202 return nlhdlr->enfopriority;
203}
204
205/** returns whether nonlinear handler is enabled */
207 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
208 )
209{
210 assert(nlhdlr != NULL);
211
212 return nlhdlr->enabled;
213}
214
215/** gives handler data of nonlinear handler */
217 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
218 )
219{
220 assert(nlhdlr != NULL);
221
222 return nlhdlr->data;
223}
224
225/** returns whether nonlinear handler implements the interval evaluation callback */
227 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
228 )
229{
230 assert(nlhdlr != NULL);
231
232 return nlhdlr->inteval != NULL;
233}
234
235/** returns whether nonlinear handler implements the reverse propagation callback */
237 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
238 )
239{
240 assert(nlhdlr != NULL);
241
242 return nlhdlr->reverseprop != NULL;
243}
244
245/** returns whether nonlinear handler implements the separation initialization callback */
247 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
248 )
249{
250 assert(nlhdlr != NULL);
251
252 return nlhdlr->initsepa != NULL;
253}
254
255/** returns whether nonlinear handler implements the separation deinitialization callback */
257 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
258 )
259{
260 assert(nlhdlr != NULL);
261
262 return nlhdlr->exitsepa != NULL;
263}
264
265/** returns whether nonlinear handler implements the enforcement callback */
267 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
268 )
269{
270 assert(nlhdlr != NULL);
271
272 return nlhdlr->enfo != NULL;
273}
274
275/** returns whether nonlinear handler implements the estimator callback */
277 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
278 )
279{
280 assert(nlhdlr != NULL);
281
282 return nlhdlr->estimate != NULL;
283}
284
285/** returns whether nonlinear handler implements the solution linearization callback */
287 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
288 )
289{
290 assert(nlhdlr != NULL);
291
292 return nlhdlr->sollinearize != NULL;
293}
294
295/** compares two nonlinear handlers by detection priority
296 *
297 * if handlers have same detection priority, then compare by name
298 */
300{
301 SCIP_NLHDLR* h1;
302 SCIP_NLHDLR* h2;
303
304 assert(elem1 != NULL);
305 assert(elem2 != NULL);
306
307 h1 = (SCIP_NLHDLR*)elem1;
308 h2 = (SCIP_NLHDLR*)elem2;
309
310 if( h1->detectpriority != h2->detectpriority )
311 return h1->detectpriority - h2->detectpriority;
312
313 return strcmp(h1->name, h2->name);
314}
315
316#ifdef SCIP_DISABLED_CODE
317/** compares nonlinear handler by enforcement priority
318 *
319 * if handlers have same enforcement priority, then compare by detection priority, then by name
320 */
321SCIP_DECL_SORTPTRCOMP(SCIPnlhdlrCompEnfo)
322{
323 SCIP_NLHDLR* h1;
324 SCIP_NLHDLR* h2;
325
326 assert(elem1 != NULL);
327 assert(elem2 != NULL);
328
329 h1 = (SCIP_NLHDLR*)elem1;
330 h2 = (SCIP_NLHDLR*)elem2;
331
332 if( h1->enfopriority != h2->enfopriority )
333 return h1->enfopriority - h2->enfopriority;
334
335 if( h1->detectpriority != h2->detectpriority )
336 return h1->detectpriority - h2->detectpriority;
337
338 return strcmp(h1->name, h2->name);
339}
340#endif
341
342/** @} */
343
344/* nlhdlr private API functions from nlhdlr.h */
345
346#ifndef NDEBUG
347#undef SCIPnlhdlrResetNDetectionslast
348#undef SCIPnlhdlrIncrementNCutoffs
349#undef SCIPnlhdlrIncrementNSeparated
350#endif
351
352/** creates a nonlinear handler */
354 SCIP* scip, /**< SCIP data structure */
355 SCIP_NLHDLR** nlhdlr, /**< buffer to store pointer to created nonlinear handler */
356 const char* name, /**< name of nonlinear handler (must not be NULL) */
357 const char* desc, /**< description of nonlinear handler (can be NULL) */
358 int detectpriority, /**< detection priority of nonlinear handler */
359 int enfopriority, /**< enforcement priority of nonlinear handler */
360 SCIP_DECL_NLHDLRDETECT((*detect)), /**< structure detection callback of nonlinear handler */
361 SCIP_DECL_NLHDLREVALAUX((*evalaux)), /**< auxiliary evaluation callback of nonlinear handler */
362 SCIP_NLHDLRDATA* nlhdlrdata /**< data of nonlinear handler (can be NULL) */
363 )
364{
366
367 assert(scip != NULL);
368 assert(nlhdlr != NULL);
369 assert(name != NULL);
370 assert(detect != NULL);
371 assert(evalaux != NULL);
372
374
375 SCIP_CALL( SCIPduplicateMemoryArray(scip, &(*nlhdlr)->name, name, strlen(name)+1) );
376 if( desc != NULL )
377 {
378 SCIP_CALL_FINALLY( SCIPduplicateMemoryArray(scip, &(*nlhdlr)->desc, desc, strlen(desc)+1),
379 SCIPfreeMemoryArray(scip, &(*nlhdlr)->name) );
380 }
381
382 (*nlhdlr)->detectpriority = detectpriority;
383 (*nlhdlr)->enfopriority = enfopriority;
384 (*nlhdlr)->data = nlhdlrdata;
385 (*nlhdlr)->detect = detect;
386 (*nlhdlr)->evalaux = evalaux;
387
388 SCIP_CALL( SCIPcreateClock(scip, &(*nlhdlr)->detecttime) );
389 SCIP_CALL( SCIPcreateClock(scip, &(*nlhdlr)->enfotime) );
390 SCIP_CALL( SCIPcreateClock(scip, &(*nlhdlr)->proptime) );
391 SCIP_CALL( SCIPcreateClock(scip, &(*nlhdlr)->intevaltime) );
392
393 (void) SCIPsnprintf(paramname, SCIP_MAXSTRLEN, "nlhdlr/%s/enabled", name);
394 SCIP_CALL( SCIPaddBoolParam(scip, paramname, "should this nonlinear handler be used",
395 &(*nlhdlr)->enabled, FALSE, TRUE, NULL, NULL) );
396
397 return SCIP_OKAY;
398}
399
400/** frees a nonlinear handler */
402 SCIP* scip, /**< SCIP data structure */
403 SCIP_NLHDLR** nlhdlr /**< pointer to nonlinear handler to be freed */
404 )
405{
406 assert(nlhdlr != NULL);
407 assert(*nlhdlr != NULL);
408
409 if( (*nlhdlr)->freehdlrdata != NULL )
410 {
411 SCIP_CALL( (*nlhdlr)->freehdlrdata(scip, *nlhdlr, &(*nlhdlr)->data) );
412 }
413
414 /* free clocks */
415 SCIP_CALL( SCIPfreeClock(scip, &(*nlhdlr)->detecttime) );
416 SCIP_CALL( SCIPfreeClock(scip, &(*nlhdlr)->enfotime) );
417 SCIP_CALL( SCIPfreeClock(scip, &(*nlhdlr)->proptime) );
418 SCIP_CALL( SCIPfreeClock(scip, &(*nlhdlr)->intevaltime) );
419
420 SCIPfreeMemory(scip, &(*nlhdlr)->name);
421 SCIPfreeMemoryNull(scip, &(*nlhdlr)->desc);
422
423 SCIPfreeBlockMemory(scip, nlhdlr);
424
425 return SCIP_OKAY;
426}
427
428/** call the handler copy callback of a nonlinear handler */
429SCIP_DECL_NLHDLRCOPYHDLR(SCIPnlhdlrCopyhdlr)
430{
431 /* TODO for now just don't copy disabled nlhdlr, a clean way would probably be to first copy and disable then */
432 if( sourcenlhdlr->copyhdlr != NULL && sourcenlhdlr->enabled )
433 {
434 SCIP_CALL( sourcenlhdlr->copyhdlr(targetscip, targetconshdlr, sourceconshdlr, sourcenlhdlr) );
435 }
436
437 return SCIP_OKAY;
438}
439
440/** call the free expression specific data callback of a nonlinear handler */
441SCIP_DECL_NLHDLRFREEEXPRDATA(SCIPnlhdlrFreeexprdata)
442{
443 assert(nlhdlr != NULL);
444 assert(nlhdlrexprdata != NULL);
445 assert(*nlhdlrexprdata != NULL);
446
447 if( nlhdlr->freeexprdata != NULL )
448 {
449 SCIP_CALL( nlhdlr->freeexprdata(scip, nlhdlr, expr, nlhdlrexprdata) );
450 assert(*nlhdlrexprdata == NULL);
451 }
452
453 return SCIP_OKAY;
454}
455
456/** call the initialization callback of a nonlinear handler */
457SCIP_DECL_NLHDLRINIT(SCIPnlhdlrInit)
458{
459 assert(nlhdlr != NULL);
460
461 nlhdlr->nenfocalls = 0;
462 nlhdlr->nintevalcalls = 0;
463 nlhdlr->npropcalls = 0;
464 nlhdlr->nseparated = 0;
465 nlhdlr->ncutoffs = 0;
466 nlhdlr->ndomreds = 0;
467 nlhdlr->nbranchscores = 0;
468 nlhdlr->ndetections = 0;
469 nlhdlr->ndetectionslast = 0;
470
475
476 if( nlhdlr->init != NULL )
477 {
478 SCIP_CALL( nlhdlr->init(scip, nlhdlr) );
479 }
480
481 return SCIP_OKAY;
482}
483
484/** call the deinitialization callback of a nonlinear handler */
485SCIP_DECL_NLHDLREXIT(SCIPnlhdlrExit)
486{
487 assert(nlhdlr != NULL);
488
489 if( nlhdlr->exit != NULL )
490 {
491 SCIP_CALL( nlhdlr->exit(scip, nlhdlr) );
492 }
493
494 return SCIP_OKAY;
495}
496
497/** call the detect callback of a nonlinear handler */
498SCIP_DECL_NLHDLRDETECT(SCIPnlhdlrDetect)
499{
500 assert(scip != NULL);
501 assert(nlhdlr != NULL);
502 assert(nlhdlr->detect != NULL);
503 assert(nlhdlr->detecttime != NULL);
504 assert(participating != NULL);
505
507 SCIP_CALL( nlhdlr->detect(scip, conshdlr, nlhdlr, expr, cons, enforcing, participating, nlhdlrexprdata) );
509
510 if( *participating != SCIP_NLHDLR_METHOD_NONE )
511 {
512 ++nlhdlr->ndetections;
513 ++nlhdlr->ndetectionslast;
514 }
515
516 return SCIP_OKAY;
517}
518
519/** call the auxiliary evaluation callback of a nonlinear handler */
520SCIP_DECL_NLHDLREVALAUX(SCIPnlhdlrEvalaux)
521{
522 assert(nlhdlr != NULL);
523 assert(nlhdlr->evalaux != NULL);
524
525 SCIP_CALL( nlhdlr->evalaux(scip, nlhdlr, expr, nlhdlrexprdata, auxvalue, sol) );
526
527 return SCIP_OKAY;
528}
529
530/** call the interval evaluation callback of a nonlinear handler */
531SCIP_DECL_NLHDLRINTEVAL(SCIPnlhdlrInteval)
532{
533 assert(scip != NULL);
534 assert(nlhdlr != NULL);
535 assert(nlhdlr->intevaltime != NULL);
536
537 if( nlhdlr->inteval != NULL )
538 {
540 SCIP_CALL( nlhdlr->inteval(scip, nlhdlr, expr, nlhdlrexprdata, interval, intevalvar, intevalvardata) );
542
543 ++nlhdlr->nintevalcalls;
544 }
545
546 return SCIP_OKAY;
547}
548
549/** call the reverse propagation callback of a nonlinear handler */
550SCIP_DECL_NLHDLRREVERSEPROP(SCIPnlhdlrReverseprop)
551{
552 assert(scip != NULL);
553 assert(nlhdlr != NULL);
554 assert(nlhdlr->proptime != NULL);
555 assert(infeasible != NULL);
556 assert(nreductions != NULL);
557
558 if( nlhdlr->reverseprop == NULL )
559 {
560 *infeasible = FALSE;
561 *nreductions = 0;
562
563 return SCIP_OKAY;
564 }
565
567 SCIP_CALL( nlhdlr->reverseprop(scip, conshdlr, nlhdlr, expr, nlhdlrexprdata, bounds, infeasible, nreductions) );
569
570 /* update statistics */
571 nlhdlr->ndomreds += *nreductions;
572 if( *infeasible )
573 ++nlhdlr->ncutoffs;
574 ++nlhdlr->npropcalls;
575
576 return SCIP_OKAY;
577}
578
579/** call the separation initialization callback of a nonlinear handler */
580SCIP_DECL_NLHDLRINITSEPA(SCIPnlhdlrInitsepa)
581{
582 assert(scip != NULL);
583 assert(nlhdlr != NULL);
584 assert(nlhdlr->enfotime != NULL);
585 assert(infeasible != NULL);
586
587 if( nlhdlr->initsepa == NULL )
588 {
589 *infeasible = FALSE;
590 return SCIP_OKAY;
591 }
592
594 SCIP_CALL( nlhdlr->initsepa(scip, conshdlr, cons, nlhdlr, expr, nlhdlrexprdata, overestimate, underestimate, infeasible) );
596
597 ++nlhdlr->nenfocalls;
598 if( *infeasible )
599 ++nlhdlr->ncutoffs;
600
601 return SCIP_OKAY;
602}
603
604/** call the separation deinitialization callback of a nonlinear handler */
605SCIP_DECL_NLHDLREXITSEPA(SCIPnlhdlrExitsepa)
606{
607 assert(scip != NULL);
608 assert(nlhdlr != NULL);
609 assert(nlhdlr->enfotime != NULL);
610
611 if( nlhdlr->exitsepa != NULL )
612 {
614 SCIP_CALL( nlhdlr->exitsepa(scip, nlhdlr, expr, nlhdlrexprdata) );
616 }
617
618 return SCIP_OKAY;
619}
620
621/** call the enforcement callback of a nonlinear handler */
622SCIP_DECL_NLHDLRENFO(SCIPnlhdlrEnfo)
623{
624 assert(scip != NULL);
625 assert(nlhdlr != NULL);
626 assert(nlhdlr->enfotime != NULL);
627 assert(result != NULL);
628
629 if( nlhdlr->enfo == NULL )
630 {
631 *result = SCIP_DIDNOTRUN;
632 return SCIP_OKAY;
633 }
634
635#ifndef NDEBUG
636 /* check that auxvalue is correct by reevaluating */
637 {
638 SCIP_Real auxvaluetest;
639 SCIP_CALL( SCIPnlhdlrEvalaux(scip, nlhdlr, expr, nlhdlrexprdata, &auxvaluetest, sol) );
640 /* we should get EXACTLY the same value from calling evalaux with the same solution as before */
641 assert(auxvalue == auxvaluetest); /*lint !e777*/
642 }
643#endif
644
646 SCIP_CALL( nlhdlr->enfo(scip, conshdlr, cons, nlhdlr, expr, nlhdlrexprdata, sol, auxvalue,
647 overestimate, allowweakcuts, separated, addbranchscores, branchcandonly, result) );
649
650 /* update statistics */
651 ++nlhdlr->nenfocalls;
652 switch( *result )
653 {
654 case SCIP_SEPARATED :
655 assert(!branchcandonly);
656 ++nlhdlr->nseparated;
657 break;
658 case SCIP_BRANCHED:
659 ++nlhdlr->nbranchscores;
660 break;
661 case SCIP_CUTOFF:
662 ++nlhdlr->ncutoffs;
663 break;
664 case SCIP_REDUCEDDOM:
665 assert(!branchcandonly);
666 ++nlhdlr->ndomreds;
667 break;
668 default: ;
669 } /*lint !e788*/
670
671 return SCIP_OKAY;
672}
673
674/** call the estimator callback of a nonlinear handler */
675SCIP_DECL_NLHDLRESTIMATE(SCIPnlhdlrEstimate)
676{
677 assert(scip != NULL);
678 assert(nlhdlr != NULL);
679 assert(nlhdlr->enfotime != NULL);
680 assert(success != NULL);
681 assert(addedbranchscores != NULL);
682
683 if( nlhdlr->estimate == NULL )
684 {
685 *success = FALSE;
686 *addedbranchscores = FALSE;
687 return SCIP_OKAY;
688 }
689
690#ifndef NDEBUG
691 /* check that auxvalue is correct by reevaluating */
692 {
693 SCIP_Real auxvaluetest;
694 SCIP_CALL( SCIPnlhdlrEvalaux(scip, nlhdlr, expr, nlhdlrexprdata, &auxvaluetest, sol) );
695 /* we should get EXACTLY the same value from calling evalaux with the same solution as before */
696 assert(auxvalue == auxvaluetest); /*lint !e777*/
697 }
698#endif
699
701 SCIP_CALL( nlhdlr->estimate(scip, conshdlr, nlhdlr, expr, nlhdlrexprdata, sol, auxvalue, overestimate, targetvalue, addbranchscores, rowpreps, success, addedbranchscores) );
703
704 /* update statistics */
705 ++nlhdlr->nenfocalls;
706
707 return SCIP_OKAY;
708}
709
710/** call the solution notification callback of a nonlinear handler */
711SCIP_DECL_NLHDLRSOLLINEARIZE(SCIPnlhdlrSollinearize)
712{
713 assert(scip != NULL);
714 assert(nlhdlr != NULL);
715
716 if( nlhdlr->sollinearize == NULL )
717 return SCIP_OKAY;
718
719 SCIP_CALL( nlhdlr->sollinearize(scip, conshdlr, cons, nlhdlr, expr, nlhdlrexprdata, sol, solisbest, overestimate, underestimate) );
720
721 return SCIP_OKAY;
722}
723
724/** reset number of detections counter for last round */
726 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
727 )
728{
729 assert(nlhdlr != NULL);
730 nlhdlr->ndetectionslast = 0;
731}
732
733/** increments number of cutoffs in statistics */
735 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
736 )
737{
738 assert(nlhdlr != NULL);
739 ++nlhdlr->ncutoffs;
740}
741
742/** increments number of separations in statistics */
744 SCIP_NLHDLR* nlhdlr /**< nonlinear handler */
745 )
746{
747 assert(nlhdlr != NULL);
748 ++nlhdlr->nseparated;
749}
750
751/** print statistics for nonlinear handlers */
753 SCIP* scip, /**< SCIP data structure */
754 SCIP_NLHDLR** nlhdlrs, /**< nonlinear handlers */
755 int nnlhdlrs, /**< number of nonlinear handlers */
756 FILE* file /**< file handle, or NULL for standard out */
757 )
758{
759 int i;
760
761 SCIPinfoMessage(scip, file, "Nlhdlrs : %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s %10s\n",
762 "Detects", "DetectAll", "DetectTime",
763 "#IntEval", "IntEvalTi",
764 "#RevProp", "RevPropTi", "DomReds", "Cutoffs",
765 "#Enforce", "EnfoTime", "Cuts", "Branching");
766
767 for( i = 0; i < nnlhdlrs; ++i )
768 {
769 /* skip disabled nlhdlr */
770 if( !nlhdlrs[i]->enabled )
771 continue;
772
773 SCIPinfoMessage(scip, file, " %-17s:", nlhdlrs[i]->name);
774 SCIPinfoMessage(scip, file, " %10lld", nlhdlrs[i]->ndetectionslast);
775 SCIPinfoMessage(scip, file, " %10lld", nlhdlrs[i]->ndetections);
776 SCIPinfoMessage(scip, file, " %10.2f", SCIPgetClockTime(scip, nlhdlrs[i]->detecttime));
777
778 SCIPinfoMessage(scip, file, " %10lld", nlhdlrs[i]->nintevalcalls);
779 SCIPinfoMessage(scip, file, " %10.2f", SCIPgetClockTime(scip, nlhdlrs[i]->intevaltime));
780
781 SCIPinfoMessage(scip, file, " %10lld", nlhdlrs[i]->npropcalls);
782 SCIPinfoMessage(scip, file, " %10.2f", SCIPgetClockTime(scip, nlhdlrs[i]->proptime));
783 SCIPinfoMessage(scip, file, " %10lld", nlhdlrs[i]->ndomreds);
784 SCIPinfoMessage(scip, file, " %10lld", nlhdlrs[i]->ncutoffs);
785
786 SCIPinfoMessage(scip, file, " %10lld", nlhdlrs[i]->nenfocalls);
787 SCIPinfoMessage(scip, file, " %10.2f", SCIPgetClockTime(scip, nlhdlrs[i]->enfotime));
788 SCIPinfoMessage(scip, file, " %10lld", nlhdlrs[i]->nseparated);
789 SCIPinfoMessage(scip, file, " %10lld", nlhdlrs[i]->nbranchscores);
790
791 SCIPinfoMessage(scip, file, "\n");
792 }
793}
#define NULL
Definition: def.h:267
#define SCIP_MAXSTRLEN
Definition: def.h:288
#define SCIP_Bool
Definition: def.h:91
#define SCIP_Real
Definition: def.h:173
#define TRUE
Definition: def.h:93
#define FALSE
Definition: def.h:94
#define SCIP_CALL(x)
Definition: def.h:374
#define SCIP_CALL_FINALLY(x, y)
Definition: def.h:416
void SCIPinfoMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:208
SCIP_RETCODE SCIPaddBoolParam(SCIP *scip, const char *name, const char *desc, SCIP_Bool *valueptr, SCIP_Bool isadvanced, SCIP_Bool defaultvalue, SCIP_DECL_PARAMCHGD((*paramchgd)), SCIP_PARAMDATA *paramdata)
Definition: scip_param.c:57
#define SCIPallocClearBlockMemory(scip, ptr)
Definition: scip_mem.h:91
#define SCIPfreeMemoryNull(scip, ptr)
Definition: scip_mem.h:79
#define SCIPduplicateMemoryArray(scip, ptr, source, num)
Definition: scip_mem.h:76
#define SCIPfreeMemoryArray(scip, ptr)
Definition: scip_mem.h:80
#define SCIPfreeMemory(scip, ptr)
Definition: scip_mem.h:78
#define SCIPfreeBlockMemory(scip, ptr)
Definition: scip_mem.h:108
void SCIPnlhdlrSetCopyHdlr(SCIP_NLHDLR *nlhdlr, SCIP_DECL_NLHDLRCOPYHDLR((*copy)))
Definition: nlhdlr.c:76
void SCIPnlhdlrSetFreeExprData(SCIP_NLHDLR *nlhdlr, SCIP_DECL_NLHDLRFREEEXPRDATA((*freeexprdata)))
Definition: nlhdlr.c:98
void SCIPnlhdlrSetProp(SCIP_NLHDLR *nlhdlr, SCIP_DECL_NLHDLRINTEVAL((*inteval)), SCIP_DECL_NLHDLRREVERSEPROP((*reverseprop)))
Definition: nlhdlr.c:123
const char * SCIPnlhdlrGetDesc(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:176
void SCIPnlhdlrSetSollinearize(SCIP_NLHDLR *nlhdlr, SCIP_DECL_NLHDLRSOLLINEARIZE((*sollinearize)))
Definition: nlhdlr.c:154
SCIP_NLHDLRDATA * SCIPnlhdlrGetData(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:216
SCIP_Bool SCIPnlhdlrHasIntEval(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:226
SCIP_Bool SCIPnlhdlrHasEnfo(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:266
int SCIPnlhdlrGetDetectPriority(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:186
void SCIPnlhdlrSetFreeHdlrData(SCIP_NLHDLR *nlhdlr, SCIP_DECL_NLHDLRFREEHDLRDATA((*freehdlrdata)))
Definition: nlhdlr.c:87
void SCIPnlhdlrSetSepa(SCIP_NLHDLR *nlhdlr, SCIP_DECL_NLHDLRINITSEPA((*initsepa)), SCIP_DECL_NLHDLRENFO((*enfo)), SCIP_DECL_NLHDLRESTIMATE((*estimate)), SCIP_DECL_NLHDLREXITSEPA((*exitsepa)))
Definition: nlhdlr.c:136
SCIP_DECL_SORTPTRCOMP(SCIPnlhdlrComp)
Definition: nlhdlr.c:299
void SCIPnlhdlrSetInitExit(SCIP_NLHDLR *nlhdlr, SCIP_DECL_NLHDLRINIT((*init)), SCIP_DECL_NLHDLREXIT((*exit_)))
Definition: nlhdlr.c:110
SCIP_Bool SCIPnlhdlrIsEnabled(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:206
SCIP_Bool SCIPnlhdlrHasReverseProp(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:236
const char * SCIPnlhdlrGetName(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:166
SCIP_Bool SCIPnlhdlrHasSollinearize(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:286
SCIP_Bool SCIPnlhdlrHasEstimate(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:276
SCIP_Bool SCIPnlhdlrHasInitSepa(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:246
int SCIPnlhdlrGetEnfoPriority(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:196
SCIP_Bool SCIPnlhdlrHasExitSepa(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:256
SCIP_RETCODE SCIPcreateClock(SCIP *scip, SCIP_CLOCK **clck)
Definition: scip_timing.c:76
SCIP_RETCODE SCIPresetClock(SCIP *scip, SCIP_CLOCK *clck)
Definition: scip_timing.c:144
SCIP_RETCODE SCIPstopClock(SCIP *scip, SCIP_CLOCK *clck)
Definition: scip_timing.c:178
SCIP_RETCODE SCIPfreeClock(SCIP *scip, SCIP_CLOCK **clck)
Definition: scip_timing.c:127
SCIP_Real SCIPgetClockTime(SCIP *scip, SCIP_CLOCK *clck)
Definition: scip_timing.c:319
SCIP_RETCODE SCIPstartClock(SCIP *scip, SCIP_CLOCK *clck)
Definition: scip_timing.c:161
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10877
static const char * paramname[]
Definition: lpi_msk.c:5096
SCIP_RETCODE SCIPnlhdlrFree(SCIP *scip, SCIP_NLHDLR **nlhdlr)
Definition: nlhdlr.c:401
SCIP_DECL_NLHDLRDETECT(SCIPnlhdlrDetect)
Definition: nlhdlr.c:498
SCIP_DECL_NLHDLRINITSEPA(SCIPnlhdlrInitsepa)
Definition: nlhdlr.c:580
SCIP_RETCODE SCIPnlhdlrCreate(SCIP *scip, SCIP_NLHDLR **nlhdlr, const char *name, const char *desc, int detectpriority, int enfopriority, SCIP_DECL_NLHDLRDETECT((*detect)), SCIP_DECL_NLHDLREVALAUX((*evalaux)), SCIP_NLHDLRDATA *nlhdlrdata)
Definition: nlhdlr.c:353
SCIP_DECL_NLHDLRINIT(SCIPnlhdlrInit)
Definition: nlhdlr.c:457
SCIP_DECL_NLHDLRCOPYHDLR(SCIPnlhdlrCopyhdlr)
Definition: nlhdlr.c:429
SCIP_DECL_NLHDLRINTEVAL(SCIPnlhdlrInteval)
Definition: nlhdlr.c:531
SCIP_DECL_NLHDLRSOLLINEARIZE(SCIPnlhdlrSollinearize)
Definition: nlhdlr.c:711
SCIP_DECL_NLHDLREVALAUX(SCIPnlhdlrEvalaux)
Definition: nlhdlr.c:520
void SCIPnlhdlrPrintStatistics(SCIP *scip, SCIP_NLHDLR **nlhdlrs, int nnlhdlrs, FILE *file)
Definition: nlhdlr.c:752
SCIP_DECL_NLHDLRESTIMATE(SCIPnlhdlrEstimate)
Definition: nlhdlr.c:675
SCIP_DECL_NLHDLRREVERSEPROP(SCIPnlhdlrReverseprop)
Definition: nlhdlr.c:550
void SCIPnlhdlrResetNDetectionslast(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:725
SCIP_DECL_NLHDLRFREEEXPRDATA(SCIPnlhdlrFreeexprdata)
Definition: nlhdlr.c:441
SCIP_DECL_NLHDLREXIT(SCIPnlhdlrExit)
Definition: nlhdlr.c:485
SCIP_DECL_NLHDLRENFO(SCIPnlhdlrEnfo)
Definition: nlhdlr.c:622
SCIP_DECL_NLHDLREXITSEPA(SCIPnlhdlrExitsepa)
Definition: nlhdlr.c:605
void SCIPnlhdlrIncrementNCutoffs(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:734
void SCIPnlhdlrIncrementNSeparated(SCIP_NLHDLR *nlhdlr)
Definition: nlhdlr.c:743
private functions of nonlinear handlers of nonlinear constraints
public methods for message output
public data structures and miscellaneous methods
public functions of nonlinear handlers of nonlinear constraints
public methods for memory management
public methods for message handling
public methods for SCIP parameter handling
public methods for timing
SCIP_Longint ndetections
Definition: struct_nlhdlr.h:76
SCIP_CLOCK * proptime
Definition: struct_nlhdlr.h:82
SCIP_CLOCK * detecttime
Definition: struct_nlhdlr.h:80
SCIP_Bool enabled
Definition: struct_nlhdlr.h:51
SCIP_Longint npropcalls
Definition: struct_nlhdlr.h:72
SCIP_CLOCK * enfotime
Definition: struct_nlhdlr.h:81
SCIP_CLOCK * intevaltime
Definition: struct_nlhdlr.h:83
SCIP_NLHDLRDATA * data
Definition: struct_nlhdlr.h:47
SCIP_Longint ndetectionslast
Definition: struct_nlhdlr.h:77
SCIP_Longint ncutoffs
Definition: struct_nlhdlr.h:74
int detectpriority
Definition: struct_nlhdlr.h:49
SCIP_Longint nseparated
Definition: struct_nlhdlr.h:73
SCIP_Longint nenfocalls
Definition: struct_nlhdlr.h:70
SCIP_Longint ndomreds
Definition: struct_nlhdlr.h:75
SCIP_Longint nintevalcalls
Definition: struct_nlhdlr.h:71
SCIP_Longint nbranchscores
Definition: struct_nlhdlr.h:78
structure definitions related to nonlinear handlers of nonlinear constraints
struct SCIP_NlhdlrData SCIP_NLHDLRDATA
Definition: type_nlhdlr.h:452
#define SCIP_NLHDLR_METHOD_NONE
Definition: type_nlhdlr.h:50
#define SCIP_DECL_NLHDLRFREEHDLRDATA(x)
Definition: type_nlhdlr.h:82
@ SCIP_DIDNOTRUN
Definition: type_result.h:42
@ SCIP_CUTOFF
Definition: type_result.h:48
@ SCIP_REDUCEDDOM
Definition: type_result.h:51
@ SCIP_BRANCHED
Definition: type_result.h:54
@ SCIP_SEPARATED
Definition: type_result.h:49
@ SCIP_OKAY
Definition: type_retcode.h:42
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63