GithubHelp home page GithubHelp logo

gmpl-mode's Introduction

gmpl-mode

https://melpa.org/packages/gmpl-mode-badge.svg 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 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 C-c C-c 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-file

You 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 C-c C-a).

For example, if you want to set the --interior option for glpsol, you can use M-x gmpl-glpsol-set-extra-args or C-c C-a. 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 --interior

You 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.

gmpl-mode's People

Contributors

cute-jumper avatar jacksondm33 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.