NREL / gdx-pandas

Python interface to read and write GAMS GDX files using pandas.DataFrames as the intermediate data format.
BSD 3-Clause "New" or "Revised" License
43 stars 16 forks source link

GAMS `eps` isn't the same as Numpy EPS #39

Open jebob opened 5 years ago

jebob commented 5 years ago

GAMS eps is a special value for an arbitrarily a small number [sic] and has all the logic of an infintesimal,

An eps in a GDX is currently converted to np.finfo(float).eps, defined as "The smallest representable positive number such that 1.0 + eps != 1.0." which is about 2.220446049250313e-16 on my machine. This is in line with the python definition but doesn't have the infitesimal properties.

I propose changing all references to np.finfo(float).eps to np.finfo(float).tiny, which is about 2.2250738585072014e-308 on my machine.

jebob commented 5 years ago

Sadly, the literature on what epsilon is seems to be inconclusive.

jebob commented 5 years ago

Actually, in GAMS eps eq 0, so maybe it should map to zero?

jebob commented 5 years ago

The documentation for the embedded code feature shows they map EPS to 0 (default) or 4.94066E-324.

elainethale commented 3 years ago

@jebob - I think it makes sense to follow what GAMS does and either map to ~1E-300 or 0. I lean toward the former (or explicitly providing the option), because in my experience part of the point of preserving eps values in GDX is to indicate that something is there/something has been calculated rather than is missing. That is, if the default maps eps to 0, that information (an actual rather than a missing value in the GDX file) may get lost.

jebob commented 3 years ago

Makes sense to me, I lean towards 1e-300 as well.