Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use always 64-bit arithemtics #112

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/CglGMI/CglGMI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -884,15 +884,15 @@ bool CglGMI::scaleCut(double* cutElem, int* cutIndex, int cutNz,
/************************************************************************/
bool CglGMI::scaleCutIntegral(double* cutElem, int* cutIndex, int cutNz,
double& cutRhs) {
long gcd, lcm;
int64_t gcd, lcm;
double maxdelta = param.getEPS();
double maxscale = 1000;
long maxdnom = 1000;
long numerator = 0, denominator = 0;
int64_t maxdnom = 1000;
int64_t numerator = 0, denominator = 0;
// Initialize gcd and lcm
CoinRational r = CoinRational(cutRhs, maxdelta, maxdnom);
if (r.getNumerator() != 0){
gcd = labs(r.getNumerator());
gcd = llabs(r.getNumerator());
lcm = r.getDenominator();
}
else{
Expand Down Expand Up @@ -933,13 +933,13 @@ bool CglGMI::scaleCutIntegral(double* cutElem, int* cutIndex, int cutNz,
} /* scaleCutIntegral */

/************************************************************************/
long CglGMI::computeGcd(long a, long b) {
int64_t CglGMI::computeGcd(int64_t a, int64_t b) {
// This is the standard Euclidean algorithm for gcd
long remainder = 1;
int64_t remainder = 1;
// Make sure a<=b (will always remain so)
if (a > b) {
// Swap a and b
long temp = a;
int64_t temp = a;
a = b;
b = temp;
}
Expand Down
6 changes: 3 additions & 3 deletions src/CglGMI/CglGMI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ class CGLLIB_EXPORT CglGMI : public CglCutGenerator {
double& cutRhs);

/// Compute the nearest rational number; used by scale_row_integral
bool nearestRational(double val, double maxdelta, long maxdnom,
long& numerator, long& denominator);
bool nearestRational(double val, double maxdelta, int64_t maxdnom,
int64_t& numerator, int64_t& denominator);

/// Compute the greatest common divisor
long computeGcd(long a, long b);
int64_t computeGcd(int64_t a, int64_t b);

/// print a vector of integers
void printvecINT(const char *vecstr, const int *x, int n) const;
Expand Down
14 changes: 7 additions & 7 deletions src/CglGomory/CglGomory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,13 @@ static long long int gcd(long long int a, long long int b)
#define GOMORY_INT int
#endif
#if USE_CGL_RATIONAL>0
static long computeGcd(long a, long b) {
static int64_t computeGcd(int64_t a, int64_t b) {
// This is the standard Euclidean algorithm for gcd
long remainder = 1;
int64_t remainder = 1;
// Make sure a<=b (will always remain so)
if (a > b) {
// Swap a and b
long temp = a;
int64_t temp = a;
a = b;
b = temp;
}
Expand All @@ -448,14 +448,14 @@ static long computeGcd(long a, long b) {
} /* computeGcd */
static bool scaleCutIntegral(double* cutElem, int* cutIndex, int cutNz,
double& cutRhs, double maxdelta) {
long gcd, lcm;
int64_t gcd, lcm;
double maxscale = 1000;
long maxdnom = USE_CGL_RATIONAL;
//long numerator = 0, denominator = 0;
int64_t maxdnom = USE_CGL_RATIONAL;
//int64_t numerator = 0, denominator = 0;
// Initialize gcd and lcm
CoinRational r = CoinRational(cutRhs, maxdelta, maxdnom);
if (r.getNumerator() != 0){
gcd = labs(r.getNumerator());
gcd = llabs(r.getNumerator());
lcm = r.getDenominator();
}
else{
Expand Down
14 changes: 7 additions & 7 deletions src/CglPreProcess/CglPreProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1183,13 +1183,13 @@ static void writeDebugMps(const OsiSolverInterface *solver,
#define USE_CGL_RATIONAL 1
#if USE_CGL_RATIONAL>0
#include "CoinRational.hpp"
static long computeGcd(long a, long b) {
static int64_t computeGcd(int64_t a, int64_t b) {
// This is the standard Euclidean algorithm for gcd
long remainder = 1;
int64_t remainder = 1;
// Make sure a<=b (will always remain so)
if (a > b) {
// Swap a and b
long temp = a;
int64_t temp = a;
a = b;
b = temp;
}
Expand All @@ -1212,15 +1212,15 @@ static long computeGcd(long a, long b) {
} /* computeGcd */
static bool scaleRowIntegral(double* rowElem, int rowNz)
{
long gcd, lcm;
int64_t gcd, lcm;
double maxdelta = 1.0e-13;
double maxscale = 1000;
long maxdnom = 1000;
//long numerator = 0, denominator = 0;
int64_t maxdnom = 1000;
//int64_t numerator = 0, denominator = 0;
// Initialize gcd and lcm
CoinRational r = CoinRational(rowElem[0], maxdelta, maxdnom);
if (r.getNumerator() != 0){
gcd = labs(r.getNumerator());
gcd = llabs(r.getNumerator());
lcm = r.getDenominator();
} else {
return false;
Expand Down
Loading