[gecode-users] Decimal

Filip Konvička filip.konvicka at logis.cz
Wed May 20 15:05:11 CEST 2009



Yes, that sounds like a job for float variables. But I've not had time 
to port the variables to 3.0 yet, sorry.

Javier, you should find a patch for Gecode 2.2.0 in this ML archive at 
gmane.org that adds floating variables to Gecode.

Note however that in all cases, you need to be careful about error 
propagation and scaling problems if you're dealing with such numbers. 
This is no easy task. The Boost.Interval library (used in float 
variables) is supposed to help with this, so the float variables should 
be correct, but the propagation may be weaker due to scaling/rounding 
problems. This is of course a limitation of the floating-point data 
types. The number you mention already has about 10 valid digits, so any 
operation you do with such number will likely result in precision lost. 
You may consider running float variables with a library like MPFR 
(www.mpfr.org) to improve precision.

Hope this helps,
Filip

> I think you should go for float variables, however I do not know whether
> they have been ported to 3.* Any comment…
>
> Christian
>
> *From:* users-bounces-2NGZVH8mcjgdnm+yROfE0A at public.gmane.org
> [mailto:users-bounces-2NGZVH8mcjgdnm+yROfE0A at public.gmane.org] *On
> Behalf Of *Javier Andrés Mena Zapata
> *Sent:* Tuesday, May 19, 2009 9:30 PM
> *To:* gecode list
> *Subject:* [gecode-users] Decimal
>
> Hi,
>
> I'm modelling a financial problem (calculating minimum interests
> payments and ROI), and I want to model the "money" value using Gecode
> integer variables.
>
> For example, representing 10.25 is like storing 1025 divided by 100.
> But, there's a problem with the multiplication, because the interests
> rates are float values with very muchs decimals. For example
> 0.00643403011. I think there may be an overflow if I model this decimal
> using something like 6434 divided by 1000000.
>
> What do you think it's the best technique for modelling this problem:
>
>    1. Use IntVars and the current propagators (as proposed here).
>    2. Use IntVars, and creating new propagators for IntVar x Float
>       multiplication.
>    3. Use float vars, and its propagators.
>    4. Other?
>
> Thanks,
>
> --
> Javier Andrés Mena Zapata
> http://StrategicDecision.net/
> Cali - Colombia
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gecode users mailing list
> users-2NGZVH8mcjgdnm+yROfE0A at public.gmane.org
> https://www.gecode.org/mailman/listinfo/gecode-users


-- 
Filip Konvička

LOGIS, s.r.o.
tel. +420 556 841 100
mob. +420 736 758 714





More information about the gecode-users mailing list