Go to the documentation of this file.
5 #ifndef CoinAbcCommon_H
6 #define CoinAbcCommon_H
11 #include "CoinPragma.hpp"
12 #include "CoinUtilsConfig.h"
19 #include "CoinHelperFunctions.hpp"
26 #define ABC_INLINE __forceinline
27 #elif defined(__GNUC__)
28 #define ABC_INLINE __attribute__((always_inline))
34 #define ABC_PARALLEL 2
36 #define ABC_PARALLEL 0
42 #include <cilk/cilk.h>
55 #define ABC_INSTRUMENT 1 //2
56 #if ABC_INSTRUMENT != 2
58 #define instrument_start(name, x)
59 #define instrument_add(x)
60 #define instrument_end()
62 #define instrument_do(name, x)
64 #define instrument_end_and_adjust(x)
75 #if __BYTE_ORDER == __LITTLE_ENDIAN
78 #if COIN_BIG_DOUBLE == 1
80 #undef USE_TEST_REALLY_ZERO
81 #undef USE_TEST_ZERO_REGISTER
82 #undef USE_TEST_LESS_TOLERANCE
83 #undef USE_TEST_LESS_TOLERANCE_REGISTER
84 #define CoinFabs(x) fabsl(x)
86 #define CoinFabs(x) fabs(x)
89 #if __BYTE_ORDER == __LITTLE_ENDIAN
90 #define TEST_DOUBLE_NONZERO(x) ((reinterpret_cast< int * >(&x))[1] != 0)
92 #define TEST_DOUBLE_NONZERO(x) ((reinterpret_cast< int * >(&x))[0] != 0)
96 #define TEST_DOUBLE_NONZERO(x) (true)
98 #define USE_TEST_INT_ZERO
99 #ifdef USE_TEST_INT_ZERO
100 #define TEST_INT_NONZERO(x) (x)
103 #define TEST_INT_NONZERO(x) (true)
105 #ifdef USE_TEST_REALLY_ZERO
106 #if __BYTE_ORDER == __LITTLE_ENDIAN
107 #define TEST_DOUBLE_REALLY_NONZERO(x) ((reinterpret_cast< int * >(&x))[1] != 0)
109 #define TEST_DOUBLE_REALLY_NONZERO(x) ((reinterpret_cast< int * >(&x))[0] != 0)
112 #define TEST_DOUBLE_REALLY_NONZERO(x) (x)
114 #ifdef USE_TEST_ZERO_REGISTER
115 #if __BYTE_ORDER == __LITTLE_ENDIAN
116 #define TEST_DOUBLE_NONZERO_REGISTER(x) ((reinterpret_cast< int * >(&x))[1] != 0)
118 #define TEST_DOUBLE_NONZERO_REGISTER(x) ((reinterpret_cast< int * >(&x))[0] != 0)
122 #define TEST_DOUBLE_NONZERO_REGISTER(x) (true)
124 #define USE_FIXED_ZERO_TOLERANCE
125 #ifdef USE_FIXED_ZERO_TOLERANCE
127 #ifdef USE_TEST_LESS_TOLERANCE
128 #if __BYTE_ORDER == __LITTLE_ENDIAN
129 #define TEST_LESS_THAN_TOLERANCE(x) ((reinterpret_cast< int * >(&x))[1] & 0x7ff00000 < 0x3d400000)
130 #define TEST_LESS_THAN_UPDATE_TOLERANCE(x) ((reinterpret_cast< int * >(&x))[1] & 0x7ff00000 < 0x3d400000)
132 #define TEST_LESS_THAN_TOLERANCE(x) ((reinterpret_cast< int * >(&x))[0] & 0x7ff00000 < 0x3d400000)
133 #define TEST_LESS_THAN_UPDATE_TOLERANCE(x) ((reinterpret_cast< int * >(&x))[0] & 0x7ff00000 < 0x3d400000)
136 #define TEST_LESS_THAN_TOLERANCE(x) (fabs(x) < pow(0.5, 43))
137 #define TEST_LESS_THAN_UPDATE_TOLERANCE(x) (fabs(x) < pow(0.5, 43))
139 #ifdef USE_TEST_LESS_TOLERANCE_REGISTER
140 #if __BYTE_ORDER == __LITTLE_ENDIAN
141 #define TEST_LESS_THAN_TOLERANCE_REGISTER(x) ((reinterpret_cast< int * >(&x))[1] & 0x7ff00000 < 0x3d400000)
143 #define TEST_LESS_THAN_TOLERANCE_REGISTER(x) ((reinterpret_cast< int * >(&x))[0] & 0x7ff00000 < 0x3d400000)
146 #define TEST_LESS_THAN_TOLERANCE_REGISTER(x) (fabs(x) < pow(0.5, 43))
149 #define TEST_LESS_THAN_TOLERANCE(x) (fabs(x) < zeroTolerance_)
150 #define TEST_LESS_THAN_TOLERANCE_REGISTER(x) (fabs(x) < zeroTolerance_)
152 #if COIN_BIG_DOUBLE != 1
154 #if __BYTE_ORDER == __LITTLE_ENDIAN
155 #define ABC_EXPONENT(x) ((reinterpret_cast< int * >(&x))[1] & 0x7ff00000)
157 #define ABC_EXPONENT(x) ((reinterpret_cast< int * >(&x))[0] & 0x7ff00000)
159 #define TEST_EXPONENT_LESS_THAN_TOLERANCE(x) (x < 0x3d400000)
160 #define TEST_EXPONENT_LESS_THAN_UPDATE_TOLERANCE(x) (x < 0x3d400000)
161 #define TEST_EXPONENT_NON_ZERO(x) (x)
164 #define ABC_EXPONENT(x) (x)
165 #define TEST_EXPONENT_LESS_THAN_TOLERANCE(x) (fabs(x) < pow(0.5, 43))
166 #define TEST_EXPONENT_LESS_THAN_UPDATE_TOLERANCE(x) (fabs(x) < pow(0.5, 43))
167 #define TEST_EXPONENT_NON_ZERO(x) (x)
170 #define COINFACTORIZATION_BITS_PER_INT 64
171 #define COINFACTORIZATION_SHIFT_PER_INT 6
172 #define COINFACTORIZATION_MASK_PER_INT 0x3f
174 #define COINFACTORIZATION_BITS_PER_INT 32
175 #define COINFACTORIZATION_SHIFT_PER_INT 5
176 #define COINFACTORIZATION_MASK_PER_INT 0x1f
178 #if ABC_USE_HOMEGROWN_LAPACK == 1
179 #define ABC_USE_LAPACK
181 #ifdef ABC_USE_LAPACK
182 #define F77_FUNC(x, y) x##_
183 #define ABC_DENSE_CODE 1
188 typedef const int cipfint;
190 enum CBLAS_ORDER { CblasRowMajor = 101,
191 CblasColMajor = 102 };
192 enum CBLAS_TRANSPOSE { CblasNoTrans = 111,
194 CblasConjTrans = 113,
200 void F77_FUNC(dgetrs, DGETRS)(
char *trans, cipfint *n,
205 void F77_FUNC(dgetrf, DGETRF)(ipfint *m, ipfint *n,
207 ipfint *ipiv, ipfint *info);
208 int clapack_dgetrf(
const enum CBLAS_ORDER Order,
const int M,
const int N,
209 double *A,
const int lda,
int *ipiv);
210 int clapack_dgetrs(
const enum CBLAS_ORDER Order,
const enum CBLAS_TRANSPOSE Trans,
211 const int N,
const int NRHS,
const double *A,
const int lda,
212 const int *ipiv,
double *B,
const int ldb);
214 #else // use home grown
220 #ifndef ABC_USE_HOMEGROWN_LAPACK
221 #define ABC_DENSE_CODE 2
223 #define ABC_DENSE_CODE ABC_USE_HOMEGROWN_LAPACK
234 throw CoinError(
"trying to fill negative number of entries",
235 "CoinAbcMemset0",
"");
237 std::memset(to, 0, size *
sizeof(T));
246 throw CoinError(
"trying to copy negative number of entries",
247 "CoinAbcMemcpy",
"");
250 std::memcpy(to, from, size *
sizeof(T));
This solves LPs using the simplex method.
#define instrument_start(name, x)
AbcTolerancesEtc & operator=(const AbcTolerancesEtc &rhs)
Assignment operator.
#define instrument_end_and_adjust(x)
double dualTolerance_
Current dual tolerance for algorithm.
int forceFactorization_
Now for some reliability aids This forces re-factorization early.
~AbcTolerancesEtc()
Destructor.
double primalToleranceToGetOptimal_
Primal tolerance needed to make dual feasible (<largeTolerance)
AbcTolerancesEtc()
Default Constructor.
double infeasibilityCost_
Weight assigned to being infeasible in primal.
double dualBound_
Dual bound.
double zeroTolerance_
Zero tolerance.
int maximumPivots_
For factorization Maximum number of pivots before factorization.
int perturbation_
Perturbation: -50 to +50 - perturb by this power of ten (-6 sounds good) 100 - auto perturb if takes ...
double largeValue_
Large bound value (for complementarity etc)
#define instrument_do(name, x)
double alphaAccuracy_
For computing whether to re-factorize.
unsigned int CoinSimplexUnsignedInt
void CoinAbcMemset0(T *to, const int size)
int numberRefinements_
How many iterative refinements to do.
double allowedInfeasibility_
unsigned char CoinCheckZero
unsigned int CoinExponent
void CoinAbcMemcpy(T *to, const T *from, const int size)
int baseIteration_
Iteration when we entered dual or primal.
double primalTolerance_
Current primal tolerance for algorithm.
int dontFactorizePivots_
If may skip final factorize then allow up to this pivots (default 20)
#define instrument_add(x)
double incomingInfeasibility_
For advanced use.