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 pub_var.h 26 * @ingroup PUBLICCOREAPI 27 * @brief public methods for problem variables 28 * @author Tobias Achterberg 29 */ 30 31 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 32 33 #ifndef __SCIP_PUB_VAR_H__ 34 #define __SCIP_PUB_VAR_H__ 35 36 37 #include "scip/def.h" 38 #include "scip/type_cons.h" 39 #include "scip/type_history.h" 40 #include "scip/type_implics.h" 41 #include "scip/type_lp.h" 42 #include "scip/type_misc.h" 43 #include "scip/type_prop.h" 44 #include "scip/type_result.h" 45 #include "scip/type_retcode.h" 46 #include "scip/type_scip.h" 47 #include "scip/type_var.h" 48 49 #ifdef NDEBUG 50 #include "scip/struct_var.h" 51 #include "scip/implics.h" 52 #include "scip/history.h" 53 #include "scip/pub_lp.h" 54 #endif 55 56 #ifdef __cplusplus 57 extern "C" { 58 #endif 59 60 /* 61 * methods for variables 62 */ 63 64 /**@addtogroup PublicVariableMethods 65 * 66 * @{ 67 */ 68 69 /** gets number of locks for rounding down 70 * 71 * @note This method will always return variable locks of type model 72 * 73 * @note It is recommented to use SCIPvarGetNLocksDownType() 74 */ 75 SCIP_EXPORT 76 int SCIPvarGetNLocksDown( 77 SCIP_VAR* var /**< problem variable */ 78 ); 79 80 /** gets number of locks for rounding up 81 * 82 * @note This method will always return variable locks of type model 83 * 84 * @note It is recommented to use SCIPvarGetNLocksUpType() 85 */ 86 SCIP_EXPORT 87 int SCIPvarGetNLocksUp( 88 SCIP_VAR* var /**< problem variable */ 89 ); 90 91 /** gets number of locks for rounding up of a special type */ 92 SCIP_EXPORT 93 int SCIPvarGetNLocksUpType( 94 SCIP_VAR* var, /**< problem variable */ 95 SCIP_LOCKTYPE locktype /**< type of variable locks */ 96 ); 97 98 /** gets number of locks for rounding down of a special type */ 99 SCIP_EXPORT 100 int SCIPvarGetNLocksDownType( 101 SCIP_VAR* var, /**< problem variable */ 102 SCIP_LOCKTYPE locktype /**< type of variable locks */ 103 ); 104 105 /** is it possible, to round variable down and stay feasible? 106 * 107 * @note This method will always check w.r.t variable locks of type model 108 */ 109 SCIP_EXPORT 110 SCIP_Bool SCIPvarMayRoundDown( 111 SCIP_VAR* var /**< problem variable */ 112 ); 113 114 /** is it possible, to round variable up and stay feasible? 115 * 116 * @note This method will always check w.r.t. variable locks of type model 117 */ 118 SCIP_EXPORT 119 SCIP_Bool SCIPvarMayRoundUp( 120 SCIP_VAR* var /**< problem variable */ 121 ); 122 123 /** compares the index of two variables, only active or negated variables are allowed, if a variable 124 * is negated then the index of the corresponding active variable is taken, returns -1 if first is 125 * smaller than, and +1 if first is greater than second variable index; returns 0 if both indices 126 * are equal, which means both variables are equal 127 */ 128 SCIP_EXPORT 129 int SCIPvarCompareActiveAndNegated( 130 SCIP_VAR* var1, /**< first problem variable */ 131 SCIP_VAR* var2 /**< second problem variable */ 132 ); 133 134 /** comparison method for sorting active and negated variables by non-decreasing index, active and negated 135 * variables are handled as the same variables 136 */ 137 SCIP_EXPORT 138 SCIP_DECL_SORTPTRCOMP(SCIPvarCompActiveAndNegated); 139 140 /** compares the index of two variables, returns -1 if first is smaller than, and +1 if first is greater than second 141 * variable index; returns 0 if both indices are equal, which means both variables are equal 142 */ 143 SCIP_EXPORT 144 int SCIPvarCompare( 145 SCIP_VAR* var1, /**< first problem variable */ 146 SCIP_VAR* var2 /**< second problem variable */ 147 ); 148 149 /** comparison method for sorting variables by non-decreasing index */ 150 SCIP_EXPORT 151 SCIP_DECL_SORTPTRCOMP(SCIPvarComp); 152 153 /** comparison method for sorting variables by non-decreasing objective coefficient */ 154 SCIP_EXPORT 155 SCIP_DECL_SORTPTRCOMP(SCIPvarCompObj); 156 157 /** hash key retrieval function for variables */ 158 SCIP_EXPORT 159 SCIP_DECL_HASHGETKEY(SCIPvarGetHashkey); 160 161 /** returns TRUE iff the indices of both variables are equal */ 162 SCIP_EXPORT 163 SCIP_DECL_HASHKEYEQ(SCIPvarIsHashkeyEq); 164 165 /** returns the hash value of the key */ 166 SCIP_EXPORT 167 SCIP_DECL_HASHKEYVAL(SCIPvarGetHashkeyVal); 168 169 170 /** gets corresponding active, fixed, or multi-aggregated problem variables of given variables, 171 * @note the content of the given array will/might change 172 */ 173 SCIP_EXPORT 174 void SCIPvarsGetProbvar( 175 SCIP_VAR** vars, /**< array of problem variables */ 176 int nvars /**< number of variables */ 177 ); 178 179 /** gets corresponding active, fixed, or multi-aggregated problem variable of a variable */ 180 SCIP_EXPORT 181 SCIP_VAR* SCIPvarGetProbvar( 182 SCIP_VAR* var /**< problem variable */ 183 ); 184 185 /** gets corresponding active, fixed, or multi-aggregated problem variables of binary variables and 186 * updates the given negation status of each variable 187 */ 188 SCIP_EXPORT 189 SCIP_RETCODE SCIPvarsGetProbvarBinary( 190 SCIP_VAR*** vars, /**< pointer to binary problem variables */ 191 SCIP_Bool** negatedarr, /**< pointer to corresponding array to update the negation status */ 192 int nvars /**< number of variables and values in vars and negated array */ 193 ); 194 195 /** gets corresponding active, fixed, or multi-aggregated problem variable of a binary variable and 196 * updates the given negation status 197 */ 198 SCIP_EXPORT 199 SCIP_RETCODE SCIPvarGetProbvarBinary( 200 SCIP_VAR** var, /**< pointer to binary problem variable */ 201 SCIP_Bool* negated /**< pointer to update the negation status */ 202 ); 203 204 /** transforms given variable, boundtype and bound to the corresponding active, fixed, or multi-aggregated variable 205 * values 206 */ 207 SCIP_EXPORT 208 SCIP_RETCODE SCIPvarGetProbvarBound( 209 SCIP_VAR** var, /**< pointer to problem variable */ 210 SCIP_Real* bound, /**< pointer to bound value to transform */ 211 SCIP_BOUNDTYPE* boundtype /**< pointer to type of bound: lower or upper bound */ 212 ); 213 214 /** transforms given variable and domain hole to the corresponding active, fixed, or multi-aggregated variable 215 * values 216 */ 217 SCIP_EXPORT 218 SCIP_RETCODE SCIPvarGetProbvarHole( 219 SCIP_VAR** var, /**< pointer to problem variable */ 220 SCIP_Real* left, /**< pointer to left bound of open interval in hole to transform */ 221 SCIP_Real* right /**< pointer to right bound of open interval in hole to transform */ 222 ); 223 224 /** retransforms given variable, scalar and constant to the corresponding original variable, scalar 225 * and constant, if possible; if the retransformation is impossible, NULL is returned as variable 226 */ 227 SCIP_EXPORT 228 SCIP_RETCODE SCIPvarGetOrigvarSum( 229 SCIP_VAR** var, /**< pointer to problem variable x in sum a*x + c */ 230 SCIP_Real* scalar, /**< pointer to scalar a in sum a*x + c */ 231 SCIP_Real* constant /**< pointer to constant c in sum a*x + c */ 232 ); 233 234 /** returns whether the given variable is the direct counterpart of an original problem variable */ 235 SCIP_EXPORT 236 SCIP_Bool SCIPvarIsTransformedOrigvar( 237 SCIP_VAR* var /**< problem variable */ 238 ); 239 240 /** returns the number of times, a bound of the variable was changed in given direction due to branching */ 241 SCIP_EXPORT 242 SCIP_Longint SCIPvarGetNBranchings( 243 SCIP_VAR* var, /**< problem variable */ 244 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */ 245 ); 246 247 /** returns the number of times, a bound of the variable was changed in given direction due to branching 248 * in the current run 249 */ 250 SCIP_EXPORT 251 SCIP_Longint SCIPvarGetNBranchingsCurrentRun( 252 SCIP_VAR* var, /**< problem variable */ 253 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */ 254 ); 255 256 /** returns the number of inferences branching on this variable in given direction triggered */ 257 SCIP_EXPORT 258 SCIP_Real SCIPvarGetInferenceSum( 259 SCIP_VAR* var, /**< problem variable */ 260 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */ 261 ); 262 263 /** returns the number of inferences branching on this variable in given direction triggered 264 * in the current run 265 */ 266 SCIP_EXPORT 267 SCIP_Real SCIPvarGetInferenceSumCurrentRun( 268 SCIP_VAR* var, /**< problem variable */ 269 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */ 270 ); 271 272 /** returns the number of cutoffs branching on this variable in given direction produced */ 273 SCIP_EXPORT 274 SCIP_Real SCIPvarGetCutoffSum( 275 SCIP_VAR* var, /**< problem variable */ 276 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */ 277 ); 278 279 /** returns the number of cutoffs branching on this variable in given direction produced in the current run */ 280 SCIP_EXPORT 281 SCIP_Real SCIPvarGetCutoffSumCurrentRun( 282 SCIP_VAR* var, /**< problem variable */ 283 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */ 284 ); 285 286 /** returns the average depth of bound changes in given direction due to branching on the variable */ 287 SCIP_EXPORT 288 SCIP_Real SCIPvarGetAvgBranchdepth( 289 SCIP_VAR* var, /**< problem variable */ 290 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */ 291 ); 292 293 /** returns the average depth of bound changes in given direction due to branching on the variable 294 * in the current run 295 */ 296 SCIP_EXPORT 297 SCIP_Real SCIPvarGetAvgBranchdepthCurrentRun( 298 SCIP_VAR* var, /**< problem variable */ 299 SCIP_BRANCHDIR dir /**< branching direction (downwards, or upwards) */ 300 ); 301 302 /** returns whether there is an implication x == varfixing -> y <= b or y >= b in the implication graph; 303 * implications that are represented as cliques in the clique table are not regarded (use SCIPvarsHaveCommonClique()); 304 * both variables must be active, variable x must be binary 305 */ 306 SCIP_EXPORT 307 SCIP_Bool SCIPvarHasImplic( 308 SCIP_VAR* var, /**< problem variable x */ 309 SCIP_Bool varfixing, /**< FALSE if y should be searched in implications for x == 0, TRUE for x == 1 */ 310 SCIP_VAR* implvar, /**< variable y to search for */ 311 SCIP_BOUNDTYPE impltype /**< type of implication y <=/>= b to search for */ 312 ); 313 314 /** returns whether there is an implication x == varfixing -> y == implvarfixing in the implication graph; 315 * implications that are represented as cliques in the clique table are not regarded (use SCIPvarsHaveCommonClique()); 316 * both variables must be active binary variables 317 */ 318 SCIP_EXPORT 319 SCIP_Bool SCIPvarHasBinaryImplic( 320 SCIP_VAR* var, /**< problem variable x */ 321 SCIP_Bool varfixing, /**< FALSE if y should be searched in implications for x == 0, TRUE for x == 1 */ 322 SCIP_VAR* implvar, /**< variable y to search for */ 323 SCIP_Bool implvarfixing /**< value of the implied variable to search for */ 324 ); 325 326 /** gets the values of b in implications x == varfixing -> y <= b or y >= b in the implication graph; 327 * the values are set to SCIP_INVALID if there is no implied bound 328 */ 329 SCIP_EXPORT 330 void SCIPvarGetImplicVarBounds( 331 SCIP_VAR* var, /**< problem variable x */ 332 SCIP_Bool varfixing, /**< FALSE if y should be searched in implications for x == 0, TRUE for x == 1 */ 333 SCIP_VAR* implvar, /**< variable y to search for */ 334 SCIP_Real* lb, /**< buffer to store the value of the implied lower bound */ 335 SCIP_Real* ub /**< buffer to store the value of the implied upper bound */ 336 ); 337 338 /** returns whether there is a clique that contains both given variable/value pairs; 339 * the variables must be active binary variables; 340 * if regardimplics is FALSE, only the cliques in the clique table are looked at; 341 * if regardimplics is TRUE, both the cliques and the implications of the implication graph are regarded 342 */ 343 SCIP_EXPORT 344 SCIP_Bool SCIPvarsHaveCommonClique( 345 SCIP_VAR* var1, /**< first variable */ 346 SCIP_Bool value1, /**< value of first variable */ 347 SCIP_VAR* var2, /**< second variable */ 348 SCIP_Bool value2, /**< value of second variable */ 349 SCIP_Bool regardimplics /**< should the implication graph also be searched for a clique? */ 350 ); 351 352 /** gets corresponding objective value of active, fixed, or multi-aggregated problem variable of given variable 353 * e.g. obj(x) = 1 this method returns for ~x the value -1 354 */ 355 SCIP_EXPORT 356 SCIP_RETCODE SCIPvarGetAggregatedObj( 357 SCIP_VAR* var, /**< problem variable */ 358 SCIP_Real* aggrobj /**< pointer to store the aggregated objective value */ 359 ); 360 361 /** sets the initial flag of a variable; only possible for original or loose variables */ 362 SCIP_EXPORT 363 SCIP_RETCODE SCIPvarSetInitial( 364 SCIP_VAR* var, /**< problem variable */ 365 SCIP_Bool initial /**< initial flag */ 366 ); 367 368 /** sets the removable flag of a variable; only possible for original or loose variables */ 369 SCIP_EXPORT 370 SCIP_RETCODE SCIPvarSetRemovable( 371 SCIP_VAR* var, /**< problem variable */ 372 SCIP_Bool removable /**< removable flag */ 373 ); 374 375 /** returns the name of the variable 376 * 377 * @note to change the name of a variable, use SCIPchgVarName() from scip.h 378 */ 379 SCIP_EXPORT 380 const char* SCIPvarGetName( 381 SCIP_VAR* var /**< problem variable */ 382 ); 383 384 /** gets number of times, the variable is currently captured */ 385 SCIP_EXPORT 386 int SCIPvarGetNUses( 387 SCIP_VAR* var /**< problem variable */ 388 ); 389 390 /** returns the user data of the variable */ 391 SCIP_EXPORT 392 SCIP_VARDATA* SCIPvarGetData( 393 SCIP_VAR* var /**< problem variable */ 394 ); 395 396 /** sets the user data for the variable */ 397 SCIP_EXPORT 398 void SCIPvarSetData( 399 SCIP_VAR* var, /**< problem variable */ 400 SCIP_VARDATA* vardata /**< user variable data */ 401 ); 402 403 /** sets method to free user data for the original variable */ 404 SCIP_EXPORT 405 void SCIPvarSetDelorigData( 406 SCIP_VAR* var, /**< problem variable */ 407 SCIP_DECL_VARDELORIG ((*vardelorig)) /**< frees user data of original variable */ 408 ); 409 410 /** sets method to transform user data of the variable */ 411 SCIP_EXPORT 412 void SCIPvarSetTransData( 413 SCIP_VAR* var, /**< problem variable */ 414 SCIP_DECL_VARTRANS ((*vartrans)) /**< creates transformed user data by transforming original user data */ 415 ); 416 417 /** sets method to free transformed user data for the variable */ 418 SCIP_EXPORT 419 void SCIPvarSetDeltransData( 420 SCIP_VAR* var, /**< problem variable */ 421 SCIP_DECL_VARDELTRANS ((*vardeltrans)) /**< frees user data of transformed variable */ 422 ); 423 424 /** sets method to copy this variable into sub-SCIPs */ 425 SCIP_EXPORT 426 void SCIPvarSetCopyData( 427 SCIP_VAR* var, /**< problem variable */ 428 SCIP_DECL_VARCOPY ((*varcopy)) /**< copy method of the variable */ 429 ); 430 431 /** gets status of variable */ 432 SCIP_EXPORT 433 SCIP_VARSTATUS SCIPvarGetStatus( 434 SCIP_VAR* var /**< problem variable */ 435 ); 436 437 /** returns whether the variable belongs to the original problem */ 438 SCIP_EXPORT 439 SCIP_Bool SCIPvarIsOriginal( 440 SCIP_VAR* var /**< problem variable */ 441 ); 442 443 /** returns whether the variable belongs to the transformed problem */ 444 SCIP_EXPORT 445 SCIP_Bool SCIPvarIsTransformed( 446 SCIP_VAR* var /**< problem variable */ 447 ); 448 449 /** returns whether the variable was created by negation of a different variable */ 450 SCIP_EXPORT 451 SCIP_Bool SCIPvarIsNegated( 452 SCIP_VAR* var /**< problem variable */ 453 ); 454 455 /** gets type of variable */ 456 SCIP_EXPORT 457 SCIP_VARTYPE SCIPvarGetType( 458 SCIP_VAR* var /**< problem variable */ 459 ); 460 461 /** returns TRUE if the variable is of binary type; this is the case if: 462 * (1) variable type is binary 463 * (2) variable type is integer or implicit integer and 464 * (i) the global lower bound is greater than or equal to zero 465 * (ii) the global upper bound is less than or equal to one 466 */ 467 SCIP_EXPORT 468 SCIP_Bool SCIPvarIsBinary( 469 SCIP_VAR* var /**< problem variable */ 470 ); 471 472 /** returns whether variable is of integral type (binary, integer, or implicit integer) */ 473 SCIP_EXPORT 474 SCIP_Bool SCIPvarIsIntegral( 475 SCIP_VAR* var /**< problem variable */ 476 ); 477 478 /** returns whether variable's column should be present in the initial root LP */ 479 SCIP_EXPORT 480 SCIP_Bool SCIPvarIsInitial( 481 SCIP_VAR* var /**< problem variable */ 482 ); 483 484 /** returns whether variable's column is removable from the LP (due to aging or cleanup) */ 485 SCIP_EXPORT 486 SCIP_Bool SCIPvarIsRemovable( 487 SCIP_VAR* var /**< problem variable */ 488 ); 489 490 /** returns whether the variable was deleted from the problem */ 491 SCIP_EXPORT 492 SCIP_Bool SCIPvarIsDeleted( 493 SCIP_VAR* var /**< problem variable */ 494 ); 495 496 /** marks the variable to be deletable, i.e., it may be deleted completely from the problem; 497 * method can only be called before the variable is added to the problem by SCIPaddVar() or SCIPaddPricedVar() 498 */ 499 SCIP_EXPORT 500 void SCIPvarMarkDeletable( 501 SCIP_VAR* var /**< problem variable */ 502 ); 503 504 /** marks the variable to be not deletable from the problem */ 505 SCIP_EXPORT 506 void SCIPvarMarkNotDeletable( 507 SCIP_VAR* var 508 ); 509 510 /** returns whether variable is allowed to be deleted completely from the problem */ 511 SCIP_EXPORT 512 SCIP_Bool SCIPvarIsDeletable( 513 SCIP_VAR* var 514 ); 515 516 /** marks variable to be deleted from global structures (cliques etc.) when cleaning up 517 * 518 * @note: this is not equivalent to marking the variable itself for deletion, this is done by using SCIPvarMarkDeletable() 519 */ 520 SCIP_EXPORT 521 void SCIPvarMarkDeleteGlobalStructures( 522 SCIP_VAR* var /**< problem variable */ 523 ); 524 525 /** returns whether variable is an active (neither fixed nor aggregated) variable */ 526 SCIP_EXPORT 527 SCIP_Bool SCIPvarIsActive( 528 SCIP_VAR* var /**< problem variable */ 529 ); 530 531 /** gets unique index of variable */ 532 SCIP_EXPORT 533 int SCIPvarGetIndex( 534 SCIP_VAR* var /**< problem variable */ 535 ); 536 537 /** gets position of variable in problem, or -1 if variable is not active */ 538 SCIP_EXPORT 539 int SCIPvarGetProbindex( 540 SCIP_VAR* var /**< problem variable */ 541 ); 542 543 /** gets transformed variable of ORIGINAL variable */ 544 SCIP_EXPORT 545 SCIP_VAR* SCIPvarGetTransVar( 546 SCIP_VAR* var /**< problem variable */ 547 ); 548 549 /** gets column of COLUMN variable */ 550 SCIP_EXPORT 551 SCIP_COL* SCIPvarGetCol( 552 SCIP_VAR* var /**< problem variable */ 553 ); 554 555 /** returns whether the variable is a COLUMN variable that is member of the current LP */ 556 SCIP_EXPORT 557 SCIP_Bool SCIPvarIsInLP( 558 SCIP_VAR* var /**< problem variable */ 559 ); 560 561 /** gets aggregation variable y of an aggregated variable x = a*y + c */ 562 SCIP_EXPORT 563 SCIP_VAR* SCIPvarGetAggrVar( 564 SCIP_VAR* var /**< problem variable */ 565 ); 566 567 /** gets aggregation scalar a of an aggregated variable x = a*y + c */ 568 SCIP_EXPORT 569 SCIP_Real SCIPvarGetAggrScalar( 570 SCIP_VAR* var /**< problem variable */ 571 ); 572 573 /** gets aggregation constant c of an aggregated variable x = a*y + c */ 574 SCIP_EXPORT 575 SCIP_Real SCIPvarGetAggrConstant( 576 SCIP_VAR* var /**< problem variable */ 577 ); 578 579 /** gets number n of aggregation variables of a multi aggregated variable x = a0*y0 + ... + a(n-1)*y(n-1) + c */ 580 SCIP_EXPORT 581 int SCIPvarGetMultaggrNVars( 582 SCIP_VAR* var /**< problem variable */ 583 ); 584 585 /** gets vector of aggregation variables y of a multi aggregated variable x = a0*y0 + ... + a(n-1)*y(n-1) + c */ 586 SCIP_EXPORT 587 SCIP_VAR** SCIPvarGetMultaggrVars( 588 SCIP_VAR* var /**< problem variable */ 589 ); 590 591 /** gets vector of aggregation scalars a of a multi aggregated variable x = a0*y0 + ... + a(n-1)*y(n-1) + c */ 592 SCIP_EXPORT 593 SCIP_Real* SCIPvarGetMultaggrScalars( 594 SCIP_VAR* var /**< problem variable */ 595 ); 596 597 /** gets aggregation constant c of a multi aggregated variable x = a0*y0 + ... + a(n-1)*y(n-1) + c */ 598 SCIP_EXPORT 599 SCIP_Real SCIPvarGetMultaggrConstant( 600 SCIP_VAR* var /**< problem variable */ 601 ); 602 603 /** gets the negation of the given variable; may return NULL, if no negation is existing yet */ 604 SCIP_EXPORT 605 SCIP_VAR* SCIPvarGetNegatedVar( 606 SCIP_VAR* var /**< negated problem variable */ 607 ); 608 609 /** gets the negation variable x of a negated variable x' = offset - x */ 610 SCIP_EXPORT 611 SCIP_VAR* SCIPvarGetNegationVar( 612 SCIP_VAR* var /**< negated problem variable */ 613 ); 614 615 /** gets the negation offset of a negated variable x' = offset - x */ 616 SCIP_EXPORT 617 SCIP_Real SCIPvarGetNegationConstant( 618 SCIP_VAR* var /**< negated problem variable */ 619 ); 620 621 /** gets objective function value of variable */ 622 SCIP_EXPORT 623 SCIP_Real SCIPvarGetObj( 624 SCIP_VAR* var /**< problem variable */ 625 ); 626 627 /** gets the unchanged objective function value of variable (ignoring temproray changes performed in probing mode) */ 628 SCIP_EXPORT 629 SCIP_Real SCIPvarGetUnchangedObj( 630 SCIP_VAR* var /**< problem variable */ 631 ); 632 633 /** gets original lower bound of original problem variable (i.e. the bound set in problem creation) */ 634 SCIP_EXPORT 635 SCIP_Real SCIPvarGetLbOriginal( 636 SCIP_VAR* var /**< original problem variable */ 637 ); 638 639 /** gets original upper bound of original problem variable (i.e. the bound set in problem creation) */ 640 SCIP_EXPORT 641 SCIP_Real SCIPvarGetUbOriginal( 642 SCIP_VAR* var /**< original problem variable */ 643 ); 644 645 /** gets the original hole list of an original variable */ 646 SCIP_EXPORT 647 SCIP_HOLELIST* SCIPvarGetHolelistOriginal( 648 SCIP_VAR* var /**< problem variable */ 649 ); 650 651 /** gets global lower bound of variable */ 652 SCIP_EXPORT 653 SCIP_Real SCIPvarGetLbGlobal( 654 SCIP_VAR* var /**< problem variable */ 655 ); 656 657 /** gets global upper bound of variable */ 658 SCIP_EXPORT 659 SCIP_Real SCIPvarGetUbGlobal( 660 SCIP_VAR* var /**< problem variable */ 661 ); 662 663 /** gets the global hole list of an active variable */ 664 SCIP_EXPORT 665 SCIP_HOLELIST* SCIPvarGetHolelistGlobal( 666 SCIP_VAR* var /**< problem variable */ 667 ); 668 669 /** gets best global bound of variable with respect to the objective function */ 670 SCIP_EXPORT 671 SCIP_Real SCIPvarGetBestBoundGlobal( 672 SCIP_VAR* var /**< problem variable */ 673 ); 674 675 /** gets worst global bound of variable with respect to the objective function */ 676 SCIP_EXPORT 677 SCIP_Real SCIPvarGetWorstBoundGlobal( 678 SCIP_VAR* var /**< problem variable */ 679 ); 680 681 /** gets current lower bound of variable */ 682 SCIP_EXPORT 683 SCIP_Real SCIPvarGetLbLocal( 684 SCIP_VAR* var /**< problem variable */ 685 ); 686 687 /** gets current upper bound of variable */ 688 SCIP_EXPORT 689 SCIP_Real SCIPvarGetUbLocal( 690 SCIP_VAR* var /**< problem variable */ 691 ); 692 693 /** gets the current hole list of an active variable */ 694 SCIP_EXPORT 695 SCIP_HOLELIST* SCIPvarGetHolelistLocal( 696 SCIP_VAR* var /**< problem variable */ 697 ); 698 699 /** gets best local bound of variable with respect to the objective function */ 700 SCIP_EXPORT 701 SCIP_Real SCIPvarGetBestBoundLocal( 702 SCIP_VAR* var /**< problem variable */ 703 ); 704 705 /** gets worst local bound of variable with respect to the objective function */ 706 SCIP_EXPORT 707 SCIP_Real SCIPvarGetWorstBoundLocal( 708 SCIP_VAR* var /**< problem variable */ 709 ); 710 711 /** gets type (lower or upper) of best bound of variable with respect to the objective function */ 712 SCIP_EXPORT 713 SCIP_BOUNDTYPE SCIPvarGetBestBoundType( 714 SCIP_VAR* var /**< problem variable */ 715 ); 716 717 /** gets type (lower or upper) of worst bound of variable with respect to the objective function */ 718 SCIP_EXPORT 719 SCIP_BOUNDTYPE SCIPvarGetWorstBoundType( 720 SCIP_VAR* var /**< problem variable */ 721 ); 722 723 /** gets lazy lower bound of variable */ 724 SCIP_EXPORT 725 SCIP_Real SCIPvarGetLbLazy( 726 SCIP_VAR* var /**< problem variable */ 727 ); 728 729 /** gets lazy upper bound of variable */ 730 SCIP_EXPORT 731 SCIP_Real SCIPvarGetUbLazy( 732 SCIP_VAR* var /**< problem variable */ 733 ); 734 735 /** gets the branch factor of the variable; this value can be used in the branching methods to scale the score 736 * values of the variables; higher factor leads to a higher probability that this variable is chosen for branching 737 */ 738 SCIP_EXPORT 739 SCIP_Real SCIPvarGetBranchFactor( 740 SCIP_VAR* var /**< problem variable */ 741 ); 742 743 /** gets the branch priority of the variable; variables with higher priority should always be preferred to variables 744 * with lower priority 745 */ 746 SCIP_EXPORT 747 int SCIPvarGetBranchPriority( 748 SCIP_VAR* var /**< problem variable */ 749 ); 750 751 /** gets the preferred branch direction of the variable (downwards, upwards, or auto) */ 752 SCIP_EXPORT 753 SCIP_BRANCHDIR SCIPvarGetBranchDirection( 754 SCIP_VAR* var /**< problem variable */ 755 ); 756 757 /** gets number of variable lower bounds x >= b_i*z_i + d_i of given variable x */ 758 SCIP_EXPORT 759 int SCIPvarGetNVlbs( 760 SCIP_VAR* var /**< problem variable */ 761 ); 762 763 /** gets array with bounding variables z_i in variable lower bounds x >= b_i*z_i + d_i of given variable x; 764 * the variable bounds are sorted by increasing variable index of the bounding variable z_i (see SCIPvarGetIndex()) 765 */ 766 SCIP_EXPORT 767 SCIP_VAR** SCIPvarGetVlbVars( 768 SCIP_VAR* var /**< problem variable */ 769 ); 770 771 /** gets array with bounding coefficients b_i in variable lower bounds x >= b_i*z_i + d_i of given variable x */ 772 SCIP_EXPORT 773 SCIP_Real* SCIPvarGetVlbCoefs( 774 SCIP_VAR* var /**< problem variable */ 775 ); 776 777 /** gets array with bounding constants d_i in variable lower bounds x >= b_i*z_i + d_i of given variable x */ 778 SCIP_EXPORT 779 SCIP_Real* SCIPvarGetVlbConstants( 780 SCIP_VAR* var /**< problem variable */ 781 ); 782 783 /** gets number of variable upper bounds x <= b_i*z_i + d_i of given variable x */ 784 SCIP_EXPORT 785 int SCIPvarGetNVubs( 786 SCIP_VAR* var /**< problem variable */ 787 ); 788 789 /** gets array with bounding variables z_i in variable upper bounds x <= b_i*z_i + d_i of given variable x; 790 * the variable bounds are sorted by increasing variable index of the bounding variable z_i (see SCIPvarGetIndex()) 791 */ 792 SCIP_EXPORT 793 SCIP_VAR** SCIPvarGetVubVars( 794 SCIP_VAR* var /**< problem variable */ 795 ); 796 797 /** gets array with bounding coefficients b_i in variable upper bounds x <= b_i*z_i + d_i of given variable x */ 798 SCIP_EXPORT 799 SCIP_Real* SCIPvarGetVubCoefs( 800 SCIP_VAR* var /**< problem variable */ 801 ); 802 803 /** gets array with bounding constants d_i in variable upper bounds x <= b_i*z_i + d_i of given variable x */ 804 SCIP_EXPORT 805 SCIP_Real* SCIPvarGetVubConstants( 806 SCIP_VAR* var /**< problem variable */ 807 ); 808 809 /** gets number of implications y <= b or y >= b for x == 0 or x == 1 of given active problem variable x, 810 * there are no implications for nonbinary variable x 811 */ 812 SCIP_EXPORT 813 int SCIPvarGetNImpls( 814 SCIP_VAR* var, /**< active problem variable */ 815 SCIP_Bool varfixing /**< FALSE for implications for x == 0, TRUE for x == 1 */ 816 ); 817 818 /** gets array with implication variables y of implications y <= b or y >= b for x == 0 or x == 1 of given active 819 * problem variable x, there are no implications for nonbinary variable x; 820 * the implications are sorted such that implications with binary implied variables precede the ones with non-binary 821 * implied variables, and as a second criteria, the implied variables are sorted by increasing variable index 822 * (see SCIPvarGetIndex()) 823 */ 824 SCIP_EXPORT 825 SCIP_VAR** SCIPvarGetImplVars( 826 SCIP_VAR* var, /**< active problem variable */ 827 SCIP_Bool varfixing /**< FALSE for implications for x == 0, TRUE for x == 1 */ 828 ); 829 830 /** gets array with implication types of implications y <= b or y >= b for x == 0 or x == 1 of given active problem 831 * variable x (SCIP_BOUNDTYPE_UPPER if y <= b, SCIP_BOUNDTYPE_LOWER if y >= b), 832 * there are no implications for nonbinary variable x 833 */ 834 SCIP_EXPORT 835 SCIP_BOUNDTYPE* SCIPvarGetImplTypes( 836 SCIP_VAR* var, /**< active problem variable */ 837 SCIP_Bool varfixing /**< FALSE for implications for x == 0, TRUE for x == 1 */ 838 ); 839 840 /** gets array with implication bounds b of implications y <= b or y >= b for x == 0 or x == 1 of given active problem 841 * variable x, there are no implications for nonbinary variable x 842 */ 843 SCIP_EXPORT 844 SCIP_Real* SCIPvarGetImplBounds( 845 SCIP_VAR* var, /**< active problem variable */ 846 SCIP_Bool varfixing /**< FALSE for implications for x == 0, TRUE for x == 1 */ 847 ); 848 849 /** Gets array with unique ids of implications y <= b or y >= b for x == 0 or x == 1 of given active problem variable x, 850 * there are no implications for nonbinary variable x. 851 * If an implication is a shortcut, i.e., it was added as part of the transitive closure of another implication, 852 * its id is negative, otherwise it is nonnegative. 853 */ 854 SCIP_EXPORT 855 int* SCIPvarGetImplIds( 856 SCIP_VAR* var, /**< active problem variable */ 857 SCIP_Bool varfixing /**< FALSE for implications for x == 0, TRUE for x == 1 */ 858 ); 859 860 /** gets number of cliques, the active variable is contained in */ 861 SCIP_EXPORT 862 int SCIPvarGetNCliques( 863 SCIP_VAR* var, /**< active problem variable */ 864 SCIP_Bool varfixing /**< FALSE for cliques containing x == 0, TRUE for x == 1 */ 865 ); 866 867 /** gets array of cliques, the active variable is contained in */ 868 SCIP_EXPORT 869 SCIP_CLIQUE** SCIPvarGetCliques( 870 SCIP_VAR* var, /**< active problem variable */ 871 SCIP_Bool varfixing /**< FALSE for cliques containing x == 0, TRUE for x == 1 */ 872 ); 873 874 /** gets primal LP solution value of variable */ 875 SCIP_EXPORT 876 SCIP_Real SCIPvarGetLPSol( 877 SCIP_VAR* var /**< problem variable */ 878 ); 879 880 /** gets primal NLP solution value of variable */ 881 SCIP_EXPORT 882 SCIP_Real SCIPvarGetNLPSol( 883 SCIP_VAR* var /**< problem variable */ 884 ); 885 886 /** return lower bound change info at requested position */ 887 SCIP_EXPORT 888 SCIP_BDCHGINFO* SCIPvarGetBdchgInfoLb( 889 SCIP_VAR* var, /**< problem variable */ 890 int pos /**< requested position */ 891 ); 892 893 /** gets the number of lower bound change info array */ 894 SCIP_EXPORT 895 int SCIPvarGetNBdchgInfosLb( 896 SCIP_VAR* var /**< problem variable */ 897 ); 898 899 /** return upper bound change info at requested position */ 900 SCIP_EXPORT 901 SCIP_BDCHGINFO* SCIPvarGetBdchgInfoUb( 902 SCIP_VAR* var, /**< problem variable */ 903 int pos /**< requested position */ 904 ); 905 906 /** gets the number upper bound change info array */ 907 SCIP_EXPORT 908 int SCIPvarGetNBdchgInfosUb( 909 SCIP_VAR* var /**< problem variable */ 910 ); 911 912 /** returns the value based history for the variable */ 913 SCIP_EXPORT 914 SCIP_VALUEHISTORY* SCIPvarGetValuehistory( 915 SCIP_VAR* var /**< problem variable */ 916 ); 917 918 /** returns whether a variable has been introduced to define a relaxation 919 * 920 * These variables are only valid for the current SCIP solve round, 921 * they are not contained in any (checked) constraints, but may be used 922 * in cutting planes, for example. 923 * Relaxation-only variables are not copied by SCIPcopyVars and cuts 924 * that contain these variables are not added as linear constraints when 925 * restarting or transferring information from a copied SCIP to a SCIP. 926 * Also conflicts with relaxation-only variables are not generated at 927 * the moment. 928 * Relaxation-only variables do not appear in the objective. 929 */ 930 SCIP_EXPORT 931 SCIP_Bool SCIPvarIsRelaxationOnly( 932 SCIP_VAR* var /**< problem variable */ 933 ); 934 935 /** marks that this variable has only been introduced to define a relaxation 936 * 937 * The variable must not have a coefficient in the objective and must be deletable. 938 * If it is not marked deletable, it will be marked as deletable, which is only possible 939 * before the variable is added to a problem. 940 * 941 * @see SCIPvarIsRelaxationOnly 942 * @see SCIPvarMarkDeletable 943 */ 944 SCIP_EXPORT 945 void SCIPvarMarkRelaxationOnly( 946 SCIP_VAR* var /**< problem variable */ 947 ); 948 949 #ifdef NDEBUG 950 951 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and 952 * speed up the algorithms. 953 */ 954 955 #define SCIPvarGetName(var) (var)->name 956 #define SCIPvarGetNUses(var) (var)->nuses 957 #define SCIPvarGetData(var) (var)->vardata 958 #define SCIPvarSetData(var,vdata) (var)->vardata = (vdata) 959 #define SCIPvarSetDelorigData(var,func) (var)->vardelorig = (func) 960 #define SCIPvarSetTransData(var,func) (var)->vartrans = (func) 961 #define SCIPvarSetDeltransData(var,func) (var)->vardeltrans = (func) 962 #define SCIPvarGetStatus(var) (SCIP_VARSTATUS)((var)->varstatus) 963 #define SCIPvarIsOriginal(var) ((var)->varstatus == SCIP_VARSTATUS_ORIGINAL \ 964 || ((var)->varstatus == SCIP_VARSTATUS_NEGATED && (var)->negatedvar->varstatus == SCIP_VARSTATUS_ORIGINAL)) 965 #define SCIPvarIsTransformed(var) ((var)->varstatus != SCIP_VARSTATUS_ORIGINAL \ 966 && ((var)->varstatus != SCIP_VARSTATUS_NEGATED || (var)->negatedvar->varstatus != SCIP_VARSTATUS_ORIGINAL)) 967 #define SCIPvarIsNegated(var) ((var)->varstatus == SCIP_VARSTATUS_NEGATED) 968 #define SCIPvarGetType(var) ((SCIP_VARTYPE)((var)->vartype)) 969 #define SCIPvarIsBinary(var) ((var)->vartype == SCIP_VARTYPE_BINARY || \ 970 ((var)->vartype != SCIP_VARTYPE_CONTINUOUS && (var)->glbdom.lb >= 0.0 && (var)->glbdom.ub <= 1.0)) 971 #define SCIPvarIsIntegral(var) ((var)->vartype != SCIP_VARTYPE_CONTINUOUS) 972 #define SCIPvarIsInitial(var) (var)->initial 973 #define SCIPvarIsRemovable(var) (var)->removable 974 #define SCIPvarIsDeleted(var) (var)->deleted 975 #define SCIPvarMarkDeletable(var) (var)->deletable = TRUE 976 #define SCIPvarMarkNotDeletable(var) (var)->deletable = FALSE 977 #define SCIPvarIsDeletable(var) (var)->deletable 978 #define SCIPvarIsActive(var) ((var)->probindex >= 0) 979 #define SCIPvarGetIndex(var) (var)->index 980 #define SCIPvarGetProbindex(var) (var)->probindex 981 #define SCIPvarGetTransVar(var) (var)->data.original.transvar 982 #define SCIPvarGetCol(var) (var)->data.col 983 #define SCIPvarIsInLP(var) ((var)->varstatus == SCIP_VARSTATUS_COLUMN && SCIPcolIsInLP((var)->data.col)) 984 /* use different name for var - otherwise we have clash with the var at the end */ 985 #define SCIPvarGetAggrVar(war) (war)->data.aggregate.var 986 #define SCIPvarGetAggrScalar(var) (var)->data.aggregate.scalar 987 #define SCIPvarGetAggrConstant(var) (var)->data.aggregate.constant 988 #define SCIPvarGetMultaggrNVars(var) (var)->data.multaggr.nvars 989 #define SCIPvarGetMultaggrVars(var) (var)->data.multaggr.vars 990 #define SCIPvarGetMultaggrScalars(var) (var)->data.multaggr.scalars 991 #define SCIPvarGetMultaggrConstant(var) (var)->data.multaggr.constant 992 #define SCIPvarGetNegatedVar(var) (var)->negatedvar 993 #define SCIPvarGetNegationVar(var) (var)->negatedvar 994 #define SCIPvarGetNegationConstant(var) (var)->data.negate.constant 995 #define SCIPvarGetObj(var) (var)->obj 996 #define SCIPvarGetLbOriginal(var) ((var)->varstatus == SCIP_VARSTATUS_ORIGINAL \ 997 ? (var)->data.original.origdom.lb \ 998 : (var)->data.negate.constant - (var)->negatedvar->data.original.origdom.ub) 999 #define SCIPvarGetUbOriginal(var) ((var)->varstatus == SCIP_VARSTATUS_ORIGINAL \ 1000 ? (var)->data.original.origdom.ub \ 1001 : (var)->data.negate.constant - (var)->negatedvar->data.original.origdom.lb) 1002 #define SCIPvarGetHolelistOriginal(var) ((var)->varstatus == SCIP_VARSTATUS_ORIGINAL \ 1003 ? (var)->data.original.origdom.holelist \ 1004 : NULL) 1005 #define SCIPvarGetLbGlobal(var) (var)->glbdom.lb 1006 #define SCIPvarGetUbGlobal(var) (var)->glbdom.ub 1007 #define SCIPvarGetHolelistGlobal(var) (var)->glbdom.holelist 1008 #define SCIPvarGetBestBoundGlobal(var) ((var)->obj >= 0.0 ? (var)->glbdom.lb : (var)->glbdom.ub) 1009 #define SCIPvarGetWorstBoundGlobal(var) ((var)->obj >= 0.0 ? (var)->glbdom.ub : (var)->glbdom.lb) 1010 #define SCIPvarGetLbLocal(var) (var)->locdom.lb 1011 #define SCIPvarGetUbLocal(var) (var)->locdom.ub 1012 #define SCIPvarGetHolelistLocal(var) (var)->locdom.holelist 1013 #define SCIPvarGetBestBoundLocal(var) ((var)->obj >= 0.0 ? (var)->locdom.lb : (var)->locdom.ub) 1014 #define SCIPvarGetWorstBoundLocal(var) ((var)->obj >= 0.0 ? (var)->locdom.ub : (var)->locdom.lb) 1015 #define SCIPvarGetBestBoundType(var) ((var)->obj >= 0.0 ? SCIP_BOUNDTYPE_LOWER : SCIP_BOUNDTYPE_UPPER) 1016 #define SCIPvarGetWorstBoundType(var) ((var)->obj >= 0.0 ? SCIP_BOUNDTYPE_UPPER : SCIP_BOUNDTYPE_LOWER) 1017 #define SCIPvarGetLbLazy(var) (var)->lazylb 1018 #define SCIPvarGetUbLazy(var) (var)->lazyub 1019 #define SCIPvarGetBranchFactor(var) (var)->branchfactor 1020 #define SCIPvarGetBranchPriority(var) (var)->branchpriority 1021 #define SCIPvarGetBranchDirection(var) (var)->branchdirection 1022 #define SCIPvarGetNVlbs(var) (SCIPvboundsGetNVbds((var)->vlbs)) 1023 #define SCIPvarGetVlbVars(var) (SCIPvboundsGetVars((var)->vlbs)) 1024 #define SCIPvarGetVlbCoefs(var) (SCIPvboundsGetCoefs((var)->vlbs)) 1025 #define SCIPvarGetVlbConstants(var) (SCIPvboundsGetConstants((var)->vlbs)) 1026 #define SCIPvarGetNVubs(var) (SCIPvboundsGetNVbds((var)->vubs)) 1027 #define SCIPvarGetVubVars(var) (SCIPvboundsGetVars((var)->vubs)) 1028 #define SCIPvarGetVubCoefs(var) (SCIPvboundsGetCoefs((var)->vubs)) 1029 #define SCIPvarGetVubConstants(var) (SCIPvboundsGetConstants((var)->vubs)) 1030 #define SCIPvarGetNImpls(var, fix) (SCIPimplicsGetNImpls((var)->implics, fix)) 1031 #define SCIPvarGetImplVars(var, fix) (SCIPimplicsGetVars((var)->implics, fix)) 1032 #define SCIPvarGetImplTypes(var, fix) (SCIPimplicsGetTypes((var)->implics, fix)) 1033 #define SCIPvarGetImplBounds(var, fix) (SCIPimplicsGetBounds((var)->implics, fix)) 1034 #define SCIPvarGetImplIds(var, fix) (SCIPimplicsGetIds((var)->implics, fix)) 1035 #define SCIPvarGetNCliques(var, fix) (SCIPcliquelistGetNCliques((var)->cliquelist, fix)) 1036 #define SCIPvarGetCliques(var, fix) (SCIPcliquelistGetCliques((var)->cliquelist, fix)) 1037 #define SCIPvarGetLPSol(var) ((var)->varstatus == SCIP_VARSTATUS_COLUMN ? SCIPcolGetPrimsol((var)->data.col) : SCIPvarGetLPSol_rec(var)) 1038 #define SCIPvarGetNLPSol(var) (((var)->varstatus == SCIP_VARSTATUS_COLUMN || ((var)->varstatus == SCIP_VARSTATUS_LOOSE)) ? (var)->nlpsol : SCIPvarGetNLPSol_rec(var)) 1039 #define SCIPvarGetBdchgInfoLb(var, pos) (&((var)->lbchginfos[pos])) 1040 #define SCIPvarGetNBdchgInfosLb(var) ((var)->nlbchginfos) 1041 #define SCIPvarGetBdchgInfoUb(var, pos) (&((var)->ubchginfos[pos])) 1042 #define SCIPvarGetNBdchgInfosUb(var) ((var)->nubchginfos) 1043 #define SCIPvarGetValuehistory(var) (var)->valuehistory 1044 #define SCIPvarGetCliqueComponentIdx(var) ((var)->clqcomponentidx) 1045 #define SCIPvarIsRelaxationOnly(var)((var)->relaxationonly) 1046 #define SCIPvarMarkRelaxationOnly(var)((var)->relaxationonly = TRUE) 1047 1048 #endif 1049 1050 /** gets primal LP solution value of variable */ 1051 SCIP_EXPORT 1052 SCIP_Real SCIPvarGetLPSol_rec( 1053 SCIP_VAR* var /**< problem variable */ 1054 ); 1055 1056 /** gets primal NLP solution value of variable */ 1057 SCIP_EXPORT 1058 SCIP_Real SCIPvarGetNLPSol_rec( 1059 SCIP_VAR* var /**< problem variable */ 1060 ); 1061 1062 /** gets pseudo solution value of variable at current node */ 1063 SCIP_EXPORT 1064 SCIP_Real SCIPvarGetPseudoSol( 1065 SCIP_VAR* var /**< problem variable */ 1066 ); 1067 1068 /** gets current LP or pseudo solution value of variable */ 1069 SCIP_EXPORT 1070 SCIP_Real SCIPvarGetSol( 1071 SCIP_VAR* var, /**< problem variable */ 1072 SCIP_Bool getlpval /**< should the LP solution value be returned? */ 1073 ); 1074 1075 /** returns the solution of the variable in the last root node's relaxation, if the root relaxation is not yet 1076 * completely solved, zero is returned 1077 */ 1078 SCIP_EXPORT 1079 SCIP_Real SCIPvarGetRootSol( 1080 SCIP_VAR* var /**< problem variable */ 1081 ); 1082 1083 /** returns the best solution (w.r.t. root reduced cost propagation) of the variable in the root node's relaxation, if 1084 * the root relaxation is not yet completely solved, zero is returned 1085 */ 1086 SCIP_EXPORT 1087 SCIP_Real SCIPvarGetBestRootSol( 1088 SCIP_VAR* var /**< problem variable */ 1089 ); 1090 1091 /** returns the best reduced costs (w.r.t. root reduced cost propagation) of the variable in the root node's relaxation, 1092 * if the root relaxation is not yet completely solved, or the variable was no column of the root LP, SCIP_INVALID is 1093 * returned 1094 */ 1095 SCIP_EXPORT 1096 SCIP_Real SCIPvarGetBestRootRedcost( 1097 SCIP_VAR* var /**< problem variable */ 1098 ); 1099 1100 /** returns the best objective value (w.r.t. root reduced cost propagation) of the root LP which belongs the root 1101 * reduced cost which is accessible via SCIPvarGetRootRedcost() or the variable was no column of the root LP, 1102 * SCIP_INVALID is returned 1103 */ 1104 SCIP_EXPORT 1105 SCIP_Real SCIPvarGetBestRootLPObjval( 1106 SCIP_VAR* var /**< problem variable */ 1107 ); 1108 1109 /** set the given solution as the best root solution w.r.t. root reduced cost propagation in the variables */ 1110 SCIP_EXPORT 1111 void SCIPvarSetBestRootSol( 1112 SCIP_VAR* var, /**< problem variable */ 1113 SCIP_Real rootsol, /**< root solution value */ 1114 SCIP_Real rootredcost, /**< root reduced cost */ 1115 SCIP_Real rootlpobjval /**< objective value of the root LP */ 1116 ); 1117 1118 /** returns a weighted average solution value of the variable in all feasible primal solutions found so far */ 1119 SCIP_EXPORT 1120 SCIP_Real SCIPvarGetAvgSol( 1121 SCIP_VAR* var /**< problem variable */ 1122 ); 1123 1124 /** returns the bound change information for the last lower bound change on given active problem variable before or 1125 * after the bound change with the given index was applied; 1126 * returns NULL, if no change to the lower bound was applied up to this point of time 1127 */ 1128 SCIP_EXPORT 1129 SCIP_BDCHGINFO* SCIPvarGetLbchgInfo( 1130 SCIP_VAR* var, /**< active problem variable */ 1131 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */ 1132 SCIP_Bool after /**< should the bound change with given index be included? */ 1133 ); 1134 1135 /** returns the bound change information for the last upper bound change on given active problem variable before or 1136 * after the bound change with the given index was applied; 1137 * returns NULL, if no change to the upper bound was applied up to this point of time 1138 */ 1139 SCIP_EXPORT 1140 SCIP_BDCHGINFO* SCIPvarGetUbchgInfo( 1141 SCIP_VAR* var, /**< active problem variable */ 1142 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */ 1143 SCIP_Bool after /**< should the bound change with given index be included? */ 1144 ); 1145 1146 /** returns the bound change information for the last lower or upper bound change on given active problem variable 1147 * before or after the bound change with the given index was applied; 1148 * returns NULL, if no change to the lower/upper bound was applied up to this point of time 1149 */ 1150 SCIP_EXPORT 1151 SCIP_BDCHGINFO* SCIPvarGetBdchgInfo( 1152 SCIP_VAR* var, /**< active problem variable */ 1153 SCIP_BOUNDTYPE boundtype, /**< type of bound: lower or upper bound */ 1154 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */ 1155 SCIP_Bool after /**< should the bound change with given index be included? */ 1156 ); 1157 1158 /** returns lower bound of variable directly before or after the bound change given by the bound change index 1159 * was applied 1160 * 1161 * @deprecated Please use SCIPgetVarLbAtIndex() 1162 */ 1163 SCIP_EXPORT 1164 SCIP_Real SCIPvarGetLbAtIndex( 1165 SCIP_VAR* var, /**< problem variable */ 1166 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */ 1167 SCIP_Bool after /**< should the bound change with given index be included? */ 1168 ); 1169 1170 /** returns upper bound of variable directly before or after the bound change given by the bound change index 1171 * was applied 1172 * 1173 * @deprecated Please use SCIPgetVarUbAtIndex() 1174 */ 1175 SCIP_EXPORT 1176 SCIP_Real SCIPvarGetUbAtIndex( 1177 SCIP_VAR* var, /**< problem variable */ 1178 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */ 1179 SCIP_Bool after /**< should the bound change with given index be included? */ 1180 ); 1181 1182 /** returns lower or upper bound of variable directly before or after the bound change given by the bound change index 1183 * was applied 1184 * 1185 * @deprecated Please use SCIPgetVarBdAtIndex() 1186 */ 1187 SCIP_EXPORT 1188 SCIP_Real SCIPvarGetBdAtIndex( 1189 SCIP_VAR* var, /**< problem variable */ 1190 SCIP_BOUNDTYPE boundtype, /**< type of bound: lower or upper bound */ 1191 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */ 1192 SCIP_Bool after /**< should the bound change with given index be included? */ 1193 ); 1194 1195 /** returns whether the binary variable was fixed at the time given by the bound change index 1196 * 1197 * @deprecated Please use SCIPgetVarWasFixedAtIndex() 1198 */ 1199 SCIP_EXPORT 1200 SCIP_Bool SCIPvarWasFixedAtIndex( 1201 SCIP_VAR* var, /**< problem variable */ 1202 SCIP_BDCHGIDX* bdchgidx, /**< bound change index representing time on path to current node */ 1203 SCIP_Bool after /**< should the bound change with given index be included? */ 1204 ); 1205 1206 /** returns the last bound change index, at which the bounds of the given variable were tightened */ 1207 SCIP_EXPORT 1208 SCIP_BDCHGIDX* SCIPvarGetLastBdchgIndex( 1209 SCIP_VAR* var /**< problem variable */ 1210 ); 1211 1212 /** returns the last depth level, at which the bounds of the given variable were tightened; 1213 * returns -2, if the variable's bounds are still the global bounds 1214 * returns -1, if the variable was fixed in presolving 1215 */ 1216 SCIP_EXPORT 1217 int SCIPvarGetLastBdchgDepth( 1218 SCIP_VAR* var /**< problem variable */ 1219 ); 1220 1221 /** returns whether the first binary variable was fixed earlier than the second one; 1222 * returns FALSE, if the first variable is not fixed, and returns TRUE, if the first variable is fixed, but the 1223 * second one is not fixed 1224 */ 1225 SCIP_EXPORT 1226 SCIP_Bool SCIPvarWasFixedEarlier( 1227 SCIP_VAR* var1, /**< first binary variable */ 1228 SCIP_VAR* var2 /**< second binary variable */ 1229 ); 1230 1231 /** 1232 * @name Public SCIP_BDCHGIDX Methods 1233 * 1234 * @{ 1235 */ 1236 1237 /** returns whether first bound change index belongs to an earlier applied bound change than second one; 1238 * if a bound change index is NULL, the bound change index represents the current time, i.e. the time after the 1239 * last bound change was applied to the current node 1240 */ 1241 SCIP_EXPORT 1242 SCIP_Bool SCIPbdchgidxIsEarlier( 1243 SCIP_BDCHGIDX* bdchgidx1, /**< first bound change index, or NULL */ 1244 SCIP_BDCHGIDX* bdchgidx2 /**< second bound change index, or NULL */ 1245 ); 1246 1247 /** returns whether first bound change index belongs to an earlier applied bound change than second one */ 1248 SCIP_EXPORT 1249 SCIP_Bool SCIPbdchgidxIsEarlierNonNull( 1250 SCIP_BDCHGIDX* bdchgidx1, /**< first bound change index */ 1251 SCIP_BDCHGIDX* bdchgidx2 /**< second bound change index */ 1252 ); 1253 1254 /**@} */ 1255 1256 /** 1257 * @name Public SCIP_BDCHGINFO Methods 1258 * 1259 * @{ 1260 */ 1261 1262 /** returns old bound that was overwritten for given bound change information */ 1263 SCIP_EXPORT 1264 SCIP_Real SCIPbdchginfoGetOldbound( 1265 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1266 ); 1267 1268 /** returns new bound installed for given bound change information */ 1269 SCIP_EXPORT 1270 SCIP_Real SCIPbdchginfoGetNewbound( 1271 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1272 ); 1273 1274 /** returns variable that belongs to the given bound change information */ 1275 SCIP_EXPORT 1276 SCIP_VAR* SCIPbdchginfoGetVar( 1277 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1278 ); 1279 1280 /** returns whether the bound change information belongs to a branching decision or a deduction */ 1281 SCIP_EXPORT 1282 SCIP_BOUNDCHGTYPE SCIPbdchginfoGetChgtype( 1283 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1284 ); 1285 1286 /** returns whether the bound change information belongs to a lower or upper bound change */ 1287 SCIP_EXPORT 1288 SCIP_BOUNDTYPE SCIPbdchginfoGetBoundtype( 1289 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1290 ); 1291 1292 /** returns depth level of given bound change information */ 1293 SCIP_EXPORT 1294 int SCIPbdchginfoGetDepth( 1295 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1296 ); 1297 1298 /** returns bound change position in its depth level of given bound change information */ 1299 SCIP_EXPORT 1300 int SCIPbdchginfoGetPos( 1301 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1302 ); 1303 1304 /** returns bound change index of given bound change information */ 1305 SCIP_EXPORT 1306 SCIP_BDCHGIDX* SCIPbdchginfoGetIdx( 1307 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1308 ); 1309 1310 /** returns inference variable of given bound change information */ 1311 SCIP_EXPORT 1312 SCIP_VAR* SCIPbdchginfoGetInferVar( 1313 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1314 ); 1315 1316 /** returns inference constraint of given bound change information */ 1317 SCIP_EXPORT 1318 SCIP_CONS* SCIPbdchginfoGetInferCons( 1319 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1320 ); 1321 1322 /** returns inference propagator of given bound change information, or NULL if no propagator was responsible */ 1323 SCIP_EXPORT 1324 SCIP_PROP* SCIPbdchginfoGetInferProp( 1325 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1326 ); 1327 1328 /** returns inference user information of given bound change information */ 1329 SCIP_EXPORT 1330 int SCIPbdchginfoGetInferInfo( 1331 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1332 ); 1333 1334 /** returns inference bound of inference variable of given bound change information */ 1335 SCIP_EXPORT 1336 SCIP_BOUNDTYPE SCIPbdchginfoGetInferBoundtype( 1337 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1338 ); 1339 1340 /** returns whether the bound change information belongs to a redundant bound change */ 1341 SCIP_EXPORT 1342 SCIP_Bool SCIPbdchginfoIsRedundant( 1343 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1344 ); 1345 1346 /** returns whether the bound change has an inference reason (constraint or propagator), that can be resolved */ 1347 SCIP_EXPORT 1348 SCIP_Bool SCIPbdchginfoHasInferenceReason( 1349 SCIP_BDCHGINFO* bdchginfo /**< bound change information */ 1350 ); 1351 1352 /** for two bound change informations belonging to the same variable and bound, returns whether the first bound change 1353 * has a tighter new bound as the second bound change 1354 */ 1355 SCIP_EXPORT 1356 SCIP_Bool SCIPbdchginfoIsTighter( 1357 SCIP_BDCHGINFO* bdchginfo1, /**< first bound change information */ 1358 SCIP_BDCHGINFO* bdchginfo2 /**< second bound change information */ 1359 ); 1360 1361 /**@} */ 1362 1363 /** 1364 * @name Public SCIP_BOUNDCHG Methods 1365 * 1366 * @{ 1367 */ 1368 1369 /** returns the new value of the bound in the bound change data */ 1370 SCIP_EXPORT 1371 SCIP_Real SCIPboundchgGetNewbound( 1372 SCIP_BOUNDCHG* boundchg /**< bound change data */ 1373 ); 1374 1375 /** returns the variable of the bound change in the bound change data */ 1376 SCIP_EXPORT 1377 SCIP_VAR* SCIPboundchgGetVar( 1378 SCIP_BOUNDCHG* boundchg /**< bound change data */ 1379 ); 1380 1381 /** returns the bound change type of the bound change in the bound change data */ 1382 SCIP_EXPORT 1383 SCIP_BOUNDCHGTYPE SCIPboundchgGetBoundchgtype( 1384 SCIP_BOUNDCHG* boundchg /**< bound change data */ 1385 ); 1386 1387 /** returns the bound type of the bound change in the bound change data */ 1388 SCIP_EXPORT 1389 SCIP_BOUNDTYPE SCIPboundchgGetBoundtype( 1390 SCIP_BOUNDCHG* boundchg /**< bound change data */ 1391 ); 1392 1393 /** returns whether the bound change is redundant due to a more global bound that is at least as strong */ 1394 SCIP_EXPORT 1395 SCIP_Bool SCIPboundchgIsRedundant( 1396 SCIP_BOUNDCHG* boundchg /**< bound change data */ 1397 ); 1398 1399 /** @} */ 1400 1401 /** 1402 * @name Public SCIP_DOMCHG Methods 1403 * 1404 * @{ 1405 */ 1406 1407 /** returns the number of bound changes in the domain change data */ 1408 SCIP_EXPORT 1409 int SCIPdomchgGetNBoundchgs( 1410 SCIP_DOMCHG* domchg /**< domain change data */ 1411 ); 1412 1413 /** returns a particular bound change in the domain change data */ 1414 SCIP_EXPORT 1415 SCIP_BOUNDCHG* SCIPdomchgGetBoundchg( 1416 SCIP_DOMCHG* domchg, /**< domain change data */ 1417 int pos /**< position of the bound change in the domain change data */ 1418 ); 1419 1420 /**@} */ 1421 1422 /** 1423 * @name Public SCIP_HOLELIST Methods 1424 * 1425 * @{ 1426 */ 1427 1428 /** returns left bound of open interval in hole */ 1429 SCIP_EXPORT 1430 SCIP_Real SCIPholelistGetLeft( 1431 SCIP_HOLELIST* holelist /**< hole list pointer to hole of interest */ 1432 ); 1433 1434 /** returns right bound of open interval in hole */ 1435 SCIP_EXPORT 1436 SCIP_Real SCIPholelistGetRight( 1437 SCIP_HOLELIST* holelist /**< hole list pointer to hole of interest */ 1438 ); 1439 1440 /** returns next hole in list or NULL */ 1441 SCIP_EXPORT 1442 SCIP_HOLELIST* SCIPholelistGetNext( 1443 SCIP_HOLELIST* holelist /**< hole list pointer to hole of interest */ 1444 ); 1445 1446 /**@} */ 1447 1448 #ifdef NDEBUG 1449 1450 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and 1451 * speed up the algorithms. 1452 */ 1453 1454 #define SCIPbdchgidxIsEarlierNonNull(idx1,idx2) \ 1455 ((idx1)->depth < (idx2)->depth || ((idx1)->depth == (idx2)->depth && (idx1)->pos < (idx2)->pos)) 1456 #define SCIPbdchgidxIsEarlier(idx1,idx2) \ 1457 ((idx1) != NULL && ((idx2) == NULL || SCIPbdchgidxIsEarlierNonNull(idx1, idx2))) 1458 #define SCIPbdchginfoGetOldbound(bdchginfo) (bdchginfo)->oldbound 1459 #define SCIPbdchginfoGetNewbound(bdchginfo) (bdchginfo)->newbound 1460 #define SCIPbdchginfoGetVar(bdchginfo) (bdchginfo)->var 1461 #define SCIPbdchginfoGetChgtype(bdchginfo) (SCIP_BOUNDCHGTYPE)((bdchginfo)->boundchgtype) 1462 #define SCIPbdchginfoGetBoundtype(bdchginfo) (SCIP_BOUNDTYPE)((bdchginfo)->boundtype) 1463 #define SCIPbdchginfoGetDepth(bdchginfo) (bdchginfo)->bdchgidx.depth 1464 #define SCIPbdchginfoGetPos(bdchginfo) (bdchginfo)->bdchgidx.pos 1465 #define SCIPbdchginfoGetIdx(bdchginfo) (&(bdchginfo)->bdchgidx) 1466 #define SCIPbdchginfoGetInferVar(bdchginfo) (bdchginfo)->inferencedata.var 1467 #define SCIPbdchginfoGetInferCons(bdchginfo) (bdchginfo)->inferencedata.reason.cons 1468 #define SCIPbdchginfoGetInferProp(bdchginfo) (bdchginfo)->inferencedata.reason.prop 1469 #define SCIPbdchginfoGetInferInfo(bdchginfo) (bdchginfo)->inferencedata.info 1470 #define SCIPbdchginfoGetInferBoundtype(bdchginfo) (SCIP_BOUNDTYPE)((bdchginfo)->inferboundtype) 1471 #define SCIPbdchginfoIsRedundant(bdchginfo) (bdchginfo)->redundant 1472 #define SCIPbdchginfoHasInferenceReason(bdchginfo) \ 1473 (((bdchginfo)->boundchgtype == SCIP_BOUNDCHGTYPE_CONSINFER) \ 1474 || ((bdchginfo)->boundchgtype == SCIP_BOUNDCHGTYPE_PROPINFER && (bdchginfo)->inferencedata.reason.prop != NULL)) 1475 #define SCIPbdchginfoIsTighter(bdchginfo1,bdchginfo2) ((bdchginfo1)->boundtype == SCIP_BOUNDTYPE_LOWER \ 1476 ? (bdchginfo1)->newbound > bdchginfo2->newbound : (bdchginfo1)->newbound < bdchginfo2->newbound) 1477 #define SCIPboundchgGetNewbound(boundchg) ((boundchg)->newbound) 1478 #define SCIPboundchgGetVar(boundchg) ((boundchg)->var) 1479 #define SCIPboundchgGetBoundchgtype(boundchg) ((SCIP_BOUNDCHGTYPE)((boundchg)->boundchgtype)) 1480 #define SCIPboundchgGetBoundtype(boundchg) ((SCIP_BOUNDTYPE)((boundchg)->boundtype)) 1481 #define SCIPboundchgIsRedundant(boundchg) ((boundchg)->redundant) 1482 #define SCIPdomchgGetNBoundchgs(domchg) ((domchg) != NULL ? (domchg)->domchgbound.nboundchgs : 0) 1483 #define SCIPdomchgGetBoundchg(domchg, pos) (&(domchg)->domchgbound.boundchgs[pos]) 1484 #define SCIPholelistGetLeft(holelist) ((holelist)->hole.left) 1485 #define SCIPholelistGetRight(holelist) ((holelist)->hole.right) 1486 #define SCIPholelistGetNext(holelist) ((holelist)->next) 1487 1488 #endif 1489 1490 /**@} */ 1491 1492 #ifdef __cplusplus 1493 } 1494 #endif 1495 1496 #endif 1497