1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ 2 /* */ 3 /* This file is part of the program and library */ 4 /* SCIP --- Solving Constraint Integer Programs */ 5 /* */ 6 /* Copyright (c) 2002-2023 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 objconshdlr.cpp 26 * @brief C++ wrapper for constraint handlers 27 * @author Tobias Achterberg 28 */ 29 30 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 31 32 #include <cassert> 33 34 #include "objconshdlr.h" 35 36 37 38 39 /* 40 * Data structures 41 */ 42 43 /** constraint handler data */ 44 struct SCIP_ConshdlrData 45 { 46 scip::ObjConshdlr* objconshdlr; /**< constraint handler object */ 47 SCIP_Bool deleteobject; /**< should the constraint handler object be deleted when conshdlr is freed? */ 48 }; 49 50 51 52 53 /* 54 * Callback methods of constraint handler 55 */ 56 57 extern "C" 58 { 59 60 /** copy method for constraint handler plugins (called when SCIP copies plugins) */ 61 static 62 SCIP_DECL_CONSHDLRCOPY(conshdlrCopyObj) 63 { /*lint --e{715}*/ 64 SCIP_CONSHDLRDATA* conshdlrdata; 65 66 assert(scip != NULL); 67 68 conshdlrdata = SCIPconshdlrGetData(conshdlr); 69 assert(conshdlrdata != NULL); 70 assert(conshdlrdata->objconshdlr != NULL); 71 assert(conshdlrdata->objconshdlr->scip_ != scip); 72 73 if( conshdlrdata->objconshdlr->iscloneable() ) 74 { 75 scip::ObjConshdlr* newobjconshdlr; 76 newobjconshdlr = dynamic_cast<scip::ObjConshdlr*> (conshdlrdata->objconshdlr->clone(scip, valid)); 77 78 /* call include method of constraint handler object */ 79 SCIP_CALL( SCIPincludeObjConshdlr(scip, newobjconshdlr, TRUE) ); 80 } 81 82 return SCIP_OKAY; 83 } 84 85 /** destructor of constraint handler to free user data (called when SCIP is exiting) */ 86 static 87 SCIP_DECL_CONSFREE(consFreeObj) 88 { /*lint --e{715}*/ 89 SCIP_CONSHDLRDATA* conshdlrdata; 90 91 conshdlrdata = SCIPconshdlrGetData(conshdlr); 92 assert(conshdlrdata != NULL); 93 assert(conshdlrdata->objconshdlr != NULL); 94 assert(conshdlrdata->objconshdlr->scip_ == scip); 95 96 /* call virtual method of conshdlr object */ 97 SCIP_CALL( conshdlrdata->objconshdlr->scip_free(scip, conshdlr) ); 98 99 /* free conshdlr object */ 100 if( conshdlrdata->deleteobject ) 101 delete conshdlrdata->objconshdlr; 102 103 /* free conshdlr data */ 104 delete conshdlrdata; 105 SCIPconshdlrSetData(conshdlr, NULL); /*lint !e64*/ 106 107 return SCIP_OKAY; 108 } 109 110 111 /** initialization method of constraint handler (called after problem was transformed) */ 112 static 113 SCIP_DECL_CONSINIT(consInitObj) 114 { /*lint --e{715}*/ 115 SCIP_CONSHDLRDATA* conshdlrdata; 116 117 conshdlrdata = SCIPconshdlrGetData(conshdlr); 118 assert(conshdlrdata != NULL); 119 assert(conshdlrdata->objconshdlr != NULL); 120 assert(conshdlrdata->objconshdlr->scip_ == scip); 121 122 /* call virtual method of conshdlr object */ 123 SCIP_CALL( conshdlrdata->objconshdlr->scip_init(scip, conshdlr, conss, nconss) ); 124 125 return SCIP_OKAY; 126 } 127 128 129 /** deinitialization method of constraint handler (called before transformed problem is freed) */ 130 static 131 SCIP_DECL_CONSEXIT(consExitObj) 132 { /*lint --e{715}*/ 133 SCIP_CONSHDLRDATA* conshdlrdata; 134 135 conshdlrdata = SCIPconshdlrGetData(conshdlr); 136 assert(conshdlrdata != NULL); 137 assert(conshdlrdata->objconshdlr != NULL); 138 139 /* call virtual method of conshdlr object */ 140 SCIP_CALL( conshdlrdata->objconshdlr->scip_exit(scip, conshdlr, conss, nconss) ); 141 142 return SCIP_OKAY; 143 } 144 145 146 /** presolving initialization method of constraint handler (called when presolving is about to begin) */ 147 static 148 SCIP_DECL_CONSINITPRE(consInitpreObj) 149 { /*lint --e{715}*/ 150 SCIP_CONSHDLRDATA* conshdlrdata; 151 152 conshdlrdata = SCIPconshdlrGetData(conshdlr); 153 assert(conshdlrdata != NULL); 154 assert(conshdlrdata->objconshdlr != NULL); 155 156 /* call virtual method of conshdlr object */ 157 SCIP_CALL( conshdlrdata->objconshdlr->scip_initpre(scip, conshdlr, conss, nconss) ); 158 159 return SCIP_OKAY; 160 } 161 162 163 /** presolving deinitialization method of constraint handler (called after presolving has been finished) */ 164 static 165 SCIP_DECL_CONSEXITPRE(consExitpreObj) 166 { /*lint --e{715}*/ 167 SCIP_CONSHDLRDATA* conshdlrdata; 168 169 conshdlrdata = SCIPconshdlrGetData(conshdlr); 170 assert(conshdlrdata != NULL); 171 assert(conshdlrdata->objconshdlr != NULL); 172 173 /* call virtual method of conshdlr object */ 174 SCIP_CALL( conshdlrdata->objconshdlr->scip_exitpre(scip, conshdlr, conss, nconss) ); 175 176 return SCIP_OKAY; 177 } 178 179 180 /** solving process initialization method of constraint handler (called when branch and bound process is about to begin) */ 181 static 182 SCIP_DECL_CONSINITSOL(consInitsolObj) 183 { /*lint --e{715}*/ 184 SCIP_CONSHDLRDATA* conshdlrdata; 185 186 conshdlrdata = SCIPconshdlrGetData(conshdlr); 187 assert(conshdlrdata != NULL); 188 assert(conshdlrdata->objconshdlr != NULL); 189 190 /* call virtual method of conshdlr object */ 191 SCIP_CALL( conshdlrdata->objconshdlr->scip_initsol(scip, conshdlr, conss, nconss) ); 192 193 return SCIP_OKAY; 194 } 195 196 197 /** solving process deinitialization method of constraint handler (called before branch and bound process data is freed) */ 198 static 199 SCIP_DECL_CONSEXITSOL(consExitsolObj) 200 { /*lint --e{715}*/ 201 SCIP_CONSHDLRDATA* conshdlrdata; 202 203 conshdlrdata = SCIPconshdlrGetData(conshdlr); 204 assert(conshdlrdata != NULL); 205 assert(conshdlrdata->objconshdlr != NULL); 206 207 /* call virtual method of conshdlr object */ 208 SCIP_CALL( conshdlrdata->objconshdlr->scip_exitsol(scip, conshdlr, conss, nconss, restart) ); 209 210 return SCIP_OKAY; 211 } 212 213 214 /** frees specific constraint data */ 215 static 216 SCIP_DECL_CONSDELETE(consDeleteObj) 217 { /*lint --e{715}*/ 218 SCIP_CONSHDLRDATA* conshdlrdata; 219 220 conshdlrdata = SCIPconshdlrGetData(conshdlr); 221 assert(conshdlrdata != NULL); 222 assert(conshdlrdata->objconshdlr != NULL); 223 224 /* call virtual method of conshdlr object */ 225 SCIP_CALL( conshdlrdata->objconshdlr->scip_delete(scip, conshdlr, cons, consdata) ); 226 227 return SCIP_OKAY; 228 } 229 230 231 /** transforms constraint data into data belonging to the transformed problem */ 232 static 233 SCIP_DECL_CONSTRANS(consTransObj) 234 { /*lint --e{715}*/ 235 SCIP_CONSHDLRDATA* conshdlrdata; 236 237 conshdlrdata = SCIPconshdlrGetData(conshdlr); 238 assert(conshdlrdata != NULL); 239 assert(conshdlrdata->objconshdlr != NULL); 240 241 /* call virtual method of conshdlr object */ 242 SCIP_CALL( conshdlrdata->objconshdlr->scip_trans(scip, conshdlr, sourcecons, targetcons) ); 243 244 return SCIP_OKAY; 245 } 246 247 248 /** LP initialization method of constraint handler */ 249 static 250 SCIP_DECL_CONSINITLP(consInitlpObj) 251 { /*lint --e{715}*/ 252 SCIP_CONSHDLRDATA* conshdlrdata; 253 254 conshdlrdata = SCIPconshdlrGetData(conshdlr); 255 assert(conshdlrdata != NULL); 256 assert(conshdlrdata->objconshdlr != NULL); 257 258 /* call virtual method of conshdlr object */ 259 SCIP_CALL( conshdlrdata->objconshdlr->scip_initlp(scip, conshdlr, conss, nconss, infeasible) ); 260 261 return SCIP_OKAY; 262 } 263 264 265 /** separation method of constraint handler for LP solutions */ 266 static 267 SCIP_DECL_CONSSEPALP(consSepalpObj) 268 { /*lint --e{715}*/ 269 SCIP_CONSHDLRDATA* conshdlrdata; 270 271 conshdlrdata = SCIPconshdlrGetData(conshdlr); 272 assert(conshdlrdata != NULL); 273 assert(conshdlrdata->objconshdlr != NULL); 274 275 /* call virtual method of conshdlr object */ 276 SCIP_CALL( conshdlrdata->objconshdlr->scip_sepalp(scip, conshdlr, conss, nconss, nusefulconss, result) ); 277 278 return SCIP_OKAY; 279 } 280 281 282 /** separation method of constraint handler for arbitrary primal solutions */ 283 static 284 SCIP_DECL_CONSSEPASOL(consSepasolObj) 285 { /*lint --e{715}*/ 286 SCIP_CONSHDLRDATA* conshdlrdata; 287 288 conshdlrdata = SCIPconshdlrGetData(conshdlr); 289 assert(conshdlrdata != NULL); 290 assert(conshdlrdata->objconshdlr != NULL); 291 292 /* call virtual method of conshdlr object */ 293 SCIP_CALL( conshdlrdata->objconshdlr->scip_sepasol(scip, conshdlr, conss, nconss, nusefulconss, sol, result) ); 294 295 return SCIP_OKAY; 296 } 297 298 299 /** constraint enforcing method of constraint handler for LP solutions */ 300 static 301 SCIP_DECL_CONSENFOLP(consEnfolpObj) 302 { /*lint --e{715}*/ 303 SCIP_CONSHDLRDATA* conshdlrdata; 304 305 conshdlrdata = SCIPconshdlrGetData(conshdlr); 306 assert(conshdlrdata != NULL); 307 assert(conshdlrdata->objconshdlr != NULL); 308 309 /* call virtual method of conshdlr object */ 310 SCIP_CALL( conshdlrdata->objconshdlr->scip_enfolp(scip, conshdlr, conss, nconss, nusefulconss, solinfeasible, result) ); 311 312 return SCIP_OKAY; 313 } 314 315 316 /** constraint enforcing method of constraint handler for relaxation solutions */ 317 static 318 SCIP_DECL_CONSENFORELAX(consEnforelaxObj) 319 { /*lint --e{715}*/ 320 SCIP_CONSHDLRDATA* conshdlrdata; 321 322 conshdlrdata = SCIPconshdlrGetData(conshdlr); 323 assert(conshdlrdata != NULL); 324 assert(conshdlrdata->objconshdlr != NULL); 325 326 /* call virtual method of conshdlr object */ 327 SCIP_CALL( conshdlrdata->objconshdlr->scip_enforelax(scip, sol, conshdlr, conss, nconss, nusefulconss, solinfeasible, result) ); 328 329 return SCIP_OKAY; 330 } 331 332 333 /** constraint enforcing method of constraint handler for pseudo solutions */ 334 static 335 SCIP_DECL_CONSENFOPS(consEnfopsObj) 336 { /*lint --e{715}*/ 337 SCIP_CONSHDLRDATA* conshdlrdata; 338 339 conshdlrdata = SCIPconshdlrGetData(conshdlr); 340 assert(conshdlrdata != NULL); 341 assert(conshdlrdata->objconshdlr != NULL); 342 343 /* call virtual method of conshdlr object */ 344 SCIP_CALL( conshdlrdata->objconshdlr->scip_enfops(scip, conshdlr, conss, nconss, nusefulconss, 345 solinfeasible, objinfeasible, result) ); 346 347 return SCIP_OKAY; 348 } 349 350 351 /** feasibility check method of constraint handler for primal solutions */ 352 static 353 SCIP_DECL_CONSCHECK(consCheckObj) 354 { /*lint --e{715}*/ 355 SCIP_CONSHDLRDATA* conshdlrdata; 356 357 conshdlrdata = SCIPconshdlrGetData(conshdlr); 358 assert(conshdlrdata != NULL); 359 assert(conshdlrdata->objconshdlr != NULL); 360 361 /* call virtual method of conshdlr object */ 362 SCIP_CALL( conshdlrdata->objconshdlr->scip_check(scip, conshdlr, conss, nconss, sol, 363 checkintegrality, checklprows, printreason, completely, result) ); 364 365 return SCIP_OKAY; 366 } 367 368 369 /** domain propagation method of constraint handler */ 370 static 371 SCIP_DECL_CONSPROP(consPropObj) 372 { /*lint --e{715}*/ 373 SCIP_CONSHDLRDATA* conshdlrdata; 374 375 conshdlrdata = SCIPconshdlrGetData(conshdlr); 376 assert(conshdlrdata != NULL); 377 assert(conshdlrdata->objconshdlr != NULL); 378 379 /* call virtual method of conshdlr object */ 380 SCIP_CALL( conshdlrdata->objconshdlr->scip_prop(scip, conshdlr, conss, nconss, nusefulconss, nmarkedconss, proptiming, result) ); 381 382 return SCIP_OKAY; 383 } 384 385 386 /** presolving method of constraint handler */ 387 static 388 SCIP_DECL_CONSPRESOL(consPresolObj) 389 { /*lint --e{715}*/ 390 SCIP_CONSHDLRDATA* conshdlrdata; 391 392 conshdlrdata = SCIPconshdlrGetData(conshdlr); 393 assert(conshdlrdata != NULL); 394 assert(conshdlrdata->objconshdlr != NULL); 395 396 /* call virtual method of conshdlr object */ 397 SCIP_CALL( conshdlrdata->objconshdlr->scip_presol(scip, conshdlr, conss, nconss, nrounds, presoltiming, 398 nnewfixedvars, nnewaggrvars, nnewchgvartypes, nnewchgbds, nnewholes, 399 nnewdelconss, nnewaddconss, nnewupgdconss, nnewchgcoefs, nnewchgsides, 400 nfixedvars, naggrvars, nchgvartypes, nchgbds, naddholes, 401 ndelconss, naddconss, nupgdconss, nchgcoefs, nchgsides, result) ); 402 403 return SCIP_OKAY; 404 } 405 406 407 /** propagation conflict resolving method of constraint handler */ 408 static 409 SCIP_DECL_CONSRESPROP(consRespropObj) 410 { /*lint --e{715}*/ 411 SCIP_CONSHDLRDATA* conshdlrdata; 412 413 conshdlrdata = SCIPconshdlrGetData(conshdlr); 414 assert(conshdlrdata != NULL); 415 assert(conshdlrdata->objconshdlr != NULL); 416 417 /* call virtual method of conshdlr object */ 418 SCIP_CALL( conshdlrdata->objconshdlr->scip_resprop(scip, conshdlr, cons, infervar, inferinfo, boundtype, bdchgidx, 419 relaxedbd, result) ); 420 421 return SCIP_OKAY; 422 } 423 424 425 /** variable rounding lock method of constraint handler */ 426 static 427 SCIP_DECL_CONSLOCK(consLockObj) 428 { /*lint --e{715}*/ 429 SCIP_CONSHDLRDATA* conshdlrdata; 430 431 conshdlrdata = SCIPconshdlrGetData(conshdlr); 432 assert(conshdlrdata != NULL); 433 assert(conshdlrdata->objconshdlr != NULL); 434 435 /* call virtual method of conshdlr object */ 436 SCIP_CALL( conshdlrdata->objconshdlr->scip_lock(scip, conshdlr, cons, locktype, nlockspos, nlocksneg) ); 437 438 return SCIP_OKAY; 439 } 440 441 442 /** constraint activation notification method of constraint handler */ 443 static 444 SCIP_DECL_CONSACTIVE(consActiveObj) 445 { /*lint --e{715}*/ 446 SCIP_CONSHDLRDATA* conshdlrdata; 447 448 conshdlrdata = SCIPconshdlrGetData(conshdlr); 449 assert(conshdlrdata != NULL); 450 assert(conshdlrdata->objconshdlr != NULL); 451 452 /* call virtual method of conshdlr object */ 453 SCIP_CALL( conshdlrdata->objconshdlr->scip_active(scip, conshdlr, cons) ); 454 455 return SCIP_OKAY; 456 } 457 458 459 /** constraint deactivation notification method of constraint handler */ 460 static 461 SCIP_DECL_CONSDEACTIVE(consDeactiveObj) 462 { /*lint --e{715}*/ 463 SCIP_CONSHDLRDATA* conshdlrdata; 464 465 conshdlrdata = SCIPconshdlrGetData(conshdlr); 466 assert(conshdlrdata != NULL); 467 assert(conshdlrdata->objconshdlr != NULL); 468 469 /* call virtual method of conshdlr object */ 470 SCIP_CALL( conshdlrdata->objconshdlr->scip_deactive(scip, conshdlr, cons) ); 471 472 return SCIP_OKAY; 473 } 474 475 476 /** constraint enabling notification method of constraint handler */ 477 static 478 SCIP_DECL_CONSENABLE(consEnableObj) 479 { /*lint --e{715}*/ 480 SCIP_CONSHDLRDATA* conshdlrdata; 481 482 conshdlrdata = SCIPconshdlrGetData(conshdlr); 483 assert(conshdlrdata != NULL); 484 assert(conshdlrdata->objconshdlr != NULL); 485 486 /* call virtual method of conshdlr object */ 487 SCIP_CALL( conshdlrdata->objconshdlr->scip_enable(scip, conshdlr, cons) ); 488 489 return SCIP_OKAY; 490 } 491 492 493 /** constraint disabling notification method of constraint handler */ 494 static 495 SCIP_DECL_CONSDISABLE(consDisableObj) 496 { /*lint --e{715}*/ 497 SCIP_CONSHDLRDATA* conshdlrdata; 498 499 conshdlrdata = SCIPconshdlrGetData(conshdlr); 500 assert(conshdlrdata != NULL); 501 assert(conshdlrdata->objconshdlr != NULL); 502 503 /* call virtual method of conshdlr object */ 504 SCIP_CALL( conshdlrdata->objconshdlr->scip_disable(scip, conshdlr, cons) ); 505 506 return SCIP_OKAY; 507 } 508 509 /** variable deletion method of constraint handler */ 510 static 511 SCIP_DECL_CONSDELVARS(consDelVarsObj) 512 { /*lint --e{715}*/ 513 SCIP_CONSHDLRDATA* conshdlrdata; 514 515 conshdlrdata = SCIPconshdlrGetData(conshdlr); 516 assert(conshdlrdata != NULL); 517 assert(conshdlrdata->objconshdlr != NULL); 518 519 /* call virtual method of conshdlr object */ 520 SCIP_CALL( conshdlrdata->objconshdlr->scip_delvars(scip, conshdlr, conss, nconss) ); 521 522 return SCIP_OKAY; 523 } 524 525 /** constraint display method of constraint handler */ 526 static 527 SCIP_DECL_CONSPRINT(consPrintObj) 528 { /*lint --e{715}*/ 529 SCIP_CONSHDLRDATA* conshdlrdata; 530 531 conshdlrdata = SCIPconshdlrGetData(conshdlr); 532 assert(conshdlrdata != NULL); 533 assert(conshdlrdata->objconshdlr != NULL); 534 535 /* call virtual method of conshdlr object */ 536 SCIP_CALL( conshdlrdata->objconshdlr->scip_print(scip, conshdlr, cons, file) ); 537 538 return SCIP_OKAY; 539 } 540 541 /** constraint copying method of constraint handler */ 542 static 543 SCIP_DECL_CONSCOPY(consCopyObj) 544 { /*lint --e{715}*/ 545 SCIP_CONSHDLRDATA* sourceconshdlrdata; 546 547 sourceconshdlrdata = SCIPconshdlrGetData(sourceconshdlr); 548 assert(sourceconshdlrdata != NULL); 549 assert(sourceconshdlrdata->objconshdlr != NULL); 550 551 /* call virtual method of conshdlr object */ 552 SCIP_CALL( sourceconshdlrdata->objconshdlr->scip_copy(scip, cons, name, sourcescip, sourceconshdlr, sourcecons, varmap, consmap, 553 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, global, valid) ); 554 555 return SCIP_OKAY; 556 } 557 558 /** constraint parsing method of constraint handler */ 559 static 560 SCIP_DECL_CONSPARSE(consParseObj) 561 { /*lint --e{715}*/ 562 SCIP_CONSHDLRDATA* conshdlrdata; 563 564 conshdlrdata = SCIPconshdlrGetData(conshdlr); 565 assert(conshdlrdata != NULL); 566 assert(conshdlrdata->objconshdlr != NULL); 567 568 /* call virtual method of conshdlr object */ 569 SCIP_CALL( conshdlrdata->objconshdlr->scip_parse(scip, conshdlr, cons, name, str, 570 initial, separate, enforce, check, propagate, local, modifiable, dynamic, removable, stickingatnode, success) ); 571 572 return SCIP_OKAY; 573 } 574 575 /** constraint method of constraint handler which returns the variables (if possible) */ 576 static 577 SCIP_DECL_CONSGETVARS(consGetVarsObj) 578 { /*lint --e{715}*/ 579 SCIP_CONSHDLRDATA* conshdlrdata; 580 581 conshdlrdata = SCIPconshdlrGetData(conshdlr); 582 assert(conshdlrdata != NULL); 583 assert(conshdlrdata->objconshdlr != NULL); 584 585 /* call virtual method of conshdlr object */ 586 SCIP_CALL( conshdlrdata->objconshdlr->scip_getvars(scip, conshdlr, cons, vars, varssize, success) ); 587 588 return SCIP_OKAY; 589 } 590 591 /** constraint method of constraint handler which returns the number of variables (if possible) */ 592 static 593 SCIP_DECL_CONSGETNVARS(consGetNVarsObj) 594 { /*lint --e{715}*/ 595 SCIP_CONSHDLRDATA* conshdlrdata; 596 597 conshdlrdata = SCIPconshdlrGetData(conshdlr); 598 assert(conshdlrdata != NULL); 599 assert(conshdlrdata->objconshdlr != NULL); 600 601 /* call virtual method of conshdlr object */ 602 SCIP_CALL( conshdlrdata->objconshdlr->scip_getnvars(scip, conshdlr, cons, nvars, success) ); 603 604 return SCIP_OKAY; 605 } 606 607 /** constraint handler method to suggest dive bound changes during the generic diving algorithm */ 608 static 609 SCIP_DECL_CONSGETDIVEBDCHGS(consGetDiveBdChgsObj) 610 { /*lint --e{715}*/ 611 SCIP_CONSHDLRDATA* conshdlrdata; 612 613 conshdlrdata = SCIPconshdlrGetData(conshdlr); 614 assert(conshdlrdata != NULL); 615 assert(conshdlrdata->objconshdlr != NULL); 616 617 /* call virtual method of conshdlr object */ 618 SCIP_CALL( conshdlrdata->objconshdlr->scip_getdivebdchgs(scip, conshdlr, diveset, sol, success, infeasible) ); 619 620 return SCIP_OKAY; 621 } 622 623 /** constraint handler method which returns the permutation symmetry detection graph of a constraint (if possible) */ 624 static 625 SCIP_DECL_CONSGETPERMSYMGRAPH(consGetPermsymGraph) 626 { /*lint --e{715}*/ 627 SCIP_CONSHDLRDATA* conshdlrdata; 628 629 conshdlrdata = SCIPconshdlrGetData(conshdlr); 630 assert(conshdlrdata != NULL); 631 assert(conshdlrdata->objconshdlr != NULL); 632 633 /* call virtual method of conshdlr object */ 634 SCIP_CALL( conshdlrdata->objconshdlr->scip_getpermsymgraph(scip, conshdlr, cons, graph, success) ); 635 636 return SCIP_OKAY; 637 } 638 639 /** constraint handler method which returns the signed permutation symmetry detection graph of a constraint (if possible) */ 640 static 641 SCIP_DECL_CONSGETSIGNEDPERMSYMGRAPH(consGetSignedPermsymGraph) 642 { /*lint --e{715}*/ 643 SCIP_CONSHDLRDATA* conshdlrdata; 644 645 conshdlrdata = SCIPconshdlrGetData(conshdlr); 646 assert(conshdlrdata != NULL); 647 assert(conshdlrdata->objconshdlr != NULL); 648 649 /* call virtual method of conshdlr object */ 650 SCIP_CALL( conshdlrdata->objconshdlr->scip_getsignedpermsymgraph(scip, conshdlr, cons, graph, success) ); 651 652 return SCIP_OKAY; 653 } 654 } 655 656 657 /* 658 * constraint handler specific interface methods 659 */ 660 661 /** creates the constraint handler for the given constraint handler object and includes it in SCIP */ 662 SCIP_RETCODE SCIPincludeObjConshdlr( 663 SCIP* scip, /**< SCIP data structure */ 664 scip::ObjConshdlr* objconshdlr, /**< constraint handler object */ 665 SCIP_Bool deleteobject /**< should the constraint handler object be deleted when conshdlr is freed? */ 666 ) 667 { 668 SCIP_CONSHDLRDATA* conshdlrdata; 669 670 assert(scip != NULL); 671 assert(objconshdlr != NULL); 672 assert(objconshdlr->scip_ == scip); 673 674 /* create obj constraint handler data */ 675 conshdlrdata = new SCIP_CONSHDLRDATA; 676 conshdlrdata->objconshdlr = objconshdlr; 677 conshdlrdata->deleteobject = deleteobject; 678 679 /* include constraint handler */ 680 SCIP_CALL( SCIPincludeConshdlr(scip, objconshdlr->scip_name_, objconshdlr->scip_desc_, 681 objconshdlr->scip_sepapriority_, objconshdlr->scip_enfopriority_, objconshdlr->scip_checkpriority_, 682 objconshdlr->scip_sepafreq_, objconshdlr->scip_propfreq_, objconshdlr->scip_eagerfreq_, 683 objconshdlr->scip_maxprerounds_, 684 objconshdlr->scip_delaysepa_, objconshdlr->scip_delayprop_, 685 objconshdlr->scip_needscons_, objconshdlr->scip_proptiming_, objconshdlr->scip_presoltiming_, 686 conshdlrCopyObj, 687 consFreeObj, consInitObj, consExitObj, 688 consInitpreObj, consExitpreObj, consInitsolObj, consExitsolObj, 689 consDeleteObj, consTransObj, consInitlpObj, 690 consSepalpObj, consSepasolObj, consEnfolpObj, consEnforelaxObj, consEnfopsObj, consCheckObj, 691 consPropObj, consPresolObj, consRespropObj, consLockObj, 692 consActiveObj, consDeactiveObj, 693 consEnableObj, consDisableObj, consDelVarsObj, 694 consPrintObj, consCopyObj, consParseObj, 695 consGetVarsObj, consGetNVarsObj, consGetDiveBdChgsObj, 696 consGetPermsymGraph, consGetSignedPermsymGraph, conshdlrdata) ); /*lint !e429*/ 697 698 return SCIP_OKAY; /*lint !e429*/ 699 } 700 701 /** returns the conshdlr object of the given name, or 0 if not existing */ 702 scip::ObjConshdlr* SCIPfindObjConshdlr( 703 SCIP* scip, /**< SCIP data structure */ 704 const char* name /**< name of constraint handler */ 705 ) 706 { 707 SCIP_CONSHDLR* conshdlr; 708 SCIP_CONSHDLRDATA* conshdlrdata; 709 710 conshdlr = SCIPfindConshdlr(scip, name); 711 if( conshdlr == NULL ) 712 return 0; 713 714 conshdlrdata = SCIPconshdlrGetData(conshdlr); 715 assert(conshdlrdata != NULL); 716 717 return conshdlrdata->objconshdlr; 718 } 719 720 /** returns the conshdlr object for the given constraint handler */ 721 scip::ObjConshdlr* SCIPgetObjConshdlr( 722 SCIP* scip, /**< SCIP data structure */ 723 SCIP_CONSHDLR* conshdlr /**< constraint handler */ 724 ) 725 { 726 SCIP_CONSHDLRDATA* conshdlrdata; 727 728 assert(scip != NULL); 729 conshdlrdata = SCIPconshdlrGetData(conshdlr); 730 assert(conshdlrdata != NULL); 731 732 return conshdlrdata->objconshdlr; 733 } 734