[Coin-discuss] arithmetic exception when using Cbc

Matthew Saltzman mjs at ces.clemson.edu
Thu Nov 2 12:27:28 EST 2006


On Thu, 2 Nov 2006, Kish Shen wrote:

> Hi,
>
> I am getting an arithmetic exception when using Cbc/Clp through OsiClp. 
> The crash happens in CbcModel.cpp, in gcd (line 84 in the copy I am 
> using):
>
>  while (remainder) {
>    remainder = b % a;
>    b = a;
>    a = remainder;
>  }
>  return b;
>
> The crash happens  in doing the % operation, I assume because a = -1.

Seems like an arithmetic exception should be easy to find.  Do you know 
what the args are that cause the crash?  What arch is this on?

One thing about / and % in C (resp. C++) is that they are ambiguous.  The 
standard requires that (a/b) * b + a % b = a, but it does not require that 
a % b >= 0, Some architectures return negative remainders if the dividend 
or divisor is negative.

On SPARC, for example, -4 % -6 == -4, -4 % 6 == -4, 4 % -6 == 4.

Not sure what the context for calls to gcd() is here, but it's worth 
paying attention to for a general-purpose gcd().

BTW, any reason not to move gcd() from Cbc to CoinUtils?  It seems like a 
generally useful thing to not have to recode.

>
> This is within a call to a call to CbcModel's branchAndBound().
>
> I am using Cbc/Clp as an MP solver for the Constraint Logic Programming 
> Language ECLiPSe, for which I am providing an interface. The original 
> problem occurs in a program of one of our users, and it happens after 
> repeated solving and modification of the problem.
>
> I have extracted the C/C++ calls to Osi/Cbc that reproduce this problem 
> without ECLiPSe. The file is quite big, nearly 300K in size, so I am not 
> including it with this message.
>
> I get this error with a copy of the development branch of Cbc I 
> donwloaded on 2006-08-17. I have just tried to run the same code with 
> the latest development branch which I downloaded today (2006-11-02), but 
> the program aborts much earlier. I haven't been able to look at why this 
> happens yet.
>
> Does this problem look like it might be something that I am doing wrong, 
> or something that might have been fixed since August?
>
> I guess John Forrest might be interested in looking at the code that 
> give this problem. Do please let me know, and I can send the code to 
> you.
>
> Thanks in advance for any information and help!
>
> Kish Shen
>
>
> _______________________________________________
> Coin-discuss mailing list
> Coin-discuss at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/coin-discuss
>

-- 
 		Matthew Saltzman

Clemson University Math Sciences
mjs AT clemson DOT edu
http://www.math.clemson.edu/~mjs



More information about the Coin-discuss mailing list