Installing GAMS on Ubuntu and setting up Emacs
Posted on Sunday, May 3, 2009

Not too long ago I faced the problem of installing GAMS on my computer. Well, you wouldn't really think that it would be a problem and maybe it isn't, but at least I found the documentation difficult to understand and ended up spending a lot of time doing something that really shouldn't more than 10 minutes. As the steps are so simple, I figured I might as well post it here. I use Emacs for most of my editing and it helps a lot having nice syntax highlighting. Luckily, somebody thought of this already and provided a script, which also adds some useful functionality when editing .gms-files.

Getting GAMS: Of course you first of need to download the GAMS file. Choose the appropriate Linux version.

Installing GAMS: Despite that the installation notes seem to suggest that you install GAMS in the /usr/ directory, I would suggest you install it somewhere in your home directory. This way you won't need root access to run GAMS, which is a very comfortable. So move the downloaded file to your favourite directory and make it executable (sudo chmod +x installFileName). Run the program and it'll unpack a lot of files. Now run ./gamsinst. You might have to chose what kind of solver you wish to use for various kinds of programs. If you don't have any preference just pick the cplex when possible and some random stuff when not. That's it!

Creating alias: As the notes mention it's probably useful to create and alias for your GAMS program. To do so open your .bashrc-file in your home directory and add something like alias gams="/home/jerome/programming/gams/23.0/gams" adjusting the path and the alias'. In this way you'll be able to run GAMS by typing gams problem.gms. Now you're ready to solve those optimization problems!

Getting Emacs set up: If you use Emacs for editing you might appreciate Shiro Takeda's script. Download the zip-file. Open your .emacs-file in your home directory and add

(setq load-path
(cons "~/programming/gams/gams-2.7.1"

(require 'gams)
(require 'font-lock)
(global-font-lock-mode t)

Remember to replace ~/programming/gams/gams-2.7.1 with the correct path!

That's it! Now you've got GAMS installed and Emacs displays .gms-files nicely. Shiro Takeda's script does more though so it is definitely worth reading more about in the readme-file provided. Please let me know if you find any errors in the above or if something could have been put more clearly...