[gecode-users] Reflection support for FloatVars questions

Filip Konvička filip.konvicka at logis.cz
Mon Aug 25 09:19:33 CEST 2008


Hi Guido,

>> Another thing is the reflection spec (Gecode::Reflection::ActorSpec).
>> There seems to be support for signed integer constants and for  
>> strings,
>> so I'll try to serialize interval domains and constants using some
>> standard conversions to/from std::string (like boost::lexical_cast). I
>> suppose that adding support for types like 'double' and 'float' to
>> ActorSpec is probably a bad idea (given the platform differences in
>> representing floats...right?)
> 
> Hm, I don't know.  An ActorSpec just must be able to represent what  
> the system uses, it doesn't have to be platform-independent.  The idea  
> is that an ActorSpec just lets you look inside the propagator.  If you  
> want to communicate the specs, e.g. over the network, you'll have to  
> make sure that a platform-independent representation is used.  E.g.,  
> we can use boost serialization to turn ActorSpecs into strings.  The  
> serialization classes should allow platform-independent transfer of  
> e.g. doubles.

Cool, in that case maybe we could consider adding support for all 
"basic" C++ numeric types: float, double, long double, long long. I'm 
sure that Boost.Serialization handles portability issues well.

My concern about portability was related to your JavaScript example: 
adding these types means that you have to extend the parser quite a bit. 
(For example, you need to solve the ambiguities between types.)

> So, I guess we should add support for double in ActorSpec.

Another option, of course, is adding support just for double, which is 
probably what most people would use. For now, anyway, I'm planning to 
use some default conversion to/from string (using boost::lexical_cast), 
and let the users override this for their numeric type of choice if that 
doesn't work with lexical_cast. The thing to keep in mind with FloatVar 
is that you never know in advance what numeric type it'll run with, so 
we have to provide such mechanism anyway.

I'll come back with more questions if my attempts to run FloatVar 
examples with Gist fail :-)

Cheers,
Filip





More information about the gecode-users mailing list