[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] Passing command line paramters to GLPK
From: |
Andrew Makhorin |
Subject: |
Re: [Help-glpk] Passing command line paramters to GLPK |
Date: |
Sat, 1 Mar 2008 23:31:27 +0300 |
> data bases will often contain multiple problem instances. Currently
> to select a problem instance it is necessary to edit the model or the
> data file passed to GLPSOL. It would be useful if the problem instance
> could be passed on the command line.
> My implementation idea is to add an option -v to be used as follows:
> ./glpsol -m model.mod -v var1=val1 -v var2=val2 ...
> Internally this should create a set
> set _ARGV := var1 var2;
> and a parameter
> param _ARGP :=
> [var1] val1
> [var2] val2;
> A usage example is:
> table ti IN
> 'MySQL'
> 'Database=glpk;UID=glpk;PWD=gnu'
> 'SELECT COL, LIN, VAL FROM sudoku WHERE ID = ' & _ARGP['ID'] :
> FIELDS <- [COL, LIN], givens ~ VAL;
All necessary substitutions can be made with the C preprocessor.
For example:
gcc -E -Dfoo1=bar1 -Dfoo2=bar2 model.txt > model.mod
glpsol -m model.mod
Another way is to use, say, sed. One could even write a shell script
to make that more convenient.