-
Notifications
You must be signed in to change notification settings - Fork 4
/
gams-template.txt
42 lines (42 loc) · 25.5 KB
/
gams-template.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
;;; -*- coding: utf-8 -*-
(("Introduction of the GAMS-TEMPLATE mode." . "* ------------------------------------------------------------\n* Introduction of the GAMS-TEMPLATE mode.\n* ------------------------------------------------------------\n$ontext\n\nGAMS-TEMPLATE mode enables you to handle templates easily. You can easily\ninsert, re-edit, delete, rename, order, and add templates. You can of course\nmake any change on this sample template file. Try it!\n\nSee the help for commands. Type `h' in the *GAMS Template List* buffer. To\nscroll this buffer, type `k' or `l'.\n\nMost of the examples in this sample `gams-template-file' are taken from Tom\nRutherford's web page and Rob Dellink's GAMS Tips and Tricks. I would like to\nthank them.\n\n`gams-template' stores templates in a template file defined by the\nvariable `gams-template-file'. Its default value is\n\"~/.emacs.d/gams-template.txt\".\n\nIf you have useful templates, please send them to me. I will add them\nto this file.\n\n\n$offtext\n* --------------------\n* Local Variables:\n* mode: gams\n* fill-column: 70\n* End:\n")
("Commands in the GAMS-TEMPLATE mode." . "* ------------------------------------------------------------\n* Commands in the GAMS-TEMPLATE mode.\n* ------------------------------------------------------------\n$ontext\nThe following commands are available in this mode.\n\nSPC Show a content of a template.\nRET Insert a template.\nq Quit.\na Add a new template.\n\nd Delete a template.\ne Re-edit a template.\nr Rename a template.\nu Move a template up.\nj Move a template down.\ng Show the gms file.\ns(S) Scroll up (down) *Template Content* buffer.\nh Show this help.\no Save the content of gams-user-template-alist.\n\np Show the previous template.\nn Show the next template.\n$offtext\n")
("Header (1)" . "$title %c\n$ontext\nTime-stamp: <2021-03-02 13:21:39 st>\nFirst-written: <2013/10/11>\nAuthor: Shiro Takeda\n\n$offtext\n")
("Footer (1)" . "* --------------------\n* Local Variables:\n* mode: gams\n* fill-column: 70\n* End:\n")
("Comment (1) with explanation" . "* ============================================================\n* %c (% + c indicate the cursor place)\n")
("Comment (2) with explanation" . "* ------------------------------------------------------------\n* %c (% + c indicate the cursor place)\n")
("Comment (1)" . "* ============================================================\n* %c\n")
("Comment (2)" . "* ------------------------------------------------------------\n* %c\n")
("Comment for Cleanup calculation." . "* ------------------------------------------------------------\n* Cleanup calculation.\n")
("Comment for Counter factual experiment." . "* ------------------------------------------------------------\n* Counter-factual experiment\n")
("Comment for Benchmark replication." . "* ------------------------------------------------------------\n* Benchmark replication.\n")
("Comment for GAMS-OUTLINE mode." . "* ------------------------------------------------------------\n* Comment for the GAMS-OUTLINE mode.\ndisplay \"@ %c\";\n")
("gdxxrw (1): excel -> gams" . "$ontext\nNote: before running this program, you first need to run GAMS_to_excel.gms to\ncreate data.xls file.\n\nSteps:\n1) Excel file -> GDX file\n2) GDX file -> GAMS.\n\n$offtext\nset\n i / 1*10 /;\nalias(i,j);\n\n* Parameters a and b must be declared beforehand.\nparameter\n a(i,j) Data A\n b(i,j) Data B\n;\n* Export a and b to the GDX file 'data_alt.gdx' from the excel file 'data.xls'.\n$call '=gdxxrw i=data.xls o=data_alt.gdx par=a rng=sheet_a!A1:K11 rdim=1 cdim=1 par=b rng=sheet_b!A1:K11 rdim=1 cdim=1'\n\n* Open the GDX file 'data_alt.gdx'.\n$gdxin data_alt.gdx\n\n* Import a and b from 'data_alt.gdx'.\n$load a b\n\n* Display the content of a and b.\ndisplay a, b;\n")
("gdxxrw (2): gams -> excel" . "$ontext\nSteps:\n1) GAMS -> GDX file\n2) GDX file -> Excel file.\n\n$offtext\nset\n i / 1*10 /;\nalias(i,j);\n\nparameter\n a(i,j) Data A\n b(i,j) Data B\n;\n* Random numbers to parameter a.\na(i,j) = uniform(0,1);\nb(i,j) = 100;\nb(i,i) = 0;\ndisplay a, b;\n\n* Export a and b to the GDX file 'data.gdx'.\nexecute_unload \"data.gdx\", a, b;\n\n* Export a and b from data.gdx to the excel file 'data.xls'.\nexecute '=gdxxrw i=data.gdx o=data.xls par=a rng=sheet_a!A1 rdim=1 cdim=1';\nexecute '=gdxxrw i=data.gdx o=data.xls par=b rng=sheet_b!A1 rdim=1 cdim=1';\n")
("gdxxrw (3): gams -> excel (multiple parameters are exported at a time)" . "$ontext\nSteps:\n1) GAMS -> GDX file\n2) GDX file -> Excel file.\n\n$offtext\nset\n i / 1*10 /;\nalias(i,j);\n\nparameter\n a(i,j) Data A\n b(i,j) Data B\n;\n* Random numbers to parameter a.\na(i,j) = uniform(0,1);\nb(i,j) = 100;\nb(i,i) = 0;\ndisplay a, b;\n\n* Export a and b to the GDX file 'data.gdx'.\nexecute_unload \"data.gdx\", a, b;\n\n$onecho > command.txt\ni = data.gdx o=data.xls\npar=a rng=sheet_a!A1 rdim=1 cdim=1\npar=b rng=sheet_b!A1 rdim=1 cdim=1\n$offecho\n\n* The following command evokes gdxxrw with the content of command.txt as\n* arguments.\nexecute '=gdxxrw @command.txt';\n\n")
("gdxxrw (4): export parameters with zero to excel." . "$title How to export parameters with zero to excel file.\n$ontext\n1) First, set eps to parameters.\n2) Replace eps with zero when exporting gdx to excel.\n$offtext\nset i Sample index / 1*100 /\n j Sample index / 1*100 /\n;\nparameter a Sample parameter\n b Sample parameter\n; \na(i,j) = eps;\nb(i,j) = 0;\ndisplay a, b;\n\n* Export parameter to results_2.gdx\nexecute_unload \"results_eps.gdx\", a, b;\n\n* ----------------------------------------------------------------------\n* Export to excel by gdxxrw\n$ontext\nThe following option for gdxxrw replace eps with STRING\nepsout=string\n$offtext\n* parameter file for gdxxrw\n$onecho > cmd.txt\ni=results_eps.gdx o=results_eps.xlsx epsout=0\npar=a rng=a!A1 rdim=1 cdim=1 \npar=b rng=b!A1 rdim=1 cdim=1 \n$offecho\n\n* Call gdxxrw\nexecute '=gdxxrw @cmd.txt';\n")
("batinclude (1)" . "* ----------------------------------------------------------------------\n* $batinclude\n$batinclude filename arg1 arg2\n\n")
("MPSGE: Solve the model by MPSGE" . "$include modelname.gen\nsolve modelname using mcp;\n")
("MPSGE: debug options" . "\noption sysout = on;\n\n$ontext\n$model:modelname\n\n* Debug options for MPSGE\n* $echop:.true.\n* $datech:.true.\n* $funlog:.true.\n")
("MPSGE: Endogenous tax." . "* MPSGE endogenous tax (n: -> endogenous tax rate)\n$prod:q(s) s:1\n o:p(s) q:q0(s) p:1 a:cons n:mul\n i:pf(f) q:fi0(f,s) p:pf0(f,s) a:cons t:txf(f,s)\n")
("MPSGE: Endogenous tax multiplier." . "* MPSGE endogenous tax multiplier (m: -> multiplier).\n\n$prod:q(s)\n o:p(s) q:q0(s)\n i:pf(f) q:af0(f,s) p:pf0(f,s) a:cons\n+ n:tau$tf(f,s) m:tf(f,s)$tf(f,s)\n")
("MPSGE: mpsgeset" . "$offtext\n$sysinclude mpsgeset %c\n")
("Limit iteration." . "* <modelname>.iterlim = 0;\n%c.iterlim = 0;\n")
("put statement ex.1" . "* ----------------------------------------------------------------------\n* put ex.1\n* From Rob Dellink's GAMS Tips and Tricks.\n* ----------------------------------------------------------------------\n\n* 13. You can use some identifiers of sets in put statements:set element label:\n* <setname>.tl (useful in loops)set element * associated text: <setname>.te(index)\n \n* set associated text: <setname>.ts\n\n* Example:\n\nfile out /\"results.out\"/; put out;\n\nset i associated text of set /i1 first element, i2 second element, i3/;\n\nput i.ts /;\n\nloop(i, put i.tl, i.te(i) /);\n\n* The resulting file results.out will look like:\n\n* associated text of set\n\n* i1 first element\n\n* i2 second element\n \n* i3 I3\n \n* {Contributed by Rob Dellink}\n\n")
("if-else example" . "* ----------------------------------------------------------------------\n* if statements ex.1.\n* ----------------------------------------------------------------------\n\nif(f <= 0,\n p(i) = -1;\n q(j) = -1;\nelse\n p(i) = p(i)**2;\n q(j) = q(j)**2;\n);\n\n")
("if-elseif example" . "* ----------------------------------------------------------------------\n* if statements ex.2.\n* ----------------------------------------------------------------------\nif(f <= 0,\n p(i) = -1;\n q(j) = -1;\nelseif((f > 0) and (f < 1)),\n p(i) = p(i);\n q(j) = q(j);\nelse\n p(i) = p(i)**2;\n q(j) = q(j)**2;\n);\n\n")
("Limit the output listing." . "* ----------------------------------------------------------------------\n* Limit the output listing.\n* From Rob Dellink's GAMS Tips and Tricks.\n* ----------------------------------------------------------------------\n\n* 8. You can limit the output listing file by including the following\n* statements:\n$offsymxref \n\n* {This stops the print of a complete cros-reference list of symbols }\n$offlisting\n\n* {This stops the echo print of the input file}\noption limcol = 0;\n\n* {This stops the print of the column listing}\noption limrow = 0;\n\n* {This stops the print of the equation listing}\n\n* {Contributed by Rob Dellink}\n")
("MODELSTAT and SOLVESTAT check." . "* ----------------------------------------------------------------------\n* MODELSTAT and SOLVESTAT check.\n* From Rob Dellink's GAMS Tips and Tricks.\n* ----------------------------------------------------------------------\n\n* 5. Always check whether your model has been normally completed and found an\n* optimal solution:\ndisplay <modelname>.MODELSTAT, <modelname>.SOLVESTAT;\n\n* Both should equal 1 if the model is linear; solvestat should equal 2 for\n* non-linear models. You can use an abort statement if one or both is\n* incorrect:\nabort$(<modelname>.MODELSTAT <> 1) \"Model not normally completed\", <modelname.MODELSTAT;\nabort$(<modelname>.SOLVESTAT <> 2) \"No local optimum found\", <modelname.SOLVESTAT;\n\n* {Contributed by Rob Dellink}\n")
("Model consistency check." . "* ----------------------------------------------------------------------\n* Model consistency check.\n* From Rob Dellink's GAMS Tips and Tricks.\n* ----------------------------------------------------------------------\n\n* 4. Use the abort statement if the model specification is incorrect, that is,\n* if you end up with a solution that does not satisfy some condition you know\n* that has to be satisfied; for example, if the benchmark does not replicate,\n* you can use:\nabort$(<modelname>.OBJVAL GT 1E-6) \"DATA CALIBRATION ERROR! LARGEST ERROR: \", <modelname>.OBJVAL;\n\n* Or in case you know (by Walras 〕aw) that the level of C2 has to equal the\n* level of X2:\nabort$((C2.L-X2.L)**2 gt 1E-20) \"Walras law not obeyed!\";\n\n* {Contributed by Rob Dellink}\n")
("Save and restart feature." . "* ------------------------------------------------------------------------\n* Save and restart feature.\n* From Rob Dellink's GAMS Tips and Tricks.\n* ------------------------------------------------------------------------\n\n* 18. If you have a model that costs a lot of time to calculate, then think\n* about using the save and restart feature. This is especially handy if you have\n* solved your model and are thinking about ways to organise the output. You caan\n* run your model, save the work files from this run and restart from these\n* workfiles for output handling. For example, if you have a GAMS-file (say,\n* part1.gms) in which the data is read, the variables and equations are\n* specified and your model is solved, then save the workfiles as, say,\n* model1. Then, write the output handling code in a separate file (say,\n* part2.gms), using the restart option. If you want to change anything in\n* part2.gms, you do not have to solve the model again, you can just include the\n* workfiles. This can save a lot of time (especially for larger models) and you\n* can play around with how you want your output organised at little cost. Note\n* that this save and restart feature can also be handy in other circumstances,\n* like saving after solving a base scenario and then solving several scenarios\n* using the restarted base. The code in the example above looks like this:\n \nGAMS part1 s=model1\n\nGAMS part2 r=model1\n\n* {Contributed by Rob Dellink}\n")
("Get information in run-time." . "* ------------------------------------------------------------------------\n* Get information in run-time.\n* From Rob Dellink's GAMS Tips and Tricks.\n* ------------------------------------------------------------------------\n\n* 15. How to get information on your screen in run-time? If you run several\n* simulations within the same GAMS model (for instance, you do a loop of\n* solves), you can\ndisplay \"%system.filesys%/\";\n\nfile screen /'con'/;\n\nloop(t,\n\n* < include commands here >\n putclose screen 'The current value of index t is ',t.tl/;\n\n);\n\n* Note: this may not work properly on a Unix or Windows NT platform.\n\n* If you use the GAMS-IDE, make sure that the DOS window is visible (select File\n* / Options / Execute and choose ‘Normal’ for the DOS window).\n\n* {Contributed by Rob Dellink}\n")
("Pass a parameter to include file." . "* ------------------------------------------------------------------------\n* Pass a parameter to include file.\n* From Rob Dellink's GAMS Tips and Tricks.\n* ------------------------------------------------------------------------\n\n* 17. Many users know the $INCLUDE command to include pieces of GAMS code, but\n* if you want to pass a parameter to the file that is to be included, use the\n* $batinclude command.\n$batinclude FILES.INC \"versionX\"\n\n* and FILES.INC may look like:\n\n* $CALL 'MD %1'\n\n* file results /\"%1\\results.out\"/;\n\n* set Version /%1/;\n\n* When running the program, \"%1\" will be automatically substituted by\n* \"versionX\". In this example, a subdirectory ‘versionx’ will be made and\n* output directed to the file results will be written to the file ‘results.out’ \n* in this subdirectory; finally, a set with only one element \"versionx\" is\n* declared.\n\n* {Contributed by Rob Dellink}\n")
("Gnuplot (0): Plot a one dimensional vector to the screen." . "* ----------------------------------------------------------------------\n* Gnuplot No.0\n* ex0.gms from Tom Rutherford's web page.\n* Example 0: Plot a one dimensional vector to the screen\n* ----------------------------------------------------------------------\n$title Example 0: Plot a one dimensional vector to the screen\n\nset t /1990*2030/;\n\nparameter a(t) Example 0: Generic output to the screen (default invocation);\na(\"1990\") = 1;\nloop(t, a(t+1) = a(t) * (1 + 0.04 * uniform(0.2,1.8)); );\n\n* I know that a() is defined over set t. The plotting package\n* knows that the argument has one dimension, but it does not know\n* what set defines those entry. Three ways to pass the domain:\n\n* (i) Let GAMS figure out which elements of A are nonzero (not a problem\n* here because the parameter is dense:\n\n$libinclude plot A \n\n$exit\n\n* Alternative invocations:\n\n* (ii) Pass GAMS the domain on the call:\n\n$libinclude plot A t\n\n* (iii) Pass GAMS the domain in an environment vaiable:\n\n$setglobal domain t\n$libinclude plot A \n")
("Gnuplot (1): Generic Invocation of GNUPLOT." . "* ----------------------------------------------------------------------\n* Gnuplot No.1\n* ex1.gms from Tom Rutherford's web page.\n* $TITLE Example 1: Generic Invocation of GNUPLOT\n* ----------------------------------------------------------------------\n$title Example 1: Generic Invocation of GNUPLOT\n\nset t /1990*2030/, j /a,b,c,d/;\n\nparameter a(t,j) Example 1: Generic output to the screen (default invocation);\na(\"1990\",j) = 1;\nloop(t, a(t+1,j) = a(t,j) * (1 + 0.04 * uniform(0.2,1.8)); );\n\n$setglobal gp_opt1 'set key top left'\n$libinclude plot A\n")
("Gnuplot (2): Directing GNUPLOT Output to File." . "* ----------------------------------------------------------------------\n* Gnuplot No.2\n* ex2.gms from Tom Rutherford's web page.\n* $TITLE Example 2: Directing GNUPLOT Output to File\n* ----------------------------------------------------------------------\n$title Example 2: Directing GNUPLOT Output to File\n\nset t /1990*2030/, j /a,b,c,d/;\n\nparameter a(t,j) Random time series with a trend; \na(\"1990\",j) = 1;\nloop(t, a(t+1,j) = a(t,j) * (1 + 0.04 * uniform(0.2,1.8)); );\n\n$setglobal gp_opt1 'set key bottom right'\n$setglobal gp_opt2\n$setglobal gp_opt3\n$libinclude plot A\n\n* Shift into a batch format:\n\n$setglobal batch yes\n\n* Generate a high-resolution image using the TIKZ terminal:\n\n$setglobal gp_opt2 \"set term lua tikz fulldoc createstyle\"\n$setglobal gp_opt3 \"set output 'a.tex'\"\n$setglobal gp_file a_tikz\n$libinclude plot A\nexecute 'pdflatex a.tex';\n\n\n$setglobal gp_opt2 'set term png crop'\n$setglobal gp_opt3 \"set output 'ex2_37.png'\"\n$setglobal gp_opt7 \"set size 0.8,0.8\"\n$libinclude plot A\n")
("Gnuplot (3): Graphs with Labels and Titles." . "* ----------------------------------------------------------------------\n* Gnuplot No.3\n* ex3.gms from Tom Rutherford's web page.\n* $TITLE Example 3: Graphs with Labels and Titles\n* ----------------------------------------------------------------------\n$title Example 3: Graphs with Labels and Titles\n\nset t /0*40/, j /a,b,c,d/;\n\n* Note: where we specify descriptive text for subset elements,\n* it is then displayed in place of the subset index on the \n* graph -- i.e. 1990,2000 etc. are displayed, not 0,10,...\n\nset decade(*) / 0 1990, 10 2000, 20 2010, 30 2020, 40 2030/;\n\nparameter a(t,j) Example 3: Labels and Titles; \na(\"0\",j) = 1;\nloop(t, a(t+1,j) = a(t,j) * (1 + 0.04 * uniform(0.2,1.8)); );\n\n* ---------------------------\n* Generic plotting commands:\n\n$setglobal labels decade\n\n\n$setglobal gp_opt5 \"set xlabel 'Year -- time step annual'\"\n$setglobal gp_opt6 \"set ylabel 'Value'\"\n\n\n* ---------------------------\n* GNUPLOT commands:\n\n$setglobal gp_opt1 \"set key at 5,3\"\n$setglobal gp_opt2 \"set title 'Graph of Random Time Series'\"\n$libinclude plot A\n\n$setglobal batch yes\n$setglobal gp_opt1 \"set key left\"\n$setglobal gp_opt3 \"set output 'ex3_37.png'\"\n$setglobal gp_opt4 \"set term png crop\"\n$setglobal gp_opt7 \"set size 0.8,0.8\"\n$libinclude plot A\n\n")
("Gnuplot (4): Changes the graph size, y range and location of key." . "* ----------------------------------------------------------------------\n* Gnuplot No.4\n* ex4.gms from Tom Rutherford's web page.\n* $TITLE Example 4: Changes the graph size, y range and location of key:\n* ----------------------------------------------------------------------\n$title Example 4: Changes the graph size, y range and location of key:\n\nset t /1990*2030/, j /a,b,c,d/;\n\nset decade(*) / 1990, 2000, 2010, 2020, 2030/;\n\nparameter a(t,j) Example 4: Changing graph size and scaling ;\na(\"1990\",j) = 1;\nloop(t, a(t+1,j) = a(t,j) * (1 + 0.04 * uniform(0.2,1.8)); );\n\n$setglobal labels decade\n\n$setglobal gp_opt5 \"set xlabel 'Year -- time step annual'\"\n$setglobal gp_opt6 \"set ylabel 'Value'\"\n\n$setglobal gp_opt1 \"set size 0.8,0.8\"\n$setglobal gp_opt2 \"set key outside right\"\n$setglobal gp_opt3 \"set grid\"\n$setglobal gp_opt4 \"set yrange [0:3]\"\n$libinclude plot A\n\n$setglobal batch yes\n$setglobal gp_opt5 \"set output 'ex4_37.png'\"\n$setglobal gp_opt6 \"set term png crop\"\n$libinclude plot A\n")
("Gnuplot (5): Unequally spaced data." . "* ----------------------------------------------------------------------\n* Gnuplot No.5\n* ex5.gms from Tom Rutherford's web page.\n* $TITLE Example 5: Unequally spaced data\n* ----------------------------------------------------------------------\n$title Example 5: Unequally spaced data\n\nset t /1990*2030/, j /a,b,c,d/; \nparameter a(t,j) Example 5: Missing data represented by NA;\na(\"1990\",j) = 1;\nloop(t, a(t+1,j) = a(t,j) * (1 + 0.04 * uniform(0.2,1.8)); );\n\nset decade(*) / 1990, 2000, 2010, 2020, 2030/;\nparameter year(*); year(t) = 1989 + ord(t);\n\n* Omit some data points randomly, indicating these as missing\n* by assigning values equal to na:\n\na(t,j)$(uniform(0,1) le 0.25) = na;\n\n$setglobal labels decade\n$setglobal xvalue year\n\n$setglobal gp_opt1 \"set key at 1995,2\"\n$setglobal gp_opt2 \"set style data linespoints\"\n$setglobal gp_opt3 \"set xlabel 'Year -- time step annual'\"\n$setglobal gp_opt4 \"set ylabel 'Value'\"\n$libinclude plot A\n\n$setglobal batch yes\n\n$setglobal gp_opt1 \"set key left\"\n$setglobal gp_opt5 \"set size 0.8,0.8\"\n$setglobal gp_opt6 \"set output 'ex5_37.png'\"\n$setglobal gp_opt7 \"set term png crop\"\n$libinclude plot A\n")
("Gnuplot (6): Dealing with Zero Rows and Zero Columns." . "* ----------------------------------------------------------------------\n* Gnuplot No.6\n* ex6.gms from Tom Rutherford's web page.\n* $TITLE Example 6: Dealing with Zero Rows and Zero Columns\n* ----------------------------------------------------------------------\n$title Example 6: Dealing with Zero Rows and Zero Columns\n\nset i evaluation points /1990*2000/\n j various time seris /a, b, c, d/;\n\n$setglobal labels i\n\ntable time_path(i,j) Time series with holes\n a b c d\n1990 0 2 0 0\n1991 1 2 1 0\n1992 2 3 4 0\n1993 3 4 0 0\n1994 4 0 2 0\n1995 0 0 0 0\n1996 1 2 3 0\n1997 2 3 4 0\n1998 3 4 5 0\n1999 4 5 6 0\n2000 5 1 7 0;\n\n* Note that time series d is all zeros, and \n* all of the time series equals zero in 1995.\n\n* Problem: Get gnuplot.gms to pass zero files\n* through to the plotting package.\n\n$setglobal gp_opt1 \"set size 0.7,0.6\"\n$setglobal gp_opt2 \"set key top left\"\n\n$setglobal gp_opt3 \"set title 'Problem: 1995 and series D are both zero.'\"\n$libinclude plot time_path\n\n$setglobal batch yes\n$setglobal gp_opt4 \"set term png crop\"\n$setglobal gp_opt5 \"set output 'ex6a_37.png'\"\n$libinclude plot time_path\n$setglobal gp_opt4\n$setglobal gp_opt5\n$setglobal batch no\n\n* Define an explicit domain and series:\n\n$setglobal domain i\n$setglobal series j\n\n$setglobal gp_opt3 \"set title 'One solution: define domain and series'\"\n$libinclude plot time_path\n\n$setglobal batch yes\n$setglobal gp_opt4 \"set term png crop\"\n$setglobal gp_opt5 \"set output 'ex6b_37.png'\"\n$libinclude plot time_path\n$setglobal gp_opt4\n$setglobal gp_opt5\n$setglobal batch no\n\n* Drop the domain and series definition:\n\n$setglobal domain\n$setglobal series \n\n* Method 2: replace zero by eps\n\ntime_path(i,j)$(not time_path(i,j)) = eps;\n\n$setglobal gp_opt3 \"set title 'Another solution: replace zero by eps.'\"\n$libinclude plot time_path\n\n$setglobal batch yes\n$setglobal gp_opt4 \"set term png crop\"\n$setglobal gp_opt5 \"set output 'ex6c_37.png'\"\n$libinclude plot time_path\n$setglobal gp_opt4\n$setglobal gp_opt5\n$setglobal batch no\n")
("Gnuplot (7): Plotting Multiple Independent Series." . "* ----------------------------------------------------------------------\n* Gnuplot No.7\n* ex7.gms from Tom Rutherford's web page.\n* $TITLE Example 7: Plotting Multiple Independent Series \n* ----------------------------------------------------------------------\n$title Example 7: Plotting Multiple Independent Series \n\nset i observation counts /1*4/,\n g graphs /a, b, c/;\n\ntable data(i,*,g)\n x.a y.a x.b y.b x.c y.c\n1 1 1 0 2 1 6\n2 2 2 3 2 2 4\n3 4 3 5 5 3 3\n4 10 4 7 6 4 1;\n\n* First define a set which can hold 4 observations x \n* 3 plot series:\nset p plot points /1*12/;\n\nset pp(p);\npp(\"1\") = yes;\n\nparameter x X coordinate for a given point,\n y Series values for points;\n\n* The next statement is crucial -- initialize\n* all plot points to NA (missing). The package\n* will then only plot those items which are \n* specified.\n\ny(p,g) = na;\nloop(g,\n loop(i,\n x(pp) = data(i,\"x\",g);\n y(pp,g) = data(i,\"y\",g);\n pp(p+1)$pp(p) = yes;\n pp(p)$pp(p+1) = no;\n );\n);\ndisplay x, y;\n\n$setglobal domain p\n$setglobal xvalue x\n\n$setglobal gp_opt1 \"set grid\"\n$setglobal gp_opt2 \"set tics\"\n\n$libinclude plot y\n\n\n* The X coordinates may also be passed as a column in the matrix.\n\ny(p,\"xv\") = x(p);\n\n$setglobal xvalue xv\n$libinclude plot y\n\n$setglobal batch yes\n$setglobal gp_opt3 \"set size 0.7,0.6\"\n$setglobal gp_opt4 \"set term png crop\"\n$setglobal gp_opt5 \"set output 'ex7_37.png'\"\n$libinclude plot y\n")
("Gnuplot (8): Plotting Two-Dimensional Series." . "* ----------------------------------------------------------------------\n* Gnuplot No.8\n* ex8.gms from Tom Rutherford's web page.\n* $TITLE Example 8: Plotting Two-Dimensional Series \n* ----------------------------------------------------------------------\n$title Example 8: Plotting Two-Dimensional Series \n\nset i Commodities /i1*i3/,\n r Regions /r1*r3/,\n t Time periods /2000*2100/\n s(i,r) Plot series;\n\ns(i,r) = yes;\n\nparameter prices(t,i,r) Commodity prices;\n\nprices(t,i,r) = 1;\nloop(t, prices(t+1,i,r) = prices(t,i,r) * (1 + 0.04 * uniform(0.2,1.8)); );\n\n$setglobal gp_opt1 'set key top left'\n$setglobal series s\n$libinclude plot prices \n\n$setglobal batch yes\n$setglobal gp_opt2 \"set size 0.9,0.8\"\n$setglobal gp_opt3 \"set term png crop\"\n$setglobal gp_opt4 \"set output 'ex8_37.png'\"\n$libinclude plot prices \n"))