Widgets#
Introduction#
Input widgets are all items that communicate input data with GAMS. While these are primarily tables for multidimensional GAMS symbols, various widgets can be used for scalar input data. Examples of such widgets include sliders, dropdown menus, date selectors and checkboxes.
The symbol type to be configured can be selected at the top. The options are:
All symbols / widgets
Select this option to configure a GAMS symbol. Already configured GAMS options and double-dash parameters are also listed here, so that their configuration can be changed or removed.
Note
After configuring a widget for a scalar GAMS symbol, the symbol is automatically removed from the Scalars table and rendered as a widget instead.
New GAMS option / New double-dash parameter
As the name suggests, GAMS options and double-dash parameters can be configured here as an input widget. Since those parameters are specified via the command line in GAMS, they cannot be tagged in the GAMS code with
$onExternalInput/$offExternalInput. To set them for a GAMS run via MIRO, you must specify them explicitly in the configuration.
If a GAMS option or a double-dash parameter is set via MIRO, your GAMS model will automatically be called with these command line parameters. The values the user selected are therefore available to the GAMS model at compile time.
numberPeriods to 11 and select CPLEX for the GAMS option mip from within MIRO, then the GAMS model is run with:gams <modelname>.gms --numberPeriods=11 MIP=CPLEX
Warning
The following GAMS options are reserved by GAMS MIRO and cannot be configured: idir1, curdir, trace, traceopt
Table#
Configuration
By default, every cell in an input table is editable and rows can be inserted and removed. If you only want to allow your users to edit certain tables or even only certain columns within a table, you can customize the table for the underlying GAMS parameter. You can also use a different type of table to enter your data. For example, if you have large amounts of data (>100,000 records) in your table, we recommend using either the Big Data Table or the pivot table. In addition, input tables can be annotated with Markdown syntax. This way you can give your users additional information, e.g. what kind of data should be entered here and in which format.
Available Options
Default table:
The following options are available for the standard (default) table in MIRO, which works similarly to a spreadsheet.
Should table be read-only?
This option prevents the user from making manual changes in the input table of a scenario. If active, the table can only be filled with scenario data from the database/local files.
Select a column to pivot
This option allows you to pivot a table column of a symbol, i.e. to have a new column from each of the elements in this column:
Unlike the table statement in the GAMS model itself (Table symbolname;), this option does not affect the data contract between
GAMS and MIRO. Hence, the columns of the symbol remain variable, since the symbol itself is communicated in list format. The pivoting of the configured column then happens "live" in the MIRO
application.
Variable columns do not only mean that the column elements can change their names. It is also possible to add or delete whole columns. On the GAMS model side, this is equivalent to adding or
deleting a set element of the affected index.
Note
Instead of pivoting a single column, the MIRO pivot table can be used in case you want to interactively filter, pivot or aggregate columns.
When using the pivot option, note the following:
The table columns displayed with the pivot option can no longer be sorted alphabetically or numerically.
Furthermore, it is not possible to add or delete columns in the symbol table if it is either read-only or displayed as a heatmap.
Now let's look at a case where we should probably avoid using this pivot functionality: For this we look at the parameter Price of the Pickstock model:
Set date 'date'
symbol 'stockSymbol';
$onExternalInput
Parameter price(date,symbol) 'Price';
$offExternalInput
If we decide to pivot the set symbol, we would end up with a table where all stock symbols (AAPL, AXP, BA, etc.) are displayed in a separate
column:
The table width quickly increases when the header index has many set elements. For example, 30 stocks would lead to 30 additional columns. In this case, the list view might be clearer.
Fix columns that are not pivoted?
This option is available if a table has more than one value column. This can be the case for pivoted tables and for GAMS tables. When enabled, all columns that are not pivoted (i.e. all non-value columns) are fixed to the left side of the table and remain visible even when scrolling horizontally.
Select columns to be readonly
This option prevents the user from making manual changes in selected columns of the input table. Note that this option is only available for table columns that have not been pivoted (see option above).
Column widths
Sets the column width (in pixels) of each column in the table. The Configuration Mode supports the specification of one column width for all columns of the table. To specify the width of each column individually, the <modelname>.json file must be modified manually.
Specify the number of decimal places for the column
Use this option to specify the number of decimal places for numeric columns. This function is not available if columns are pivoted.
Hide indexing column?
Hides the indexing column of the input table.
Turn table into a heatmap?
Turns the table into a heatmap.
JSON example
Default input table with a label and without index column; the 'date' column is read-only.
{
"inputWidgets": {
"price": {
"widgetType": "table",
"tableType": "default",
"readonly": false,
"readonlyCols": "date",
"hideIndexCol": true,
"heatmap": false,
"label": "This table shows the price trend of the 30 DOW Jones stocks"
}
}
}
Big Data table:
The following options are available for the Big Data table. This table type is intended for situations in which large amounts of data are to be displayed within a table. Instead of a long, 1-page table, a multi-page table is displayed. Only the data currently visible on the client side is loaded in this table.
Should table be read-only?
This option prevents the user from making manual changes in the input table of a scenario. If active, the table can only be filled with scenario data from the database/local files.
Select a column to pivot
See previous section
JSON example
Big data input table.
{
"inputWidgets": {
"price": {
"widgetType": "table",
"tableType": "bigdata",
"readonly": false,
"label": "This table shows the price trend of the 30 DOW Jones stocks"
}
}
}
MIRO Pivot Table:
The following options are available for the MIRO Pivot Table. This table type is also capable of handling large amounts of data (> 1 million records). It allows you to interactively filter, pivot or aggregate data. See here for more information about the MIRO Pivot Table. The configuration of this table can be done directly from the preview on the right side.
Note
The MIRO Pivot Table has no concept of "order" because the table can be sorted interactively by changing the order of the rows. When you add or change UELs, they are always appended to the underlying data source. So when MIRO passes the data to GAMS, you cannot rely on the order of the elements coming from this table type. If you need UELs in a certain order, you should either use one of the other input table types or declare the sets you need sorted as additional external input (instead of using the implicit set definition).
JSON example
MIRO Pivot input table.
{
"inputWidgets": {
"price": {
"options": {
"aggregationFunction": "sum",
"cols": {
"symbol": null
},
"fixedColumns": true,
"hideEmptyCols": true,
"hidePivotControls": false,
"pivotRenderer": "table",
"rows": "date",
"tableSummarySettings": {
"colEnabled": true,
"colSummaryFunction": "max",
"rowEnabled": false,
"rowSummaryFunction": "sum"
}
},
"readonly": false,
"tableType": "pivot",
"widgetType": "table"
}
}
}
Slider#
Configuration
Sliders are useful in situations where the user has to select a numeric value from a range.
Example:
Let's configure a widget for our transport model. For the scalar value freight a slider is a good choice. From the list of available symbols we choose the desired scalar, select slider as widget type and give it a label, which then appears above the slider. Next, we specify the upper and lower bounds of the slider, the default value as well as the step size.
When we are satisfied with the selected configuration, we click "save". A confirmation that the configuration has been updated successfully will appear:
Available Options
The following options are available for a slider widget:
Enter the element name as it should be displayed in a tab
With this option the tab name of the symbol is defined, see screenshot below. The default value of the element name is the explanatory text of the symbol.
Note
If all scalar widgets are displayed in the same tab (see aggregate widgets in the general options), then the name specified here is not displayed at all.
Choose a label
If a label has been specified, it will be displayed above the slider. In the example below the label select the maximum number of stocks is used. A label is optional.
Tooltip (optional)
If a tooltip has been specified, it will be displayed when the mouse pointer is moved over the info icon. A tooltip is optional.
Minimum / maximum / default value
Minimum / maximum value: Both a minimum and a maximum value are required for a slider. These define the range from which the user can select values. Default value: A default value is the initial value of the slider, i.e. the slider value set when starting the application. This is optional. If the value does not fall between the minimum and maximum values, a warning is issued. If this value is not specified, the minimum value is used as the default value. As soon as data is loaded which contains a value for the slider symbol, the slider is set to that value.
All three parameters can be set either statically or dynamically. If the range of the slider is independent of the data loaded, it is a good idea to configure it as a static slider. This means, for example, that the lower and upper limits of a slider are always 1 and 10. Scenario data does not change these.
Dynamic limits: Sometimes it makes sense to adapt the limits to the data. An example for this can be found in the demo model pickstock. Here, two sliders are used. With one of the sliders, the user can select the maximum number of stocks, with the other one the number of training days.
In both sliders the maximum value - the upper limit - results from the input data of the parameter Price.
The maximum value for the maximum number of stocks is 30, since the dataset Price that is currently loaded contains 30 stocks. If the user deletes e.g. all values of the stock AAPL from the data, the maximum value of the slider changes to 29. The same is true for the second slider: the number of training days. Here the maximum value of 252 results from the number of available dates in price. In the Configuration Mode we can easily define such dynamic limits. For the first slider the configuration looks as follows:
The Static value? box is unchecked for the maximum value. Since the maximum slider value should result from the data of the symbol price, the corresponding header stock symbol in which the stocks are contained is selected (see table above). The operator is set to count since we want to count all stock symbols in our data to set the maximum value.
For the calculation of such limits from the data, the following operators are available:
More on dependencies among widgets can be found here.
Step size
The step size specifies the interval between each selectable value on the slider. The value must be greater than 0 and must not exceed the total range of the slider.
Minimum step size
Note
The minimum step size is only relevant when submitting a Hypercube job. It defines the minimum interval that can be used for a range slider when submitting a Hypercube job.
When submitting a Hypercube job and a slider range is used, scenarios are generated depending on the specified step size. Example: We configure a single slider with a lower bound of 70, an upper bound of 100 and a step size of 5. When submitting a Hypercube job, this single slider becomes a slider range with the same limits and the same step size. In the image below the selected limits of 75 to 90 and a step size of 5 result in 4 different variants (75, 80, 85, 90), i.e. 4 scenarios to be calculated.
The minimum step size sets the minimum value the user can specify as step size when submitting a Hypercube job. The value may be lower than the regular step size. For example, if the slider above is configured with a regular step size of 5, the limits of the slider can be set in increments of 5. However, the step size for scenario generation on the right side can differ, e.g. be set in smaller intervals. If set to 1, this would result in 16 scenarios (75, 76, 77, ..., 89, 90).
Show tick marks?
Tick marks are displayed below the sliders and help to visually divide the entire slider width.
Slider without tick marks:
Slider with tick marks:
Should element be expanded automatically when submitting a Hypercube job?
As explained in detail in the corresponding chapter, widgets will be expanded when submitting a Hypercube job. With the option available here, the automatic expansion of a widget can be switched off. The picture below shows expanded widgets.
JSON example
Slider with dynamic upper bound.
{
"inputWidgets": {
"maxstock": {
"label": "Select the maximum number of stocks",
"tooltip": "This is a tooltip",
"min": 1,
"default": 3,
"step": 1,
"max": "card(price$symbol)",
"widgetType": "slider"
}
}
}
Range slider#
Configuration
A range slider returns two numeric values. For this reason, such a slider is not suitable for GAMS scalars, but only for GAMS command line parameters, i.e. double-dash parameters.
Example:
In the Configuration Mode we define a double-dash parameter --range with the bounds 1 and 100. The lower default value shall be 42 and the upper default value 75:
In the GAMS model we can access the selected range with %RANGE_LO% for the lower value and %RANGE_UP% for the upper value.
More on widgets with ranges can be found here.
Range sliders for Hypercube jobs
A range slider in Base Mode becomes a range slider with an additional checkbox when submitting a Hypercube job:
With this checkbox you can determine if the selected range of the slider should result in a single scenario (All combinations? unchecked) or if all possible combinations within this range should be used (All combinations? checked). In the example above - All combinations? is checked - the selected step size determines which scenarios are generated for the Hypercube job. With a step size of 5 this would result in 10 different symbol ranges / scenarios:
75 - 90
80 - 90
85 - 90
90 - 90
75 - 85
80 - 85
85 - 85
75 - 80
80 - 80
75 - 75
An unchecked All combinations? would result in a single scenario. In this scenario, the symbol would have a range from 75 to 90.
Available Options
The available options of a range slider are identical to those of a normal slider. The only difference is that instead of a single default value, two of these values need to be specified.
JSON example
Note: To let MIRO recognize whether a symbol is a double-dash parameter or a GAMS option, its name is prefixed with _gmspar_ for double-dash parameters or _gmsopt_ for
GAMS options.
{
"inputWidgets": {
"_gmspar_range": {
"widgetType": "slider",
"min": 1,
"max": 100,
"default": 42,
"step": 1,
"ticks": false,
"noHcube": false,
"label": "Select a range",
"tooltip": "This is a tooltip"
}
}
}
Checkbox#
Configuration
A checkbox returns 0 or 1 and is therefore suitable for use in binary decisions.
Example:
Configuration of a GAMS scalar binaryDecision as a checkbox:
$onExternalInput
Scalar binaryDecision 'binary decision' / 0 /;
$offExternalInput
Available Options
The following options are available for a checkbox widget:
Enter the element name as it should be displayed in a tab
With this option the tab name of the symbol is defined. For an example see the same option for a slider. The default value of the element name is the explanatory text of the symbol.
Choose a label
If a label has been specified, it will be displayed above the checkbox. For an example see the same option for a slider.
Tooltip (optional)
If a tooltip has been specified, it will be displayed when the mouse pointer is moved over the info icon. A tooltip is optional. For an example see the same option for a slider.
Default value
The default value specifies the initial state of the checkbox (checked or unchecked).
Should element be expanded automatically when submitting a Hypercube job?
As explained in detail in the corresponding chapter, widgets will be expanded when submitting a Hypercube job. When submitting a Hypercube job, a checkbox becomes a multi-dropdown menu with the entries yes and no. With the option available here, the automatic expansion of a widget can be switched off.
JSON example
{
"inputWidgets": {
"_gmsopt_keep": {
"widgetType": "checkbox",
"label": "Keep process directory?",
"value": 1,
"noHcube": true,
"class": "checkbox-material",
"tooltip": "This is a tooltip"
}
}
}
Date selector#
Configuration
Returns a date string in the format yyyy-mm-dd.
Example:
Date selector for Singleton Set singleDate:
$onExternalInput
Singleton Set singleDate 'single date' / 2016-01-01 /;
$offExternalInput
Available options
The following options are available for a date selector widget:
Enter the element name as it should be displayed in a tab
With this option the tab name of the symbol is defined. For an example see the same option for a slider. The default value of the element name is the explanatory text of the symbol.
Choose a label
If a label has been specified, it will be displayed above the date selector. For an example see the same option for a slider.
Tooltip (optional)
If a tooltip has been specified, it will be displayed when the mouse pointer is moved over the info icon. A tooltip is optional. For an example see the same option for a slider.
Default / earliest / latest date
When configuring a date selector, the earliest and the latest date that can be selected by the user can be specified. Dates outside this range cannot be selected. In addition, a specific date can be set as the default date. The dates for the earliest and the latest selectable date are optional. If required, they can be set statically by specifying a fixed date. The default date is not optional. Here either a static date string can be specified or the option Use current date can be activated. The current date is then always selected as the default.
Choose how you want the date to be formatted
This option specifies the format of the date to display in the browser. The default is yyyy-mm-dd. This setting does not affect the actual format of the string the widget returns.
What date range should be displayed per default?
Specifies the start screen of the date overview. The start screens Month, Year and Decade are available.
If you click on a year, the monthly overview opens. From there, you can click on a month to go to the detailed day view.
What day shall be the start of the week?
This option determines the day of the week with which each line of the date overview should begin.
Select weekdays that you want to disable
Individual weekdays can be deactivated in the date overview, so that the corresponding days are not selectable by the user.
Should datepicker be closed immediately when a date is selected?
If active, the date overview of the widget will be closed as soon as a date is clicked. Otherwise, the widget remains open and closes only when you click outside the datepicker.
Should element be expanded automatically when submitting a Hypercube job?
As explained in detail in the corresponding chapter, widgets will be expanded when submitting a Hypercube job. With the option available here, the automatic expansion of a widget can be switched off.
JSON example
{
"inputWidgets": {
"singledate": {
"widgetType": "date",
"format": "yyyy-mm-dd",
"startview": "month",
"weekstart": 0,
"autoclose": true,
"noHcube": false,
"label": "Select a date",
"tooltip": "This is a tooltip",
"value": "2016-01-01",
"min": "2016-01-01",
"max": "2017-01-01"
}
}
}
Daterange selector#
Configuration
Returns two dates. For more on widget ranges, see here.
Example:
Date range selector for double-dash parameter date:
Available options
The available options of a date range selector are almost identical to those of a date selector. The following options are available in addition to a date selector:
Default dates
Since the widget is used for date ranges, the date range selector needs two default dates instead of one. The configuration of these does not differ from that of the standard date selector.
Select the separator between start and end date selector
With this option you can determine what should be displayed between the two date selectors (default: "to").
Example with two different separators:
JSON example
{
"inputWidgets": {
"_gmspar_date": {
"widgetType": "daterange",
"format": "yyyy-mm-dd",
"startview": "month",
"weekstart": 0,
"separator": " to ",
"autoclose": true,
"noHcube": false,
"label": "Select a time range",
"tooltip": "This is a tooltip",
"start": "2020-01-01"
}
}
}
Text input#
Configuration
Returns the entered text.
Example:
Text input for double-dash parameter comment:
Available options
The following options are available for a text input widget:
Enter the element name as it should be displayed in a tab
With this option the tab name of the symbol is defined. For an example see the same option for a slider. The default value of the element name is the explanatory text of the symbol.
Choose a label
If a label has been specified, it will be displayed above the text input. For an example see the same option for a slider.
Tooltip (optional)
If a tooltip has been specified, it will be displayed when the mouse pointer is moved over the info icon. A tooltip is optional. For an example see the same option for a slider.
Choose the default value
The default value is the initial value of the text input, i.e. the text set when starting the application. This is optional.
Choose a placeholder
A placeholder is a text that is displayed in the text box as long as no input has been made by the user. This is primarily for orientation purposes. A placeholder is optional.
Communicate as element text with GAMS?
Tip
This option is intended for the use of singleton sets to define compile-time variables in the GAMS model. Using singleton sets instead of command line parameters has the advantage that their information is not lost at any time, e.g. during GDX export. Read more about this topic here.
Singleton sets can have an element label and an element text. When configured as a text input, both components can be communicated with GAMS by using a double pipe ('||') as separator:
If this option is activated, the entire content of the text input widget is communicated as the element text of the singleton set to GAMS. The element label in turn is communicated as an empty
string. Migrating a singleton set into a compile-time variable in GAMS can then be done using the $eval.set method.
Since the variable should be filled by the element text, the attribute TE has to be used: $eval.Set VARNAME SETID.TE.
Text input and singleton sets
If a text input is used for a singleton set and you want to communicate both its label and its element text via GAMS MIRO, you must use a double pipe ('||') as separator:
Find more information here.
JSON example
{
"inputWidgets": {
"_gmspar_comment": {
"widgetType": "textinput",
"value": "",
"placeholder": "e.g. \"experimental run\"",
"label": "Insert a comment",
"tooltip": "This is a tooltip"
}
}
}
Numeric input#
Configuration
Returns a number.
Example:
Available options
The following options are available for a numeric input widget:
Enter the element name as it should be displayed in a tab
With this option the tab name of the symbol is defined. For an example see the same option for a slider. The default value of the element name is the explanatory text of the symbol.
Choose a label
If a label has been specified, it will be displayed above the numeric input. For an example see the same option for a slider.
Tooltip (optional)
If a tooltip has been specified, it will be displayed when the mouse pointer is moved over the info icon. A tooltip is optional. For an example see the same option for a slider.
Default value
A default value is the initial value of the numeric input, i.e. the value set when starting the application. This is optional.
Minimum value
Specifies the minimum valid value for the widget. This is optional.
Maximum value
Specifies the maximum valid value for the widget. This is optional.
Number of decimal places
Defines the number of decimal places shown in the formatted value and kept for precision.
Decimal separator to use
Defines the decimal separator character to be used. Default: "." (dot).
Thousand grouping separator to use
Defines the thousand grouping separator character to be used. Default: "," (comma).
Currency symbol
Places a symbol in front of the entered value, e.g. a dollar sign. This option is used exclusively for visual support. Only the number is returned as value. This is optional.
JSON example
{
"inputWidgets": {
"maxstock": {
"widgetType": "numericinput",
"value": 4,
"min": 0,
"max": 30,
"sign": null,
"label": "Select the maximum number of stocks",
"tooltip": "This is a tooltip"
}
}
}