Hi,

This is not a bug: it is really a restriction compared to Gecode 5. You will 
have to do some thinking on the initial variable domains.

The implementation in Gecode 5 _was_ in fact broken: the overflow might not 
have occurred but the new checks make sure that there will never be an overflow.

Cheers
Christian

--
Christian Schulte, https://chschulte.github.io/
Professor of Computer Science
Software and  Computer Systems
School of Electrical Engineering and Computer Science
KTH Royal Institute of Technology, Sweden

From: users-boun...@gecode.org <users-boun...@gecode.org> On Behalf Of Konvicka 
Filip
Sent: 24 August 2018 09:48
To: 'users@gecode.org' <users@gecode.org>
Subject: [gecode-users] Float overflow exceptions with 'linear' in 6.0.1

Hi,

I'm in process of upgrading our code to Gecode 6.0.1 (which looks great by the 
way!)

I found some cases where code that used to run fine with Gecode 5 now throws 
exceptions.  The following is a simple example that demonstrates this.  I was 
able to work around to defaulting to (Gecode::Float::Limits::max/4) as the 
default max bound of float variables, but I think it's still probably a bug.

Thanks,
Filip

#include <gecode/float.hh>
#include <iostream>
using namespace Gecode;
int main() {
  struct MySpace : public Space {
    Space* copy() { return nullptr;  }
  };
  MySpace s;

  try {
    FloatVarArgs args(2);
    args[0] = FloatVar(s, 0., Gecode::Float::Limits::max);
    args[1] = FloatVar(s, 0., Gecode::Float::Limits::max);
    FloatVar result(s, 0., Gecode::Float::Limits::max);
    linear(s, args, FRT_EQ, result);
  }
  catch (std::exception& e) {
    std::cerr << e.what() << "\n";
  }

  try {
    FloatVarArgs args(2);
    args[0] = FloatVar(s, 1., 1.);
    args[1] = FloatVar(s, 0., Gecode::Float::Limits::max);
    FloatVar result(s, 0., Gecode::Float::Limits::max);
    linear(s, args, FRT_EQ, result);
  }
  catch (std::exception& e) {
    std::cerr << e.what() << "\n";
  }
}
_______________________________________________
Gecode users mailing list
users@gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users

Reply via email to