Skip to main content

Convert GMPL (GNU MathProg) models into LaTeX.

Project description

gmpl-tex

Convert GMPL (GNU MathProg) optimization models into LaTeX, so the constraints, sets, parameters, variables and objectives you wrote for a solver can go straight into a paper with readable, renamed symbols.

The tool works in two phases so you stay in control of the notation:

  1. Lookup-table generation - parse model.mod into a JSON table listing every set, parameter, variable, constraint and objective name. Each name maps to a label you can edit.
  2. LaTeX generation - render the model to LaTeX, substituting your edited labels from the JSON table.

Requirements

  • Python 3.10 or newer. Check what you have:
    • Windows: py --version
    • macOS / Linux: python3 --version
    • If it's missing, install from python.org. On Windows, tick "Add python.exe to PATH" in the installer.
  • lark - installed automatically.

Install

pip install gmpl-tex

After installing, the command gmpl-tex works the same on every platform.

Windows users: use py -m pip install gmpl-tex if pip isn't on your PATH.

Usage

gmpl-tex model.mod [lookup.json] --json
gmpl-tex model.mod [lookup.json] [output.tex] --latex

A full run, start to finish:

# 1. Generate the editable lookup table (writes model.json)
gmpl-tex model.mod --json

# 2. Open model.json and edit the label on the right-hand side of each entry,
#    e.g. "finishTime": "fTime"

# 3. Render LaTeX using your edited labels (writes model.tex)
gmpl-tex model.mod model.json --latex

If you skip step 1 and run gmpl-tex model.mod --latex directly, a default table is created automatically (labels equal to the raw names) and used. If a model.json already exists next to the model, it is reused as-is and never overwritten.

An example model is included under examples/model.mod.

Troubleshooting

  • A symbol shows up in red in the output. That symbol is missing from your model.json lookup table - regenerate the table with --json after changing the model, then re-render.

License

MIT - see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gmpl_tex-1.0.0b1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gmpl_tex-1.0.0b1-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

Details for the file gmpl_tex-1.0.0b1.tar.gz.

File metadata

  • Download URL: gmpl_tex-1.0.0b1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"x86_64","distro":{"id":"noble","libc":{"lib":"glibc","version":"2.39"},"name":"Ubuntu","version":"24.04"},"implementation":{"name":"CPython","version":"3.12.3"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.13 30 Jan 2024","python":"3.12.3","system":{"name":"Linux","release":"6.17.0-35-generic"}} HTTPX2/2.4.0

File hashes

Hashes for gmpl_tex-1.0.0b1.tar.gz
Algorithm Hash digest
SHA256 9727ce063e85c1fcc90a2ded8870a8ea44e40497ea9a02734c074ec5bc9f0736
MD5 c8414e473936367e7d4c0a63201ce69d
BLAKE2b-256 451352596ca92c63ff3e0337d2b0380001bb436091c950be0802323d6802cb0a

See more details on using hashes here.

File details

Details for the file gmpl_tex-1.0.0b1-py3-none-any.whl.

File metadata

  • Download URL: gmpl_tex-1.0.0b1-py3-none-any.whl
  • Upload date:
  • Size: 18.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.17.0 {"ci":null,"cpu":"x86_64","distro":{"id":"noble","libc":{"lib":"glibc","version":"2.39"},"name":"Ubuntu","version":"24.04"},"implementation":{"name":"CPython","version":"3.12.3"},"installer":{"name":"hatch","version":"1.17.0"},"openssl_version":"OpenSSL 3.0.13 30 Jan 2024","python":"3.12.3","system":{"name":"Linux","release":"6.17.0-35-generic"}} HTTPX2/2.4.0

File hashes

Hashes for gmpl_tex-1.0.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 709639444b0814c00b9b8c56c0e4e5dae37fec2ec58638c55b24924246f81e2c
MD5 01535e3f44a554872af9f5b46aec3bcb
BLAKE2b-256 406957a95bb12cc9eb9fb093251ea6b8a24feb15596046326c72474556c58a40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page