Skip to main content

Solver-intrinsic explanations and reoptimization for linear programming

Project description

CLARA — Classical LP Analysis for Reoptimization and Attribution

License: MIT Python 3.10+

A solver-intrinsic explanation framework for linear programming. CLARA extracts explanations directly from the simplex basis inverse $B^{-1}$ — without machine learning surrogates, without inverse formulations — and unifies factual and counterfactual perspectives on LP explainability within a single geometric framework.

What CLARA does

CLARA contributes two central capabilities, complemented by two supporting modules:

  • Factual–counterfactual duality — a formal bound showing that the basis robustness $d_0$, computable in $O(mn)$ time from $B^{-1}$ alone, lower-bounds the cost of any basis-changing counterfactual explanation. Connects classical sensitivity analysis with counterfactual explanations for optimization.
  • Reoptimization pipeline — automatic change detection, Oguz-bound impact analysis, warm-start method selection (primal simplex, dual simplex, or parametric LP), and structured diff reports.
  • Simultaneous sensitivity regions (supporting) — Chebyshev center of the basis-preserving polyhedron, the geometric foundation of the duality bound.
  • Objective-change attribution (supporting) — first-order and Shapley decomposition that annotates diff reports during reoptimization.

CLARA also offers two solver backends:

  • Internal Revised Simplex — full transparency, retains $B^{-1}$ at every pivot for downstream analysis (practical for $n \le 100$).
  • HiGHS — production-grade reference solver; CLARA reconstructs $B^{-1}$ from the reported basis for larger problems.

Installation

pip install clara-opt

For development:

git clone https://github.com/yoonsik-jung-opt/clara-opt.git
cd clara-opt
pip install -e ".[dev]"

Quick Start

# Explain a production planning problem
clara explain examples/production.lp

# Brief summary
clara explain problem.lp --level brief

# JSON output
clara explain problem.lp --format json

# Use HiGHS engine for larger problems
clara explain problem.lp --engine highs

# Solve only (no explanation)
clara solve problem.lp

# Problem info
clara info problem.lp

Python API

from clara.io import read_lp
from clara.engine.simplex import RevisedSimplex
from clara.explain import Explainer

problem = read_lp("problem.lp")
state = RevisedSimplex(problem).solve()
report = Explainer().explain(state, problem=problem)
print(report.to_text())

Roadmap

  • v0.1.0 — LP solver, basis-inverse extraction, explanation modules, CLI
  • v0.5.0 — MIP (Branch-and-Bound), counterfactual computation via $d_0$ warm-start, TUI
  • v1.0.0 — Incremental reoptimization, parametric LP, streaming
  • v2.0.0 — LLM-augmented natural-language explanations, web UI

Academic Use

CLARA contributes to the explainability of mathematical optimization solvers, a research area surveyed by De Bock et al. (2024) in the XAIOR framework.

A manuscript describing the framework is in preparation. Citation information will be added here when a preprint or peer-reviewed version is available.

License

MIT © 2026 Yoonsik

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

clara_opt-0.2.1.tar.gz (3.3 MB view details)

Uploaded Source

Built Distribution

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

clara_opt-0.2.1-py3-none-any.whl (110.1 kB view details)

Uploaded Python 3

File details

Details for the file clara_opt-0.2.1.tar.gz.

File metadata

  • Download URL: clara_opt-0.2.1.tar.gz
  • Upload date:
  • Size: 3.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.12

File hashes

Hashes for clara_opt-0.2.1.tar.gz
Algorithm Hash digest
SHA256 dfda0179c036644c54516967157b7d4a8720b67f9339bbfa47af0329a3c5bd70
MD5 f45f19a32020e36c743d235cfce7f88c
BLAKE2b-256 50f7bd08b5ce91ec931acf3a0768ee6612d69d15647a930d254b1861ac9ceffa

See more details on using hashes here.

File details

Details for the file clara_opt-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: clara_opt-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 110.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.12

File hashes

Hashes for clara_opt-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a80497209584f3d0a03834ee8cf6702fdafe8ec40e5517786799ad6b368f26d2
MD5 fbed5ca45da7f336cfcb387b7ee7b1a4
BLAKE2b-256 f2c3e61b7664e9b5f65efd8c1315787ec60a3e92f273af6afc184653d40096d7

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