mathematical-optimizationlinear-programmingamplglpkmathprog

Syntax error with Glpk: MathProg model processing error


This is my model:

set linhas;
set colunas;
param c{j in colunas};
param A{i in linhas,j in colunas};
param b{i in linhas};

var x{j in colunas}>=0;

minimize FO:
   sum{j in colunas} c[j]*x[j];

s.t. R{i in linhas}:
   sum{j in colunas} A[i,j] = b[i];

end;

I got the following error when solving the model with glpsol:

Arquivo1.txt:3: syntax error in parameter data block
Context:  set linhas ; set colunas ; param c {
MathProg model processing error.

Can you help me? I could not find what's wrong with this code.


Solution

  • This problem occurred because you provided to the solver a model file also as a data file, i.e., you invoked glpsol using the following command-line:

    glpsol -m Arquivo1.txt -d Arquivo1.txt
    

    In order to solve the syntax error you need to provide a data file, e.g. Arquivo1.dat, to the option -d that is different from your model . In the data file you must provide concrete data to your sets colunas and linhas, as well as to your parameters a, b, and c. Once you have a data file, you can run:

    glpsol -m Arquivo1.txt -d Arquivo1.dat -o solution.sol
    

    Last but not least, enjoy the solution provided in solution.sol.