Metadata-Version: 2.1
Name: los-lang
Version: 3.3.7
Summary: Write Math, Run Python. A Language for Optimization Specification (LOS).
Project-URL: Homepage, https://github.com/jowpereira/los
Project-URL: Documentation, https://github.com/jowpereira/los/blob/master/MANUAL.md
Project-URL: Repository, https://github.com/jowpereira/los
Project-URL: Issues, https://github.com/jowpereira/los/issues
Project-URL: Changelog, https://github.com/jowpereira/los/blob/master/CHANGELOG.md
Author: Jonathan Pereira
License: MIT License
        
        Copyright (c) 2025-2026 Jonathan Pereira
        
        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
Keywords: linear-programming,mathematical-optimization,milp,mixed-integer-programming,modeling-language,operations-research,optimization,pulp,solver
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Software Development :: Compilers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: lark>=1.1.5
Requires-Dist: numpy>=1.21.0
Requires-Dist: pandas>=1.5.0
Requires-Dist: pulp>=2.7.0
Provides-Extra: cli
Requires-Dist: click>=8.0.0; extra == 'cli'
Provides-Extra: dev
Requires-Dist: black>=22.0.0; extra == 'dev'
Requires-Dist: flake8>=5.0.0; extra == 'dev'
Requires-Dist: mypy>=1.0.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Provides-Extra: docs
Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == 'docs'
Requires-Dist: sphinx>=5.0.0; extra == 'docs'
Description-Content-Type: text/markdown

# LOS — Language for Optimization Specification

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![Security: Hardened](https://img.shields.io/badge/security-hardened-green.svg)](./SECURITY.md)

**LOS** is a **Language for Optimization Specification**. It compiles human-readable model definitions into executable Python code (currently using **PuLP** as the primary engine), keeping your business logic clean and your data pipeline separate.

> **"Write Math, Run Python."**

---

## Installation

```bash
pip install los-lang
```

Or install from source:
```bash
git clone https://github.com/jowpereira/los.git
cd los
pip install -e .
```

---

## Quick Start

### 1. Write a Model (`production.los`)
```los
import "products.csv"
import "factories.csv"

set Products
set Factories

param Cost[Products]
param Capacity[Factories]

var qty[Products, Factories] >= 0

minimize:
    sum(qty[p,f] * Cost[p] for p in Products, f in Factories)

subject to:
    capacity_limit:
        sum(qty[p,f] for p in Products) <= Capacity[f]
        for f in Factories
```

### 2. Prepare Data
**`products.csv`**
```csv
Products,Cost
WidgetA,10
WidgetB,15
```

**`factories.csv`**
```csv
Factories,Capacity
Factory1,1000
Factory2,2000
```

### 3. Solve (`solve.py`)
```python
import los

result = los.solve("production.los")

if result.is_optimal:
    print(f"Optimal Cost: {result.objective}")
    print(result.get_variable("qty", as_df=True))
```

---

## Why LOS?

| Feature | LOS | Raw PuLP/Pyomo |
|---|---|---|
| **Readability** | Whiteboard-like syntax | Python boilerplate |
| **Data Binding** | Native CSV imports | Manual DataFrame wrangling |
| **Security** | Sandboxed execution | Full Python access |
| **Debug** | Inspect generated code (`model.code()`) | Black box |
| **Solver** | CBC, GLPK, Gurobi, CPLEX (via PuLP) | Same |
| **Backends** | PuLP (Pyomo planned) | N/A |

---

## Advanced: Manual Data Binding

For dynamic data (APIs, databases), inject DataFrames directly:

```python
import los
import pandas as pd

df = pd.DataFrame({"Products": ["A", "B"], "Cost": [10, 20]})

result = los.solve("model.los", data={"Products": df})
```

---

## Documentation

| Document | Description |
|---|---|
| [User Manual](./MANUAL.md) | Full syntax reference and API guide |
| [Security Policy](./SECURITY.md) | Sandbox details and threat model |
| [Changelog](./CHANGELOG.md) | Version history |
| [Backlog](./BACKLOG.md) | Roadmap and future features |
| [Contributing](./CONTRIBUTING.md) | How to contribute |

---

## License

[MIT](./LICENSE) © Jonathan Pereira
