Hi - I am a very new IML user and I'd appreciate any help. I'm trying to optimize a system of pricing equations subject to a set of nonlinear constraints. Setting this up, I wrote a module to calculate the total profit, which will be my objective function. That code (below) when called with my initial values for the objective function returns the value I expect. However, when I try to call NLPQN, I get an error (below) directing me to the calculation of A, the average prices. It reports that I'm trying to multiply a 186 x 558 matrix by a 1 x 558 vector, which obviously won't work. However, the vector X should be 558 x 1. Can anybody shed any light on this for me? I've tried transposing the vector, but I get the same error.
proc iml;
**INITIAL VALUES FOR PRICES;
use &OPT_DATA.;
read all var{PRICE1,PRICE2,PRICE3} into prices;
X0 = prices[,1]//prices[,2]//prices[,3];
start PROFIT(X);
**READING IN THE RAW DATA;
use &OPT_INTCRS.(keep=EFF:);
read all var _ALL_ into CI;
use &OPT_EXTCRS.(keep=EXT_COEF EXT_FIXED);
read all var _ALL_ into CX;
use &OPT_DATA.;
read all var{A1,A2,A3,A4} into param;
**CREATING PARAMETERS USED IN OBJECTIVE FUNCTION;
S = (j(&N.,2*&N.,0)||I(&N.)); *Selection Matrix;
A = S*X; *Average Prices;
M = A - param[,4]; *Margin;
C = param[,1]#I(&N.)||param[,2]#I(&N.)||(T(CI) + (CX[,1]#I(&N.))); *Coefficients on Prices;
F = CX[,2] + param[,3]; *Fixed Effect;
Q = exp(C*log(X) + F); *Total Quantity;
**OBJECTIVE FUNCTION;
P = T(M)*Q; *Profit;
return(P);
finish PROFIT;
**When I run this bit of code it reports the expected value;
z = PROFIT(X0);
print z;
**However, when I try to optimize (even without the constraints), I get the following error;
call NLPQN(rc,xres,"PROFIT",X0,optn) nlc="CONSTRAINTS";
ERROR: (execution) Matrices do not conform to the operation.
operation : * at line 33514 column 12
operands : S, X
S 186 rows 558 cols (numeric)
X 1 row 558 cols (numeric)