Metadata-Version: 2.4
Name: gmpl-tex
Version: 1.0.0b1
Summary: Convert GMPL (GNU MathProg) models into LaTeX.
Author: Philipp Molnar
License: MIT License
        
        Copyright (c) 2026 philippmoln
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: lark>=1.1
Description-Content-Type: text/markdown

# 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](https://www.python.org/downloads/). On Windows,
    tick **"Add python.exe to PATH"** in the installer.
- [`lark`](https://github.com/lark-parser/lark) - installed automatically.

## Install

```bash
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
```text
gmpl-tex model.mod [lookup.json] --json
gmpl-tex model.mod [lookup.json] [output.tex] --latex
```

A full run, start to finish:

```bash
# 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`](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](LICENSE).