spine-tools / Spine-Database-API

Database interface to Spine generic data model
https://www.tools-for-energy-system-modelling.org/
GNU Lesser General Public License v3.0
6 stars 5 forks source link

Support EPS Value in GDX Exporter #413

Closed EWLCJahns closed 1 month ago

EWLCJahns commented 1 month ago

Hello,

first of all thanks for the great work. I would like to make a suggestion for an improvement. Currently exporting "Inf" Values is supportet in the GDX exporter. Here is my suggestion to support "EPS" values as well:

In Line 23 of the file spine_db_api/spine_io/exporter/gdx_writer.py is a dictionary that translates math.inf to a GAMS "Inf value.

SPECIAL_CONVERSIONS = {EPS_VALUE: gdxcc.GMS_SV_EPS, math.inf: gdxcc.GMS_SV_PINF, -math.inf: gdxcc.GMS_SV_MINF}

We could add that a small value, for exmaple 1**-10 is translatet to EPS as well.

SPECIAL_CONVERSIONS = {EPS_VALUE: gdxcc.GMS_SV_EPS, math.inf: gdxcc.GMS_SV_PINF, -math.inf: gdxcc.GMS_SV_MINF,  0.0000000001: gdxcc.GMS_SV_EPS}

The conversion from the string "EPS" to a Gams "EPS" would be more intuitive but would possibly require more changes.

soininen commented 1 month ago

"EPS" string also now converts to GAMS Eps.

jkiviluo commented 1 month ago

@EWLCJahns Thanks for the nice issue report - it was easy for Antti to implement.