Metadata-Version: 2.4
Name: mixsqpx
Version: 0.2.1a2
Summary: JAX interface to the Rust implementation of the mixSQP algorithm
Author-email: Paul Diegert <pdiegert@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Jackson Bunting, Paul Diegert, and Arnaud Maurel
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: <3.14,>=3.12
Requires-Dist: jax<=0.9.2,>=0.9.2
Requires-Dist: jaxlib<=0.9.2,>=0.9.2
Description-Content-Type: text/markdown

# MIXSQPX: A JAX-compatible interface to the mixSQP algorithm

This package provides a `jax`-compatible interface to the mixSQP algorithm described in,

> Kim, Y., Carbonetto, P., Stephens, M., & Anitescu, M. (2020). A Fast Algorithm for Maximum Likelihood Estimation of Mixture Proportions Using Sequential Quadratic Programming. Journal of Computational and Graphical Statistics, 29(2), 261–273. 

The implementation of the mixSQP algorithm in this package was ported from the [R
implementation](https://github.com/stephenslab/mixSQP) by
the authors of this paper which uses the Rarmadillo package as an interface to the
Armadillo C++ library.

This package provides a function `mixsolve`, which can be transformed with
[JAX](https://github.com/jax-ml/jax) transformations such as `jit`.

## Installation

This branch uses [`uv`](https://docs.astral.sh/uv/) as the project frontend and
`hatchling` as the build backend. Building the package requires a working Rust
toolchain because the default backend is a bundled Rust shared library.

### Local Development

```bash
# Install uv if you don't have it already.
curl -LsSf https://astral.sh/uv/install.sh | sh

# Clone the repository.
git clone https://github.com/pdiegert/mixsqpx.git
cd mixsqpx

# Install Rust if you don't have it already.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Sync the development environment and install the package editable.
uv sync --group test --group examples
```

`uv sync` builds the Rust library through the Hatch build hook and installs the
package in editable mode.

### Verification

Run the test suite to verify your installation:

```bash
uv run --group test pytest tests
```

Build a wheel locally with:

```bash
uv build
```

Benchmark the Rust backend explicitly with:

```bash
uv run --group test python scripts/benchmark_mixsolve.py
```

## Legacy C++ Reference Path

This branch is intended to merge as a Rust-first package. The legacy
C++/Armadillo backend is kept only as an archival benchmark/reference path.

- Keep the legacy implementation in a separate checkout or worktree.
- Use a separate environment for the legacy package.
- Do not treat the legacy C++ build as part of the default developer install on
  this branch.

A recommended setup is:

```bash
git worktree add ../mixsqpx-legacy legacy-cpp-final
```

Additional details for benchmarking and the opt-in exact legacy reference test
are documented in [LEGACY_CPP_REFERENCE.md](LEGACY_CPP_REFERENCE.md).

## License

This project is licensed under the MIT License - see the [LICENCE](LICENCE) file for details.

## Acknowledgements

This project includes code adapted from the [mixSQP](https://github.com/stephenslab/mixSQP) project, which is available under the MIT license. We thank the original authors (Youngseok Kim, Peter Carbonetto,
Matthew Stephens and Mihai Anitescu) for their work.
