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>
94#define SOPLEX_VERSION 712
95#define SOPLEX_SUBVERSION 0
96#define SOPLEX_APIVERSION 17
97#define SOPLEX_COPYRIGHT "Copyright (c) 1996-2024 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__ << ": " \
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 != nullptr ) \
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 ) }
173extern 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
209typedef 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
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
400#ifdef WITH_LONG_DOUBLE
404 return nextafterl(x, y);
411 return nextafter(x, y);
413 return _nextafter(x, y);
437 return absa > absb ? absa : absb;
443 return (a - b) / (
maxAbs(a, b) > 1.0 ?
maxAbs(a, b) : 1.0);
457 assert(t !=
nullptr);
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
488using namespace boost::multiprecision;
490#ifdef SOPLEX_WITH_GMP
491template<boost::multiprecision::expression_
template_option eto>
492inline number<gmp_rational, eto>
ldexp(number<gmp_rational, eto>,
int exp)
495 return number<gmp_rational>();
498template<boost::multiprecision::expression_
template_option eto>
499inline number<gmp_rational, eto>
frexp(number<gmp_rational, eto>,
int* exp)
502 return number<gmp_rational>();
505inline cpp_rational
ldexp(cpp_rational r,
int exp)
508 return cpp_rational();
511inline cpp_rational
frexp(cpp_rational,
int* exp)
514 return cpp_rational();
519template <
typename T, boost::multiprecision::expression_
template_option eto>
520boost::multiprecision::number<T, eto>
spxFrexp(boost::multiprecision::number<T, eto> y,
int* exp)
522 return frexp(y, exp);
526template <
typename T, boost::multiprecision::expression_
template_option eto>
527boost::multiprecision::number<T>
spxLdexp(boost::multiprecision::number<T, eto> x,
int exp)
529 return ldexp(x, exp);
533template <
typename T, expression_
template_option ep>
540template <
typename T, expression_
template_option eto>
562template <
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;
572template <
typename T, expression_
template_option et>
576 return (a - b) / (
maxAbs(a, b) > 1.0 ?
maxAbs(a, b) : 1.0);
584#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