Integer or Long?

Help
Sylvain
2012-01-13
2013-05-30
  • Sylvain

    Sylvain - 2012-01-13

    Hi,

    Is there some reason JaCoP uses Integer and not Long? I deal with rather high numbers and I run into overflows quite often during the consistency calculations. I then have to decrease the bounds of my variables but it is not necessarily very realistic.
    Regards,

    Sylvain

     
  • kris

    kris - 2012-01-13

    Hi,

    This is basically historical reason to use integer instead of long. Currently it would be difficult to rewrite all to long.

    /Kris

     
  • Radoslaw Szymanek

    Hi,

    We choose a primitive type for efficiency reasons. Now, given that choice we had to choose between int or long. The problems we were dealing with did not use very large numbers so we choose int. Now, this is very old choice when 64bit machines were not yet used so we also did for performance and memory gains. Now, when 64bits machines are used commonly maybe we need to revisit that choice.

    I guess you could do a package wide change from int to long. Search for usage of Integer.MAX_INT, Integer.MIN_INT and replace it. It will be interesting to see what is the efficiency penalty when JaCoP is switched to long values.

    best regards,
    Radoslaw Szymanek

     
  • Sylvain

    Sylvain - 2012-01-16

    Hi,

    Thanks for your answers. It would be indeed rather difficult to rewrite all code. :-) If I had some time, I could try and make the changes you suggested, compile and make a few performance tests.
    Regards.

    Sylvain

     
  • kris

    kris - 2012-01-16

    Right. it is a lot of work since many constraints use min and max values and assume that there are int. Moreover, there is a lot of computations of domains that assumes int not long :(

    You can try to do it and test performance but it will require a lot of tests with all constraints :(

    /Kris

     

Log in to post a comment.