[gecode-users] Float overflow exceptions with 'linear' in 6.0.1

Konvicka Filip Filip.Konvicka at logis.cz
Mon Sep 3 08:36:54 CEST 2018


Hi Christian,

OK, I yield! :)  Thanks.  I didn't know that about the integer propagators and I guess I should check that I'm careful enough where I'm using them.

Cheers,
Filip

From: Christian Schulte [mailto:cschulte at kth.se]
Sent: Saturday, September 1, 2018 1:40 PM
To: Konvicka Filip; 'users at gecode.org'
Subject: RE: Float overflow exceptions with 'linear' in 6.0.1

Hi Filip,

Actually, it is the other way around: now the float propagators behave as the integer propagators always did.

Well, the risk was there before but the system would not tell that.

Best
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-bounces at gecode.org <users-bounces at gecode.org> On Behalf Of Konvicka Filip
Sent: 30 August 2018 21:10
To: Christian Schulte <cschulte at kth.se>; 'users at gecode.org' <users at gecode.org>
Subject: Re: [gecode-users] Float overflow exceptions with 'linear' in 6.0.1

Hi Christian,

Thanks.  I'll see what I can do.  I think I understand the intention.... I guess my expectation was that the propagators do the necessary domain pruning themselves (like they do with integers), and I guess that this is not being done as there could be multiple ways of eliminating the overflow risk, so Gecode would in fact influence the results in some "random" way.

My fear is that unless I get to understand in detail what checks are being made by each constraint that I post, I'll run the risk of a runtime error, or that I'll unnecessarily reduce the solution space.

In my scenario, I have several arithmetic expressions (equations or the like) provided by the end user as input, and after parsing this into an AST I'm translating these to Gecode constraints.  The intermediates in the AST are "fresh" (unconstrained) variables.  Hopefully I can do some domain analysis upfront.... but it's still surprising to me, I would guess that e.g. the minizinc interface would also be impacted...

Cheers,
Filip

From: Christian Schulte [mailto:cschulte at kth.se]
Sent: Tuesday, August 28, 2018 4:56 PM
To: Konvicka Filip; 'users at gecode.org'
Subject: RE: Float overflow exceptions with 'linear' in 6.0.1

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-bounces at gecode.org<mailto:users-bounces at gecode.org> <users-bounces at gecode.org<mailto:users-bounces at gecode.org>> On Behalf Of Konvicka Filip
Sent: 24 August 2018 09:48
To: 'users at gecode.org' <users at gecode.org<mailto:users at 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";
  }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.gecode.org/pipermail/users/attachments/20180903/b4f93e65/attachment-0001.html>


More information about the users mailing list