예제 #1
0
def load_gdxcc(gams_dir=None):
    if 'pandas' in sys.modules:
        logger.warn("Especially on Linux, gdxpds should be imported before " + \
                    "pandas to avoid a library conflict. Also make sure your " + \
                    "GAMS directory is listed in LD_LIBRARY_PATH.")
    import gdxcc
    from gdxpds.tools import GamsDirFinder
    finder = GamsDirFinder(gams_dir=gams_dir)
    H = gdxcc.new_gdxHandle_tp()
    rc = gdxcc.gdxCreateD(H, finder.gams_dir, gdxcc.GMS_SSSIZE)
    gdxcc.gdxFree(H)
    return
예제 #2
0
def load_gdxcc(gams_dir=None):
    """
    Method to initialize GAMS, especially to load required libraries that can 
    sometimes conflict with other packages.

    Parameters
    ----------
    gams_dir : None or str
        if not None, directory containing the GAMS executable
    """
    if 'pandas' in sys.modules:
        logger.warn("Especially on Linux, gdxpds should be imported before " + \
                    "pandas to avoid a library conflict. Also make sure your " + \
                    "GAMS directory is listed in LD_LIBRARY_PATH.")
    import gdxcc
    from gdxpds.tools import GamsDirFinder
    finder = GamsDirFinder(gams_dir=gams_dir)
    H = gdxcc.new_gdxHandle_tp()
    rc = gdxcc.gdxCreateD(H, finder.gams_dir, gdxcc.GMS_SSSIZE)
    gdxcc.gdxFree(H)
    return
예제 #3
0
        if not None, directory containing the GAMS executable
    """
    if 'pandas' in sys.modules:
        logger.warn("Especially on Linux, gdxpds should be imported before " + \
                    "pandas to avoid a library conflict. Also make sure your " + \
                    "GAMS directory is listed in LD_LIBRARY_PATH.")
    import gdxcc
    from gdxpds.tools import GamsDirFinder
    finder = GamsDirFinder(gams_dir=gams_dir)
    H = gdxcc.new_gdxHandle_tp()
    rc = gdxcc.gdxCreateD(H, finder.gams_dir, gdxcc.GMS_SSSIZE)
    gdxcc.gdxFree(H)
    return


try:
    load_gdxcc()
except:
    from gdxpds.tools import GamsDirFinder
    gams_dir = None
    try:
        gams_dir = GamsDirFinder().gams_dir
    except:
        pass
    logger.warn("Unable to load gdxcc with default GAMS directory '{}'. ".format(gams_dir) + \
                "You may need to explicitly call gdxpds.load_gdxcc(gams_dir) " + \
                "before importing pandas to avoid a library conflict.")

from gdxpds.read_gdx import to_dataframes, list_symbols, to_dataframe
from gdxpds.write_gdx import to_gdx