Metadata-Version: 2.4
Name: moselpy
Version: 9.9.0
Summary: Python bindings for FICO Xpress Mosel
License: LicenseRef-FICO-Shrinkwrap-License
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: Programming Language :: Python :: 3.14
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type

FICO&#174; Xpress Mosel Python Interface
========================================

Run [FICO Xpress Mosel](https://www.fico.com/en/products/fico-xpress-optimization)
optimization models directly from Python. Define your model in Mosel, solve it with
the full power of the Xpress solver, and exchange data and results with Python objects:

```python
from io import BytesIO, StringIO
import moselpy as mp

MODEL = """
model "production"
  uses "mmxprs"
  declarations
    PRODUCTS = {"Chairs", "Tables", "Desks"}
    Profit:      array(PRODUCTS) of real
    Capacity:    real
    produce:     array(PRODUCTS) of mpvar
    TotalProfit: real
  end-declarations
  initializations from "moselpy:" Profit Capacity end-initializations
  forall(p in PRODUCTS) produce(p) is_integer
  sum(p in PRODUCTS) produce(p) <= Capacity
  maximize(sum(p in PRODUCTS) Profit(p) * produce(p))
  TotalProfit := getobjval
  initializations to "moselpy:" TotalProfit end-initializations
end-model
"""

mp.symbols["src"] = StringIO(MODEL)
mp.symbols["bim"] = BytesIO()
mp.compile_model("moselpy:src", "moselpy:bim")
del mp.symbols["src"]

mp.symbols["bim"].seek(0)
model = mp.load_model("moselpy:bim")
del mp.symbols["bim"]

results = model.run(input_data={
    "Profit":   {"Chairs": 45, "Tables": 80, "Desks": 120},
    "Capacity": 10,
})
print("Total profit:", results["TotalProfit"])
```

With the `moselpy` module, one can control Mosel optimization models using the
Python&#174; programming language. The module allows for:

- Compiling, loading, and running Mosel models (`.mos` source or `.bim` binary)
- Passing input data from Python to Mosel and retrieving results, supporting
  scalars, arrays, sets, dicts, NumPy arrays, and Pandas DataFrames
- Redirecting Mosel output streams to Python file-like objects
- Introspecting model symbols and querying solution status


Installation
------------

Install from PyPI:

```
pip install moselpy
```

A valid FICO Xpress installation with Mosel support is required at runtime.
Set the `XPRESSDIR` environment variable to point to the Xpress installation
directory before importing the module.


Licensing
---------

The Xpress software is governed by the
[Xpress Shrinkwrap License Agreement](https://www.fico.com/en/shrinkwrap-license-agreement-fico-xpress-optimization-suite-on-premises).
When downloading the package, you accept the license terms. A copy of the Xpress
Shrinkwrap License is stored in the file `LICENSE.txt` in the `dist-info` directory
of the moselpy module.


Miscellaneous
-------------

"Python" is a registered trademark of the Python Software Foundation. "FICO" is a
registered trademark of Fair Isaac Corporation in the United States and may be a
registered trademark of Fair Isaac Corporation in other countries. Other product and
company names herein may be trademarks of their respective owners.
