sets inp /mat, cap, lab, ene/
     oup /man, mat/;

alias(inp,jnp);

parameter a0(oup) Constant Terms
       /man 0.0300,
        mat 0.0500/;

table a(oup,inp) Constant Table
          mat   cap   lab   ene
man      0.40  0.20  0.10  0.05
mat      0.00  0.30  0.25  0.15 ;

table aa(oup,inp,jnp) Quadratic Table
            mat    cap     lab     ene
man.mat  -0.0010  0.0005 -0.0002  0.0009
man.cap          -0.0009  0.0006  0.0010
man.lab                  -0.0012  0.0003
man.ene                          -0.0001
mat.cap          -0.0100  0.0010 -0.0020
mat.lab                  -0.0250  0.0050
mat.ene                          -0.0090;

variables x(oup,inp) Inputs
          y(oup)     Outputs
          profit     Profit
          matsell    Materials Sold;

positive variables x;

equations prd(oup) Production
          matsold  Materials sold
          prft     Profit;

prd(oup).. exp(a0(oup)+sum(inp,a(oup,inp)*log(x(oup,inp)))+
               sum((inp,jnp),aa(oup,inp,jnp)*log(x(oup,inp))*log(x(oup,jnp))))
               =e= y(oup);
matsold..  sum(oup,x(oup,"mat")) + matsell =l= y("mat");
prft..     10*matsell+15*y("man")-0.50*sum(oup,x(oup,"cap"))
           -0.95*sum(oup,x(oup,"lab"))-1.5*sum(oup,x(oup,"ene")) =e= profit;

x.lo(oup,inp) = 0.0001;

model sect /all/;
solve sect using nlp maximizing profit;
