|
ASK is a utility developed by Erwin Kalvelagen to ask simple interactive questions of the end-user. For instance, if your model requires a scalar to be changed regularly, instead of letting the end-user change the .gms source file, it may be better to pop up a window, with a question text, where the required number can be entered .
Ask is in the form of a GUI (Graphical User Interface). The main purpose of it is to allow a developer quickly put an application together such that an end user does not have to edit GAMS files.
It requires a GAMS model run in the GAMS-IDE and generates a standard GAMS include file, this file can then be used through a $include statement
Usage
ask <options>
where the options are
T= string
|
where the string identifies the type of input item to go after and can be
integer when one wants an integer number
float when one wants a real number
radiobutton when one wants a radio button choice
combobox when one wants a combo (drop down choice) box
checklistbox when one wants a check list box
fileopenbox when one wants the name of a file to open
filesavebox when one wants the name of a file to save
For example T=integer
|
M="string"
|
where the string is the text to in the box
For example M="Enter a number"
|
O="filename"
|
where the filename is the name of a file in which to place the results for subsequent inclusion into GAMS
For example O="file.inc"
|
D="string 1|string 2..."
|
where the "string 1|string 2|string 3|...|string n" gives the n strings to be associated with multiple choices when using checkbox, radiobutton, combobox, or checklistbox. The individual strings are separated by the delimiter "|"
For example D="Small data set|Medium data set|Large data set"
|
E="number 1|number 2..."
|
where the "number 1|number 2|number 3|...|number n" gives the n numbers to be returned to GAMS associated with the choices made when using checkbox, radiobutton, combobox, or checklistbox. The individual numbers are separated by the delimiter "|"
For example E="1|2|3|4|5"
|
I="filepath"
|
where filepath gives the path in which to look for the file under the fileopenbox and filesavebox dialogues. If not specified this is the project directory
For example I="C:\gams\mine"
|
F="filemask"
|
where filemask gives the mask for acceptable files under the fileopenbox and filesavebox dialogues. If not specified this is *.*.
For example I="*.gdx"
|
R="string"
|
where the string gives a line of GAMS code to place in the include file.
This can contain a %s parameter in which the information to return is substituted
For example R="$include '%s'" or R="set i /1990*%s/;"
|
C="string"
|
A title for the dialogue box being used
For example C="Box to ask for a file"
|
L=number
|
where the number gives a lower bound on a numeric entry
For example L=15
|
U=number
|
where the number gives an upper bound on a numeric entry
For example U=15
|
@"filename"
|
where filename gives the name of a file of input instructions containing the options above in this table
For example @ask.opt
|
In addition a number by itself can be entered to put multiple entries into columns under the checkbox, radiobutton, combobox, or checklistbox entries.
One can use GAMS to generate the input instruction file , but note that it is not possible to do this easily with the PUT facility since $call to ask is handled at compile time, before the PUT statement has done its work. Rather one must use $onecho and $offecho as follows
$onecho > asktest.opt
T=checklistbox
M=Choose multiple options
D=option 1|option 2|option 3|option 4|option 5
E=1|2|3|4|5
R=%s checked list box choice
O=k2.inc
$offecho
Then one would use the file as follows
$call =ask @asktest.opt
set k2 /
$include k2.inc
/;
display k2;
These options are discussed in http://www.gams.com/dd/docs/tools/ask.pdf and illustrated in ask.gms which contains the examples in the documentation referred to above.
Example (ask.gms)
$call =ask T=integer M="Enter number of cities" o=n.inc
scalar n 'number of cities' /
$include n.inc
/;
display n;
More examples are in ask.gms and in the GAMS Data Utilities Models choice under model libraries in the IDE.
|