Skip to main content

LOS — Language for Optimization Specification

License: MIT Python 3.9+ Security: Hardened

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

pip install los-lang

Or install from source:

git clone https://github.com/jowpereira/los.git
cd los
pip install -e .

Quick Start

1. Write a Model (production.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

Products,Cost
WidgetA,10
WidgetB,15

factories.csv

Factories,Capacity
Factory1,1000
Factory2,2000

3. Solve (solve.py)

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:

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 Full syntax reference and API guide
Security Policy Sandbox details and threat model
Changelog Version history
Backlog Roadmap and future features
Contributing How to contribute

License

MIT © Jonathan Pereira

Metadata

Release files for los-lang 3.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for los-lang 3.3.6
File Size Uploaded Provenance Actions
los_lang-3.3.6.tar.gz 279.7 kB Without provenance Details for los_lang-3.3.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for los-lang 3.3.6
File Interpreter ABI Platform Actions
los_lang-3.3.6-py3-none-any.whl Python 3 none any Details for los_lang-3.3.6-py3-none-any.whl

Total release size: 358.3 kB

Release files / los_lang-3.3.6.tar.gz

Download URL los_lang-3.3.6.tar.gz
Size 279.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d79df7fca9ff1469fa7860095fc3299fe925db0940025e46de5c570a0f426ad4
BLAKE2b-256 checksum
How to use checksums
df64f2a5be704cf5b9bb5c36aa00b5f9c9ef355dca2751f99ecee1a6818fa1a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / los_lang-3.3.6-py3-none-any.whl

Download URL los_lang-3.3.6-py3-none-any.whl
Size 78.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
86a702e10c2e68c4134ab2bdc1ddb9b033eebab445ce70101797593b6adfa7cf
BLAKE2b-256 checksum
How to use checksums
6670596964992b0032051bba79250be41e748853d7bd81c66ad80d907b146818
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for los-lang 3.3.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page