39 #ifndef _SPXDEFINES_H_ 40 #define _SPXDEFINES_H_ 58 #ifndef SOPLEX_NO_CONFIG_HEADER 62 #ifdef SOPLEX_WITH_BOOST 63 #include "boost/multiprecision/number.hpp" 64 #ifdef SOPLEX_WITH_FLOAT128 65 #include <boost/multiprecision/float128.hpp> 68 #ifdef SOPLEX_WITH_MPFR 70 #include <boost/multiprecision/mpfr.hpp> 72 #include "boost/multiprecision/debug_adaptor.hpp" 74 #endif // SOPLEX_WITH_MPFR 75 #ifdef SOPLEX_WITH_CPPMPF 76 #include <boost/serialization/nvp.hpp> 77 #include <boost/multiprecision/cpp_dec_float.hpp> 78 #endif // SOPLEX_WITH_CPPMPF 80 #ifdef SOPLEX_WITH_GMP 81 #include <boost/multiprecision/gmp.hpp> 83 #include <boost/multiprecision/cpp_int.hpp> 92 bool EQ(
int a,
int b);
94 #define SOPLEX_VERSION 700 95 #define SOPLEX_SUBVERSION 0 96 #define SOPLEX_APIVERSION 14 97 #define SOPLEX_COPYRIGHT "Copyright (c) 1996-2023 Zuse Institute Berlin (ZIB)" 114 #if defined (NDEBUG) && defined (WITH_WARNINGS) 115 #define SOPLEX_ASSERT_WARN( prefix, expr ) \ 120 << " failed assertion on line " << __LINE__ \ 121 << " in file " << __FILE__ << ": " \ 125 #else // just a normal assert 126 #define SOPLEX_ASSERT_WARN( prefix, expr ) ( assert( expr ) ) 142 #ifdef DISABLE_VERBOSITY 143 #define SOPLEX_DO_WITH_TMP_VERBOSITY( verbosity, spxout, do_something ) {} 144 #define SOPLEX_DO_WITH_ERR_VERBOSITY( do_something ) {} 146 #define SOPLEX_DO_WITH_TMP_VERBOSITY( verbosity, spxout, do_something ) \ 148 if( &spxout != NULL ) \ 150 if( verbosity <= spxout.getVerbosity() ) \ 152 const SPxOut::Verbosity old_verbosity = spxout.getVerbosity(); \ 153 spxout.setVerbosity( verbosity ); \ 155 spxout.setVerbosity( old_verbosity ); \ 159 #define SOPLEX_DO_WITH_ERR_VERBOSITY( do_something ) { do_something; } 163 #define SPX_MSG_ERROR(x) { SOPLEX_DO_WITH_ERR_VERBOSITY( x ) } 165 #define SPX_MSG_WARNING(spxout, x) { SOPLEX_DO_WITH_TMP_VERBOSITY( SPxOut::WARNING, spxout, x ) } 167 #define SPX_MSG_INFO1(spxout, x) { SOPLEX_DO_WITH_TMP_VERBOSITY( SPxOut::INFO1, spxout, x ) } 169 #define SPX_MSG_INFO2(spxout, x) { SOPLEX_DO_WITH_TMP_VERBOSITY( SPxOut::INFO2, spxout, x ) } 171 #define SPX_MSG_INFO3(spxout, x) { SOPLEX_DO_WITH_TMP_VERBOSITY( SPxOut::INFO3, spxout, x ) } 173 extern bool msginconsistent(
const char* name,
const char* file,
int line);
175 #define SPX_MSG_INCONSISTENT(name) msginconsistent(name, __FILE__, __LINE__) 177 #if defined(SOPLEX_DEBUG) 179 #define SPX_MSG_DEBUG(x) { x; } 180 #define SPX_DEBUG(x) { x; } 182 #define SPX_MSG_DEBUG(x) 192 #if !defined(SOPLEX_THREADLOCAL) 193 #if defined(_MSC_VER) && _MSC_VER < 1900 194 #define SOPLEX_THREADLOCAL 196 #define SOPLEX_THREADLOCAL thread_local 206 #ifdef WITH_LONG_DOUBLE 209 typedef long double Real;
212 #define SOPLEX_REAL(x) x##L 213 #define SOPLEX_REAL_FORMAT "Lf" 216 #ifndef SOPLEX_DEFAULT_BND_VIOL 217 #define SOPLEX_DEFAULT_BND_VIOL 1e-12L 220 #ifndef SOPLEX_DEFAULT_EPS_ZERO 221 #define SOPLEX_DEFAULT_EPS_ZERO 1e-28L 224 #ifndef SOPLEX_DEFAULT_EPS_FACTOR 225 #define SOPLEX_DEFAULT_EPS_FACTOR 1e-30L 228 #ifndef SOPLEX_DEFAULT_EPS_UPDATE 229 #define SOPLEX_DEFAULT_EPS_UPDATE 1e-26L 231 #ifndef SOPLEX_DEFAULT_EPS_PIVOR 232 #define SOPLEX_DEFAULT_EPS_PIVOR 1e-20L 235 #define SOPLEX_DEFAULT_INFINITY 1e100L 245 #define SOPLEX_REAL(x) x 246 #define SOPLEX_REAL_FORMAT "f" 249 #ifndef SOPLEX_DEFAULT_BND_VIOL 250 #define SOPLEX_DEFAULT_BND_VIOL 1e-1f 253 #ifndef SOPLEX_DEFAULT_EPS_ZERO 254 #define SOPLEX_DEFAULT_EPS_ZERO 1e-7f 256 #ifndef SOPLEX_DEFAULT_EPS_FACTOR 257 #define SOPLEX_DEFAULT_EPS_FACTOR 1e-7f 259 #ifndef SOPLEX_DEFAULT_EPS_UPDATE 260 #define SOPLEX_DEFAULT_EPS_UPDATE 1e-6f 262 #ifndef SOPLEX_DEFAULT_EPS_PIVOR 263 #define SOPLEX_DEFAULT_EPS_PIVOR 1e-6f 265 #define SOPLEX_DEFAULT_INFINITY 1e35f 272 #define SOPLEX_REAL(x) x 273 #define SOPLEX_REAL_FORMAT "lf" 276 #ifndef SOPLEX_DEFAULT_BND_VIOL 277 #define SOPLEX_DEFAULT_BND_VIOL 1e-6 280 #ifndef SOPLEX_DEFAULT_EPS_ZERO 281 #define SOPLEX_DEFAULT_EPS_ZERO 1e-16 283 #ifndef SOPLEX_DEFAULT_EPS_FACTOR 284 #define SOPLEX_DEFAULT_EPS_FACTOR 1e-20 286 #ifndef SOPLEX_DEFAULT_EPS_UPDATE 287 #define SOPLEX_DEFAULT_EPS_UPDATE 1e-16 289 #ifndef SOPLEX_DEFAULT_EPS_PIVOR 290 #define SOPLEX_DEFAULT_EPS_PIVOR 1e-10 292 #define SOPLEX_DEFAULT_INFINITY 1e100 294 #endif // !WITH_FLOAT 295 #endif // !WITH_LONG_DOUBLE 297 #define SOPLEX_MAX(x,y) ((x)>(y) ? (x) : (y)) 298 #define SOPLEX_MIN(x,y) ((x)<(y) ? (x) : (y)) 300 #define SPX_MAXSTRLEN 1024 340 s_epsilon_multiplier(1.0)
400 #ifdef WITH_LONG_DOUBLE 404 return nextafterl(x, y);
411 return nextafter(x, y);
413 return _nextafter(x, y);
434 const Real absa =
spxAbs(a);
435 const Real absb =
spxAbs(b);
437 return absa > absb ? absa : absb;
443 return (a - b) / (
maxAbs(a, b) > 1.0 ?
maxAbs(a, b) : 1.0);
462 #if defined(_WIN32) || defined(_WIN64) 463 n = _vsnprintf(t, len, s, ap);
465 n = vsnprintf(t, len, s, ap);
469 if(n < 0 || (
size_t) n >= len)
475 SPX_MSG_ERROR(std::cerr <<
"vsnprintf returned " << n <<
" while reading: " << s << std::endl;)
486 #ifdef SOPLEX_WITH_BOOST 490 #ifdef SOPLEX_WITH_GMP 491 template<boost::multiprecision::expression_
template_option eto>
492 inline number<gmp_rational, eto>
ldexp(number<gmp_rational, eto>,
int exp)
495 return number<gmp_rational>();
498 template<boost::multiprecision::expression_
template_option eto>
499 inline number<gmp_rational, eto>
frexp(number<gmp_rational, eto>,
int* exp)
502 return number<gmp_rational>();
505 inline cpp_rational
ldexp(cpp_rational r,
int exp)
508 return cpp_rational();
511 inline cpp_rational
frexp(cpp_rational,
int* exp)
514 return cpp_rational();
519 template <
typename T, boost::multiprecision::expression_
template_option eto>
520 boost::multiprecision::number<T, eto>
spxFrexp(boost::multiprecision::number<T, eto> y,
int* exp)
522 return frexp(y, exp);
526 template <
typename T, boost::multiprecision::expression_
template_option eto>
527 boost::multiprecision::number<T>
spxLdexp(boost::multiprecision::number<T, eto> x,
int exp)
529 return ldexp(x, exp);
533 template <
typename T, expression_
template_option ep>
540 template <
typename T, expression_
template_option eto>
555 template <
typename T>
562 template <
typename T, expression_
template_option et>
564 number<T, et> a, number<T, et> b)
566 const auto absa =
spxAbs(a);
567 const auto absb =
spxAbs(b);
569 return absa > absb ? absa : absb;
572 template <
typename T, expression_
template_option et>
576 return (a - b) / (
maxAbs(a, b) > 1.0 ?
maxAbs(a, b) : 1.0);
584 #include "spxdefines.hpp" 586 #endif // _SPXDEFINES_H_ Real opttol()
global optimality tolerance
void setFloatingPointOpttol(Real otol)
set floating point optimality tolerance used within the solver
number< gmp_rational, eto > ldexp(number< gmp_rational, eto >, int exp)
Real epsilonUpdate()
zero espilon used in factorization update
Real s_epsilon_pivot
epsilon for pivot zero tolerance in factorization
void setFloatingPointFeastol(Real ftol)
set floating point feasibility tolerance used within the solver
Real maxAbs(Real a, Real b)
returns max(|a|,|b|)
bool msginconsistent(const char *name, const char *file, int line)
Real feastol()
global feasibility tolerance
#define SOPLEX_DEFAULT_EPS_ZERO
default allowed additive zero: 1.0 + EPS_ZERO == 1.0
#define SPX_MSG_ERROR(x)
Prints out message x if the verbosity level is at least SPxOut::ERROR.
Real s_epsilon_factorization
epsilon for factorization
#define SOPLEX_DEFAULT_EPS_PIVOR
void setEpsilon(Real eps)
set global zero epsilon
boost::multiprecision::number< T, eto > spxFrexp(boost::multiprecision::number< T, eto > y, int *exp)
Real epsilonPivot()
zero espilon used in pivot
void setFeastol(Real ftol)
set global feasibility tolerance
int spxSnprintf(char *t, size_t len, const char *s,...)
safe version of snprintf
number< gmp_rational, eto > frexp(number< gmp_rational, eto >, int *exp)
Real s_floating_point_feastol
floating point feasibility tolerance
#define SOPLEX_DEFAULT_EPS_UPDATE
Real spxSqrt(Real a)
returns square root
Real epsilon()
global zero epsilon
Real s_epsilon_update
epsilon for factorization update
void setEpsilonUpdate(Real eps)
set zero espilon used in factorization update
SOPLEX_THREADLOCAL const Real infinity
boost::multiprecision::number< T > spxLdexp(boost::multiprecision::number< T, eto > x, int exp)
#define SOPLEX_THREADLOCAL
SOPLEX_DEBUG.
Everything should be within this namespace.
Real relDiff(Real a, Real b)
returns (a-b) / max(|a|,|b|,1.0)
Real s_opttol
optimality tolerance
Real spxNextafter(Real x, Real y)
void setEpsilonPivot(Real eps)
set zero espilon used in pivot
Real floatingPointFeastol()
floating point feasibility tolerance used within the solver
Real s_epsilon
default allowed additive zero: 1.0 + EPS_ZERO == 1.0
#define SOPLEX_DEFAULT_EPS_FACTOR
Real s_epsilon_multiplier
multiplier for fixed numbers that should change if s_epsilon changes
void setOpttol(Real otol)
set global optimality tolerance
#define SOPLEX_DEFAULT_BND_VIOL
default allowed bound violation
void setEpsilonFactorization(Real eps)
set zero espilon used in factorization
Real floatingPointOpttol()
floating point optimality tolerance used within the solver
Real s_floating_point_opttol
floating point optimality tolerance
Real epsilonFactorization()
zero espilon used in factorization
Real s_feastol
feasibility tolerance
Real scaleAccordingToEpsilon(Real a)
scale a value such that it remains unchanged at default epsilon, but is scaled withs smaller epsilon ...