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 scip_numerics.h 26 * @ingroup PUBLICCOREAPI 27 * @brief public methods for numerical tolerances 28 * @author Tobias Achterberg 29 * @author Timo Berthold 30 * @author Thorsten Koch 31 * @author Alexander Martin 32 * @author Marc Pfetsch 33 * @author Kati Wolter 34 * @author Gregor Hendel 35 * @author Leona Gottwald 36 */ 37 38 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ 39 40 #ifndef __SCIP_SCIP_NUMERICS_H__ 41 #define __SCIP_SCIP_NUMERICS_H__ 42 43 44 #include "scip/def.h" 45 #include "scip/type_retcode.h" 46 #include "scip/type_scip.h" 47 48 /* In debug mode, we include the SCIP's structure in scip.c, such that no one can access 49 * this structure except the interface methods in scip.c. 50 * In optimized mode, the structure is included in scip.h, because some of the methods 51 * are implemented as defines for performance reasons (e.g. the numerical comparisons). 52 * Additionally, the internal "set.h" is included, such that the defines in set.h are 53 * available in optimized mode. 54 */ 55 #ifdef NDEBUG 56 #include "scip/struct_scip.h" 57 #include "scip/set.h" 58 #endif 59 60 #ifdef __cplusplus 61 extern "C" { 62 #endif 63 64 /**@addtogroup PublicToleranceMethods 65 * 66 * @{ 67 */ 68 69 /** returns value treated as zero 70 * 71 * @return value treated as zero 72 */ 73 SCIP_EXPORT 74 SCIP_Real SCIPepsilon( 75 SCIP* scip /**< SCIP data structure */ 76 ); 77 78 /** returns value treated as zero for sums of floating point values 79 * 80 * @return value treated as zero for sums of floating point values 81 */ 82 SCIP_EXPORT 83 SCIP_Real SCIPsumepsilon( 84 SCIP* scip /**< SCIP data structure */ 85 ); 86 87 /** returns feasibility tolerance for constraints 88 * 89 * @return feasibility tolerance for constraints 90 */ 91 SCIP_EXPORT 92 #ifdef __GNUC__ 93 __attribute__ ((pure)) 94 #endif 95 SCIP_Real SCIPfeastol( 96 SCIP* scip /**< SCIP data structure */ 97 ); 98 99 /** returns primal feasibility tolerance of LP solver 100 * 101 * @deprecated Please use SCIPgetLPFeastol(). 102 * 103 * @return primal feasibility tolerance of LP solver 104 */ 105 SCIP_DEPRECATED 106 SCIP_EXPORT 107 SCIP_Real SCIPlpfeastol( 108 SCIP* scip /**< SCIP data structure */ 109 ); 110 111 /** returns feasibility tolerance for reduced costs 112 * 113 * @return feasibility tolerance for reduced costs 114 */ 115 SCIP_EXPORT 116 #ifdef __GNUC__ 117 __attribute__ ((pure)) 118 #endif 119 SCIP_Real SCIPdualfeastol( 120 SCIP* scip /**< SCIP data structure */ 121 ); 122 123 /** returns convergence tolerance used in barrier algorithm 124 * 125 * @return convergence tolerance used in barrier algorithm 126 */ 127 SCIP_EXPORT 128 SCIP_Real SCIPbarrierconvtol( 129 SCIP* scip /**< SCIP data structure */ 130 ); 131 132 /** return the cutoff bound delta 133 * 134 * @return cutoff bound data 135 */ 136 SCIP_EXPORT 137 SCIP_Real SCIPcutoffbounddelta( 138 SCIP* scip /**< SCIP data structure */ 139 ); 140 141 /** return the relaxation primal feasibility tolerance 142 * 143 * @see SCIPchgRelaxfeastol 144 * @return relaxfeastol 145 */ 146 SCIP_EXPORT 147 SCIP_Real SCIPrelaxfeastol( 148 SCIP* scip /**< SCIP data structure */ 149 ); 150 151 /** sets the feasibility tolerance for constraints 152 * 153 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 154 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 155 */ 156 SCIP_EXPORT 157 SCIP_RETCODE SCIPchgFeastol( 158 SCIP* scip, /**< SCIP data structure */ 159 SCIP_Real feastol /**< new feasibility tolerance for constraints */ 160 ); 161 162 /** sets the primal feasibility tolerance of LP solver 163 * 164 * @deprecated Please use SCIPsetLPFeastol(). 165 * 166 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 167 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 168 */ 169 SCIP_EXPORT 170 SCIP_DEPRECATED 171 SCIP_RETCODE SCIPchgLpfeastol( 172 SCIP* scip, /**< SCIP data structure */ 173 SCIP_Real lpfeastol, /**< new primal feasibility tolerance of LP solver */ 174 SCIP_Bool printnewvalue /**< should "numerics/lpfeastol = ..." be printed? */ 175 ); 176 177 /** sets the feasibility tolerance for reduced costs 178 * 179 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 180 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 181 */ 182 SCIP_EXPORT 183 SCIP_RETCODE SCIPchgDualfeastol( 184 SCIP* scip, /**< SCIP data structure */ 185 SCIP_Real dualfeastol /**< new feasibility tolerance for reduced costs */ 186 ); 187 188 /** sets the convergence tolerance used in barrier algorithm 189 * 190 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref 191 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes. 192 */ 193 SCIP_EXPORT 194 SCIP_RETCODE SCIPchgBarrierconvtol( 195 SCIP* scip, /**< SCIP data structure */ 196 SCIP_Real barrierconvtol /**< new convergence tolerance used in barrier algorithm */ 197 ); 198 199 /** sets the primal feasibility tolerance of relaxations 200 * 201 * This tolerance value is used by the SCIP core and plugins to tighten then feasibility tolerance on relaxations 202 * (especially the LP relaxation) during a solve. It is set to SCIP_INVALID initially, which means that only the 203 * feasibility tolerance of the particular relaxation is taken into account. If set to a valid value, however, 204 * then this value should be used to reduce the primal feasibility tolerance of a relaxation (thus, use the 205 * minimum of relaxfeastol and the relaxations primal feastol). 206 * 207 * @pre The value of relaxfeastol is reset to SCIP_INVALID when initializing the solve (INITSOL). 208 * Therefore, this method can only be called in one of the following stages of the SCIP solving process: 209 * - \ref SCIP_STAGE_INITSOLVE 210 * - \ref SCIP_STAGE_SOLVING 211 * 212 * @return previous value of relaxfeastol 213 */ 214 SCIP_EXPORT 215 SCIP_Real SCIPchgRelaxfeastol( 216 SCIP* scip, /**< SCIP data structure */ 217 SCIP_Real relaxfeastol /**< new primal feasibility tolerance of relaxations */ 218 ); 219 220 /** marks that some limit parameter was changed */ 221 SCIP_EXPORT 222 void SCIPmarkLimitChanged( 223 SCIP* scip /**< SCIP data structure */ 224 ); 225 226 /** returns value treated as infinity */ 227 SCIP_EXPORT 228 SCIP_Real SCIPinfinity( 229 SCIP* scip /**< SCIP data structure */ 230 ); 231 232 /** returns the minimum value that is regarded as huge and should be handled separately (e.g., in activity 233 * computation) 234 */ 235 SCIP_EXPORT 236 SCIP_Real SCIPgetHugeValue( 237 SCIP* scip /**< SCIP data structure */ 238 ); 239 240 /** checks, if values are in range of epsilon */ 241 SCIP_EXPORT 242 SCIP_Bool SCIPisEQ( 243 SCIP* scip, /**< SCIP data structure */ 244 SCIP_Real val1, /**< first value to be compared */ 245 SCIP_Real val2 /**< second value to be compared */ 246 ); 247 248 /** checks, if val1 is (more than epsilon) lower than val2 */ 249 SCIP_EXPORT 250 SCIP_Bool SCIPisLT( 251 SCIP* scip, /**< SCIP data structure */ 252 SCIP_Real val1, /**< first value to be compared */ 253 SCIP_Real val2 /**< second value to be compared */ 254 ); 255 256 /** checks, if val1 is not (more than epsilon) greater than val2 */ 257 SCIP_EXPORT 258 SCIP_Bool SCIPisLE( 259 SCIP* scip, /**< SCIP data structure */ 260 SCIP_Real val1, /**< first value to be compared */ 261 SCIP_Real val2 /**< second value to be compared */ 262 ); 263 264 /** checks, if val1 is (more than epsilon) greater than val2 */ 265 SCIP_EXPORT 266 SCIP_Bool SCIPisGT( 267 SCIP* scip, /**< SCIP data structure */ 268 SCIP_Real val1, /**< first value to be compared */ 269 SCIP_Real val2 /**< second value to be compared */ 270 ); 271 272 /** checks, if val1 is not (more than epsilon) lower than val2 */ 273 SCIP_EXPORT 274 SCIP_Bool SCIPisGE( 275 SCIP* scip, /**< SCIP data structure */ 276 SCIP_Real val1, /**< first value to be compared */ 277 SCIP_Real val2 /**< second value to be compared */ 278 ); 279 280 /** checks, if value is (positive) infinite */ 281 SCIP_EXPORT 282 SCIP_Bool SCIPisInfinity( 283 SCIP* scip, /**< SCIP data structure */ 284 SCIP_Real val /**< value to be compared against infinity */ 285 ); 286 287 /** checks, if value is huge and should be handled separately (e.g., in activity computation) */ 288 SCIP_EXPORT 289 SCIP_Bool SCIPisHugeValue( 290 SCIP* scip, /**< SCIP data structure */ 291 SCIP_Real val /**< value to be checked whether it is huge */ 292 ); 293 294 /** checks, if value is in range epsilon of 0.0 */ 295 SCIP_EXPORT 296 SCIP_Bool SCIPisZero( 297 SCIP* scip, /**< SCIP data structure */ 298 SCIP_Real val /**< value to process */ 299 ); 300 301 /** checks, if value is greater than epsilon */ 302 SCIP_EXPORT 303 SCIP_Bool SCIPisPositive( 304 SCIP* scip, /**< SCIP data structure */ 305 SCIP_Real val /**< value to process */ 306 ); 307 308 /** checks, if value is lower than -epsilon */ 309 SCIP_EXPORT 310 SCIP_Bool SCIPisNegative( 311 SCIP* scip, /**< SCIP data structure */ 312 SCIP_Real val /**< value to process */ 313 ); 314 315 /** checks, if value is integral within epsilon */ 316 SCIP_EXPORT 317 SCIP_Bool SCIPisIntegral( 318 SCIP* scip, /**< SCIP data structure */ 319 SCIP_Real val /**< value to process */ 320 ); 321 322 /** checks whether the product val * scalar is integral in epsilon scaled by scalar */ 323 SCIP_EXPORT 324 SCIP_Bool SCIPisScalingIntegral( 325 SCIP* scip, /**< SCIP data structure */ 326 SCIP_Real val, /**< unscaled value to check for scaled integrality */ 327 SCIP_Real scalar /**< value to scale val with for checking for integrality */ 328 ); 329 330 /** checks, if given fractional part is smaller than epsilon */ 331 SCIP_EXPORT 332 SCIP_Bool SCIPisFracIntegral( 333 SCIP* scip, /**< SCIP data structure */ 334 SCIP_Real val /**< value to process */ 335 ); 336 337 /** rounds value + epsilon down to the next integer */ 338 SCIP_EXPORT 339 SCIP_Real SCIPfloor( 340 SCIP* scip, /**< SCIP data structure */ 341 SCIP_Real val /**< value to process */ 342 ); 343 344 /** rounds value - epsilon up to the next integer */ 345 SCIP_EXPORT 346 SCIP_Real SCIPceil( 347 SCIP* scip, /**< SCIP data structure */ 348 SCIP_Real val /**< value to process */ 349 ); 350 351 /** rounds value to the nearest integer with epsilon tolerance */ 352 SCIP_EXPORT 353 SCIP_Real SCIPround( 354 SCIP* scip, /**< SCIP data structure */ 355 SCIP_Real val /**< value to process */ 356 ); 357 358 /** returns fractional part of value, i.e. x - floor(x) in epsilon tolerance */ 359 SCIP_EXPORT 360 SCIP_Real SCIPfrac( 361 SCIP* scip, /**< SCIP data structure */ 362 SCIP_Real val /**< value to return fractional part for */ 363 ); 364 365 /** checks, if values are in range of sumepsilon */ 366 SCIP_EXPORT 367 SCIP_Bool SCIPisSumEQ( 368 SCIP* scip, /**< SCIP data structure */ 369 SCIP_Real val1, /**< first value to be compared */ 370 SCIP_Real val2 /**< second value to be compared */ 371 ); 372 373 /** checks, if val1 is (more than sumepsilon) lower than val2 */ 374 SCIP_EXPORT 375 SCIP_Bool SCIPisSumLT( 376 SCIP* scip, /**< SCIP data structure */ 377 SCIP_Real val1, /**< first value to be compared */ 378 SCIP_Real val2 /**< second value to be compared */ 379 ); 380 381 /** checks, if val1 is not (more than sumepsilon) greater than val2 */ 382 SCIP_EXPORT 383 SCIP_Bool SCIPisSumLE( 384 SCIP* scip, /**< SCIP data structure */ 385 SCIP_Real val1, /**< first value to be compared */ 386 SCIP_Real val2 /**< second value to be compared */ 387 ); 388 389 /** checks, if val1 is (more than sumepsilon) greater than val2 */ 390 SCIP_EXPORT 391 SCIP_Bool SCIPisSumGT( 392 SCIP* scip, /**< SCIP data structure */ 393 SCIP_Real val1, /**< first value to be compared */ 394 SCIP_Real val2 /**< second value to be compared */ 395 ); 396 397 /** checks, if val1 is not (more than sumepsilon) lower than val2 */ 398 SCIP_EXPORT 399 SCIP_Bool SCIPisSumGE( 400 SCIP* scip, /**< SCIP data structure */ 401 SCIP_Real val1, /**< first value to be compared */ 402 SCIP_Real val2 /**< second value to be compared */ 403 ); 404 405 /** checks, if value is in range sumepsilon of 0.0 */ 406 SCIP_EXPORT 407 SCIP_Bool SCIPisSumZero( 408 SCIP* scip, /**< SCIP data structure */ 409 SCIP_Real val /**< value to process */ 410 ); 411 412 /** checks, if value is greater than sumepsilon */ 413 SCIP_EXPORT 414 SCIP_Bool SCIPisSumPositive( 415 SCIP* scip, /**< SCIP data structure */ 416 SCIP_Real val /**< value to process */ 417 ); 418 419 /** checks, if value is lower than -sumepsilon */ 420 SCIP_EXPORT 421 SCIP_Bool SCIPisSumNegative( 422 SCIP* scip, /**< SCIP data structure */ 423 SCIP_Real val /**< value to process */ 424 ); 425 426 /** checks, if relative difference of values is in range of feasibility tolerance */ 427 SCIP_EXPORT 428 SCIP_Bool SCIPisFeasEQ( 429 SCIP* scip, /**< SCIP data structure */ 430 SCIP_Real val1, /**< first value to be compared */ 431 SCIP_Real val2 /**< second value to be compared */ 432 ); 433 434 /** checks, if relative difference val1 and val2 is lower than feasibility tolerance */ 435 SCIP_EXPORT 436 SCIP_Bool SCIPisFeasLT( 437 SCIP* scip, /**< SCIP data structure */ 438 SCIP_Real val1, /**< first value to be compared */ 439 SCIP_Real val2 /**< second value to be compared */ 440 ); 441 442 /** checks, if relative difference of val1 and val2 is not greater than feasibility tolerance */ 443 SCIP_EXPORT 444 SCIP_Bool SCIPisFeasLE( 445 SCIP* scip, /**< SCIP data structure */ 446 SCIP_Real val1, /**< first value to be compared */ 447 SCIP_Real val2 /**< second value to be compared */ 448 ); 449 450 /** checks, if relative difference of val1 and val2 is greater than feastol */ 451 SCIP_EXPORT 452 SCIP_Bool SCIPisFeasGT( 453 SCIP* scip, /**< SCIP data structure */ 454 SCIP_Real val1, /**< first value to be compared */ 455 SCIP_Real val2 /**< second value to be compared */ 456 ); 457 458 /** checks, if relative difference of val1 and val2 is not lower than -feastol */ 459 SCIP_EXPORT 460 SCIP_Bool SCIPisFeasGE( 461 SCIP* scip, /**< SCIP data structure */ 462 SCIP_Real val1, /**< first value to be compared */ 463 SCIP_Real val2 /**< second value to be compared */ 464 ); 465 466 /** checks, if value is in range feasibility tolerance of 0.0 */ 467 SCIP_EXPORT 468 SCIP_Bool SCIPisFeasZero( 469 SCIP* scip, /**< SCIP data structure */ 470 SCIP_Real val /**< value to process */ 471 ); 472 473 /** checks, if value is greater than feasibility tolerance */ 474 SCIP_EXPORT 475 SCIP_Bool SCIPisFeasPositive( 476 SCIP* scip, /**< SCIP data structure */ 477 SCIP_Real val /**< value to process */ 478 ); 479 480 /** checks, if value is lower than -feasibility tolerance */ 481 SCIP_EXPORT 482 SCIP_Bool SCIPisFeasNegative( 483 SCIP* scip, /**< SCIP data structure */ 484 SCIP_Real val /**< value to process */ 485 ); 486 487 /** checks, if value is integral within the LP feasibility bounds */ 488 SCIP_EXPORT 489 SCIP_Bool SCIPisFeasIntegral( 490 SCIP* scip, /**< SCIP data structure */ 491 SCIP_Real val /**< value to process */ 492 ); 493 494 /** checks, if given fractional part is smaller than feastol */ 495 SCIP_EXPORT 496 SCIP_Bool SCIPisFeasFracIntegral( 497 SCIP* scip, /**< SCIP data structure */ 498 SCIP_Real val /**< value to process */ 499 ); 500 501 /** rounds value + feasibility tolerance down to the next integer */ 502 SCIP_EXPORT 503 SCIP_Real SCIPfeasFloor( 504 SCIP* scip, /**< SCIP data structure */ 505 SCIP_Real val /**< value to process */ 506 ); 507 508 /** rounds value - feasibility tolerance up to the next integer */ 509 SCIP_EXPORT 510 SCIP_Real SCIPfeasCeil( 511 SCIP* scip, /**< SCIP data structure */ 512 SCIP_Real val /**< value to process */ 513 ); 514 515 /** rounds value to the nearest integer in feasibility tolerance */ 516 SCIP_EXPORT 517 SCIP_Real SCIPfeasRound( 518 SCIP* scip, /**< SCIP data structure */ 519 SCIP_Real val /**< value to process */ 520 ); 521 522 /** returns fractional part of value, i.e. x - floor(x) */ 523 SCIP_EXPORT 524 SCIP_Real SCIPfeasFrac( 525 SCIP* scip, /**< SCIP data structure */ 526 SCIP_Real val /**< value to process */ 527 ); 528 529 /** checks, if relative difference of values is in range of dual feasibility tolerance */ 530 SCIP_EXPORT 531 SCIP_Bool SCIPisDualfeasEQ( 532 SCIP* scip, /**< SCIP data structure */ 533 SCIP_Real val1, /**< first value to be compared */ 534 SCIP_Real val2 /**< second value to be compared */ 535 ); 536 537 /** checks, if relative difference val1 and val2 is lower than dual feasibility tolerance */ 538 SCIP_EXPORT 539 SCIP_Bool SCIPisDualfeasLT( 540 SCIP* scip, /**< SCIP data structure */ 541 SCIP_Real val1, /**< first value to be compared */ 542 SCIP_Real val2 /**< second value to be compared */ 543 ); 544 545 /** checks, if relative difference of val1 and val2 is not greater than dual feasibility tolerance */ 546 SCIP_EXPORT 547 SCIP_Bool SCIPisDualfeasLE( 548 SCIP* scip, /**< SCIP data structure */ 549 SCIP_Real val1, /**< first value to be compared */ 550 SCIP_Real val2 /**< second value to be compared */ 551 ); 552 553 /** checks, if relative difference of val1 and val2 is greater than dual feasibility tolerance */ 554 SCIP_EXPORT 555 SCIP_Bool SCIPisDualfeasGT( 556 SCIP* scip, /**< SCIP data structure */ 557 SCIP_Real val1, /**< first value to be compared */ 558 SCIP_Real val2 /**< second value to be compared */ 559 ); 560 561 /** checks, if relative difference of val1 and val2 is not lower than -dual feasibility tolerance */ 562 SCIP_EXPORT 563 SCIP_Bool SCIPisDualfeasGE( 564 SCIP* scip, /**< SCIP data structure */ 565 SCIP_Real val1, /**< first value to be compared */ 566 SCIP_Real val2 /**< second value to be compared */ 567 ); 568 569 /** checks, if value is in range dual feasibility tolerance of 0.0 */ 570 SCIP_EXPORT 571 SCIP_Bool SCIPisDualfeasZero( 572 SCIP* scip, /**< SCIP data structure */ 573 SCIP_Real val /**< value to process */ 574 ); 575 576 /** checks, if value is greater than dual feasibility tolerance */ 577 SCIP_EXPORT 578 SCIP_Bool SCIPisDualfeasPositive( 579 SCIP* scip, /**< SCIP data structure */ 580 SCIP_Real val /**< value to process */ 581 ); 582 583 /** checks, if value is lower than -dual feasibility tolerance */ 584 SCIP_EXPORT 585 SCIP_Bool SCIPisDualfeasNegative( 586 SCIP* scip, /**< SCIP data structure */ 587 SCIP_Real val /**< value to process */ 588 ); 589 590 /** checks, if value is integral within the LP dual feasibility tolerance */ 591 SCIP_EXPORT 592 SCIP_Bool SCIPisDualfeasIntegral( 593 SCIP* scip, /**< SCIP data structure */ 594 SCIP_Real val /**< value to process */ 595 ); 596 597 /** checks, if given fractional part is smaller than dual feasibility tolerance */ 598 SCIP_EXPORT 599 SCIP_Bool SCIPisDualfeasFracIntegral( 600 SCIP* scip, /**< SCIP data structure */ 601 SCIP_Real val /**< value to process */ 602 ); 603 604 /** rounds value + dual feasibility tolerance down to the next integer */ 605 SCIP_EXPORT 606 SCIP_Real SCIPdualfeasFloor( 607 SCIP* scip, /**< SCIP data structure */ 608 SCIP_Real val /**< value to process */ 609 ); 610 611 /** rounds value - dual feasibility tolerance up to the next integer */ 612 SCIP_EXPORT 613 SCIP_Real SCIPdualfeasCeil( 614 SCIP* scip, /**< SCIP data structure */ 615 SCIP_Real val /**< value to process */ 616 ); 617 618 /** rounds value to the nearest integer in dual feasibility tolerance */ 619 SCIP_EXPORT 620 SCIP_Real SCIPdualfeasRound( 621 SCIP* scip, /**< SCIP data structure */ 622 SCIP_Real val /**< value to process */ 623 ); 624 625 /** returns fractional part of value, i.e. x - floor(x) in dual feasibility tolerance */ 626 SCIP_EXPORT 627 SCIP_Real SCIPdualfeasFrac( 628 SCIP* scip, /**< SCIP data structure */ 629 SCIP_Real val /**< value to process */ 630 ); 631 632 /** checks, if the given new lower bound is tighter (w.r.t. bound strengthening epsilon) than the old one */ 633 SCIP_EXPORT 634 SCIP_Bool SCIPisLbBetter( 635 SCIP* scip, /**< SCIP data structure */ 636 SCIP_Real newlb, /**< new lower bound */ 637 SCIP_Real oldlb, /**< old lower bound */ 638 SCIP_Real oldub /**< old upper bound */ 639 ); 640 641 /** checks, if the given new upper bound is tighter (w.r.t. bound strengthening epsilon) than the old one */ 642 SCIP_EXPORT 643 SCIP_Bool SCIPisUbBetter( 644 SCIP* scip, /**< SCIP data structure */ 645 SCIP_Real newub, /**< new upper bound */ 646 SCIP_Real oldlb, /**< old lower bound */ 647 SCIP_Real oldub /**< old upper bound */ 648 ); 649 650 /** checks, if relative difference of values is in range of epsilon */ 651 SCIP_EXPORT 652 SCIP_Bool SCIPisRelEQ( 653 SCIP* scip, /**< SCIP data structure */ 654 SCIP_Real val1, /**< first value to be compared */ 655 SCIP_Real val2 /**< second value to be compared */ 656 ); 657 658 /** checks, if relative difference of val1 and val2 is lower than epsilon */ 659 SCIP_EXPORT 660 SCIP_Bool SCIPisRelLT( 661 SCIP* scip, /**< SCIP data structure */ 662 SCIP_Real val1, /**< first value to be compared */ 663 SCIP_Real val2 /**< second value to be compared */ 664 ); 665 666 /** checks, if relative difference of val1 and val2 is not greater than epsilon */ 667 SCIP_EXPORT 668 SCIP_Bool SCIPisRelLE( 669 SCIP* scip, /**< SCIP data structure */ 670 SCIP_Real val1, /**< first value to be compared */ 671 SCIP_Real val2 /**< second value to be compared */ 672 ); 673 674 /** checks, if relative difference of val1 and val2 is greater than epsilon */ 675 SCIP_EXPORT 676 SCIP_Bool SCIPisRelGT( 677 SCIP* scip, /**< SCIP data structure */ 678 SCIP_Real val1, /**< first value to be compared */ 679 SCIP_Real val2 /**< second value to be compared */ 680 ); 681 682 /** checks, if relative difference of val1 and val2 is not lower than -epsilon */ 683 SCIP_EXPORT 684 SCIP_Bool SCIPisRelGE( 685 SCIP* scip, /**< SCIP data structure */ 686 SCIP_Real val1, /**< first value to be compared */ 687 SCIP_Real val2 /**< second value to be compared */ 688 ); 689 690 /** checks, if relative difference of values is in range of sumepsilon */ 691 SCIP_EXPORT 692 SCIP_Bool SCIPisSumRelEQ( 693 SCIP* scip, /**< SCIP data structure */ 694 SCIP_Real val1, /**< first value to be compared */ 695 SCIP_Real val2 /**< second value to be compared */ 696 ); 697 698 /** checks, if relative difference of val1 and val2 is lower than sumepsilon */ 699 SCIP_EXPORT 700 SCIP_Bool SCIPisSumRelLT( 701 SCIP* scip, /**< SCIP data structure */ 702 SCIP_Real val1, /**< first value to be compared */ 703 SCIP_Real val2 /**< second value to be compared */ 704 ); 705 706 /** checks, if relative difference of val1 and val2 is not greater than sumepsilon */ 707 SCIP_EXPORT 708 SCIP_Bool SCIPisSumRelLE( 709 SCIP* scip, /**< SCIP data structure */ 710 SCIP_Real val1, /**< first value to be compared */ 711 SCIP_Real val2 /**< second value to be compared */ 712 ); 713 714 /** checks, if relative difference of val1 and val2 is greater than sumepsilon */ 715 SCIP_EXPORT 716 SCIP_Bool SCIPisSumRelGT( 717 SCIP* scip, /**< SCIP data structure */ 718 SCIP_Real val1, /**< first value to be compared */ 719 SCIP_Real val2 /**< second value to be compared */ 720 ); 721 722 /**! [SnippetCodeStyleNaming] */ 723 724 /** checks, if relative difference of val1 and val2 is not lower than -sumepsilon */ 725 SCIP_EXPORT 726 SCIP_Bool SCIPisSumRelGE( 727 SCIP* scip, /**< SCIP data structure */ 728 SCIP_Real val1, /**< first value to be compared */ 729 SCIP_Real val2 /**< second value to be compared */ 730 ); 731 732 /** converts the given real number representing an integer to an int; in optimized mode the function gets inlined for 733 * performance; in debug mode we check some additional conditions 734 */ 735 SCIP_EXPORT 736 int SCIPconvertRealToInt( 737 SCIP* scip, /**< SCIP data structure */ 738 SCIP_Real real /**< double bound to convert */ 739 ); 740 741 /**! [SnippetCodeStyleNaming] */ 742 743 /** converts the given real number representing an integer to a long integer; in optimized mode the function gets inlined for 744 * performance; in debug mode we check some additional conditions 745 */ 746 SCIP_EXPORT 747 SCIP_Longint SCIPconvertRealToLongint( 748 SCIP* scip, /**< SCIP data structure */ 749 SCIP_Real real /**< double bound to convert */ 750 ); 751 752 /** Checks, if an iteratively updated value is reliable or should be recomputed from scratch. 753 * This is useful, if the value, e.g., the activity of a linear constraint or the pseudo objective value, gets a high 754 * absolute value during the optimization process which is later reduced significantly. In this case, the last digits 755 * were canceled out when increasing the value and are random after decreasing it. 756 * We do not consider the cancellations which can occur during increasing the absolute value because they just cannot 757 * be expressed using fixed precision floating point arithmetic, anymore. 758 * In order to get more reliable values, the idea is to always store the last reliable value, where increasing the 759 * absolute of the value is viewed as preserving reliability. Then, after each update, the new absolute value can be 760 * compared against the last reliable one with this method, checking whether it was decreased by a factor of at least 761 * "lp/recompfac" and should be recomputed. 762 */ 763 SCIP_EXPORT 764 SCIP_Bool SCIPisUpdateUnreliable( 765 SCIP* scip, /**< SCIP data structure */ 766 SCIP_Real newvalue, /**< new value after update */ 767 SCIP_Real oldvalue /**< old value, i.e., last reliable value */ 768 ); 769 770 #ifdef NDEBUG 771 772 /* In optimized mode, the function calls are overwritten by defines to reduce the number of function calls and 773 * speed up the algorithms. 774 */ 775 776 #define SCIPinfinity(scip) SCIPsetInfinity((scip)->set) 777 #define SCIPisInfinity(scip, val) SCIPsetIsInfinity((scip)->set, val) 778 #define SCIPisHugeValue(scip, val) SCIPsetIsHugeValue((scip)->set, val) 779 #define SCIPgetHugeValue(scip) SCIPsetGetHugeValue((scip)->set) 780 #define SCIPisEQ(scip, val1, val2) SCIPsetIsEQ((scip)->set, val1, val2) 781 #define SCIPisLT(scip, val1, val2) SCIPsetIsLT((scip)->set, val1, val2) 782 #define SCIPisLE(scip, val1, val2) SCIPsetIsLE((scip)->set, val1, val2) 783 #define SCIPisGT(scip, val1, val2) SCIPsetIsGT((scip)->set, val1, val2) 784 #define SCIPisGE(scip, val1, val2) SCIPsetIsGE((scip)->set, val1, val2) 785 #define SCIPisZero(scip, val) SCIPsetIsZero((scip)->set, val) 786 #define SCIPisPositive(scip, val) SCIPsetIsPositive((scip)->set, val) 787 #define SCIPisNegative(scip, val) SCIPsetIsNegative((scip)->set, val) 788 #define SCIPisIntegral(scip, val) SCIPsetIsIntegral((scip)->set, val) 789 #define SCIPisScalingIntegral(scip, val, scalar) SCIPsetIsScalingIntegral((scip)->set, val, scalar) 790 #define SCIPisFracIntegral(scip, val) SCIPsetIsFracIntegral((scip)->set, val) 791 #define SCIPfloor(scip, val) SCIPsetFloor((scip)->set, val) 792 #define SCIPceil(scip, val) SCIPsetCeil((scip)->set, val) 793 #define SCIPround(scip, val) SCIPsetRound((scip)->set, val) 794 #define SCIPfrac(scip, val) SCIPsetFrac((scip)->set, val) 795 796 #define SCIPisSumEQ(scip, val1, val2) SCIPsetIsSumEQ((scip)->set, val1, val2) 797 #define SCIPisSumLT(scip, val1, val2) SCIPsetIsSumLT((scip)->set, val1, val2) 798 #define SCIPisSumLE(scip, val1, val2) SCIPsetIsSumLE((scip)->set, val1, val2) 799 #define SCIPisSumGT(scip, val1, val2) SCIPsetIsSumGT((scip)->set, val1, val2) 800 #define SCIPisSumGE(scip, val1, val2) SCIPsetIsSumGE((scip)->set, val1, val2) 801 #define SCIPisSumZero(scip, val) SCIPsetIsSumZero((scip)->set, val) 802 #define SCIPisSumPositive(scip, val) SCIPsetIsSumPositive((scip)->set, val) 803 #define SCIPisSumNegative(scip, val) SCIPsetIsSumNegative((scip)->set, val) 804 805 #define SCIPisFeasEQ(scip, val1, val2) SCIPsetIsFeasEQ((scip)->set, val1, val2) 806 #define SCIPisFeasLT(scip, val1, val2) SCIPsetIsFeasLT((scip)->set, val1, val2) 807 #define SCIPisFeasLE(scip, val1, val2) SCIPsetIsFeasLE((scip)->set, val1, val2) 808 #define SCIPisFeasGT(scip, val1, val2) SCIPsetIsFeasGT((scip)->set, val1, val2) 809 #define SCIPisFeasGE(scip, val1, val2) SCIPsetIsFeasGE((scip)->set, val1, val2) 810 #define SCIPisFeasZero(scip, val) SCIPsetIsFeasZero((scip)->set, val) 811 #define SCIPisFeasPositive(scip, val) SCIPsetIsFeasPositive((scip)->set, val) 812 #define SCIPisFeasNegative(scip, val) SCIPsetIsFeasNegative((scip)->set, val) 813 #define SCIPisFeasIntegral(scip, val) SCIPsetIsFeasIntegral((scip)->set, val) 814 #define SCIPisFeasFracIntegral(scip, val) SCIPsetIsFeasFracIntegral((scip)->set, val) 815 #define SCIPfeasFloor(scip, val) SCIPsetFeasFloor((scip)->set, val) 816 #define SCIPfeasCeil(scip, val) SCIPsetFeasCeil((scip)->set, val) 817 #define SCIPfeasRound(scip, val) SCIPsetFeasRound((scip)->set, val) 818 #define SCIPfeasFrac(scip, val) SCIPsetFeasFrac((scip)->set, val) 819 820 #define SCIPisDualfeasEQ(scip, val1, val2) SCIPsetIsDualfeasEQ((scip)->set, val1, val2) 821 #define SCIPisDualfeasLT(scip, val1, val2) SCIPsetIsDualfeasLT((scip)->set, val1, val2) 822 #define SCIPisDualfeasLE(scip, val1, val2) SCIPsetIsDualfeasLE((scip)->set, val1, val2) 823 #define SCIPisDualfeasGT(scip, val1, val2) SCIPsetIsDualfeasGT((scip)->set, val1, val2) 824 #define SCIPisDualfeasGE(scip, val1, val2) SCIPsetIsDualfeasGE((scip)->set, val1, val2) 825 #define SCIPisDualfeasZero(scip, val) SCIPsetIsDualfeasZero((scip)->set, val) 826 #define SCIPisDualfeasPositive(scip, val) SCIPsetIsDualfeasPositive((scip)->set, val) 827 #define SCIPisDualfeasNegative(scip, val) SCIPsetIsDualfeasNegative((scip)->set, val) 828 #define SCIPisDualfeasIntegral(scip, val) SCIPsetIsDualfeasIntegral((scip)->set, val) 829 #define SCIPisDualfeasFracIntegral(scip, val) SCIPsetIsDualfeasFracIntegral((scip)->set, val) 830 #define SCIPdualfeasFloor(scip, val) SCIPsetDualfeasFloor((scip)->set, val) 831 #define SCIPdualfeasCeil(scip, val) SCIPsetDualfeasCeil((scip)->set, val) 832 #define SCIPdualfeasRound(scip, val) SCIPsetDualfeasRound((scip)->set, val) 833 #define SCIPdualfeasFrac(scip, val) SCIPsetDualfeasFrac((scip)->set, val) 834 835 #define SCIPisLbBetter(scip, newlb, oldlb, oldub) SCIPsetIsLbBetter(scip->set, newlb, oldlb, oldub) 836 #define SCIPisUbBetter(scip, newub, oldlb, oldub) SCIPsetIsUbBetter(scip->set, newub, oldlb, oldub) 837 838 #define SCIPisRelEQ(scip, val1, val2) SCIPsetIsRelEQ((scip)->set, val1, val2) 839 #define SCIPisRelLT(scip, val1, val2) SCIPsetIsRelLT((scip)->set, val1, val2) 840 #define SCIPisRelLE(scip, val1, val2) SCIPsetIsRelLE((scip)->set, val1, val2) 841 #define SCIPisRelGT(scip, val1, val2) SCIPsetIsRelGT((scip)->set, val1, val2) 842 #define SCIPisRelGE(scip, val1, val2) SCIPsetIsRelGE((scip)->set, val1, val2) 843 844 #define SCIPisSumRelEQ(scip, val1, val2) SCIPsetIsSumRelEQ((scip)->set, val1, val2) 845 #define SCIPisSumRelLT(scip, val1, val2) SCIPsetIsSumRelLT((scip)->set, val1, val2) 846 #define SCIPisSumRelLE(scip, val1, val2) SCIPsetIsSumRelLE((scip)->set, val1, val2) 847 #define SCIPisSumRelGT(scip, val1, val2) SCIPsetIsSumRelGT((scip)->set, val1, val2) 848 #define SCIPisSumRelGE(scip, val1, val2) SCIPsetIsSumRelGE((scip)->set, val1, val2) 849 #define SCIPconvertRealToInt(scip, real) ((int)((real) < 0 ? ((real) - 0.5) : ((real) + 0.5))) 850 #define SCIPconvertRealToLongint(scip, real) ((SCIP_Longint)((real) < 0 ? ((real) - 0.5) : ((real) + 0.5))) 851 852 #define SCIPisUpdateUnreliable(scip, newval, oldval) SCIPsetIsUpdateUnreliable((scip)->set, newval, oldval) 853 854 #endif 855 856 /** outputs a real number, or "+infinity", or "-infinity" to a file */ 857 SCIP_EXPORT 858 void SCIPprintReal( 859 SCIP* scip, /**< SCIP data structure */ 860 FILE* file, /**< output file (or NULL for standard output) */ 861 SCIP_Real val, /**< value to print */ 862 int width, /**< width of the field */ 863 int precision /**< number of significant digits printed */ 864 ); 865 866 /** parse a real value that was written with SCIPprintReal() */ 867 SCIP_EXPORT 868 SCIP_Bool SCIPparseReal( 869 SCIP* scip, /**< SCIP data structure */ 870 const char* str, /**< string to search */ 871 SCIP_Real* value, /**< pointer to store the parsed value */ 872 char** endptr /**< pointer to store the final string position if successfully parsed, otherwise @p str */ 873 ); 874 875 /**@} */ 876 877 #ifdef __cplusplus 878 } 879 #endif 880 881 #endif 882