lumix-opt


Namelumix-opt JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryA type-safe, IDE-friendly wrapper for optimization solvers with automatic data-driven modeling
upload_time2025-10-30 11:24:51
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseAcademic Free License ("AFL") v. 3.0 This Academic Free License (the "License") applies to any original work of authorship (the "Original Work") whose owner (the "Licensor") has placed the following licensing notice adjacent to the copyright notice for the Original Work: Licensed under the Academic Free License version 3.0 1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: a) to reproduce the Original Work in copies, either alone or as part of a collective work; b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; c) to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License; d) to perform the Original Work publicly; and e) to display the Original Work publicly. 2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. 3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. 4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. 5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). 6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. 7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. 8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. 9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c). 10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. 12) Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. 13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. 14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. 15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. 16) Modification of This License. This License is Copyright Β© 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the "Academic Free License" or "AFL" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under <insert your license name here>" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process.
keywords optimization mathematical-programming linear-programming solver ortools gurobi cplex academic
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <img src="docs/source/_static/Lumix_Logo_1024.png" alt="LumiX Logo" width="200"/>
</p>

# LumiX

[![Python Version](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/license-AFL--3.0-green.svg)](https://opensource.org/licenses/AFL-3.0)
[![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://lumix.readthedocs.io)

**A modern, type-safe wrapper for optimization solvers with automatic data-driven modeling**

LumiX makes mathematical programming accessible, maintainable, and enjoyable by providing a unified, type-safe interface to multiple optimization solvers.

## ✨ Key Features

- 🎯 **Type-Safe & IDE-Friendly** β€” Full type hints and autocomplete support for a superior development experience
- πŸ”Œ **Multi-Solver Support** β€” Seamlessly switch between OR-Tools, Gurobi, CPLEX, GLPK, and CP-SAT
- πŸ“Š **Data-Driven Modeling** β€” Build models directly from your data with automatic indexing and mapping
- πŸ”„ **Automatic Linearization** β€” Automatically linearize non-linear constraints (bilinear, absolute value, piecewise)
- πŸ“ˆ **Advanced Analysis** β€” Built-in sensitivity analysis, scenario analysis, and what-if analysis tools
- 🎯 **Goal Programming** β€” Native support for multi-objective optimization with priorities and weights
- ⚑ **ORM Integration** β€” Map solutions directly to your ORM models for seamless data flow

## πŸš€ Quick Start

### Installation

```bash
# Install core library
pip install lumix

# Install with a solver (e.g., OR-Tools - free and open-source)
pip install lumix[ortools]

# Or install with multiple solvers
pip install lumix[ortools,gurobi,cplex]
```

### Simple Example

```python
from dataclasses import dataclass
from lumix import (
    LXModel,
    LXVariable,
    LXConstraint,
    LXLinearExpression,
    LXOptimizer,
)

# Define your data
@dataclass
class Product:
    id: str
    name: str
    profit: float
    resource_usage: float

products = [
    Product("A", "Product A", profit=30, resource_usage=2),
    Product("B", "Product B", profit=40, resource_usage=3),
]

# Define decision variables
production = (
    LXVariable[Product, float]("production")
    .continuous()
    .bounds(lower=0)
    .indexed_by(lambda p: p.id)
    .from_data(products)
)

# Build the model
model = (
    LXModel("production_plan")
    .add_variable(production)
    .maximize(
        LXLinearExpression()
        .add_term(production, lambda p: p.profit)
    )
)

# Add constraints
model.add_constraint(
    LXConstraint("resource_limit")
    .expression(
        LXLinearExpression()
        .add_term(production, lambda p: p.resource_usage)
    )
    .le()
    .rhs(100)  # Resource capacity
)

# Solve
optimizer = LXOptimizer().use_solver("ortools")
solution = optimizer.solve(model)

# Access results
if solution.is_optimal():
    print(f"Optimal profit: ${solution.objective_value:,.2f}")
    for product in products:
        qty = solution.variables["production"][product.id]
        print(f"Produce {qty:.2f} units of {product.name}")
```

## πŸ”§ Supported Solvers

LumiX provides a unified interface to multiple solvers:

| Solver | Linear | Integer | Quadratic | Advanced Features | License | Best For |
|--------|--------|---------|-----------|-------------------|---------|----------|
| **OR-Tools** | βœ“ | βœ“ | βœ— | SOS, Indicator | Apache 2.0 (Free) | General LP/MIP, Learning |
| **Gurobi** | βœ“ | βœ“ | βœ“ | SOCP, PWL, Callbacks | Commercial/Academic | Large-scale, Production |
| **CPLEX** | βœ“ | βœ“ | βœ“ | SOCP, PWL, Callbacks | Commercial/Academic | Large-scale, Production |
| **GLPK** | βœ“ | βœ“ | βœ— | Basic | GPL (Free) | Small problems, Teaching |
| **CP-SAT** | βœ— | βœ“ | βœ— | Constraint Programming | Apache 2.0 (Free) | Scheduling, Assignment |

### Switching Solvers

```python
# Just change one line to switch solvers
optimizer = LXOptimizer().use_solver("ortools")   # Free
optimizer = LXOptimizer().use_solver("gurobi")    # Requires license
optimizer = LXOptimizer().use_solver("cplex")     # Requires license
optimizer = LXOptimizer().use_solver("glpk")      # Free
optimizer = LXOptimizer().use_solver("cpsat")     # Free
```

## πŸ“š Core Capabilities

### Variables with Automatic Indexing

```python
# Single-dimension indexing
production = (
    LXVariable[Product, float]("production")
    .continuous()
    .indexed_by(lambda p: p.id)
    .from_data(products)
)

# Multi-dimension indexing
from lumix import LXCartesianProduct

assignment = (
    LXVariable[tuple[Driver, Date, Shift], int]("assignment")
    .binary()
    .indexed_by(lambda t: (t[0].id, t[1].id, t[2].id))
    .from_data(LXCartesianProduct(drivers, dates, shifts))
)
```

### Type-Safe Expressions

```python
# Linear expressions with automatic coefficient extraction
profit_expr = (
    LXLinearExpression()
    .add_term(production, lambda p: p.profit)
)

# Quadratic expressions
quadratic_expr = (
    LXQuadraticExpression()
    .add_quadratic_term(x, y, coefficient=0.5)
)
```

### Automatic Linearization

LumiX can automatically linearize non-linear terms:

```python
from lumix import LXBilinearTerm, LXAbsoluteTerm, LXPiecewiseLinearTerm

# Bilinear products (x * y)
bilinear = LXBilinearTerm(x, y, bounds_x=(0, 10), bounds_y=(0, 5))

# Absolute values |x|
absolute = LXAbsoluteTerm(x)

# Piecewise-linear functions
piecewise = LXPiecewiseLinearTerm(
    variable=x,
    breakpoints=[0, 10, 20, 30],
    slopes=[1.0, 0.5, 0.2]
)
```

### Advanced Analysis

```python
from lumix import (
    LXSensitivityAnalyzer,
    LXScenarioAnalyzer,
    LXWhatIfAnalyzer,
)

# Sensitivity analysis
sens = LXSensitivityAnalyzer(model, solution)
report = sens.generate_report()
print(report)

# Scenario analysis
scenario_analyzer = LXScenarioAnalyzer(model, optimizer)
scenario_analyzer.add_scenario("base", {})
scenario_analyzer.add_scenario("high_demand", {"demand": 150})
results = scenario_analyzer.solve_all()

# What-if analysis
whatif = LXWhatIfAnalyzer(model, optimizer)
result = whatif.increase_constraint_rhs("capacity", by=10)
print(f"Impact: ${result.delta_objective:,.2f}")
```

### Goal Programming

```python
from lumix import (
    LXGoal,
    LXGoalMode,
    solve_goal_programming,
)

# Define multiple goals with priorities
goals = [
    LXGoal(
        name="profit",
        target=1000,
        priority=1,
        weight=1.0,
        is_minimization=False,
    ),
    LXGoal(
        name="quality",
        target=95,
        priority=2,
        weight=0.8,
    ),
]

# Solve with goal programming
solution = solve_goal_programming(
    model,
    goals,
    mode=LXGoalMode.SEQUENTIAL,
    solver="gurobi",
)
```

## πŸ“– Documentation

- **[Installation Guide](docs/source/getting-started/installation.rst)** β€” Install LumiX and solvers
- **[Quick Start](docs/source/getting-started/quickstart.rst)** β€” Build your first model
- **[Solver Guide](docs/source/getting-started/solvers.rst)** β€” Choose the right solver
- **[Examples](examples/)** β€” 11 comprehensive examples

### Examples

The repository includes 11 examples demonstrating various features:

1. **Production Planning** β€” Single-model indexing, data-driven modeling
2. **Driver Scheduling** β€” Multi-dimensional indexing, scheduling
3. **Facility Location** β€” Binary variables, fixed costs
4. **Basic LP** β€” Simple linear programming
5. **CP-SAT Assignment** β€” Constraint programming solver
6. **McCormick Bilinear** β€” Bilinear term linearization
7. **Piecewise Functions** β€” Piecewise-linear approximations
8. **Scenario Analysis** β€” Multiple scenario comparison
9. **Sensitivity Analysis** β€” Parameter sensitivity
10. **What-If Analysis** β€” Decision support
11. **Goal Programming** β€” Multi-objective optimization

## 🎯 Why LumiX?

### Before (Traditional Approach)

```python
# Manual indexing, no type safety
x = {}
for i in range(len(products)):
    x[i] = model.addVar(name=f"x_{i}")

# String-based error-prone expressions
model.addConstr(
    sum(x[i] * data[i] for i in range(len(products))) <= capacity
)
```

### After (LumiX)

```python
# Type-safe, data-driven, IDE-friendly
production = (
    LXVariable[Product, float]("production")
    .continuous()
    .indexed_by(lambda p: p.id)
    .from_data(products)
)

model.add_constraint(
    LXConstraint("capacity")
    .expression(
        LXLinearExpression()
        .add_term(production, lambda p: p.usage)
    )
    .le()
    .rhs(capacity)
)
```

**Benefits:**
- βœ“ Full IDE autocomplete
- βœ“ Type checking catches errors early
- βœ“ No manual indexing
- βœ“ Data-driven coefficients
- βœ“ Readable, maintainable code
- βœ“ Easy to refactor

## πŸ› οΈ Development

### Setup Development Environment

```bash
git clone https://github.com/tdelphi1981/LumiX.git
cd LumiX
pip install -e .[dev]
```

### Run Tests

```bash
pytest
```

### Type Checking

```bash
mypy src/lumix
```

### Code Formatting

```bash
black src/lumix
ruff check src/lumix
```

## πŸ“¦ Project Structure

```
lumix/
β”œβ”€β”€ src/lumix/
β”‚   β”œβ”€β”€ core/              # Core model building (variables, constraints, expressions)
β”‚   β”œβ”€β”€ solvers/           # Solver interfaces (OR-Tools, Gurobi, CPLEX, GLPK, CP-SAT)
β”‚   β”œβ”€β”€ analysis/          # Analysis tools (sensitivity, scenario, what-if)
β”‚   β”œβ”€β”€ linearization/     # Automatic linearization engine
β”‚   β”œβ”€β”€ goal_programming/  # Goal programming support
β”‚   β”œβ”€β”€ indexing/          # Multi-dimensional indexing
β”‚   β”œβ”€β”€ nonlinear/         # Non-linear terms
β”‚   β”œβ”€β”€ solution/          # Solution handling and mapping
β”‚   └── utils/             # Utilities (logger, ORM, rational converter)
β”œβ”€β”€ examples/              # 11 comprehensive examples
β”œβ”€β”€ tests/                 # Test suite
└── docs/                  # Sphinx documentation
```

## 🀝 Contributing

Contributions are welcome! Please:

1. Open an issue to discuss your idea
2. Fork the repository
3. Create a feature branch
4. Add tests for new functionality
5. Ensure all tests pass
6. Submit a pull request

## πŸ“„ License

LumiX is licensed under the [Academic Free License v3.0](LICENSE).

This is a permissive open-source license that:
- βœ“ Allows commercial use
- βœ“ Allows modification and distribution
- βœ“ Provides patent protection
- βœ“ Is OSI-approved

## πŸ™ Acknowledgments

LumiX builds upon the excellent work of:

- [OR-Tools](https://developers.google.com/optimization) by Google
- [Gurobi](https://www.gurobi.com/) Optimization
- [CPLEX](https://www.ibm.com/products/ilog-cplex-optimization-studio) by IBM
- [GLPK](https://www.gnu.org/software/glpk/) by GNU

## πŸ“ž Support

- **Documentation**: https://lumix.readthedocs.io
- **Issues**: https://github.com/tdelphi1981/LumiX/issues
- **Discussions**: https://github.com/tdelphi1981/LumiX/discussions

## πŸ—ΊοΈ Roadmap

- [ ] Additional solver support (HiGHS, SCIP)
- [ ] Jupyter notebook integration
- [ ] Interactive visualization tools
- [ ] Cloud solver integration
- [ ] Extended ORM support (SQLAlchemy, Django)
- [ ] Advanced constraint programming features
- [ ] Parallel scenario evaluation
- [ ] Model versioning and serialization

## Authors

This project is maintained by:

- **Tolga BERBER** - tolga.berber@fen.ktu.edu.tr
- **Beyzanur SΔ°YAH** - beyzanursiyah@ktu.edu.tr

For a complete list of contributors, see [AUTHORS](AUTHORS).

---

**Made with ❀️ by the LumiX Contributors**

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "lumix-opt",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "optimization, mathematical-programming, linear-programming, solver, ortools, gurobi, cplex, academic",
    "author": null,
    "author_email": "Tolga BERBER <tolga.berber@fen.ktu.edu.tr>, Beyzanur S\u0130YAH <beyzanursiyah@ktu.edu.tr>",
    "download_url": "https://files.pythonhosted.org/packages/67/79/5264878e85ada4245cd944ffed50f6253a358a3938b9f7ea8aea33e9ed95/lumix_opt-0.1.1.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n  <img src=\"docs/source/_static/Lumix_Logo_1024.png\" alt=\"LumiX Logo\" width=\"200\"/>\n</p>\n\n# LumiX\n\n[![Python Version](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)\n[![License](https://img.shields.io/badge/license-AFL--3.0-green.svg)](https://opensource.org/licenses/AFL-3.0)\n[![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://lumix.readthedocs.io)\n\n**A modern, type-safe wrapper for optimization solvers with automatic data-driven modeling**\n\nLumiX makes mathematical programming accessible, maintainable, and enjoyable by providing a unified, type-safe interface to multiple optimization solvers.\n\n## \u2728 Key Features\n\n- \ud83c\udfaf **Type-Safe & IDE-Friendly** \u2014 Full type hints and autocomplete support for a superior development experience\n- \ud83d\udd0c **Multi-Solver Support** \u2014 Seamlessly switch between OR-Tools, Gurobi, CPLEX, GLPK, and CP-SAT\n- \ud83d\udcca **Data-Driven Modeling** \u2014 Build models directly from your data with automatic indexing and mapping\n- \ud83d\udd04 **Automatic Linearization** \u2014 Automatically linearize non-linear constraints (bilinear, absolute value, piecewise)\n- \ud83d\udcc8 **Advanced Analysis** \u2014 Built-in sensitivity analysis, scenario analysis, and what-if analysis tools\n- \ud83c\udfaf **Goal Programming** \u2014 Native support for multi-objective optimization with priorities and weights\n- \u26a1 **ORM Integration** \u2014 Map solutions directly to your ORM models for seamless data flow\n\n## \ud83d\ude80 Quick Start\n\n### Installation\n\n```bash\n# Install core library\npip install lumix\n\n# Install with a solver (e.g., OR-Tools - free and open-source)\npip install lumix[ortools]\n\n# Or install with multiple solvers\npip install lumix[ortools,gurobi,cplex]\n```\n\n### Simple Example\n\n```python\nfrom dataclasses import dataclass\nfrom lumix import (\n    LXModel,\n    LXVariable,\n    LXConstraint,\n    LXLinearExpression,\n    LXOptimizer,\n)\n\n# Define your data\n@dataclass\nclass Product:\n    id: str\n    name: str\n    profit: float\n    resource_usage: float\n\nproducts = [\n    Product(\"A\", \"Product A\", profit=30, resource_usage=2),\n    Product(\"B\", \"Product B\", profit=40, resource_usage=3),\n]\n\n# Define decision variables\nproduction = (\n    LXVariable[Product, float](\"production\")\n    .continuous()\n    .bounds(lower=0)\n    .indexed_by(lambda p: p.id)\n    .from_data(products)\n)\n\n# Build the model\nmodel = (\n    LXModel(\"production_plan\")\n    .add_variable(production)\n    .maximize(\n        LXLinearExpression()\n        .add_term(production, lambda p: p.profit)\n    )\n)\n\n# Add constraints\nmodel.add_constraint(\n    LXConstraint(\"resource_limit\")\n    .expression(\n        LXLinearExpression()\n        .add_term(production, lambda p: p.resource_usage)\n    )\n    .le()\n    .rhs(100)  # Resource capacity\n)\n\n# Solve\noptimizer = LXOptimizer().use_solver(\"ortools\")\nsolution = optimizer.solve(model)\n\n# Access results\nif solution.is_optimal():\n    print(f\"Optimal profit: ${solution.objective_value:,.2f}\")\n    for product in products:\n        qty = solution.variables[\"production\"][product.id]\n        print(f\"Produce {qty:.2f} units of {product.name}\")\n```\n\n## \ud83d\udd27 Supported Solvers\n\nLumiX provides a unified interface to multiple solvers:\n\n| Solver | Linear | Integer | Quadratic | Advanced Features | License | Best For |\n|--------|--------|---------|-----------|-------------------|---------|----------|\n| **OR-Tools** | \u2713 | \u2713 | \u2717 | SOS, Indicator | Apache 2.0 (Free) | General LP/MIP, Learning |\n| **Gurobi** | \u2713 | \u2713 | \u2713 | SOCP, PWL, Callbacks | Commercial/Academic | Large-scale, Production |\n| **CPLEX** | \u2713 | \u2713 | \u2713 | SOCP, PWL, Callbacks | Commercial/Academic | Large-scale, Production |\n| **GLPK** | \u2713 | \u2713 | \u2717 | Basic | GPL (Free) | Small problems, Teaching |\n| **CP-SAT** | \u2717 | \u2713 | \u2717 | Constraint Programming | Apache 2.0 (Free) | Scheduling, Assignment |\n\n### Switching Solvers\n\n```python\n# Just change one line to switch solvers\noptimizer = LXOptimizer().use_solver(\"ortools\")   # Free\noptimizer = LXOptimizer().use_solver(\"gurobi\")    # Requires license\noptimizer = LXOptimizer().use_solver(\"cplex\")     # Requires license\noptimizer = LXOptimizer().use_solver(\"glpk\")      # Free\noptimizer = LXOptimizer().use_solver(\"cpsat\")     # Free\n```\n\n## \ud83d\udcda Core Capabilities\n\n### Variables with Automatic Indexing\n\n```python\n# Single-dimension indexing\nproduction = (\n    LXVariable[Product, float](\"production\")\n    .continuous()\n    .indexed_by(lambda p: p.id)\n    .from_data(products)\n)\n\n# Multi-dimension indexing\nfrom lumix import LXCartesianProduct\n\nassignment = (\n    LXVariable[tuple[Driver, Date, Shift], int](\"assignment\")\n    .binary()\n    .indexed_by(lambda t: (t[0].id, t[1].id, t[2].id))\n    .from_data(LXCartesianProduct(drivers, dates, shifts))\n)\n```\n\n### Type-Safe Expressions\n\n```python\n# Linear expressions with automatic coefficient extraction\nprofit_expr = (\n    LXLinearExpression()\n    .add_term(production, lambda p: p.profit)\n)\n\n# Quadratic expressions\nquadratic_expr = (\n    LXQuadraticExpression()\n    .add_quadratic_term(x, y, coefficient=0.5)\n)\n```\n\n### Automatic Linearization\n\nLumiX can automatically linearize non-linear terms:\n\n```python\nfrom lumix import LXBilinearTerm, LXAbsoluteTerm, LXPiecewiseLinearTerm\n\n# Bilinear products (x * y)\nbilinear = LXBilinearTerm(x, y, bounds_x=(0, 10), bounds_y=(0, 5))\n\n# Absolute values |x|\nabsolute = LXAbsoluteTerm(x)\n\n# Piecewise-linear functions\npiecewise = LXPiecewiseLinearTerm(\n    variable=x,\n    breakpoints=[0, 10, 20, 30],\n    slopes=[1.0, 0.5, 0.2]\n)\n```\n\n### Advanced Analysis\n\n```python\nfrom lumix import (\n    LXSensitivityAnalyzer,\n    LXScenarioAnalyzer,\n    LXWhatIfAnalyzer,\n)\n\n# Sensitivity analysis\nsens = LXSensitivityAnalyzer(model, solution)\nreport = sens.generate_report()\nprint(report)\n\n# Scenario analysis\nscenario_analyzer = LXScenarioAnalyzer(model, optimizer)\nscenario_analyzer.add_scenario(\"base\", {})\nscenario_analyzer.add_scenario(\"high_demand\", {\"demand\": 150})\nresults = scenario_analyzer.solve_all()\n\n# What-if analysis\nwhatif = LXWhatIfAnalyzer(model, optimizer)\nresult = whatif.increase_constraint_rhs(\"capacity\", by=10)\nprint(f\"Impact: ${result.delta_objective:,.2f}\")\n```\n\n### Goal Programming\n\n```python\nfrom lumix import (\n    LXGoal,\n    LXGoalMode,\n    solve_goal_programming,\n)\n\n# Define multiple goals with priorities\ngoals = [\n    LXGoal(\n        name=\"profit\",\n        target=1000,\n        priority=1,\n        weight=1.0,\n        is_minimization=False,\n    ),\n    LXGoal(\n        name=\"quality\",\n        target=95,\n        priority=2,\n        weight=0.8,\n    ),\n]\n\n# Solve with goal programming\nsolution = solve_goal_programming(\n    model,\n    goals,\n    mode=LXGoalMode.SEQUENTIAL,\n    solver=\"gurobi\",\n)\n```\n\n## \ud83d\udcd6 Documentation\n\n- **[Installation Guide](docs/source/getting-started/installation.rst)** \u2014 Install LumiX and solvers\n- **[Quick Start](docs/source/getting-started/quickstart.rst)** \u2014 Build your first model\n- **[Solver Guide](docs/source/getting-started/solvers.rst)** \u2014 Choose the right solver\n- **[Examples](examples/)** \u2014 11 comprehensive examples\n\n### Examples\n\nThe repository includes 11 examples demonstrating various features:\n\n1. **Production Planning** \u2014 Single-model indexing, data-driven modeling\n2. **Driver Scheduling** \u2014 Multi-dimensional indexing, scheduling\n3. **Facility Location** \u2014 Binary variables, fixed costs\n4. **Basic LP** \u2014 Simple linear programming\n5. **CP-SAT Assignment** \u2014 Constraint programming solver\n6. **McCormick Bilinear** \u2014 Bilinear term linearization\n7. **Piecewise Functions** \u2014 Piecewise-linear approximations\n8. **Scenario Analysis** \u2014 Multiple scenario comparison\n9. **Sensitivity Analysis** \u2014 Parameter sensitivity\n10. **What-If Analysis** \u2014 Decision support\n11. **Goal Programming** \u2014 Multi-objective optimization\n\n## \ud83c\udfaf Why LumiX?\n\n### Before (Traditional Approach)\n\n```python\n# Manual indexing, no type safety\nx = {}\nfor i in range(len(products)):\n    x[i] = model.addVar(name=f\"x_{i}\")\n\n# String-based error-prone expressions\nmodel.addConstr(\n    sum(x[i] * data[i] for i in range(len(products))) <= capacity\n)\n```\n\n### After (LumiX)\n\n```python\n# Type-safe, data-driven, IDE-friendly\nproduction = (\n    LXVariable[Product, float](\"production\")\n    .continuous()\n    .indexed_by(lambda p: p.id)\n    .from_data(products)\n)\n\nmodel.add_constraint(\n    LXConstraint(\"capacity\")\n    .expression(\n        LXLinearExpression()\n        .add_term(production, lambda p: p.usage)\n    )\n    .le()\n    .rhs(capacity)\n)\n```\n\n**Benefits:**\n- \u2713 Full IDE autocomplete\n- \u2713 Type checking catches errors early\n- \u2713 No manual indexing\n- \u2713 Data-driven coefficients\n- \u2713 Readable, maintainable code\n- \u2713 Easy to refactor\n\n## \ud83d\udee0\ufe0f Development\n\n### Setup Development Environment\n\n```bash\ngit clone https://github.com/tdelphi1981/LumiX.git\ncd LumiX\npip install -e .[dev]\n```\n\n### Run Tests\n\n```bash\npytest\n```\n\n### Type Checking\n\n```bash\nmypy src/lumix\n```\n\n### Code Formatting\n\n```bash\nblack src/lumix\nruff check src/lumix\n```\n\n## \ud83d\udce6 Project Structure\n\n```\nlumix/\n\u251c\u2500\u2500 src/lumix/\n\u2502   \u251c\u2500\u2500 core/              # Core model building (variables, constraints, expressions)\n\u2502   \u251c\u2500\u2500 solvers/           # Solver interfaces (OR-Tools, Gurobi, CPLEX, GLPK, CP-SAT)\n\u2502   \u251c\u2500\u2500 analysis/          # Analysis tools (sensitivity, scenario, what-if)\n\u2502   \u251c\u2500\u2500 linearization/     # Automatic linearization engine\n\u2502   \u251c\u2500\u2500 goal_programming/  # Goal programming support\n\u2502   \u251c\u2500\u2500 indexing/          # Multi-dimensional indexing\n\u2502   \u251c\u2500\u2500 nonlinear/         # Non-linear terms\n\u2502   \u251c\u2500\u2500 solution/          # Solution handling and mapping\n\u2502   \u2514\u2500\u2500 utils/             # Utilities (logger, ORM, rational converter)\n\u251c\u2500\u2500 examples/              # 11 comprehensive examples\n\u251c\u2500\u2500 tests/                 # Test suite\n\u2514\u2500\u2500 docs/                  # Sphinx documentation\n```\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Please:\n\n1. Open an issue to discuss your idea\n2. Fork the repository\n3. Create a feature branch\n4. Add tests for new functionality\n5. Ensure all tests pass\n6. Submit a pull request\n\n## \ud83d\udcc4 License\n\nLumiX is licensed under the [Academic Free License v3.0](LICENSE).\n\nThis is a permissive open-source license that:\n- \u2713 Allows commercial use\n- \u2713 Allows modification and distribution\n- \u2713 Provides patent protection\n- \u2713 Is OSI-approved\n\n## \ud83d\ude4f Acknowledgments\n\nLumiX builds upon the excellent work of:\n\n- [OR-Tools](https://developers.google.com/optimization) by Google\n- [Gurobi](https://www.gurobi.com/) Optimization\n- [CPLEX](https://www.ibm.com/products/ilog-cplex-optimization-studio) by IBM\n- [GLPK](https://www.gnu.org/software/glpk/) by GNU\n\n## \ud83d\udcde Support\n\n- **Documentation**: https://lumix.readthedocs.io\n- **Issues**: https://github.com/tdelphi1981/LumiX/issues\n- **Discussions**: https://github.com/tdelphi1981/LumiX/discussions\n\n## \ud83d\uddfa\ufe0f Roadmap\n\n- [ ] Additional solver support (HiGHS, SCIP)\n- [ ] Jupyter notebook integration\n- [ ] Interactive visualization tools\n- [ ] Cloud solver integration\n- [ ] Extended ORM support (SQLAlchemy, Django)\n- [ ] Advanced constraint programming features\n- [ ] Parallel scenario evaluation\n- [ ] Model versioning and serialization\n\n## Authors\n\nThis project is maintained by:\n\n- **Tolga BERBER** - tolga.berber@fen.ktu.edu.tr\n- **Beyzanur S\u0130YAH** - beyzanursiyah@ktu.edu.tr\n\nFor a complete list of contributors, see [AUTHORS](AUTHORS).\n\n---\n\n**Made with \u2764\ufe0f by the LumiX Contributors**\n",
    "bugtrack_url": null,
    "license": "Academic Free License (\"AFL\") v. 3.0  This Academic Free License (the \"License\") applies to any original work of authorship (the \"Original Work\") whose owner (the \"Licensor\") has placed the following licensing notice adjacent to the copyright notice for the Original Work:  Licensed under the Academic Free License version 3.0  1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following:  a) to reproduce the Original Work in copies, either alone or as part of a collective work;  b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works (\"Derivative Works\") based upon the Original Work;  c) to distribute or communicate copies of the Original Work and Derivative Works to the public, under any license of your choice that does not contradict the terms and conditions, including Licensor's reserved rights and remedies, in this Academic Free License;  d) to perform the Original Work publicly; and  e) to display the Original Work publicly.  2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works.  3) Grant of Source Code License. The term \"Source Code\" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work.  4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license.  5) External Deployment. The term \"External Deployment\" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c).  6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an \"Attribution Notice.\" You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work.  7) Warranty of Provenance and Disclaimer of Warranty. Licensor warrants that the copyright in and to the Original Work and the patent rights granted herein by Licensor are owned by the Licensor or are sublicensed to You under the terms of this License with the permission of the contributor(s) of those copyrights and patent rights. Except as expressly stated in the immediately preceding sentence, the Original Work is provided under this License on an \"AS IS\" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer.  8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation.  9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honoring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including \"fair use\" or \"fair dealing\"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honor the conditions in Section 1(c).  10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware.  11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License.  12) Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License.  13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable.  14) Definition of \"You\" in This License. \"You\" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, \"You\" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, \"control\" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.  15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You.  16) Modification of This License. This License is Copyright \u00a9 2005 Lawrence Rosen. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the \"Modified License\") and apply it to other original works of authorship subject to the following conditions: (i) You may not indicate in any way that your Modified License is the \"Academic Free License\" or \"AFL\" and you may not use those names in the name of your Modified License; (ii) You must replace the notice specified in the first paragraph above with the notice \"Licensed under <insert your license name here>\" or with a notice of your own that is not confusingly similar to the notice in this License; and (iii) You may not claim that your original works are open source software unless your Modified License has been approved by Open Source Initiative (OSI) and You comply with its license review and certification process. ",
    "summary": "A type-safe, IDE-friendly wrapper for optimization solvers with automatic data-driven modeling",
    "version": "0.1.1",
    "project_urls": {
        "Documentation": "https://lumix.readthedocs.io",
        "Homepage": "https://github.com/tdelphi1981/LumiX",
        "Issues": "https://github.com/tdelphi1981/LumiX/issues",
        "Repository": "https://github.com/tdelphi1981/LumiX"
    },
    "split_keywords": [
        "optimization",
        " mathematical-programming",
        " linear-programming",
        " solver",
        " ortools",
        " gurobi",
        " cplex",
        " academic"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "26e152be83e3d733c292a7221b7b0bf4e4934f59f40d103f86a7e30ba36c08d6",
                "md5": "03fcd6136439120b19afb7b2532443c1",
                "sha256": "1a8683a244a689b5934431345788670e6a24ab26bc43de7ff577aebbdf859c01"
            },
            "downloads": -1,
            "filename": "lumix_opt-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "03fcd6136439120b19afb7b2532443c1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 145731,
            "upload_time": "2025-10-30T11:24:50",
            "upload_time_iso_8601": "2025-10-30T11:24:50.187753Z",
            "url": "https://files.pythonhosted.org/packages/26/e1/52be83e3d733c292a7221b7b0bf4e4934f59f40d103f86a7e30ba36c08d6/lumix_opt-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "67795264878e85ada4245cd944ffed50f6253a358a3938b9f7ea8aea33e9ed95",
                "md5": "b0de42ed2dbfbbcf492273d22ac2378f",
                "sha256": "6c098ca656c8d5a63f7e62e9afc460b3ecf7571b650d7aa83ff0ab99d87e351c"
            },
            "downloads": -1,
            "filename": "lumix_opt-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "b0de42ed2dbfbbcf492273d22ac2378f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 124201,
            "upload_time": "2025-10-30T11:24:51",
            "upload_time_iso_8601": "2025-10-30T11:24:51.682419Z",
            "url": "https://files.pythonhosted.org/packages/67/79/5264878e85ada4245cd944ffed50f6253a358a3938b9f7ea8aea33e9ed95/lumix_opt-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-30 11:24:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tdelphi1981",
    "github_project": "LumiX",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "lumix-opt"
}
        
Elapsed time: 2.18845s