https://github.com/cute-jumper/gmpl-mode
Major mode for editing GMPL (MathProg) files
https://github.com/cute-jumper/gmpl-mode
emacs gmpl major-mode mathprog
Last synced: about 2 months ago
JSON representation
Major mode for editing GMPL (MathProg) files
- Host: GitHub
- URL: https://github.com/cute-jumper/gmpl-mode
- Owner: cute-jumper
- Created: 2015-11-05T19:02:22.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2022-01-21T06:31:49.000Z (over 3 years ago)
- Last Synced: 2024-05-09T21:03:20.310Z (about 1 year ago)
- Topics: emacs, gmpl, major-mode, mathprog
- Language: Emacs Lisp
- Homepage:
- Size: 148 KB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
#+TITLE: gmpl-mode
[[https://melpa.org/#/gmpl-mode][file:https://melpa.org/packages/gmpl-mode-badge.svg]]
[[https://stable.melpa.org/#/gmpl-mode][file:https://stable.melpa.org/packages/gmpl-mode-badge.svg]]Major mode for editing GMPL (MathProg) files.
If you are writing GMPL and using GLPK and to solve problems, try this out!
* Overview
GMPL is a modeling language to create mathematical programming models which
can be used by [[https://www.gnu.org/software/glpk/][GLPK]].Although GMPL is a subset of AMPL, the current Emacs major mode for AMPL,
which can be found at https://github.com/dpo/ampl-mode, doesn't work well with
GMPL files. Here is the list of the reasons why =gmpl-mode= works better
compared to =ampl-mode= when editing GMPL files:
1. Support single quoted string and C style comments.
2. Some keywords(such as =for=, =end=) are highlighted properly, and it
provides better hightlighting generally.
3. A usable indent function.
4. Some useful commands to interact with =glpsol= directly.* Usage
** Using the Major Mode
First, add the =load-path= and load the file:
: (add-to-list 'load-path "/path/to/gmpl-mode.el")
: (require 'gmpl-mode)Use =gmpl-mode= when editing files with the =.mod= extension:
: (add-to-list 'auto-mode-alist '("\\.mod\\'" . gmpl-mode))
** Using =gmpl-glpsol-solve-dwim=
When in =gmpl-mode=, you can use @@html:@@C-c C-c@@html:@@ to
invoke =gmpl-glpsol-solve-dwim=. This command will use the content of the
current buffer(or the region if the region is active) as the input for the
=glpsol= command, and then display the results in a separate buffer with some
colors added. The following command is basically what =gmpl-glpsol-solve-dwim=
does(Yes, =--ranges= only makes sense for simplex):
: glpsol -m input-file -o output-file --ranges sensitivity-fileYou can set the variable =gmpl-glpsol-program= to the exact location of your
=glpsol= command if it is not in the PATH or has some other magic name.It is also possible that you can pass extra arguments to =glpsol= command. The
buffer-local variable, =gmpl-glpsol-extra-args=, controls the value of extra
arguments. To set extra arguments for =glpsol=, use =M-x
gmpl-glpsol-set-extra-args= (which is bound to @@html:@@C-c
C-a@@html:@@).For example, if you want to set the =--interior= option for =glpsol=, you can
use =M-x gmpl-glpsol-set-extra-args= or @@html:@@C-c C-a@@html:@@.
This command will set the value of =gmpl-glpsol-extra-args= and add the
following lines at the end of the file:
: # Local Variables:
: # gmpl-glpsol-extra-args: "--interior"
: # End:After that, when we invoke =gmpl-glpsol-solve-dwim=, essentially following
command will be used:
: glpsol -m input-file -o output-file --ranges sensitivity-file --interiorYou can use =gmpl-glpsol-set-extra-args= to set the value of
=gmpl-glpsol-extra-args= in different buffers so that you can have different
commnd line arguments for different problems.* Screenshot
Here is the screenshot using Emacs 24's builtin theme =tsdh-dark=:[[./screenshot.png]]
* *TODO*
- Translate LaTeX equations to GMPL format and solve the problem directly.
- Add company-keywords support.