If I have a number of named parameters in an AMPL model, and a table (either in an Excel spreadsheet or in AMPL's built-in format) with columns ParamName, ParamValue, is there a nice way to read these values in so that the parameter with name ParamName gets the value ParamValue?
For example, if I had a file called params.tab with the contents
ampl.tab 1 1
ParamName ParamVal
n 9
max 100
min 0
is there a way to get an equivalent result to loading a data file containing
param n := 9;
param max := 100;
param min := 0;
?
In particular, I would like an approach that is flexible to changes in what parameters are involved, by which I mean that if I add a new parameter to the model I'd like to just add it as a new row in the table and not have to modify the commands used to load it in too much.
If it simplifies things, it's safe to assume that all of the parameters have the same type (e.g. integer).
I can think of two approaches that I will write up as a self-answer, but I would very much appreciate any better options.