GAMS MIRO and GAMS connect

In my current project, I created a GAMS model that runs either directly on the Engine UI or through GAMS Studio, using the engine for execution. Now, I want to adapt this model to work as a GAMS MIRO application. According to the documentation, I need to use $onExternalInput and $offExternalInput to specify the symbols for input data.

However, I’m currently using GAMS Connect to handle data for the project, and MIRO’s approach seems to be closer to GDXXRW for loading data. Given this setup, how can I integrate GAMS Connect with MIRO?

Currently, my input data is loaded using the following code:

parameter hholdData_raw
          consoData_raw
          gpriData_raw;
$onEmbeddedCode Connect:
- ExcelReader:
    file: hholddata_raw_new.xlsx
    symbols:
       - {name: hholdData_raw, range: hholdData!A1, columnDimension: 1,rowDimension: 1}
       - {name: consoData_raw, range: consoData!A1, columnDimension: 1,rowDimension: 2}
- GAMSWriter:
    writeAll: True  # GAMS 47
    #symbols: all  # GAMS 48
$offEmbeddedCode

So I try this which obviously doesnt’ work:

$onExternalInput
parameter hholdData_raw
          consoData_raw
          gpriData_raw;
$onEmbeddedCode Connect:
- ExcelReader:
    file: hholddata_raw_new.xlsx
    symbols:
       - {name: hholdData_raw, range: hholdData!A1, columnDimension: 1,rowDimension: 1}
       - {name: consoData_raw, range: consoData!A1, columnDimension: 1,rowDimension: 2}
- GAMSWriter:
    writeAll: True  # GAMS 47
    #symbols: all  # GAMS 48
$offEmbeddedCode
$offExternalInput

I would greatly appreciate any help or hint from you. Thanks a lot in advance.

Mathieu

Hi Mathieu,

Your approach is exactly the right one. The $embeddedcode section must be written between the $externalInput tags. As a result, the connect part is ignored when the model is called via MIRO (but the model continues to function normally independently of MIRO). Since the whole $embeddedcode block is ignored, we only need to tell GAMS which symbol data should be loaded implicitly. We do this by specifying an explicit list of symbol names after the $offEmbeddedcode.

$onExternalInput
parameter hholdData_raw
          consoData_raw
          gpriData_raw;
$onEmbeddedCode Connect:
- ExcelReader:
    file: hholddata_raw_new.xlsx
    symbols:
       - {name: hholdData_raw, range: hholdData!A1, columnDimension: 1,rowDimension: 1}
       - {name: consoData_raw, range: consoData!A1, columnDimension: 1,rowDimension: 2}
- GAMSWriter:
    writeAll: True  # GAMS 47
    #symbols: all  # GAMS 48
$offEmbeddedCode hholdData_raw consoData_raw
$offExternalInput

Note that gpriData_raw needs to be added to the list after the $offEmbeddedCode as well if it is also read from the xlsx file.