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"
75#ifdef SOPLEX_WITH_CPPMPF
76#include <boost/serialization/nvp.hpp>
77#include <boost/multiprecision/cpp_dec_float.hpp>
81#include <boost/multiprecision/gmp.hpp>
83#include <boost/multiprecision/cpp_int.hpp>
93#define SOPLEX_VERSION 713
94#define SOPLEX_SUBVERSION 0
95#define SOPLEX_APIVERSION 17
96#define SOPLEX_COPYRIGHT "Copyright (c) 1996-2025 Zuse Institute Berlin (ZIB)"
113#if defined (NDEBUG) && defined (WITH_WARNINGS)
114#define SOPLEX_ASSERT_WARN( prefix, expr ) \
119 << " failed assertion on line " << __LINE__ \
120 << " in file " << __FILE__ << ": " \
125#define SOPLEX_ASSERT_WARN( prefix, expr ) ( assert( expr ) )
141#ifdef DISABLE_VERBOSITY
142#define SOPLEX_DO_WITH_TMP_VERBOSITY( verbosity, spxout, do_something ) {}
143#define SOPLEX_DO_WITH_ERR_VERBOSITY( do_something ) {}
145#define SOPLEX_DO_WITH_TMP_VERBOSITY( verbosity, spxout, do_something ) \
147 if( &spxout != nullptr ) \
149 if( verbosity <= spxout.getVerbosity() ) \
151 const SPxOut::Verbosity old_verbosity = spxout.getVerbosity(); \
152 spxout.setVerbosity( verbosity ); \
154 spxout.setVerbosity( old_verbosity ); \
158#define SOPLEX_DO_WITH_ERR_VERBOSITY( do_something ) { do_something; }
162#define SPX_MSG_ERROR(x) { SOPLEX_DO_WITH_ERR_VERBOSITY( x ) }
164#define SPX_MSG_WARNING(spxout, x) { SOPLEX_DO_WITH_TMP_VERBOSITY( SPxOut::WARNING, spxout, x ) }
166#define SPX_MSG_INFO1(spxout, x) { SOPLEX_DO_WITH_TMP_VERBOSITY( SPxOut::INFO1, spxout, x ) }
168#define SPX_MSG_INFO2(spxout, x) { SOPLEX_DO_WITH_TMP_VERBOSITY( SPxOut::INFO2, spxout, x ) }
170#define SPX_MSG_INFO3(spxout, x) { SOPLEX_DO_WITH_TMP_VERBOSITY( SPxOut::INFO3, spxout, x ) }
172extern bool msginconsistent(
const char* name,
const char* file,
int line);
174#define SPX_MSG_INCONSISTENT(name) msginconsistent(name, __FILE__, __LINE__)
176#if defined(SOPLEX_DEBUG)
178#define SPX_MSG_DEBUG(x) { x; }
179#define SPX_DEBUG(x) { x; }
181#define SPX_MSG_DEBUG(x)
191#if !defined(SOPLEX_THREADLOCAL)
192#if defined(_MSC_VER) && _MSC_VER < 1900
193#define SOPLEX_THREADLOCAL
195#define SOPLEX_THREADLOCAL thread_local
205#ifdef WITH_LONG_DOUBLE
208typedef long double Real;
211#define SOPLEX_REAL(x) x##L
212#define SOPLEX_REAL_FORMAT "Lf"
215#ifndef SOPLEX_DEFAULT_BND_VIOL
216#define SOPLEX_DEFAULT_BND_VIOL 1e-12L
219#ifndef SOPLEX_DEFAULT_EPS_ZERO
220#define SOPLEX_DEFAULT_EPS_ZERO 1e-28L
223#ifndef SOPLEX_DEFAULT_EPS_FACTOR
224#define SOPLEX_DEFAULT_EPS_FACTOR 1e-30L
227#ifndef SOPLEX_DEFAULT_EPS_UPDATE
228#define SOPLEX_DEFAULT_EPS_UPDATE 1e-26L
230#ifndef SOPLEX_DEFAULT_EPS_PIVOR
231#define SOPLEX_DEFAULT_EPS_PIVOR 1e-20L
234#define SOPLEX_DEFAULT_INFINITY 1e100L
244#define SOPLEX_REAL(x) x
245#define SOPLEX_REAL_FORMAT "f"
248#ifndef SOPLEX_DEFAULT_BND_VIOL
249#define SOPLEX_DEFAULT_BND_VIOL 1e-1f
252#ifndef SOPLEX_DEFAULT_EPS_ZERO
253#define SOPLEX_DEFAULT_EPS_ZERO 1e-7f
255#ifndef SOPLEX_DEFAULT_EPS_FACTOR
256#define SOPLEX_DEFAULT_EPS_FACTOR 1e-7f
258#ifndef SOPLEX_DEFAULT_EPS_UPDATE
259#define SOPLEX_DEFAULT_EPS_UPDATE 1e-6f
261#ifndef SOPLEX_DEFAULT_EPS_PIVOR
262#define SOPLEX_DEFAULT_EPS_PIVOR 1e-6f
264#define SOPLEX_DEFAULT_INFINITY 1e35f
271#define SOPLEX_REAL(x) x
272#define SOPLEX_REAL_FORMAT "lf"
275#ifndef SOPLEX_DEFAULT_BND_VIOL
276#define SOPLEX_DEFAULT_BND_VIOL 1e-6
279#ifndef SOPLEX_DEFAULT_EPS_ZERO
280#define SOPLEX_DEFAULT_EPS_ZERO 1e-16
282#ifndef SOPLEX_DEFAULT_EPS_FACTOR
283#define SOPLEX_DEFAULT_EPS_FACTOR 1e-20
285#ifndef SOPLEX_DEFAULT_EPS_UPDATE
286#define SOPLEX_DEFAULT_EPS_UPDATE 1e-16
288#ifndef SOPLEX_DEFAULT_EPS_PIVOR
289#define SOPLEX_DEFAULT_EPS_PIVOR 1e-10
291#define SOPLEX_DEFAULT_INFINITY 1e100
296#define SOPLEX_MAX(x,y) ((x)>(y) ? (x) : (y))
297#define SOPLEX_MIN(x,y) ((x)<(y) ? (x) : (y))
299#define SPX_MAXSTRLEN 1024
399#ifdef WITH_LONG_DOUBLE
403 return nextafterl(x, y);
410 return nextafter(x, y);
412 return _nextafter(x, y);
436 return absa > absb ? absa : absb;
442 return (a - b) / (
maxAbs(a, b) > 1.0 ?
maxAbs(a, b) : 1.0);
456 assert(t !=
nullptr);
461#if defined(_WIN32) || defined(_WIN64)
462 n = _vsnprintf(t, len, s, ap);
464 n = vsnprintf(t, len, s, ap);
468 if(n < 0 || (
size_t) n >= len)
474 SPX_MSG_ERROR(std::cerr <<
"vsnprintf returned " << n <<
" while reading: " << s << std::endl;)
485#ifdef SOPLEX_WITH_BOOST
487using namespace boost::multiprecision;
489#ifdef SOPLEX_WITH_GMP
490template<boost::multiprecision::expression_
template_option eto>
491inline number<gmp_rational, eto>
ldexp(number<gmp_rational, eto>,
int exp)
494 return number<gmp_rational>();
497template<boost::multiprecision::expression_
template_option eto>
498inline number<gmp_rational, eto>
frexp(number<gmp_rational, eto>,
int* exp)
501 return number<gmp_rational>();
504inline cpp_rational
ldexp(cpp_rational r,
int exp)
507 return cpp_rational();
510inline cpp_rational
frexp(cpp_rational,
int* exp)
513 return cpp_rational();
518template <
typename T, boost::multiprecision::expression_
template_option eto>
519boost::multiprecision::number<T, eto>
spxFrexp(boost::multiprecision::number<T, eto> y,
int* exp)
521 return frexp(y, exp);
525template <
typename T, boost::multiprecision::expression_
template_option eto>
526boost::multiprecision::number<T>
spxLdexp(boost::multiprecision::number<T, eto> x,
int exp)
528 return ldexp(x, exp);
532template <
typename T, expression_
template_option ep>
539template <
typename T, expression_
template_option eto>
561template <
typename T, expression_
template_option et>
563 number<T, et> a, number<T, et> b)
565 const auto absa =
spxAbs(a);
566 const auto absb =
spxAbs(b);
568 return absa > absb ? absa : absb;
571template <
typename T, expression_
template_option et>
575 return (a - b) / (
maxAbs(a, b) > 1.0 ?
maxAbs(a, b) : 1.0);
583#include "spxdefines.hpp"
Real s_epsilon_factorization
epsilon for factorization
Real feastol()
global feasibility tolerance
Real floatingPointFeastol()
floating point feasibility tolerance used within the solver
void setFloatingPointFeastol(Real ftol)
set floating point feasibility tolerance used within the solver
Real s_floating_point_opttol
floating point optimality tolerance
Real s_floating_point_feastol
floating point feasibility tolerance
Real epsilon()
global zero epsilon
Real s_epsilon_update
epsilon for factorization update
Real s_epsilon_pivot
epsilon for pivot zero tolerance in factorization
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 ...
void setFeastol(Real ftol)
set global feasibility tolerance
void setEpsilonUpdate(Real eps)
set zero espilon used in factorization update
Real epsilonPivot()
zero espilon used in pivot
void setOpttol(Real otol)
set global optimality tolerance
void setEpsilonFactorization(Real eps)
set zero espilon used in factorization
Real floatingPointOpttol()
floating point optimality tolerance used within the solver
void setFloatingPointOpttol(Real otol)
set floating point optimality tolerance used within the solver
void setEpsilon(Real eps)
set global zero epsilon
Real s_epsilon
default allowed additive zero: 1.0 + EPS_ZERO == 1.0
void setEpsilonPivot(Real eps)
set zero espilon used in pivot
Real s_epsilon_multiplier
multiplier for fixed numbers that should change if s_epsilon changes
Real epsilonUpdate()
zero espilon used in factorization update
Real s_opttol
optimality tolerance
Real opttol()
global optimality tolerance
Everything should be within this namespace.
int spxSnprintf(char *t, size_t len, const char *s,...)
safe version of snprintf
Real spxNextafter(Real x, Real y)
bool msginconsistent(const char *name, const char *file, int line)
Real maxAbs(Real a, Real b)
returns max(|a|,|b|)
number< gmp_rational, eto > ldexp(number< gmp_rational, eto >, int exp)
Real spxSqrt(Real a)
returns square root
Real relDiff(Real a, Real b)
returns (a-b) / max(|a|,|b|,1.0)
number< gmp_rational, eto > frexp(number< gmp_rational, eto >, int *exp)
boost::multiprecision::number< T > spxLdexp(boost::multiprecision::number< T, eto > x, int exp)
SOPLEX_THREADLOCAL const Real infinity
boost::multiprecision::number< T, eto > spxFrexp(boost::multiprecision::number< T, eto > y, int *exp)
#define SOPLEX_DEFAULT_EPS_PIVOR
#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.
#define SOPLEX_THREADLOCAL
SOPLEX_DEBUG.
#define SOPLEX_DEFAULT_EPS_UPDATE
#define SOPLEX_DEFAULT_EPS_FACTOR
#define SOPLEX_DEFAULT_BND_VIOL
default allowed bound violation