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> 60 #define ABC_INSTRUMENT 1 //2 63 #define instrument_start(name,x) 64 #define instrument_add(x) 65 #define instrument_end() 67 #define instrument_do(name,x) 69 #define instrument_end_and_adjust(x) 80 #if __BYTE_ORDER == __LITTLE_ENDIAN 83 #if COIN_BIG_DOUBLE==1 85 #undef USE_TEST_REALLY_ZERO 86 #undef USE_TEST_ZERO_REGISTER 87 #undef USE_TEST_LESS_TOLERANCE 88 #undef USE_TEST_LESS_TOLERANCE_REGISTER 89 #define CoinFabs(x) fabsl(x) 91 #define CoinFabs(x) fabs(x) 94 #if __BYTE_ORDER == __LITTLE_ENDIAN 95 #define TEST_DOUBLE_NONZERO(x) ((reinterpret_cast<int *>(&x))[1]!=0) 97 #define TEST_DOUBLE_NONZERO(x) ((reinterpret_cast<int *>(&x))[0]!=0) 101 #define TEST_DOUBLE_NONZERO(x) (true) 103 #define USE_TEST_INT_ZERO 104 #ifdef USE_TEST_INT_ZERO 105 #define TEST_INT_NONZERO(x) (x) 108 #define TEST_INT_NONZERO(x) (true) 110 #ifdef USE_TEST_REALLY_ZERO 111 #if __BYTE_ORDER == __LITTLE_ENDIAN 112 #define TEST_DOUBLE_REALLY_NONZERO(x) ((reinterpret_cast<int *>(&x))[1]!=0) 114 #define TEST_DOUBLE_REALLY_NONZERO(x) ((reinterpret_cast<int *>(&x))[0]!=0) 117 #define TEST_DOUBLE_REALLY_NONZERO(x) (x) 119 #ifdef USE_TEST_ZERO_REGISTER 120 #if __BYTE_ORDER == __LITTLE_ENDIAN 121 #define TEST_DOUBLE_NONZERO_REGISTER(x) ((reinterpret_cast<int *>(&x))[1]!=0) 123 #define TEST_DOUBLE_NONZERO_REGISTER(x) ((reinterpret_cast<int *>(&x))[0]!=0) 127 #define TEST_DOUBLE_NONZERO_REGISTER(x) (true) 129 #define USE_FIXED_ZERO_TOLERANCE 130 #ifdef USE_FIXED_ZERO_TOLERANCE 132 #ifdef USE_TEST_LESS_TOLERANCE 133 #if __BYTE_ORDER == __LITTLE_ENDIAN 134 #define TEST_LESS_THAN_TOLERANCE(x) ((reinterpret_cast<int *>(&x))[1]&0x7ff00000<0x3d400000) 135 #define TEST_LESS_THAN_UPDATE_TOLERANCE(x) ((reinterpret_cast<int *>(&x))[1]&0x7ff00000<0x3d400000) 137 #define TEST_LESS_THAN_TOLERANCE(x) ((reinterpret_cast<int *>(&x))[0]&0x7ff00000<0x3d400000) 138 #define TEST_LESS_THAN_UPDATE_TOLERANCE(x) ((reinterpret_cast<int *>(&x))[0]&0x7ff00000<0x3d400000) 141 #define TEST_LESS_THAN_TOLERANCE(x) (fabs(x)<pow(0.5,43)) 142 #define TEST_LESS_THAN_UPDATE_TOLERANCE(x) (fabs(x)<pow(0.5,43)) 144 #ifdef USE_TEST_LESS_TOLERANCE_REGISTER 145 #if __BYTE_ORDER == __LITTLE_ENDIAN 146 #define TEST_LESS_THAN_TOLERANCE_REGISTER(x) ((reinterpret_cast<int *>(&x))[1]&0x7ff00000<0x3d400000) 148 #define TEST_LESS_THAN_TOLERANCE_REGISTER(x) ((reinterpret_cast<int *>(&x))[0]&0x7ff00000<0x3d400000) 151 #define TEST_LESS_THAN_TOLERANCE_REGISTER(x) (fabs(x)<pow(0.5,43)) 154 #define TEST_LESS_THAN_TOLERANCE(x) (fabs(x)<zeroTolerance_) 155 #define TEST_LESS_THAN_TOLERANCE_REGISTER(x) (fabs(x)<zeroTolerance_) 157 #if COIN_BIG_DOUBLE!=1 159 #if __BYTE_ORDER == __LITTLE_ENDIAN 160 #define ABC_EXPONENT(x) ((reinterpret_cast<int *>(&x))[1]&0x7ff00000) 162 #define ABC_EXPONENT(x) ((reinterpret_cast<int *>(&x))[0]&0x7ff00000) 164 #define TEST_EXPONENT_LESS_THAN_TOLERANCE(x) (x<0x3d400000) 165 #define TEST_EXPONENT_LESS_THAN_UPDATE_TOLERANCE(x) (x<0x3d400000) 166 #define TEST_EXPONENT_NON_ZERO(x) (x) 169 #define ABC_EXPONENT(x) (x) 170 #define TEST_EXPONENT_LESS_THAN_TOLERANCE(x) (fabs(x)<pow(0.5,43)) 171 #define TEST_EXPONENT_LESS_THAN_UPDATE_TOLERANCE(x) (fabs(x)<pow(0.5,43)) 172 #define TEST_EXPONENT_NON_ZERO(x) (x) 175 #define COINFACTORIZATION_BITS_PER_INT 64 176 #define COINFACTORIZATION_SHIFT_PER_INT 6 177 #define COINFACTORIZATION_MASK_PER_INT 0x3f 179 #define COINFACTORIZATION_BITS_PER_INT 32 180 #define COINFACTORIZATION_SHIFT_PER_INT 5 181 #define COINFACTORIZATION_MASK_PER_INT 0x1f 183 #if ABC_USE_HOMEGROWN_LAPACK==1 184 #define ABC_USE_LAPACK 186 #ifdef ABC_USE_LAPACK 187 #define F77_FUNC(x,y) x##_ 188 #define ABC_DENSE_CODE 1 193 typedef const int cipfint;
195 enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102 };
196 enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113,
203 void F77_FUNC(dgetrs,DGETRS)(
char *trans, cipfint *n,
208 void F77_FUNC(dgetrf,DGETRF)(ipfint * m, ipfint *n,
210 ipfint * ipiv, ipfint *info);
211 int clapack_dgetrf(
const enum CBLAS_ORDER Order,
const int M,
const int N,
212 double *A,
const int lda,
int *ipiv);
214 (
const enum CBLAS_ORDER Order,
const enum CBLAS_TRANSPOSE Trans,
215 const int N,
const int NRHS,
const double *A,
const int lda,
216 const int *ipiv,
double *B,
const int ldb);
218 #else // use home grown 224 #ifndef ABC_USE_HOMEGROWN_LAPACK 225 #define ABC_DENSE_CODE 2 227 #define ABC_DENSE_CODE ABC_USE_HOMEGROWN_LAPACK 231 template <
class T>
inline void 237 throw CoinError(
"trying to fill negative number of entries",
238 "CoinAbcMemset0",
"");
240 std::memset(to,0,size*
sizeof(T));
242 template <
class T>
inline void 248 throw CoinError(
"trying to copy negative number of entries",
249 "CoinAbcMemcpy",
"");
252 std::memcpy(to,from,size*
sizeof(T));
int baseIteration_
Iteration when we entered dual or primal.
double allowedInfeasibility_
double primalTolerance_
Current primal tolerance for algorithm.
#define instrument_end_and_adjust(x)
double incomingInfeasibility_
For advanced use.
double dualTolerance_
Current dual tolerance for algorithm.
int dontFactorizePivots_
If may skip final factorize then allow up to this pivots (default 20)
void CoinAbcMemcpy(register T *to, register const T *from, const int size)
This solves LPs using the simplex method.
double primalToleranceToGetOptimal_
Primal tolerance needed to make dual feasible (<largeTolerance)
AbcTolerancesEtc()
Default Constructor.
int forceFactorization_
Now for some reliability aids This forces re-factorization early.
unsigned char CoinCheckZero
~AbcTolerancesEtc()
Destructor.
double zeroTolerance_
Zero tolerance.
AbcTolerancesEtc & operator=(const AbcTolerancesEtc &rhs)
Assignment operator.
double largeValue_
Large bound value (for complementarity etc)
double dualBound_
Dual bound.
#define instrument_start(name, x)
#define instrument_add(x)
void CoinAbcMemset0(register T *to, const int size)
#define instrument_do(name, x)
double infeasibilityCost_
Weight assigned to being infeasible in primal.
int perturbation_
Perturbation: -50 to +50 - perturb by this power of ten (-6 sounds good) 100 - auto perturb if takes ...
int numberRefinements_
How many iterative refinements to do.
double alphaAccuracy_
For computing whether to re-factorize.
unsigned int CoinExponent
int maximumPivots_
For factorization Maximum number of pivots before factorization.
unsigned int CoinSimplexUnsignedInt