Indenting with Gams-mode

The new version of Gams-mode has a nice feature that helps you in formatting your model.
You can automatically indent GAMS programs according to GAMS syntax.
 
M-C-\        =       Indent region.  Specify region and type M-C-\.
TAB          =       Indent the current line.
 
On the left you see the model before using the indent feature of Gams-mode. I selected the region and typed M-C-\ (`indent-region’).
You can see on the right side what happened. The set and parameter declarations are nicely formatted and the loop is clearly
Read the rest “Indenting with Gams-mode”

Version 3.5 of Gams-mode released

There is a new version of Gams-mode for Emacs (Release 3.5). When I install a new version on my Windows machine, I usually rename the old Gams-mode directory (on my computer this is ‘C:\Program Files\Emacs\site-lisp\gams’ in ‘C:\Program Files\Emacs\site-lisp\gamsOld’ and put the downloaded Gams-mode files in a directory with the original name (C:\Program Files\Emacs\site-lisp\gams). This way I can check if the new version runs without problems (all settings are preserved) and go back to the old version if there are any problems (just by renaming the directories again). The new version has a great feature for aligning blocks in Gams code.
Read the rest “Version 3.5 of Gams-mode released”

GAMS mode goodies: Looking up the identifier part of a parameter, variable or set

One of the nice features of Gams-Mode for Emacs is the possibility to quickly look up the identifier part of a variable, parameter or set. This is a nice feature in big models or when you haven’t worked with the model for some time. Just put the cursor somewhere on the parameter in the code you are looking at and hit F7. The screen will split and an additional side pane will appear.
Here is an example: in the lower pane you see the file readdata.gms, where I am working on, and the cursor is on the parameter “total” (red
Read the rest “GAMS mode goodies: Looking up the identifier part of a parameter, variable or set”

Golden Rule 2: Comments and Descriptions

The next golden rule might also be obvious:Always add comments to your work and label your sets, variables, parameters and equations
Now this might be obvious if you have a lot of time, but usually the rule is forgotten if you are stressed and want to finish what you are working on. Not writing comments will probably cost you a lot of time, if you take your model a year from now and see your code: Wow, that looks interesting and very ingenious, but what the %*?!  did I do here? If you send your model to somebody else for
Read the rest “Golden Rule 2: Comments and Descriptions”

Golden Rule 1: Display and use your intuition

The first golden rule for modeling is: Always display the results of your calculations and check them with your expectations about the results.
Often you are working on a model doing a lot of preparing calculations (calibrating the model, preparing the data). Those calculations might be easy, for example calculating the shares for some parameter, but if you make an unnoticed error can cost you a lot of time and frustration.
Here is a simple example. I want to calculate the shares for the investment function
 
 
Calculating the share is not difficult thing, but you can make small
Read the rest “Golden Rule 1: Display and use your intuition”