Overview
Topics covered in this chapter:
MoselPy is a Python package that provides bindings to FICO Xpress Mosel, enabling seamless integration between Python and Mosel. It allows Python developers to:
- compile and run Mosel models from Python,
- exchange data bidirectionally (Python ↔ Mosel),
- integrate with Pandas Series and DataFrames,
- control Mosel execution and stream redirection,
- access optimization results programmatically,
- query model status, security, and annotations.
A typical workflow involves three steps: prepare your data in Python, run a Mosel model to solve an optimization problem, and retrieve the results back in Python. The moselpy I/O driver for data exchange in memory handles data conversion automatically.
Document scope
This document serves as both a tutorial introduction and a complete API reference for the moselpy package.
Part 1: User Guide introduces MoselPy through practical examples, focusing on the core workflows needed to integrate Mosel optimization models into Python applications and data science workflows.
- Chapter Getting Started with MoselPy covers installation, prerequisites, and your first MoselPy model, introducing the basic compile-load-run workflow.
- Chapter Data Exchange explains bidirectional data exchange between Python and Mosel, including type mapping, arrays, sets, and Pandas integration.
- Chapter Optimization Workflows demonstrates running optimization models, accessing solution values, checking problem status, and visualizing results with matplotlib.
- Chapter Advanced Topics covers advanced topics including iterative solving, model control, annotations, security, binary format, and stream redirection.
Part 2: API Reference provides a complete reference for all classes, functions, enumerations, and the moselpy I/O driver.
Relationship to python3.dso
The moselpy package and the python3 Mosel module address opposite use cases:
| Component | Host Language | Called Language | Use Case |
|---|---|---|---|
| python3.dso | Mosel | Python | Use Python libraries from Mosel models |
| moselpy | Python | Mosel | Embed Mosel models in Python applications |
Choose moselpy when your main application is written in Python and you want to call Mosel code, in particular for optimization. Choose python3.dso when your main application is a Mosel model and you want to leverage advanced Python functionality such as specialized analytics, statistics, or graphical libraries. Using both components together (i.e., a Mosel model that uses python3.dso running inside a moselpy host) is not currently supported.
© 2001-2026 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.
