If you get the parameter (or better the scalar) at compile time then there is a way. Since you get your values from Excel, I guess you do at some stage:
Code: Select all
Scalar num_gridpoints;
$gdxIn fromExcel.gdx
$load num_gridpoints
...
$gdxIn
Now you can turn the value of scalar num_gridpoints at compile time into a compile time variable and use that in your grid definition:
Code: Select all
$eval NUM_GRIDPOINTS num_gridpoints
Set
g 'grid points' / g0*g%NUM_GRIDPOINTS% /
...
$gdxIn
Important this does not work with scalar calculated (at execution time). You can do some limited calculation at compile time with the $eval command, you can also use some functions, e.g. card, so if you have a 2-dim grid and need 1-dim set representing all points this also works:
Code: Select all
$if not set XMAX $set XMAX 9
$if not set YMAX $set YMAX 9
Set
x 'x-axis' / x0*x%XMAX% /
y 'y-axis' / y0*y%YMAX% /
g(x,y) 'grid points' / #x.#y /;
$eval PMAX card(x)*card(y)-1
Set p / p0*p%PMAX% /
xypmap(x,y,p) / #x.#y:#p /;
...
-Michael