1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the program and library */
4 /* SCIP --- Solving Constraint Integer Programs */
5 /* */
6 /* Copyright (C) 2002-2021 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SCIP is distributed under the terms of the ZIB Academic License. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SCIP; see the file COPYING. If not visit scipopt.org. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15
16 /**@file scip_numerics.c
17 * @ingroup OTHER_CFILES
18 * @brief public methods for numerical tolerances
19 * @author Tobias Achterberg
20 * @author Timo Berthold
21 * @author Gerald Gamrath
22 * @author Leona Gottwald
23 * @author Stefan Heinz
24 * @author Gregor Hendel
25 * @author Thorsten Koch
26 * @author Alexander Martin
27 * @author Marc Pfetsch
28 * @author Michael Winkler
29 * @author Kati Wolter
30 *
31 * @todo check all SCIP_STAGE_* switches, and include the new stages TRANSFORMED and INITSOLVE
32 */
33
34 /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
35
36 #include <ctype.h>
37 #include "scip/debug.h"
38 #include "scip/pub_message.h"
39 #include "scip/pub_misc.h"
40 #include "scip/scip_numerics.h"
41 #include "scip/set.h"
42 #include "scip/struct_lp.h"
43 #include "scip/struct_scip.h"
44 #include "scip/scip_lp.h"
45 #include "scip/scip_message.h"
46 #include <string.h>
47
48
49 /* In debug mode, the following methods are implemented as function calls to ensure
50 * type validity.
51 * In optimized mode, the methods are implemented as defines to improve performance.
52 * However, we want to have them in the library anyways, so we have to undef the defines.
53 */
54
55 #undef SCIPinfinity
56 #undef SCIPisInfinity
57 #undef SCIPisEQ
58 #undef SCIPisLT
59 #undef SCIPisLE
60 #undef SCIPisGT
61 #undef SCIPisGE
62 #undef SCIPisZero
63 #undef SCIPisPositive
64 #undef SCIPisNegative
65 #undef SCIPisIntegral
66 #undef SCIPisScalingIntegral
67 #undef SCIPisFracIntegral
68 #undef SCIPfloor
69 #undef SCIPceil
70 #undef SCIPround
71 #undef SCIPfrac
72 #undef SCIPisSumEQ
73 #undef SCIPisSumLT
74 #undef SCIPisSumLE
75 #undef SCIPisSumGT
76 #undef SCIPisSumGE
77 #undef SCIPisSumZero
78 #undef SCIPisSumPositive
79 #undef SCIPisSumNegative
80 #undef SCIPisFeasEQ
81 #undef SCIPisFeasLT
82 #undef SCIPisFeasLE
83 #undef SCIPisFeasGT
84 #undef SCIPisFeasGE
85 #undef SCIPisFeasZero
86 #undef SCIPisFeasPositive
87 #undef SCIPisFeasNegative
88 #undef SCIPisFeasIntegral
89 #undef SCIPisFeasFracIntegral
90 #undef SCIPfeasFloor
91 #undef SCIPfeasCeil
92 #undef SCIPfeasRound
93 #undef SCIPfeasFrac
94 #undef SCIPisDualfeasEQ
95 #undef SCIPisDualfeasLT
96 #undef SCIPisDualfeasLE
97 #undef SCIPisDualfeasGT
98 #undef SCIPisDualfeasGE
99 #undef SCIPisDualfeasZero
100 #undef SCIPisDualfeasPositive
101 #undef SCIPisDualfeasNegative
102 #undef SCIPisDualfeasIntegral
103 #undef SCIPisDualfeasFracIntegral
104 #undef SCIPdualfeasFloor
105 #undef SCIPdualfeasCeil
106 #undef SCIPdualfeasRound
107 #undef SCIPdualfeasFrac
108 #undef SCIPisLbBetter
109 #undef SCIPisUbBetter
110 #undef SCIPisRelEQ
111 #undef SCIPisRelLT
112 #undef SCIPisRelLE
113 #undef SCIPisRelGT
114 #undef SCIPisRelGE
115 #undef SCIPisSumRelEQ
116 #undef SCIPisSumRelLT
117 #undef SCIPisSumRelLE
118 #undef SCIPisSumRelGT
119 #undef SCIPisSumRelGE
120 #undef SCIPconvertRealToInt
121 #undef SCIPconvertRealToLongint
122 #undef SCIPisUpdateUnreliable
123 #undef SCIPisHugeValue
124 #undef SCIPgetHugeValue
125
126 /** returns value treated as zero
127 *
128 * @return value treated as zero
129 */
SCIPepsilon(SCIP * scip)130 SCIP_Real SCIPepsilon(
131 SCIP* scip /**< SCIP data structure */
132 )
133 {
134 assert(scip != NULL);
135 assert(scip->set != NULL);
136
137 return SCIPsetEpsilon(scip->set);
138 }
139
140 /** returns value treated as zero for sums of floating point values
141 *
142 * @return value treated as zero for sums of floating point values
143 */
SCIPsumepsilon(SCIP * scip)144 SCIP_Real SCIPsumepsilon(
145 SCIP* scip /**< SCIP data structure */
146 )
147 {
148 assert(scip != NULL);
149 assert(scip->set != NULL);
150
151 return SCIPsetSumepsilon(scip->set);
152 }
153
154 /** returns feasibility tolerance for constraints
155 *
156 * @return feasibility tolerance for constraints
157 */
SCIPfeastol(SCIP * scip)158 SCIP_Real SCIPfeastol(
159 SCIP* scip /**< SCIP data structure */
160 )
161 {
162 assert(scip != NULL);
163 assert(scip->set != NULL);
164
165 return SCIPsetFeastol(scip->set);
166 }
167
168 /** returns primal feasibility tolerance of LP solver
169 *
170 * @deprecated Please use SCIPgetLPFeastol().
171 *
172 * @return primal feasibility tolerance of LP solver
173 */
SCIPlpfeastol(SCIP * scip)174 SCIP_Real SCIPlpfeastol(
175 SCIP* scip /**< SCIP data structure */
176 )
177 {
178 assert(scip != NULL);
179 assert(scip->set != NULL);
180
181 return SCIPgetLPFeastol(scip);
182 }
183
184 /** returns feasibility tolerance for reduced costs
185 *
186 * @return feasibility tolerance for reduced costs
187 */
SCIPdualfeastol(SCIP * scip)188 SCIP_Real SCIPdualfeastol(
189 SCIP* scip /**< SCIP data structure */
190 )
191 {
192 assert(scip != NULL);
193 assert(scip->set != NULL);
194
195 return SCIPsetDualfeastol(scip->set);
196 }
197
198 /** returns convergence tolerance used in barrier algorithm
199 *
200 * @return convergence tolerance used in barrier algorithm
201 */
SCIPbarrierconvtol(SCIP * scip)202 SCIP_Real SCIPbarrierconvtol(
203 SCIP* scip /**< SCIP data structure */
204 )
205 {
206 assert(scip != NULL);
207 assert(scip->set != NULL);
208
209 return SCIPsetBarrierconvtol(scip->set);
210 }
211
212 /** return the cutoff bound delta
213 *
214 * @return cutoff bound data
215 */
SCIPcutoffbounddelta(SCIP * scip)216 SCIP_Real SCIPcutoffbounddelta(
217 SCIP* scip /**< SCIP data structure */
218 )
219 {
220 assert(scip != NULL);
221 assert(scip->set != NULL);
222
223 return SCIPsetCutoffbounddelta(scip->set);
224 }
225
226 /** return the relaxation primal feasibility tolerance
227 *
228 * @see SCIPchgRelaxfeastol
229 * @return relaxfeastol
230 */
SCIPrelaxfeastol(SCIP * scip)231 SCIP_Real SCIPrelaxfeastol(
232 SCIP* scip /**< SCIP data structure */
233 )
234 {
235 assert(scip != NULL);
236 assert(scip->set != NULL);
237
238 return SCIPsetRelaxfeastol(scip->set);
239 }
240
241 /** sets the feasibility tolerance for constraints
242 *
243 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
244 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
245 */
SCIPchgFeastol(SCIP * scip,SCIP_Real feastol)246 SCIP_RETCODE SCIPchgFeastol(
247 SCIP* scip, /**< SCIP data structure */
248 SCIP_Real feastol /**< new feasibility tolerance for constraints */
249 )
250 {
251 assert(scip != NULL);
252
253 /* change the settings */
254 SCIP_CALL( SCIPsetSetFeastol(scip->set, scip->lp, feastol) );
255
256 return SCIP_OKAY;
257 }
258
259 /** sets the primal feasibility tolerance of LP solver
260 *
261 * @deprecated Please use SCIPsetLPFeastol().
262 *
263 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
264 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
265 */
SCIPchgLpfeastol(SCIP * scip,SCIP_Real lpfeastol,SCIP_Bool printnewvalue)266 SCIP_RETCODE SCIPchgLpfeastol(
267 SCIP* scip, /**< SCIP data structure */
268 SCIP_Real lpfeastol, /**< new primal feasibility tolerance of LP solver */
269 SCIP_Bool printnewvalue /**< should "numerics/lpfeastol = ..." be printed? */
270 )
271 {
272 SCIPsetLPFeastol(scip, lpfeastol);
273
274 if( printnewvalue )
275 {
276 SCIPverbMessage(scip, SCIP_VERBLEVEL_HIGH, NULL, "numerics/lpfeastol = %.15g\n", lpfeastol);
277 }
278
279 return SCIP_OKAY;
280 }
281
282 /** sets the feasibility tolerance for reduced costs
283 *
284 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
285 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
286 */
SCIPchgDualfeastol(SCIP * scip,SCIP_Real dualfeastol)287 SCIP_RETCODE SCIPchgDualfeastol(
288 SCIP* scip, /**< SCIP data structure */
289 SCIP_Real dualfeastol /**< new feasibility tolerance for reduced costs */
290 )
291 {
292 assert(scip != NULL);
293
294 /* mark the LP unsolved, if the dual feasibility tolerance was tightened */
295 if( scip->lp != NULL && dualfeastol < SCIPsetDualfeastol(scip->set) )
296 {
297 scip->lp->solved = FALSE;
298 scip->lp->lpsolstat = SCIP_LPSOLSTAT_NOTSOLVED;
299 }
300
301 /* change the settings */
302 SCIP_CALL( SCIPsetSetDualfeastol(scip->set, dualfeastol) );
303
304 return SCIP_OKAY;
305 }
306
307 /** sets the convergence tolerance used in barrier algorithm
308 *
309 * @return \ref SCIP_OKAY is returned if everything worked. Otherwise a suitable error code is passed. See \ref
310 * SCIP_Retcode "SCIP_RETCODE" for a complete list of error codes.
311 */
SCIPchgBarrierconvtol(SCIP * scip,SCIP_Real barrierconvtol)312 SCIP_RETCODE SCIPchgBarrierconvtol(
313 SCIP* scip, /**< SCIP data structure */
314 SCIP_Real barrierconvtol /**< new convergence tolerance used in barrier algorithm */
315 )
316 {
317 assert(scip != NULL);
318
319 /* mark the LP unsolved, if the convergence tolerance was tightened, and the LP was solved with the barrier algorithm */
320 if( scip->lp != NULL && barrierconvtol < SCIPsetBarrierconvtol(scip->set)
321 && (scip->lp->lastlpalgo == SCIP_LPALGO_BARRIER || scip->lp->lastlpalgo == SCIP_LPALGO_BARRIERCROSSOVER) )
322 scip->lp->solved = FALSE;
323
324 /* change the settings */
325 SCIP_CALL( SCIPsetSetBarrierconvtol(scip->set, barrierconvtol) );
326
327 return SCIP_OKAY;
328 }
329
330 /** sets the primal feasibility tolerance of relaxations
331 *
332 * This tolerance value is used by the SCIP core and plugins to tighten then feasibility tolerance on relaxations
333 * (especially the LP relaxation) during a solve. It is set to SCIP_INVALID initially, which means that only the
334 * feasibility tolerance of the particular relaxation is taken into account. If set to a valid value, however,
335 * then this value should be used to reduce the primal feasibility tolerance of a relaxation (thus, use the
336 * minimum of relaxfeastol and the relaxations primal feastol).
337 *
338 * @pre The value of relaxfeastol is reset to SCIP_INVALID when initializing the solve (INITSOL).
339 * Therefore, this method can only be called in one of the following stages of the SCIP solving process:
340 * - \ref SCIP_STAGE_INITSOLVE
341 * - \ref SCIP_STAGE_SOLVING
342 *
343 * @return previous value of relaxfeastol
344 */
SCIPchgRelaxfeastol(SCIP * scip,SCIP_Real relaxfeastol)345 SCIP_Real SCIPchgRelaxfeastol(
346 SCIP* scip, /**< SCIP data structure */
347 SCIP_Real relaxfeastol /**< new primal feasibility tolerance of relaxations */
348 )
349 {
350 assert(scip != NULL);
351 assert(scip->set != NULL);
352
353 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPchgRelaxfeastol", FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE) );
354
355 return SCIPsetSetRelaxfeastol(scip->set, relaxfeastol);
356 }
357
358 /** marks that some limit parameter was changed */
SCIPmarkLimitChanged(SCIP * scip)359 void SCIPmarkLimitChanged(
360 SCIP* scip /**< SCIP data structure */
361 )
362 {
363 assert(scip != NULL);
364
365 /* change the settings */
366 SCIPsetSetLimitChanged(scip->set);
367 }
368
369 /** outputs a real number, or "+infinity", or "-infinity" to a file */
SCIPprintReal(SCIP * scip,FILE * file,SCIP_Real val,int width,int precision)370 void SCIPprintReal(
371 SCIP* scip, /**< SCIP data structure */
372 FILE* file, /**< output file (or NULL for standard output) */
373 SCIP_Real val, /**< value to print */
374 int width, /**< width of the field */
375 int precision /**< number of significant digits printed */
376 )
377 {
378 char s[SCIP_MAXSTRLEN];
379 char strformat[SCIP_MAXSTRLEN];
380
381 assert(scip != NULL);
382
383 if( SCIPsetIsInfinity(scip->set, val) )
384 (void) SCIPsnprintf(s, SCIP_MAXSTRLEN, "+infinity");
385 else if( SCIPsetIsInfinity(scip->set, -val) )
386 (void) SCIPsnprintf(s, SCIP_MAXSTRLEN, "-infinity");
387 else
388 {
389 (void) SCIPsnprintf(strformat, SCIP_MAXSTRLEN, "%%.%dg", precision);
390 (void) SCIPsnprintf(s, SCIP_MAXSTRLEN, (const char*)strformat, val);
391 }
392 (void) SCIPsnprintf(strformat, SCIP_MAXSTRLEN, "%%%ds", width);
393 SCIPmessageFPrintInfo(scip->messagehdlr, file, (const char*)strformat, s);
394 }
395
396 /** parse a real value that was written with SCIPprintReal() */
SCIPparseReal(SCIP * scip,const char * str,SCIP_Real * value,char ** endptr)397 SCIP_Bool SCIPparseReal(
398 SCIP* scip, /**< SCIP data structure */
399 const char* str, /**< string to search */
400 SCIP_Real* value, /**< pointer to store the parsed value */
401 char** endptr /**< pointer to store the final string position if successfully parsed, otherwise @p str */
402 )
403 {
404 char* localstr;
405
406 assert(scip != NULL);
407 assert(str != NULL);
408 assert(value != NULL);
409 assert(endptr != NULL);
410
411 localstr = (char*)str;
412
413 /* ignore white space */
414 while(isspace((unsigned char)*localstr))
415 ++localstr;
416
417 /* test for a special infinity first */
418 if( strncmp(localstr, "+infinity", 9) == 0 )
419 {
420 *value = SCIPinfinity(scip);
421 *endptr = (char*)(localstr + 9);
422 return TRUE;
423 }
424 else if( strncmp(localstr, "-infinity", 9) == 0 )
425 {
426 *value = -SCIPinfinity(scip);
427 *endptr = (char*)(localstr + 9);
428 return TRUE;
429 }
430 else
431 {
432 /* parse a finite value */
433 return SCIPstrToRealValue(str, value, endptr);
434 }
435 }
436
437 /** checks, if values are in range of epsilon */
SCIPisEQ(SCIP * scip,SCIP_Real val1,SCIP_Real val2)438 SCIP_Bool SCIPisEQ(
439 SCIP* scip, /**< SCIP data structure */
440 SCIP_Real val1, /**< first value to be compared */
441 SCIP_Real val2 /**< second value to be compared */
442 )
443 {
444 assert(scip != NULL);
445 assert(scip->set != NULL);
446
447 return SCIPsetIsEQ(scip->set, val1, val2);
448 }
449
450 /** checks, if val1 is (more than epsilon) lower than val2 */
SCIPisLT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)451 SCIP_Bool SCIPisLT(
452 SCIP* scip, /**< SCIP data structure */
453 SCIP_Real val1, /**< first value to be compared */
454 SCIP_Real val2 /**< second value to be compared */
455 )
456 {
457 assert(scip != NULL);
458 assert(scip->set != NULL);
459
460 return SCIPsetIsLT(scip->set, val1, val2);
461 }
462
463 /** checks, if val1 is not (more than epsilon) greater than val2 */
SCIPisLE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)464 SCIP_Bool SCIPisLE(
465 SCIP* scip, /**< SCIP data structure */
466 SCIP_Real val1, /**< first value to be compared */
467 SCIP_Real val2 /**< second value to be compared */
468 )
469 {
470 assert(scip != NULL);
471 assert(scip->set != NULL);
472
473 return SCIPsetIsLE(scip->set, val1, val2);
474 }
475
476 /** checks, if val1 is (more than epsilon) greater than val2 */
SCIPisGT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)477 SCIP_Bool SCIPisGT(
478 SCIP* scip, /**< SCIP data structure */
479 SCIP_Real val1, /**< first value to be compared */
480 SCIP_Real val2 /**< second value to be compared */
481 )
482 {
483 assert(scip != NULL);
484 assert(scip->set != NULL);
485
486 return SCIPsetIsGT(scip->set, val1, val2);
487 }
488
489 /** checks, if val1 is not (more than epsilon) lower than val2 */
SCIPisGE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)490 SCIP_Bool SCIPisGE(
491 SCIP* scip, /**< SCIP data structure */
492 SCIP_Real val1, /**< first value to be compared */
493 SCIP_Real val2 /**< second value to be compared */
494 )
495 {
496 assert(scip != NULL);
497 assert(scip->set != NULL);
498
499 return SCIPsetIsGE(scip->set, val1, val2);
500 }
501
502 /** returns value treated as infinity */
SCIPinfinity(SCIP * scip)503 SCIP_Real SCIPinfinity(
504 SCIP* scip /**< SCIP data structure */
505 )
506 {
507 assert(scip != NULL);
508 assert(scip->set != NULL);
509
510 return SCIPsetInfinity(scip->set);
511 }
512
513 /** checks, if value is (positive) infinite */
SCIPisInfinity(SCIP * scip,SCIP_Real val)514 SCIP_Bool SCIPisInfinity(
515 SCIP* scip, /**< SCIP data structure */
516 SCIP_Real val /**< value to be compared against infinity */
517 )
518 {
519 assert(scip != NULL);
520 assert(scip->set != NULL);
521
522 return SCIPsetIsInfinity(scip->set, val);
523 }
524
525 /** checks, if value is huge and should be handled separately (e.g., in activity computation) */
SCIPisHugeValue(SCIP * scip,SCIP_Real val)526 SCIP_Bool SCIPisHugeValue(
527 SCIP* scip, /**< SCIP data structure */
528 SCIP_Real val /**< value to be checked whether it is huge */
529 )
530 {
531 assert(scip != NULL);
532 assert(scip->set != NULL);
533
534 return SCIPsetIsHugeValue(scip->set, val);
535 }
536
537 /** returns the minimum value that is regarded as huge and should be handled separately (e.g., in activity
538 * computation)
539 */
SCIPgetHugeValue(SCIP * scip)540 SCIP_Real SCIPgetHugeValue(
541 SCIP* scip /**< SCIP data structure */
542 )
543 {
544 assert(scip != NULL);
545 assert(scip->set != NULL);
546
547 return SCIPsetGetHugeValue(scip->set);
548 }
549
550 /** checks, if value is in range epsilon of 0.0 */
SCIPisZero(SCIP * scip,SCIP_Real val)551 SCIP_Bool SCIPisZero(
552 SCIP* scip, /**< SCIP data structure */
553 SCIP_Real val /**< value to process */
554 )
555 {
556 assert(scip != NULL);
557 assert(scip->set != NULL);
558
559 return SCIPsetIsZero(scip->set, val);
560 }
561
562 /** checks, if value is greater than epsilon */
SCIPisPositive(SCIP * scip,SCIP_Real val)563 SCIP_Bool SCIPisPositive(
564 SCIP* scip, /**< SCIP data structure */
565 SCIP_Real val /**< value to process */
566 )
567 {
568 assert(scip != NULL);
569 assert(scip->set != NULL);
570
571 return SCIPsetIsPositive(scip->set, val);
572 }
573
574 /** checks, if value is lower than -epsilon */
SCIPisNegative(SCIP * scip,SCIP_Real val)575 SCIP_Bool SCIPisNegative(
576 SCIP* scip, /**< SCIP data structure */
577 SCIP_Real val /**< value to process */
578 )
579 {
580 assert(scip != NULL);
581 assert(scip->set != NULL);
582
583 return SCIPsetIsNegative(scip->set, val);
584 }
585
586 /** checks, if value is integral within epsilon */
SCIPisIntegral(SCIP * scip,SCIP_Real val)587 SCIP_Bool SCIPisIntegral(
588 SCIP* scip, /**< SCIP data structure */
589 SCIP_Real val /**< value to process */
590 )
591 {
592 assert(scip != NULL);
593 assert(scip->set != NULL);
594
595 return SCIPsetIsIntegral(scip->set, val);
596 }
597
598 /** checks whether the product val * scalar is integral in epsilon scaled by scalar */
SCIPisScalingIntegral(SCIP * scip,SCIP_Real val,SCIP_Real scalar)599 SCIP_Bool SCIPisScalingIntegral(
600 SCIP* scip, /**< SCIP data structure */
601 SCIP_Real val, /**< unscaled value to check for scaled integrality */
602 SCIP_Real scalar /**< value to scale val with for checking for integrality */
603 )
604 {
605 assert(scip != NULL);
606 assert(scip->set != NULL);
607
608 return SCIPsetIsScalingIntegral(scip->set, val, scalar);
609 }
610
611 /** checks, if given fractional part is smaller than epsilon */
SCIPisFracIntegral(SCIP * scip,SCIP_Real val)612 SCIP_Bool SCIPisFracIntegral(
613 SCIP* scip, /**< SCIP data structure */
614 SCIP_Real val /**< value to process */
615 )
616 {
617 assert(scip != NULL);
618 assert(scip->set != NULL);
619
620 return SCIPsetIsFracIntegral(scip->set, val);
621 }
622
623 /** rounds value + epsilon down to the next integer */
SCIPfloor(SCIP * scip,SCIP_Real val)624 SCIP_Real SCIPfloor(
625 SCIP* scip, /**< SCIP data structure */
626 SCIP_Real val /**< value to process */
627 )
628 {
629 assert(scip != NULL);
630 assert(scip->set != NULL);
631
632 return SCIPsetFloor(scip->set, val);
633 }
634
635 /** rounds value - epsilon up to the next integer */
SCIPceil(SCIP * scip,SCIP_Real val)636 SCIP_Real SCIPceil(
637 SCIP* scip, /**< SCIP data structure */
638 SCIP_Real val /**< value to process */
639 )
640 {
641 assert(scip != NULL);
642 assert(scip->set != NULL);
643
644 return SCIPsetCeil(scip->set, val);
645 }
646
647 /** rounds value to the nearest integer with epsilon tolerance */
SCIPround(SCIP * scip,SCIP_Real val)648 SCIP_Real SCIPround(
649 SCIP* scip, /**< SCIP data structure */
650 SCIP_Real val /**< value to process */
651 )
652 {
653 assert(scip != NULL);
654 assert(scip->set != NULL);
655
656 return SCIPsetRound(scip->set, val);
657 }
658
659 /** returns fractional part of value, i.e. x - floor(x) in epsilon tolerance */
SCIPfrac(SCIP * scip,SCIP_Real val)660 SCIP_Real SCIPfrac(
661 SCIP* scip, /**< SCIP data structure */
662 SCIP_Real val /**< value to return fractional part for */
663 )
664 {
665 assert(scip != NULL);
666 assert(scip->set != NULL);
667
668 return SCIPsetFrac(scip->set, val);
669 }
670
671 /** checks, if values are in range of sumepsilon */
SCIPisSumEQ(SCIP * scip,SCIP_Real val1,SCIP_Real val2)672 SCIP_Bool SCIPisSumEQ(
673 SCIP* scip, /**< SCIP data structure */
674 SCIP_Real val1, /**< first value to be compared */
675 SCIP_Real val2 /**< second value to be compared */
676 )
677 {
678 assert(scip != NULL);
679 assert(scip->set != NULL);
680
681 return SCIPsetIsSumEQ(scip->set, val1, val2);
682 }
683
684 /** checks, if val1 is (more than sumepsilon) lower than val2 */
SCIPisSumLT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)685 SCIP_Bool SCIPisSumLT(
686 SCIP* scip, /**< SCIP data structure */
687 SCIP_Real val1, /**< first value to be compared */
688 SCIP_Real val2 /**< second value to be compared */
689 )
690 {
691 assert(scip != NULL);
692 assert(scip->set != NULL);
693
694 return SCIPsetIsSumLT(scip->set, val1, val2);
695 }
696
697 /** checks, if val1 is not (more than sumepsilon) greater than val2 */
SCIPisSumLE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)698 SCIP_Bool SCIPisSumLE(
699 SCIP* scip, /**< SCIP data structure */
700 SCIP_Real val1, /**< first value to be compared */
701 SCIP_Real val2 /**< second value to be compared */
702 )
703 {
704 assert(scip != NULL);
705 assert(scip->set != NULL);
706
707 return SCIPsetIsSumLE(scip->set, val1, val2);
708 }
709
710 /** checks, if val1 is (more than sumepsilon) greater than val2 */
SCIPisSumGT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)711 SCIP_Bool SCIPisSumGT(
712 SCIP* scip, /**< SCIP data structure */
713 SCIP_Real val1, /**< first value to be compared */
714 SCIP_Real val2 /**< second value to be compared */
715 )
716 {
717 assert(scip != NULL);
718 assert(scip->set != NULL);
719
720 return SCIPsetIsSumGT(scip->set, val1, val2);
721 }
722
723 /** checks, if val1 is not (more than sumepsilon) lower than val2 */
SCIPisSumGE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)724 SCIP_Bool SCIPisSumGE(
725 SCIP* scip, /**< SCIP data structure */
726 SCIP_Real val1, /**< first value to be compared */
727 SCIP_Real val2 /**< second value to be compared */
728 )
729 {
730 assert(scip != NULL);
731 assert(scip->set != NULL);
732
733 return SCIPsetIsSumGE(scip->set, val1, val2);
734 }
735
736 /** checks, if value is in range sumepsilon of 0.0 */
SCIPisSumZero(SCIP * scip,SCIP_Real val)737 SCIP_Bool SCIPisSumZero(
738 SCIP* scip, /**< SCIP data structure */
739 SCIP_Real val /**< value to process */
740 )
741 {
742 assert(scip != NULL);
743 assert(scip->set != NULL);
744
745 return SCIPsetIsSumZero(scip->set, val);
746 }
747
748 /** checks, if value is greater than sumepsilon */
SCIPisSumPositive(SCIP * scip,SCIP_Real val)749 SCIP_Bool SCIPisSumPositive(
750 SCIP* scip, /**< SCIP data structure */
751 SCIP_Real val /**< value to process */
752 )
753 {
754 assert(scip != NULL);
755 assert(scip->set != NULL);
756
757 return SCIPsetIsSumPositive(scip->set, val);
758 }
759
760 /** checks, if value is lower than -sumepsilon */
SCIPisSumNegative(SCIP * scip,SCIP_Real val)761 SCIP_Bool SCIPisSumNegative(
762 SCIP* scip, /**< SCIP data structure */
763 SCIP_Real val /**< value to process */
764 )
765 {
766 assert(scip != NULL);
767 assert(scip->set != NULL);
768
769 return SCIPsetIsSumNegative(scip->set, val);
770 }
771
772 /** checks, if relative difference of values is in range of feasibility tolerance */
SCIPisFeasEQ(SCIP * scip,SCIP_Real val1,SCIP_Real val2)773 SCIP_Bool SCIPisFeasEQ(
774 SCIP* scip, /**< SCIP data structure */
775 SCIP_Real val1, /**< first value to be compared */
776 SCIP_Real val2 /**< second value to be compared */
777 )
778 {
779 assert(scip != NULL);
780 assert(scip->set != NULL);
781
782 return SCIPsetIsFeasEQ(scip->set, val1, val2);
783 }
784
785 /** checks, if relative difference val1 and val2 is lower than feasibility tolerance */
SCIPisFeasLT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)786 SCIP_Bool SCIPisFeasLT(
787 SCIP* scip, /**< SCIP data structure */
788 SCIP_Real val1, /**< first value to be compared */
789 SCIP_Real val2 /**< second value to be compared */
790 )
791 {
792 assert(scip != NULL);
793 assert(scip->set != NULL);
794
795 return SCIPsetIsFeasLT(scip->set, val1, val2);
796 }
797
798 /** checks, if relative difference of val1 and val2 is not greater than feasibility tolerance */
SCIPisFeasLE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)799 SCIP_Bool SCIPisFeasLE(
800 SCIP* scip, /**< SCIP data structure */
801 SCIP_Real val1, /**< first value to be compared */
802 SCIP_Real val2 /**< second value to be compared */
803 )
804 {
805 assert(scip != NULL);
806 assert(scip->set != NULL);
807
808 return SCIPsetIsFeasLE(scip->set, val1, val2);
809 }
810
811 /** checks, if relative difference of val1 and val2 is greater than feastol */
SCIPisFeasGT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)812 SCIP_Bool SCIPisFeasGT(
813 SCIP* scip, /**< SCIP data structure */
814 SCIP_Real val1, /**< first value to be compared */
815 SCIP_Real val2 /**< second value to be compared */
816 )
817 {
818 assert(scip != NULL);
819 assert(scip->set != NULL);
820
821 return SCIPsetIsFeasGT(scip->set, val1, val2);
822 }
823
824 /** checks, if relative difference of val1 and val2 is not lower than -feastol */
SCIPisFeasGE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)825 SCIP_Bool SCIPisFeasGE(
826 SCIP* scip, /**< SCIP data structure */
827 SCIP_Real val1, /**< first value to be compared */
828 SCIP_Real val2 /**< second value to be compared */
829 )
830 {
831 assert(scip != NULL);
832 assert(scip->set != NULL);
833
834 return SCIPsetIsFeasGE(scip->set, val1, val2);
835 }
836
837 /** checks, if value is in range feasibility tolerance of 0.0 */
SCIPisFeasZero(SCIP * scip,SCIP_Real val)838 SCIP_Bool SCIPisFeasZero(
839 SCIP* scip, /**< SCIP data structure */
840 SCIP_Real val /**< value to process */
841 )
842 {
843 assert(scip != NULL);
844 assert(scip->set != NULL);
845
846 return SCIPsetIsFeasZero(scip->set, val);
847 }
848
849 /** checks, if value is greater than feasibility tolerance */
SCIPisFeasPositive(SCIP * scip,SCIP_Real val)850 SCIP_Bool SCIPisFeasPositive(
851 SCIP* scip, /**< SCIP data structure */
852 SCIP_Real val /**< value to process */
853 )
854 {
855 assert(scip != NULL);
856 assert(scip->set != NULL);
857
858 return SCIPsetIsFeasPositive(scip->set, val);
859 }
860
861 /** checks, if value is lower than -feasibility tolerance */
SCIPisFeasNegative(SCIP * scip,SCIP_Real val)862 SCIP_Bool SCIPisFeasNegative(
863 SCIP* scip, /**< SCIP data structure */
864 SCIP_Real val /**< value to process */
865 )
866 {
867 assert(scip != NULL);
868 assert(scip->set != NULL);
869
870 return SCIPsetIsFeasNegative(scip->set, val);
871 }
872
873 /** checks, if value is integral within the LP feasibility bounds */
SCIPisFeasIntegral(SCIP * scip,SCIP_Real val)874 SCIP_Bool SCIPisFeasIntegral(
875 SCIP* scip, /**< SCIP data structure */
876 SCIP_Real val /**< value to process */
877 )
878 {
879 assert(scip != NULL);
880 assert(scip->set != NULL);
881
882 return SCIPsetIsFeasIntegral(scip->set, val);
883 }
884
885 /** checks, if given fractional part is smaller than feastol */
SCIPisFeasFracIntegral(SCIP * scip,SCIP_Real val)886 SCIP_Bool SCIPisFeasFracIntegral(
887 SCIP* scip, /**< SCIP data structure */
888 SCIP_Real val /**< value to process */
889 )
890 {
891 assert(scip != NULL);
892 assert(scip->set != NULL);
893
894 return SCIPsetIsFeasFracIntegral(scip->set, val);
895 }
896
897 /** rounds value + feasibility tolerance down to the next integer */
SCIPfeasFloor(SCIP * scip,SCIP_Real val)898 SCIP_Real SCIPfeasFloor(
899 SCIP* scip, /**< SCIP data structure */
900 SCIP_Real val /**< value to process */
901 )
902 {
903 assert(scip != NULL);
904 assert(scip->set != NULL);
905
906 return SCIPsetFeasFloor(scip->set, val);
907 }
908
909 /** rounds value - feasibility tolerance up to the next integer */
SCIPfeasCeil(SCIP * scip,SCIP_Real val)910 SCIP_Real SCIPfeasCeil(
911 SCIP* scip, /**< SCIP data structure */
912 SCIP_Real val /**< value to process */
913 )
914 {
915 assert(scip != NULL);
916 assert(scip->set != NULL);
917
918 return SCIPsetFeasCeil(scip->set, val);
919 }
920
921 /** rounds value to the nearest integer in feasibility tolerance */
SCIPfeasRound(SCIP * scip,SCIP_Real val)922 SCIP_Real SCIPfeasRound(
923 SCIP* scip, /**< SCIP data structure */
924 SCIP_Real val /**< value to process */
925 )
926 {
927 assert(scip != NULL);
928 assert(scip->set != NULL);
929
930 return SCIPsetFeasRound(scip->set, val);
931 }
932
933 /** returns fractional part of value, i.e. x - floor(x) in feasibility tolerance */
SCIPfeasFrac(SCIP * scip,SCIP_Real val)934 SCIP_Real SCIPfeasFrac(
935 SCIP* scip, /**< SCIP data structure */
936 SCIP_Real val /**< value to process */
937 )
938 {
939 assert(scip != NULL);
940 assert(scip->set != NULL);
941
942 return SCIPsetFeasFrac(scip->set, val);
943 }
944
945 /** checks, if relative difference of values is in range of dual feasibility tolerance */
SCIPisDualfeasEQ(SCIP * scip,SCIP_Real val1,SCIP_Real val2)946 SCIP_Bool SCIPisDualfeasEQ(
947 SCIP* scip, /**< SCIP data structure */
948 SCIP_Real val1, /**< first value to be compared */
949 SCIP_Real val2 /**< second value to be compared */
950 )
951 {
952 assert(scip != NULL);
953 assert(scip->set != NULL);
954
955 return SCIPsetIsDualfeasEQ(scip->set, val1, val2);
956 }
957
958 /** checks, if relative difference val1 and val2 is lower than dual feasibility tolerance */
SCIPisDualfeasLT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)959 SCIP_Bool SCIPisDualfeasLT(
960 SCIP* scip, /**< SCIP data structure */
961 SCIP_Real val1, /**< first value to be compared */
962 SCIP_Real val2 /**< second value to be compared */
963 )
964 {
965 assert(scip != NULL);
966 assert(scip->set != NULL);
967
968 return SCIPsetIsDualfeasLT(scip->set, val1, val2);
969 }
970
971 /** checks, if relative difference of val1 and val2 is not greater than dual feasibility tolerance */
SCIPisDualfeasLE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)972 SCIP_Bool SCIPisDualfeasLE(
973 SCIP* scip, /**< SCIP data structure */
974 SCIP_Real val1, /**< first value to be compared */
975 SCIP_Real val2 /**< second value to be compared */
976 )
977 {
978 assert(scip != NULL);
979 assert(scip->set != NULL);
980
981 return SCIPsetIsDualfeasLE(scip->set, val1, val2);
982 }
983
984 /** checks, if relative difference of val1 and val2 is greater than dual feasibility tolerance */
SCIPisDualfeasGT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)985 SCIP_Bool SCIPisDualfeasGT(
986 SCIP* scip, /**< SCIP data structure */
987 SCIP_Real val1, /**< first value to be compared */
988 SCIP_Real val2 /**< second value to be compared */
989 )
990 {
991 assert(scip != NULL);
992 assert(scip->set != NULL);
993
994 return SCIPsetIsDualfeasGT(scip->set, val1, val2);
995 }
996
997 /** checks, if relative difference of val1 and val2 is not lower than -dual feasibility tolerance */
SCIPisDualfeasGE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)998 SCIP_Bool SCIPisDualfeasGE(
999 SCIP* scip, /**< SCIP data structure */
1000 SCIP_Real val1, /**< first value to be compared */
1001 SCIP_Real val2 /**< second value to be compared */
1002 )
1003 {
1004 assert(scip != NULL);
1005 assert(scip->set != NULL);
1006
1007 return SCIPsetIsDualfeasGE(scip->set, val1, val2);
1008 }
1009
1010 /** checks, if value is in range dual feasibility tolerance of 0.0 */
SCIPisDualfeasZero(SCIP * scip,SCIP_Real val)1011 SCIP_Bool SCIPisDualfeasZero(
1012 SCIP* scip, /**< SCIP data structure */
1013 SCIP_Real val /**< value to process */
1014 )
1015 {
1016 assert(scip != NULL);
1017 assert(scip->set != NULL);
1018
1019 return SCIPsetIsDualfeasZero(scip->set, val);
1020 }
1021
1022 /** checks, if value is greater than dual feasibility tolerance */
SCIPisDualfeasPositive(SCIP * scip,SCIP_Real val)1023 SCIP_Bool SCIPisDualfeasPositive(
1024 SCIP* scip, /**< SCIP data structure */
1025 SCIP_Real val /**< value to process */
1026 )
1027 {
1028 assert(scip != NULL);
1029 assert(scip->set != NULL);
1030
1031 return SCIPsetIsDualfeasPositive(scip->set, val);
1032 }
1033
1034 /** checks, if value is lower than -dual feasibility tolerance */
SCIPisDualfeasNegative(SCIP * scip,SCIP_Real val)1035 SCIP_Bool SCIPisDualfeasNegative(
1036 SCIP* scip, /**< SCIP data structure */
1037 SCIP_Real val /**< value to process */
1038 )
1039 {
1040 assert(scip != NULL);
1041 assert(scip->set != NULL);
1042
1043 return SCIPsetIsDualfeasNegative(scip->set, val);
1044 }
1045
1046 /** checks, if value is integral within the LP dual feasibility tolerance */
SCIPisDualfeasIntegral(SCIP * scip,SCIP_Real val)1047 SCIP_Bool SCIPisDualfeasIntegral(
1048 SCIP* scip, /**< SCIP data structure */
1049 SCIP_Real val /**< value to process */
1050 )
1051 {
1052 assert(scip != NULL);
1053 assert(scip->set != NULL);
1054
1055 return SCIPsetIsDualfeasIntegral(scip->set, val);
1056 }
1057
1058 /** checks, if given fractional part is smaller than dual feasibility tolerance */
SCIPisDualfeasFracIntegral(SCIP * scip,SCIP_Real val)1059 SCIP_Bool SCIPisDualfeasFracIntegral(
1060 SCIP* scip, /**< SCIP data structure */
1061 SCIP_Real val /**< value to process */
1062 )
1063 {
1064 assert(scip != NULL);
1065 assert(scip->set != NULL);
1066
1067 return SCIPsetIsDualfeasFracIntegral(scip->set, val);
1068 }
1069
1070 /** rounds value + dual feasibility tolerance down to the next integer */
SCIPdualfeasFloor(SCIP * scip,SCIP_Real val)1071 SCIP_Real SCIPdualfeasFloor(
1072 SCIP* scip, /**< SCIP data structure */
1073 SCIP_Real val /**< value to process */
1074 )
1075 {
1076 assert(scip != NULL);
1077 assert(scip->set != NULL);
1078
1079 return SCIPsetDualfeasFloor(scip->set, val);
1080 }
1081
1082 /** rounds value - dual feasibility tolerance up to the next integer */
SCIPdualfeasCeil(SCIP * scip,SCIP_Real val)1083 SCIP_Real SCIPdualfeasCeil(
1084 SCIP* scip, /**< SCIP data structure */
1085 SCIP_Real val /**< value to process */
1086 )
1087 {
1088 assert(scip != NULL);
1089 assert(scip->set != NULL);
1090
1091 return SCIPsetDualfeasCeil(scip->set, val);
1092 }
1093
1094 /** rounds value to the nearest integer in dual feasibility tolerance */
SCIPdualfeasRound(SCIP * scip,SCIP_Real val)1095 SCIP_Real SCIPdualfeasRound(
1096 SCIP* scip, /**< SCIP data structure */
1097 SCIP_Real val /**< value to process */
1098 )
1099 {
1100 assert(scip != NULL);
1101 assert(scip->set != NULL);
1102
1103 return SCIPsetDualfeasRound(scip->set, val);
1104 }
1105
1106 /** returns fractional part of value, i.e. x - floor(x) in dual feasibility tolerance */
SCIPdualfeasFrac(SCIP * scip,SCIP_Real val)1107 SCIP_Real SCIPdualfeasFrac(
1108 SCIP* scip, /**< SCIP data structure */
1109 SCIP_Real val /**< value to process */
1110 )
1111 {
1112 assert(scip != NULL);
1113 assert(scip->set != NULL);
1114
1115 return SCIPsetDualfeasFrac(scip->set, val);
1116 }
1117
1118 /** checks, if the given new lower bound is at least min(oldub - oldlb, |oldlb|) times the bound
1119 * strengthening epsilon better than the old one
1120 */
SCIPisLbBetter(SCIP * scip,SCIP_Real newlb,SCIP_Real oldlb,SCIP_Real oldub)1121 SCIP_Bool SCIPisLbBetter(
1122 SCIP* scip, /**< SCIP data structure */
1123 SCIP_Real newlb, /**< new lower bound */
1124 SCIP_Real oldlb, /**< old lower bound */
1125 SCIP_Real oldub /**< old upper bound */
1126 )
1127 {
1128 assert(scip != NULL);
1129
1130 return SCIPsetIsLbBetter(scip->set, newlb, oldlb, oldub);
1131 }
1132
1133 /** checks, if the given new upper bound is at least min(oldub - oldlb, |oldub|) times the bound
1134 * strengthening epsilon better than the old one
1135 */
SCIPisUbBetter(SCIP * scip,SCIP_Real newub,SCIP_Real oldlb,SCIP_Real oldub)1136 SCIP_Bool SCIPisUbBetter(
1137 SCIP* scip, /**< SCIP data structure */
1138 SCIP_Real newub, /**< new upper bound */
1139 SCIP_Real oldlb, /**< old lower bound */
1140 SCIP_Real oldub /**< old upper bound */
1141 )
1142 {
1143 assert(scip != NULL);
1144
1145 return SCIPsetIsUbBetter(scip->set, newub, oldlb, oldub);
1146 }
1147
1148 /** checks, if relative difference of values is in range of epsilon */
SCIPisRelEQ(SCIP * scip,SCIP_Real val1,SCIP_Real val2)1149 SCIP_Bool SCIPisRelEQ(
1150 SCIP* scip, /**< SCIP data structure */
1151 SCIP_Real val1, /**< first value to be compared */
1152 SCIP_Real val2 /**< second value to be compared */
1153 )
1154 {
1155 assert(scip != NULL);
1156 assert(scip->set != NULL);
1157
1158 return SCIPsetIsRelEQ(scip->set, val1, val2);
1159 }
1160
1161 /** checks, if relative difference of val1 and val2 is lower than epsilon */
SCIPisRelLT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)1162 SCIP_Bool SCIPisRelLT(
1163 SCIP* scip, /**< SCIP data structure */
1164 SCIP_Real val1, /**< first value to be compared */
1165 SCIP_Real val2 /**< second value to be compared */
1166 )
1167 {
1168 assert(scip != NULL);
1169 assert(scip->set != NULL);
1170
1171 return SCIPsetIsRelLT(scip->set, val1, val2);
1172 }
1173
1174 /** checks, if relative difference of val1 and val2 is not greater than epsilon */
SCIPisRelLE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)1175 SCIP_Bool SCIPisRelLE(
1176 SCIP* scip, /**< SCIP data structure */
1177 SCIP_Real val1, /**< first value to be compared */
1178 SCIP_Real val2 /**< second value to be compared */
1179 )
1180 {
1181 assert(scip != NULL);
1182 assert(scip->set != NULL);
1183
1184 return SCIPsetIsRelLE(scip->set, val1, val2);
1185 }
1186
1187 /** checks, if relative difference of val1 and val2 is greater than epsilon */
SCIPisRelGT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)1188 SCIP_Bool SCIPisRelGT(
1189 SCIP* scip, /**< SCIP data structure */
1190 SCIP_Real val1, /**< first value to be compared */
1191 SCIP_Real val2 /**< second value to be compared */
1192 )
1193 {
1194 assert(scip != NULL);
1195 assert(scip->set != NULL);
1196
1197 return SCIPsetIsRelGT(scip->set, val1, val2);
1198 }
1199
1200 /** checks, if relative difference of val1 and val2 is not lower than -epsilon */
SCIPisRelGE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)1201 SCIP_Bool SCIPisRelGE(
1202 SCIP* scip, /**< SCIP data structure */
1203 SCIP_Real val1, /**< first value to be compared */
1204 SCIP_Real val2 /**< second value to be compared */
1205 )
1206 {
1207 assert(scip != NULL);
1208 assert(scip->set != NULL);
1209
1210 return SCIPsetIsRelGE(scip->set, val1, val2);
1211 }
1212
1213 /** checks, if relative difference of values is in range of sumepsilon */
SCIPisSumRelEQ(SCIP * scip,SCIP_Real val1,SCIP_Real val2)1214 SCIP_Bool SCIPisSumRelEQ(
1215 SCIP* scip, /**< SCIP data structure */
1216 SCIP_Real val1, /**< first value to be compared */
1217 SCIP_Real val2 /**< second value to be compared */
1218 )
1219 {
1220 assert(scip != NULL);
1221 assert(scip->set != NULL);
1222
1223 return SCIPsetIsSumRelEQ(scip->set, val1, val2);
1224 }
1225
1226 /** checks, if relative difference of val1 and val2 is lower than sumepsilon */
SCIPisSumRelLT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)1227 SCIP_Bool SCIPisSumRelLT(
1228 SCIP* scip, /**< SCIP data structure */
1229 SCIP_Real val1, /**< first value to be compared */
1230 SCIP_Real val2 /**< second value to be compared */
1231 )
1232 {
1233 assert(scip != NULL);
1234 assert(scip->set != NULL);
1235
1236 return SCIPsetIsSumRelLT(scip->set, val1, val2);
1237 }
1238
1239 /** checks, if relative difference of val1 and val2 is not greater than sumepsilon */
SCIPisSumRelLE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)1240 SCIP_Bool SCIPisSumRelLE(
1241 SCIP* scip, /**< SCIP data structure */
1242 SCIP_Real val1, /**< first value to be compared */
1243 SCIP_Real val2 /**< second value to be compared */
1244 )
1245 {
1246 assert(scip != NULL);
1247 assert(scip->set != NULL);
1248
1249 return SCIPsetIsSumRelLE(scip->set, val1, val2);
1250 }
1251
1252 /** checks, if relative difference of val1 and val2 is greater than sumepsilon */
SCIPisSumRelGT(SCIP * scip,SCIP_Real val1,SCIP_Real val2)1253 SCIP_Bool SCIPisSumRelGT(
1254 SCIP* scip, /**< SCIP data structure */
1255 SCIP_Real val1, /**< first value to be compared */
1256 SCIP_Real val2 /**< second value to be compared */
1257 )
1258 {
1259 assert(scip != NULL);
1260 assert(scip->set != NULL);
1261
1262 return SCIPsetIsSumRelGT(scip->set, val1, val2);
1263 }
1264
1265 /** checks, if relative difference of val1 and val2 is not lower than -sumepsilon */
SCIPisSumRelGE(SCIP * scip,SCIP_Real val1,SCIP_Real val2)1266 SCIP_Bool SCIPisSumRelGE(
1267 SCIP* scip, /**< SCIP data structure */
1268 SCIP_Real val1, /**< first value to be compared */
1269 SCIP_Real val2 /**< second value to be compared */
1270 )
1271 {
1272 assert(scip != NULL);
1273 assert(scip->set != NULL);
1274
1275 return SCIPsetIsSumRelGE(scip->set, val1, val2);
1276 }
1277
1278 /** converts the given real number representing an integer to an int; in optimized mode the function gets inlined for
1279 * performance; in debug mode we check some additional conditions
1280 */
SCIPconvertRealToInt(SCIP * scip,SCIP_Real real)1281 int SCIPconvertRealToInt(
1282 SCIP* scip, /**< SCIP data structure */
1283 SCIP_Real real /**< double bound to convert */
1284 )
1285 {
1286 assert(SCIPisFeasIntegral(scip, real));
1287 assert(SCIPisFeasEQ(scip, real, (SCIP_Real)(int)(real < 0 ? real - 0.5 : real + 0.5)));
1288 assert(real < INT_MAX);
1289 assert(real > INT_MIN);
1290
1291 return (int)(real < 0 ? (real - 0.5) : (real + 0.5));
1292 }
1293
1294 /** converts the given real number representing an integer to a long integer; in optimized mode the function gets inlined for
1295 * performance; in debug mode we check some additional conditions
1296 */
SCIPconvertRealToLongint(SCIP * scip,SCIP_Real real)1297 SCIP_Longint SCIPconvertRealToLongint(
1298 SCIP* scip, /**< SCIP data structure */
1299 SCIP_Real real /**< double bound to convert */
1300 )
1301 {
1302 assert(SCIPisFeasIntegral(scip, real));
1303 assert(SCIPisFeasEQ(scip, real, (SCIP_Real)(SCIP_Longint)(real < 0 ? real - 0.5 : real + 0.5)));
1304 assert(real < SCIP_LONGINT_MAX);
1305 assert(real > SCIP_LONGINT_MIN);
1306
1307 return (SCIP_Longint)(real < 0 ? (real - 0.5) : (real + 0.5));
1308 }
1309
1310 /** Checks, if an iteratively updated value is reliable or should be recomputed from scratch.
1311 * This is useful, if the value, e.g., the activity of a linear constraint or the pseudo objective value, gets a high
1312 * absolute value during the optimization process which is later reduced significantly. In this case, the last digits
1313 * were canceled out when increasing the value and are random after decreasing it.
1314 * We do not consider the cancellations which can occur during increasing the absolute value because they just cannot
1315 * be expressed using fixed precision floating point arithmetic, anymore.
1316 * In order to get more reliable values, the idea is to always store the last reliable value, where increasing the
1317 * absolute of the value is viewed as preserving reliability. Then, after each update, the new absolute value can be
1318 * compared against the last reliable one with this method, checking whether it was decreased by a factor of at least
1319 * "lp/recompfac" and should be recomputed.
1320 */
SCIPisUpdateUnreliable(SCIP * scip,SCIP_Real newvalue,SCIP_Real oldvalue)1321 SCIP_Bool SCIPisUpdateUnreliable(
1322 SCIP* scip, /**< SCIP data structure */
1323 SCIP_Real newvalue, /**< new value after update */
1324 SCIP_Real oldvalue /**< old value, i.e., last reliable value */
1325 )
1326 {
1327 assert(scip != NULL);
1328
1329 SCIP_CALL_ABORT( SCIPcheckStage(scip, "SCIPisUpdateUnreliable", FALSE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE) );
1330
1331 return SCIPsetIsUpdateUnreliable(scip->set, newvalue, oldvalue);
1332 }
1333