Matrix of variables

Here is an example of how you could formulate an AMPL model for the situation that you describe:

param m;  # number of constraints
set V;    # set of variables

param A {1..m, V};
param B {1..m};

var X {V};

subject to constr {i in 1..m}:
   sum {j in V} A[i,j] * X[j] <= B[i];

Then in the data, you can specify

set V := p1 b x y ;

Alternatively, if the variables will always be the same, you can just write this set definition in your model:

set V = {"p1","b","x","y"};

(Note that, in large-scale applications of linear optimization, almost all of the constraint coefficients are zero, and so it is not practical to specify coefficient matrices explicitly. For this reason, AMPL does not have a “matrix” data type.)