Overflow problem, license issue, NLP solver advice

Jesse



You have a lot of exp-terms depending on large variables and they overflow. Your variable qmf is initialized to the values in mfcap, and these values range from 300 to 100,000. Try to compute exp(300) – my calculator gives 9.9999999e99 or overflow. Exp(100000) is even worse.



Why do you have these huge exp terms? A constraint like exp(a) + exp(b) =E= exp(c) can much better be expressed as a*b =E= c;



Good luck



Arne


\

Arne Stolbjerg Drud

ARKI Consulting & Development A/S

Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark

Phone: (+45) 44 49 03 23, Fax: (+45) 44 49 03 33, email: adrud@arki.dk



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of Jesse Henderson
Sent: Tuesday, November 05, 2013 9:00 PM
To: gamsworld@googlegroups.com
Subject: Overflow problem, license issue, NLP solver advice



Hello GAMS users,

I’m new to GAMS. I’ve read previous posts about overflow errors, but I don’t think they apply to my case. First, my model is large and I’m going to have to upgrade beyond the demo version of GAMS. Here are some details:



MODEL STATISTICS



BLOCKS OF EQUATIONS 24 SINGLE EQUATIONS 38,492

BLOCKS OF VARIABLES 9 SINGLE VARIABLES 27,329

NON ZERO ELEMENTS 134,658 NON LINEAR N-Z 0

DERIVATIVE POOL 10 CONSTANT POOL 134

CODE LENGTH 332,397



**** THE MODEL EXCEEDS THE DEMO LIMITS

**** MAX MATRIX ROWS 300

**** MAX MATRIX COLUMNS 300

**** MAX NON ZERO ELEMENTS 2000

**** MAX NON LINEAR N-Z 1000

**** MAX DISCRETE VARIABLES 50



As to my problem, I get the following error: “Error at line 549: overflow in + operation (addop)”

Line 549 is a material balance equation/constraint. All variables correspond to quantities.

Commenting out the constraint and equation declaration eliminates the error flag. After some more troubleshooting, I found that the error goes away when I remove the term “+ exp(qmf(i,“CMP”,t))*oconv1(i,“CMP”)”

Still I’m unable to find why that term might be causing the error.



I’m tasked with finding the source of this error and planning for a GAMS upgrade.

  1. Is it possible that the “termination due to licensing error” may hide other overflow problems?

  2. Do you have experience with an NLP solver capable of handling a model with my model statistics? I have read some things on different solvers but I’d appreciate some advice from first hand experience.

  3. Can you identify the source of the overflow error?



    Abbreviated code, relevant to the constraint in question, is included below. The full model is attached.



    Sets

i regions

/omitted for brevity

/

  • regions aggregated from GFPM: EUR = Europe/Russia, USA = United States,

  • EST = Asia and Oceania, CAN = Canada, BRA = Brazil, OAM = Other Americas,

  • AFR = Africa, ZZ = Exogenous Region

ap all products

/omitted for brevity

/

*more sets omitted for brevity

jCMP(mf) chemical pulp subset /CMP/

  • the above set of one is referenced in the apparently offending term.

*more sets omitted for brevity

c1(mf) industrial roundwood conversions /SWN, PLY, PTB, FBB, MCP, CMP/

c2(mf) mechanical pulp conversions /NWS, PAW, OPR/

c3(mf) chemical pulp conversions /NWS, PAW, OPR/

c4(mf) other fiber pulp conversions /NWS, PAW, OPR/

c5(mf) wastepaper conversions /NWS, PAW, OPR/

tr(ap) traded products /FLW, INR, SWN, PLY, PTB, FBB, MCP, CMP, OFP, WST, NWS, PAW, OPR/

t time /2010*2070/



Table

oconv1(i,c1) conversion in region i by product c1

SWN PLY PTB FBB MCP CMP

EUR 1.765572678 1.870303873 1.153689340 1.175629256 2.517468963 2.505681702

USA 2.025000000 2.025000000 1.225000000 1.225000000 1.840402900 2.230529500

EST 1.364383739 1.206012945 0.998747938 0.978280533 1.713750025 1.883911219

CAN 2.025000000 2.025000000 1.225000000 1.225000000 1.794554800 1.897412900

BRA 2.025000000 2.025000200 1.225000200 1.225000200 3.385676800 3.527719900

OAM 1.821997302 1.691359534 1.300013279 1.250683255 3.265774996 3.073869934

AFR 2.316092507 1.897666885 1.384103466 1.441884191 3.899303744 3.731963735 ;



Table

oqs0(i,j) initial quantity for supply curves in region i by product j

FLW INR OIR OFP WST

EUR 147262 458894.030 29180 4240.480 54710.393

USA 41496 301457.000 8278 245.000 39878.000

EST 782457 287256.026 66589 18994.005 82351.155

CAN 2840 123687.000 2027 40.000 3465.000

BRA 141631 112086.000 7817 57.001 3875.000

OAM 140633 72421.808 3386 547.049 4157.586

AFR 596285 39583.450 28433 237.947 1565.088 ;



Table

oqd0(i,k) initial quantity demanded in region i by product k

FLW OIR SWN PLY PTB FBB NWS PAW OPR

EUR 145849.000 29180.000 107151.000 10693.301 45254.000 16659.000 11006.403 29490.747 54255.259

USA 41436.000 8278.000 76691.000 12255.000 19460.000 9008.000 5469.000 21587.000 48775.000

EST 782583.000 66589.000 114968.000 58516.133 24643.000 41382.000 14745.165 44577.663 114542.713

CAN 2869.000 2027.000 17596.000 3446.000 3701.000 1409.000 358.000 1854.000 3801.000

BRA 141631.000 7817.000 23455.000 1215.000 2652.000 2767.000 547.000 2012.000 6002.000

OAM 140628.000 3386.000 16975.000 2867.811 1706.000 2545.000 1500.923 4770.586 11647.946

AFR 596273.000 28433.000 14344.000 2284.000 944.000 547.000 757.320 1769.940 3919.830 ;



Parameter qd0(i,k) log transform of conversion ;

qd0(i,k) = log(oqd0(i,k)) ;



*I take the log transform of quantities to make certain constraints linear



Parameter qs0(i,j) log transform of conversion ;

qs0(i,j) = log(oqs0(i,j)) ;



Table

moex(i,tr) quantity of exports in region i by traded product tr

FLW INR SWN PLY PTB FBB MCP CMP OFP WST NWS PAW OPR

EUR 5387 93397 69052 6003 15987 11439 660 12891 162 24458 7181 30977 29521

USA 168 17704 3834 812 536 912 158 5784 114 19436 740 2151 8487

EST 59 30141 6729 13761 2274 7300 244 3621 99 8316 1466 9020 6009

CAN 77 6122 21865 836 3682 706 48 8740 5 1783 4715 3791 1998

BRA 1 1879 1636 1774 63 222 1 7833 6 2 1 1119 772

OAM 8 10066 3567 1033 294 1609 1 5335 3 590 246 253 1163

AFR 17 7314 1770 507 25 35 3 450 15 80 60 542 560 ;



Parameter ex(i,tr) log transform of export quantity ;

ex(i,tr) = log(moex(i,tr)) ;



Table

moim(i,tr) quantity of imports in region i by traded product tr

FLW INR SWN PLY PTB FBB MCP CMP OFP WST NWS PAW OPR

EUR 3974 82029 40759 8611 14286 11000 471 17620 229 14108 6064 24629 25296

USA 108 2482 17997 3098 3430 2028 46 5085 38 553 2777 5825 2834

EST 185 70950 24885 8702 3482 5568 483 19546 164 34840 3536 8539 11749

CAN 106 7982 1783 1813 826 717 1 262 23 1379 70 1059 1607

BRA 1 302 104 15 44 203 1 348 7 15 416 527 129

OAM 3 562 4249 661 465 1194 13 1889 14 3712 1023 2573 5081

AFR 5 776 7631 937 187 386 6 435 30 86 464 1286 1977 ;



Parameter im(i,tr) log transform of import quantity ;

im(i,tr) = log(moim(i,tr)) ;



Table

mfcap(i,mf) manufacturing capacity in region i for product k

SWN PLY PTB FBB MCP CMP NWS PAW OPR

EUR 135444 8085.301 46955 17098 14244.748 33176.691 12123.403 35838.747 58480.259

USA 62528 9969 16566 7892 3854 45897 3432 17913 54428

EST 96812 63575.133 23435 43114 3914.049 24954.959 12675.165 45058.663 108802.713

CAN 37678 2469 6557 1398 8873 9793 5003 4586 4192

BRA 24987 2974 2671 2786 456 12943 131 2604 6645

OAM 16293 3239.811 1535 2960 578.367 6560.448 723.923 2450.586 7729.946

AFR 8483 1854 782 196 429.013 1833.334 353.32 1025.94 2502.83 ;



Free Variables

z total global welfare ;



Positive Variables

qs(i,j,t) quantity produced in region i of primary product j at time t

ps(i,j,t) supply price for primary products

qd(i,k,t) quantity demanded in region i of final product k at time t

pd(i,k,t) demand price for final products

qmf(i,mf,t) quantity manufactured domestically

qm(i,tr,t) quantity imported to region i by product tr at time t

qx(i,tr,t) quantity exported to region i by product tr at time t



Equations

obj define objective function

supply(i,j,t) observe supply limit in region i for primary product j at time t

demand(i,k,t) satisfy demand in region i for product k at time t

mupper(i,tr,t) upper bound for imports

mlower(i,tr,t) lower bound for imports

xupper(i,tr,t) upper bound for exports

xlower(i,tr,t) lower bound for exports

manufact1(i,jINR,t) material balance is satisfied in production of primary and secondary goods

manufact2(i,jMCP,t) material balance is satisfied in production of primary and secondary goods

manufact3(i,jCMP,t) material balance is satisfied in production of primary and secondary goods

manufact4(i,jOFP,t) material balance is satisfied in production of primary and secondary goods

manufact5(i,jWST,t) material balance is satisfied in production of primary and secondary goods

capacity(i,mf,t) observe capacity limit in region i for secondary products k at time t

consume1(i,kFLW,t) material balance is satisfied in consumption of final goods

consume2(i,kOIR,t) material balance is satisfied in consumption of final goods

consume3(i,kSWN,t) material balance is satisfied in consumption of final goods

consume4(i,kPLY,t) material balance is satisfied in consumption of final goods

consume5(i,kPTB,t) material balance is satisfied in consumption of final goods

consume6(i,kFBB,t) material balance is satisfied in consumption of final goods

consume7(i,kNWS,t) material balance is satisfied in consumption of final goods

consume8(i,kPAW,t) material balance is satisfied in consumption of final goods

consume9(i,kOPR,t) material balance is satisfied in consumption of final goods

tradebal(t) material balance for imports and exports

recycle(i,j,t) defines wastepaper recycling ;



obj … z =e= SUM((i,j,t),qs(i,j,t)*ps(i,j,t)/2) + SUM((i,k,t),qd(i,k,t)*pd(i,k,t)/2) - SUM((i,mf,t),qmf(i,mf,t)*mfcost(i,mf)) - SUM((i,tr,t),qm(i,tr,t)*tran(i,tr));

supply(i,j,t) … qs(i,j,t) =l= qs(i,j,t-1) + esp(i,j)*ps(i,j,t) - esp(i,j)*ps(i,j,t-1) ;

  • The above equation has no exogenous shifter …

demand(i,k,t) … qd(i,k,t) =g= qd(i,k,t-1) + gdp(i,t) + edp(i,k)*pd(i,k,t) - edp(i,k)*pd(i,k,t-1) ;

mupper(i,tr,t) … exp(qm(i,tr,t)) =l= exp(qm(i,tr,t-1)) * Utinertia(i,t) ;

mlower(i,tr,t) … exp(qm(i,tr,t)) =g= exp(qm(i,tr,t-1)) * Ltinertia(i,t) ;

xupper(i,tr,t) … exp(qx(i,tr,t)) =l= exp(qx(i,tr,t-1)) * Utinertia(i,t) ;

xlower(i,tr,t) … exp(qx(i,tr,t)) =g= exp(qx(i,tr,t-1)) * Ltinertia(i,t) ; ;

manufact1(i,jINR,t) … exp(qs(i,jINR,t)) =e= exp(qx(i,“INR”,t)) - exp(qm(i,“INR”,t)) + exp(qmf(i,“SWN”,t))*oconv1(i,“SWN”) + exp(qmf(i,“PLY”,t))*oconv1(i,“PLY”) + exp(qmf(i,“PTB”,t))*oconv1(i,“PTB”) + exp(qmf(i,“FBB”,t))*oconv1(i,“FBB”) + exp(qmf(i,“CMP”,t))*oconv1(i,“CMP”) + exp(qmf(i,“MCP”,t))*oconv1(i,“MCP”) - exp(qm(i,“INR”,t)) + exp(qx(i,“INR”,t));

  • Above is the equation that apparently causes the overflow. Removing the term in bold eliminates the error for some reason…

manufact2(i,jMCP,t) … exp(qmf(i,jMCP,t)) =e= exp(qx(i,“MCP”,t)) - exp(qm(i,“MCP”,t)) + exp(qmf(i,“NWS”,t))*oconv2(i,“NWS”) + exp(qmf(i,“PAW”,t))*oconv2(i,“PAW”) + exp(qmf(i,“OPR”,t))*oconv2(i,“OPR”) - exp(qm(i,“MCP”,t)) + exp(qx(i,“MCP”,t));

manufact3(i,jCMP,t) … exp(qmf(i,jCMP,t)) =e= exp(qx(i,“CMP”,t)) - exp(qm(i,“CMP”,t)) + exp(qmf(i,“NWS”,t))*oconv3(i,“NWS”) + exp(qmf(i,“PAW”,t))*oconv3(i,“PAW”) + exp(qmf(i,“OPR”,t))*oconv3(i,“OPR”) - exp(qm(i,“CMP”,t)) + exp(qx(i,“CMP”,t));

  • qmf(i,jCMP,t) appears in the above equation as well.

manufact4(i,jOFP,t) … exp(qs(i,jOFP,t)) =e= exp(qx(i,“OFP”,t)) - exp(qm(i,“OFP”,t)) + exp(qmf(i,“NWS”,t))*oconv4(i,“NWS”) + exp(qmf(i,“PAW”,t))*oconv4(i,“PAW”) + exp(qmf(i,“OPR”,t))*oconv4(i,“OPR”) - exp(qm(i,“OFP”,t)) + exp(qx(i,“OFP”,t));

manufact5(i,jWST,t) … exp(qs(i,jWST,t)) =e= exp(qx(i,“WST”,t)) - exp(qm(i,“WST”,t)) - exp(rec(i,jWST,t)) + exp(qmf(i,“NWS”,t))*oconv5(i,“NWS”) + exp(qmf(i,“PAW”,t))*oconv5(i,“PAW”) + exp(qmf(i,“OPR”,t))*oconv5(i,“OPR”) - exp(qm(i,“WST”,t)) + exp(qx(i,“WST”,t));

capacity(i,mf,t) … exp(qmf(i,mf,t)) =l= cumgdp(i,t) * mfcap(i,mf);

consume1(i,kFLW,t) … exp(qd(i,kFLW,t)) =e= exp(qs(i,“FLW”,t)) + exp(qm(i,“FLW”,t)) + exp(qx(i,“FLW”,t));

consume2(i,kOIR,t) … exp(qd(i,kOIR,t)) =e= exp(qs(i,“OIR”,t));

consume3(i,kSWN,t) … exp(qd(i,kSWN,t)) =e= exp(qmf(i,“SWN”,t)) + exp(qm(i,“SWN”,t)) + exp(qx(i,“SWN”,t));

consume4(i,kPLY,t) … exp(qd(i,kPLY,t)) =e= exp(qmf(i,“PLY”,t)) + exp(qm(i,“PLY”,t)) + exp(qx(i,“PLY”,t));

consume5(i,kPTB,t) … exp(qd(i,kPTB,t)) =e= exp(qmf(i,“PTB”,t)) + exp(qm(i,“PTB”,t)) + exp(qx(i,“PTB”,t));

consume6(i,kFBB,t) … exp(qd(i,kFBB,t)) =e= exp(qmf(i,“FBB”,t)) + exp(qm(i,“FBB”,t)) + exp(qx(i,“FBB”,t));

consume7(i,kNWS,t) … exp(qd(i,kNWS,t)) =e= exp(qmf(i,“NWS”,t)) + exp(qm(i,“NWS”,t)) + exp(qx(i,“NWS”,t));

consume8(i,kPAW,t) … exp(qd(i,kPAW,t)) =e= exp(qmf(i,“PAW”,t)) + exp(qm(i,“PAW”,t)) + exp(qx(i,“PAW”,t));

consume9(i,kOPR,t) … exp(qd(i,kOPR,t)) =e= exp(qmf(i,“OPR”,t)) + exp(qm(i,“OPR”,t)) + exp(qx(i,“OPR”,t));

tradebal(t) … SUM((i,tr), exp(qm(i,tr,t))) =e= SUM((i,tr),exp(qx(i,tr,t)));

recycle(i,jWST,t) … exp(rec(i,jWST,t)) =e= exp(qd(i,“NWS”,t-1)) + exp(qd(i,“PAW”,t-1)) + exp(qd(i,“OPR”,t-1));



qs.fx(i,j,“2010”) = qs0(i,j);

ps.fx(i,j,“2010”) = ps0(i,j);

qd.fx(i,k,“2010”) = qd0(i,k);

pd.fx(i,k,“2010”) = pd0(i,k);

qm.fx(i,tr,“2010”) = im(i,tr);

qx.fx(i,tr,“2010”) = ex(i,tr);

qmf.fx(i,mf,“2010”) = mfcap(i,mf);

*Could the issue stem from the above line?



loop(t$(ord(t) > 1),

qs.l(i,j,t) = qs.l(i,j,t-1);

qs.lo(i,j,t) = 1;

qs.up(i,j,t) = 2*qs.l(i,j,t-1);

qd.l(i,k,t) = qd.l(i,k,t-1);

qd.lo(i,k,t) = 1;

qd.up(i,k,t) = 2*qd.l(i,k,t-1);

ps.l(i,j,t) = ps.l(i,j,t-1);

ps.lo(i,j,t) = 3;

ps.up(i,j,t) = 2*ps.l(i,j,t-1);

pd.l(i,k,t) = pd.l(i,k,t-1);

pd.lo(i,k,t) = 3;

pd.up(i,k,t) = 2*pd.l(i,k,t-1);

qm.l(i,tr,t) = qm.l(i,tr,t-1);

qx.l(i,tr,t) = qx.l(i,tr,t-1);

qmf.l(i,mf,t) = qmf.l(i,mf,t-1);

qmf.lo(i,mf,t) = 1;

) ;



Model forsite /all/;

Solve forsite using nlp maximizing z;



Thanks for any help you might be able to provide. Again, the full code is attached.

Cheers,

Jesse Henderson


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks a lot Arne,
I had forgotten to take the logarithm of the values in my mfcap table. I did this with my other tables, so the corresponding variables are initialized at the correct small numbers.
I realize all of the “exp” terms seems odd. I wanted to keep my demand and supply equations linear, and I wanted my objective function to have a geometric interpretation. Maybe this is a costly aesthetic choice.
Is there a way to perform integrals in an objective function in GAMS? I resorted to this because I couldn’t find a method other than discrete approximations.
Thanks again,
Jesse

On Tuesday, November 5, 2013 2:59:49 PM UTC-5, Jesse Henderson wrote:

Hello GAMS users,
I’m new to GAMS. I’ve read previous posts about overflow errors, but I don’t think they apply to my case. First, my model is large and I’m going to have to upgrade beyond the demo version of GAMS. Here are some details:

MODEL STATISTICS

BLOCKS OF EQUATIONS 24 SINGLE EQUATIONS 38,492
BLOCKS OF VARIABLES 9 SINGLE VARIABLES 27,329
NON ZERO ELEMENTS 134,658 NON LINEAR N-Z 0
DERIVATIVE POOL 10 CONSTANT POOL 134
CODE LENGTH 332,397

**** THE MODEL EXCEEDS THE DEMO LIMITS
**** MAX MATRIX ROWS 300
**** MAX MATRIX COLUMNS 300
**** MAX NON ZERO ELEMENTS 2000
**** MAX NON LINEAR N-Z 1000
**** MAX DISCRETE VARIABLES 50

As to my problem, I get the following error: “Error at line 549: overflow in + operation (addop)”
Line 549 is a material balance equation/constraint. All variables correspond to quantities.
Commenting out the constraint and equation declaration eliminates the error flag. After some more troubleshooting, I found that the error goes away when I remove the term “+ exp(qmf(i,“CMP”,t))*oconv1(i,“CMP”)”
Still I’m unable to find why that term might be causing the error.

I’m tasked with finding the source of this error and planning for a GAMS upgrade.

  1. Is it possible that the “termination due to licensing error” may hide other overflow problems?
  2. Do you have experience with an NLP solver capable of handling a model with my model statistics? I have read some things on different solvers but I’d appreciate some advice from first hand experience.
  3. Can you identify the source of the overflow error?

Abbreviated code, relevant to the constraint in question, is included below. The full model is attached.

Sets
i regions
/omitted for brevity
/

  • regions aggregated from GFPM: EUR = Europe/Russia, USA = United States,
  • EST = Asia and Oceania, CAN = Canada, BRA = Brazil, OAM = Other Americas,
  • AFR = Africa, ZZ = Exogenous Region
    ap all products
    /omitted for brevity
    /
    *more sets omitted for brevity
    jCMP(mf) chemical pulp subset /CMP/
  • the above set of one is referenced in the apparently offending term.
    more sets omitted for brevity
    c1(mf) industrial roundwood conversions /SWN, PLY, PTB, FBB, MCP, CMP/
    c2(mf) mechanical pulp conversions /NWS, PAW, OPR/
    c3(mf) chemical pulp conversions /NWS, PAW, OPR/
    c4(mf) other fiber pulp conversions /NWS, PAW, OPR/
    c5(mf) wastepaper conversions /NWS, PAW, OPR/
    tr(ap) traded products /FLW, INR, SWN, PLY, PTB, FBB, MCP, CMP, OFP, WST, NWS, PAW, OPR/
    t time /2010
    2070/

Table
oconv1(i,c1) conversion in region i by product c1
SWN PLY PTB FBB MCP CMP
EUR 1.765572678 1.870303873 1.153689340 1.175629256 2.517468963 2.505681702
USA 2.025000000 2.025000000 1.225000000 1.225000000 1.840402900 2.230529500
EST 1.364383739 1.206012945 0.998747938 0.978280533 1.713750025 1.883911219
CAN 2.025000000 2.025000000 1.225000000 1.225000000 1.794554800 1.897412900
BRA 2.025000000 2.025000200 1.225000200 1.225000200 3.385676800 3.527719900
OAM 1.821997302 1.691359534 1.300013279 1.250683255 3.265774996 3.073869934
AFR 2.316092507 1.897666885 1.384103466 1.441884191 3.899303744 3.731963735 ;

Table
oqs0(i,j) initial quantity for supply curves in region i by product j
FLW INR OIR OFP WST
EUR 147262 458894.030 29180 4240.480 54710.393
USA 41496 301457.000 8278 245.000 39878.000
EST 782457 287256.026 66589 18994.005 82351.155
CAN 2840 123687.000 2027 40.000 3465.000
BRA 141631 112086.000 7817 57.001 3875.000
OAM 140633 72421.808 3386 547.049 4157.586
AFR 596285 39583.450 28433 237.947 1565.088 ;

Table
oqd0(i,k) initial quantity demanded in region i by product k
FLW OIR SWN PLY PTB FBB NWS PAW OPR
EUR 145849.000 29180.000 107151.000 10693.301 45254.000 16659.000 11006.403 29490.747 54255.259
USA 41436.000 8278.000 76691.000 12255.000 19460.000 9008.000 5469.000 21587.000 48775.000
EST 782583.000 66589.000 114968.000 58516.133 24643.000 41382.000 14745.165 44577.663 114542.713
CAN 2869.000 2027.000 17596.000 3446.000 3701.000 1409.000 358.000 1854.000 3801.000
BRA 141631.000 7817.000 23455.000 1215.000 2652.000 2767.000 547.000 2012.000 6002.000
OAM 140628.000 3386.000 16975.000 2867.811 1706.000 2545.000 1500.923 4770.586 11647.946
AFR 596273.000 28433.000 14344.000 2284.000 944.000 547.000 757.320 1769.940 3919.830 ;

Parameter qd0(i,k) log transform of conversion ;
qd0(i,k) = log(oqd0(i,k)) ;

*I take the log transform of quantities to make certain constraints linear

Parameter qs0(i,j) log transform of conversion ;
qs0(i,j) = log(oqs0(i,j)) ;

Table
moex(i,tr) quantity of exports in region i by traded product tr
FLW INR SWN PLY PTB FBB MCP CMP OFP WST NWS PAW OPR
EUR 5387 93397 69052 6003 15987 11439 660 12891 162 24458 7181 30977 29521
USA 168 17704 3834 812 536 912 158 5784 114 19436 740 2151 8487
EST 59 30141 6729 13761 2274 7300 244 3621 99 8316 1466 9020 6009
CAN 77 6122 21865 836 3682 706 48 8740 5 1783 4715 3791 1998
BRA 1 1879 1636 1774 63 222 1 7833 6 2 1 1119 772
OAM 8 10066 3567 1033 294 1609 1 5335 3 590 246 253 1163
AFR 17 7314 1770 507 25 35 3 450 15 80 60 542 560 ;

Parameter ex(i,tr) log transform of export quantity ;
ex(i,tr) = log(moex(i,tr)) ;

Table
moim(i,tr) quantity of imports in region i by traded product tr
FLW INR SWN PLY PTB FBB MCP CMP OFP WST NWS PAW OPR
EUR 3974 82029 40759 8611 14286 11000 471 17620 229 14108 6064 24629 25296
USA 108 2482 17997 3098 3430 2028 46 5085 38 553 2777 5825 2834
EST 185 70950 24885 8702 3482 5568 483 19546 164 34840 3536 8539 11749
CAN 106 7982 1783 1813 826 717 1 262 23 1379 70 1059 1607
BRA 1 302 104 15 44 203 1 348 7 15 416 527 129
OAM 3 562 4249 661 465 1194 13 1889 14 3712 1023 2573 5081
AFR 5 776 7631 937 187 386 6 435 30 86 464 1286 1977 ;

Parameter im(i,tr) log transform of import quantity ;
im(i,tr) = log(moim(i,tr)) ;

Table
mfcap(i,mf) manufacturing capacity in region i for product k
SWN PLY PTB FBB MCP CMP NWS PAW OPR
EUR 135444 8085.301 46955 17098 14244.748 33176.691 12123.403 35838.747 58480.259
USA 62528 9969 16566 7892 3854 45897 3432 17913 54428
EST 96812 63575.133 23435 43114 3914.049 24954.959 12675.165 45058.663 108802.713
CAN 37678 2469 6557 1398 8873 9793 5003 4586 4192
BRA 24987 2974 2671 2786 456 12943 131 2604 6645
OAM 16293 3239.811 1535 2960 578.367 6560.448 723.923 2450.586 7729.946
AFR 8483 1854 782 196 429.013 1833.334 353.32 1025.94 2502.83 ;

Free Variables
z total global welfare ;

Positive Variables
qs(i,j,t) quantity produced in region i of primary product j at time t
ps(i,j,t) supply price for primary products
qd(i,k,t) quantity demanded in region i of final product k at time t
pd(i,k,t) demand price for final products
qmf(i,mf,t) quantity manufactured domestically
qm(i,tr,t) quantity imported to region i by product tr at time t
qx(i,tr,t) quantity exported to region i by product tr at time t

Equations
obj define objective function
supply(i,j,t) observe supply limit in region i for primary product j at time t
demand(i,k,t) satisfy demand in region i for product k at time t
mupper(i,tr,t) upper bound for imports
mlower(i,tr,t) lower bound for imports
xupper(i,tr,t) upper bound for exports
xlower(i,tr,t) lower bound for exports
manufact1(i,jINR,t) material balance is satisfied in production of primary and secondary goods
manufact2(i,jMCP,t) material balance is satisfied in production of primary and secondary goods
manufact3(i,jCMP,t) material balance is satisfied in production of primary and secondary goods
manufact4(i,jOFP,t) material balance is satisfied in production of primary and secondary goods
manufact5(i,jWST,t) material balance is satisfied in production of primary and secondary goods
capacity(i,mf,t) observe capacity limit in region i for secondary products k at time t
consume1(i,kFLW,t) material balance is satisfied in consumption of final goods
consume2(i,kOIR,t) material balance is satisfied in consumption of final goods
consume3(i,kSWN,t) material balance is satisfied in consumption of final goods
consume4(i,kPLY,t) material balance is satisfied in consumption of final goods
consume5(i,kPTB,t) material balance is satisfied in consumption of final goods
consume6(i,kFBB,t) material balance is satisfied in consumption of final goods
consume7(i,kNWS,t) material balance is satisfied in consumption of final goods
consume8(i,kPAW,t) material balance is satisfied in consumption of final goods
consume9(i,kOPR,t) material balance is satisfied in consumption of final goods
tradebal(t) material balance for imports and exports
recycle(i,j,t) defines wastepaper recycling ;

obj … z =e= SUM((i,j,t),qs(i,j,t)*ps(i,j,t)/2) + SUM((i,k,t),qd(i,k,t)*pd(i,k,t)/2) - SUM((i,mf,t),qmf(i,mf,t)*mfcost(i,mf)) - SUM((i,tr,t),qm(i,tr,t)*tran(i,tr));
supply(i,j,t) … qs(i,j,t) =l= qs(i,j,t-1) + esp(i,j)*ps(i,j,t) - esp(i,j)*ps(i,j,t-1) ;

  • The above equation has no exogenous shifter …
    demand(i,k,t) … qd(i,k,t) =g= qd(i,k,t-1) + gdp(i,t) + edp(i,k)*pd(i,k,t) - edp(i,k)*pd(i,k,t-1) ;
    mupper(i,tr,t) … exp(qm(i,tr,t)) =l= exp(qm(i,tr,t-1)) * Utinertia(i,t) ;
    mlower(i,tr,t) … exp(qm(i,tr,t)) =g= exp(qm(i,tr,t-1)) * Ltinertia(i,t) ;
    xupper(i,tr,t) … exp(qx(i,tr,t)) =l= exp(qx(i,tr,t-1)) * Utinertia(i,t) ;
    xlower(i,tr,t) … exp(qx(i,tr,t)) =g= exp(qx(i,tr,t-1)) * Ltinertia(i,t) ; ;
    manufact1(i,jINR,t) … exp(qs(i,jINR,t)) =e= exp(qx(i,“INR”,t)) - exp(qm(i,“INR”,t)) + exp(qmf(i,“SWN”,t))*oconv1(i,“SWN”) + exp(qmf(i,“PLY”,t))*oconv1(i,“PLY”) + exp(qmf(i,“PTB”,t))*oconv1(i,“PTB”) + exp(qmf(i,“FBB”,t))*oconv1(i,“FBB”) + exp(qmf(i,“CMP”,t))*oconv1(i,“CMP”) + exp(qmf(i,“MCP”,t))*oconv1(i,“MCP”) - exp(qm(i,“INR”,t)) + exp(qx(i,“INR”,t));
  • Above is the equation that apparently causes the overflow. Removing the term in bold eliminates the error for some reason…
    manufact2(i,jMCP,t) … exp(qmf(i,jMCP,t)) =e= exp(qx(i,“MCP”,t)) - exp(qm(i,“MCP”,t)) + exp(qmf(i,“NWS”,t))*oconv2(i,“NWS”) + exp(qmf(i,“PAW”,t))*oconv2(i,“PAW”) + exp(qmf(i,“OPR”,t))*oconv2(i,“OPR”) - exp(qm(i,“MCP”,t)) + exp(qx(i,“MCP”,t));
    manufact3(i,jCMP,t) … exp(qmf(i,jCMP,t)) =e= exp(qx(i,“CMP”,t)) - exp(qm(i,“CMP”,t)) + exp(qmf(i,“NWS”,t))*oconv3(i,“NWS”) + exp(qmf(i,“PAW”,t))*oconv3(i,“PAW”) + exp(qmf(i,“OPR”,t))*oconv3(i,“OPR”) - exp(qm(i,“CMP”,t)) + exp(qx(i,“CMP”,t));
  • qmf(i,jCMP,t) appears in the above equation as well.
    manufact4(i,jOFP,t) … exp(qs(i,jOFP,t)) =e= exp(qx(i,“OFP”,t)) - exp(qm(i,“OFP”,t)) + exp(qmf(i,“NWS”,t))*oconv4(i,“NWS”) + exp(qmf(i,“PAW”,t))*oconv4(i,“PAW”) + exp(qmf(i,“OPR”,t))*oconv4(i,“OPR”) - exp(qm(i,“OFP”,t)) + exp(qx(i,“OFP”,t));
    manufact5(i,jWST,t) … exp(qs(i,jWST,t)) =e= exp(qx(i,“WST”,t)) - exp(qm(i,“WST”,t)) - exp(rec(i,jWST,t)) + exp(qmf(i,“NWS”,t))*oconv5(i,“NWS”) + exp(qmf(i,“PAW”,t))*oconv5(i,“PAW”) + exp(qmf(i,“OPR”,t))*oconv5(i,“OPR”) - exp(qm(i,“WST”,t)) + exp(qx(i,“WST”,t));
    capacity(i,mf,t) … exp(qmf(i,mf,t)) =l= cumgdp(i,t) * mfcap(i,mf);
    consume1(i,kFLW,t) … exp(qd(i,kFLW,t)) =e= exp(qs(i,“FLW”,t)) + exp(qm(i,“FLW”,t)) + exp(qx(i,“FLW”,t));
    consume2(i,kOIR,t) … exp(qd(i,kOIR,t)) =e= exp(qs(i,“OIR”,t));
    consume3(i,kSWN,t) … exp(qd(i,kSWN,t)) =e= exp(qmf(i,“SWN”,t)) + exp(qm(i,“SWN”,t)) + exp(qx(i,“SWN”,t));
    consume4(i,kPLY,t) … exp(qd(i,kPLY,t)) =e= exp(qmf(i,“PLY”,t)) + exp(qm(i,“PLY”,t)) + exp(qx(i,“PLY”,t));
    consume5(i,kPTB,t) … exp(qd(i,kPTB,t)) =e= exp(qmf(i,“PTB”,t)) + exp(qm(i,“PTB”,t)) + exp(qx(i,“PTB”,t));
    consume6(i,kFBB,t) … exp(qd(i,kFBB,t)) =e= exp(qmf(i,“FBB”,t)) + exp(qm(i,“FBB”,t)) + exp(qx(i,“FBB”,t));
    consume7(i,kNWS,t) … exp(qd(i,kNWS,t)) =e= exp(qmf(i,“NWS”,t)) + exp(qm(i,“NWS”,t)) + exp(qx(i,“NWS”,t));
    consume8(i,kPAW,t) … exp(qd(i,kPAW,t)) =e= exp(qmf(i,“PAW”,t)) + exp(qm(i,“PAW”,t)) + exp(qx(i,“PAW”,t));
    consume9(i,kOPR,t) … exp(qd(i,kOPR,t)) =e= exp(qmf(i,“OPR”,t)) + exp(qm(i,“OPR”,t)) + exp(qx(i,“OPR”,t));
    tradebal(t) … SUM((i,tr), exp(qm(i,tr,t))) =e= SUM((i,tr),exp(qx(i,tr,t)));
    recycle(i,jWST,t) … exp(rec(i,jWST,t)) =e= exp(qd(i,“NWS”,t-1)) + exp(qd(i,“PAW”,t-1)) + exp(qd(i,“OPR”,t-1));

qs.fx(i,j,“2010”) = qs0(i,j);
ps.fx(i,j,“2010”) = ps0(i,j);
qd.fx(i,k,“2010”) = qd0(i,k);
pd.fx(i,k,“2010”) = pd0(i,k);
qm.fx(i,tr,“2010”) = im(i,tr);
qx.fx(i,tr,“2010”) = ex(i,tr);
qmf.fx(i,mf,“2010”) = mfcap(i,mf);
*Could the issue stem from the above line?

loop(t$(ord(t) > 1),
qs.l(i,j,t) = qs.l(i,j,t-1);
qs.lo(i,j,t) = 1;
qs.up(i,j,t) = 2qs.l(i,j,t-1);
qd.l(i,k,t) = qd.l(i,k,t-1);
qd.lo(i,k,t) = 1;
qd.up(i,k,t) = 2
qd.l(i,k,t-1);
ps.l(i,j,t) = ps.l(i,j,t-1);
ps.lo(i,j,t) = 3;
ps.up(i,j,t) = 2ps.l(i,j,t-1);
pd.l(i,k,t) = pd.l(i,k,t-1);
pd.lo(i,k,t) = 3;
pd.up(i,k,t) = 2
pd.l(i,k,t-1);
qm.l(i,tr,t) = qm.l(i,tr,t-1);
qx.l(i,tr,t) = qx.l(i,tr,t-1);
qmf.l(i,mf,t) = qmf.l(i,mf,t-1);
qmf.lo(i,mf,t) = 1;
) ;

Model forsite /all/;
Solve forsite using nlp maximizing z;

Thanks for any help you might be able to provide. Again, the full code is attached.
Cheers,
Jesse Henderson


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/groups/opt_out.