Metadata-Version: 2.4
Name: optimaze
Version: 0.3.0
Summary: AI-powered optimization model tuning
License-File: LICENSE
Requires-Python: >=3.11
Requires-Dist: httpx>=0.25.0
Requires-Dist: typer>=0.9.0
Provides-Extra: dev
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: ruff>=0.3.0; extra == 'dev'
Description-Content-Type: text/markdown

# Gurobi Optimizer Agent

**Automatically speed up any Gurobi optimization model.**

An AI agent that analyzes your model, identifies bottlenecks, and finds the best solver settings and formulation improvements.

![Demo](https://img.shields.io/badge/speedup-up%20to%2099%25-brightgreen) ![Python](https://img.shields.io/badge/python-3.11+-blue) ![License](https://img.shields.io/badge/license-MIT-green)

## What It Does

```
Input: Your Gurobi model (.mps, .lp, or gurobipy)
Output: Faster solve time + recommendations

┌─────────────┐    ┌─────────────┐    ┌─────────────┐
│  Your Model │ →  │   Agent     │ →  │  30% faster │
│             │    │  analyzes   │    │  + report   │
└─────────────┘    └─────────────┘    └─────────────┘
```

## Quick Start

```bash
# Install
pip install gurobipy numpy

# Clone
git clone https://github.com/danielpuri1901/tax-optimization-agent.git
cd tax-optimization-agent

# Run on your model
python demo.py
```

## Usage

```python
from src.agent.general import GurobiAgent

# Load your model
import gurobipy as gp
model = gp.read("your_model.mps")  # or build with gurobipy

# Run the agent
agent = GurobiAgent()
result = agent.improve(model)

# See results
print(f"Best: {result.best_improvement} ({result.best_speedup:+.1f}%)")
print(f"Params: {result.best_params}")
```

## How It Works

1. **Profile** - Analyzes model structure (variables, constraints, sparsity, symmetry)
2. **Match** - Selects improvements likely to help based on detected patterns
3. **Smoke Test** - Quick tests to filter out bad candidates
4. **Benchmark** - Full tests on promising improvements
5. **Report** - Returns best settings and recommendations

## Example Results

| Model | Baseline | Best Improvement | Speedup |
|-------|----------|------------------|---------|
| Supply Chain (150K vars) | 0.194s | disaggregate_constraints | +23.7% |
| Tax Optimization (10K constrs) | 4.2s | aggregation | +99.8% |
| Facility Location (2K binary) | 0.084s | Already optimal | - |

## What It Tries

**Solver Parameters:**
- MIPFocus (feasibility, optimality, bound)
- Cuts (off, moderate, aggressive)
- Presolve (off, conservative, aggressive)
- Method (primal, dual, barrier)
- Heuristics, Threads, Symmetry

**Formulation Transforms:**
- Variable bound tightening
- Symmetry breaking constraints
- Constraint disaggregation

## Requirements

- Python 3.11+
- Gurobi with valid license ([free academic license](https://www.gurobi.com/academia/academic-program-and-licenses/))
- numpy

## Project Structure

```
├── src/agent/general/     # Core agent
│   ├── agent.py           # Main GurobiAgent class
│   ├── profiler.py        # Model analysis
│   ├── catalog.py         # Improvement library
│   └── matcher.py         # Rule-based selection
├── demo.py                # Simple demo
├── demo_supply_chain.py   # Supply chain example
└── run_general_agent.py   # Full demo with multiple models
```

## License

MIT - see [LICENSE](LICENSE)

## Contributing

Issues and PRs welcome. If you have a model where the agent helped (or didn't), we'd love to hear about it.
