[Lemon-user] min-cost network flow use of numeric_limits for artificial cost

Kovács Péter kpeter at inf.elte.hu
Fri Jul 30 08:36:27 CEST 2010


Dear Matt,

> In the calculation of artificial cost, you are using numeric_limits to
> initialize the value. However, it will be different depending on if you
> are using double or integer. See here:
> http://gorithm.blogs.com/gorithm/2006/07/c_gotcha_numeri.html
>
> Is this a problem for the algorithm?
>
> numeric_limits<int>::max() is 2147483647
> numeric_limits<int>::min() is -2147483648
> numeric_limits<double>::max() is 1.79769e+308
>
> What do you suppose numeric_limits<double>::min() would be?
>
> I assumed it would be -1.79769e+308, but no. It is 2.22507e-308,

Yes, this behavior was strange for me, too. I have noticed it a few 
months ago and made a fix for NS. In most cases, you could use -max() 
instead of min() in a template program.

In release 1.2, min() is not used properly. However, it is fixed in the 
current development version and will be fixed in 1.2.1 (the bugfix 
release of 1.2). For more details, see:
http://lemon.cs.elte.hu/trac/lemon/ticket/368

The extended LEQ-GEQ version of NS that I sent to you also contains this 
fix.

Regards,
Peter



More information about the Lemon-user mailing list