This project provides a robust Python environment for fitting optimal Continuous Piecewise Linear (CPWL) functions to datasets in general dimensions
The core script formulates the fitting problem as a Mixed-Integer Linear Programming (MILP) model, allowing for precise optimization using Google's OR-Tools. It supports a variety of industry-standard solvers, including GUROBI, HiGHS, and SCIP.
Additionally, the environment includes built-in tools to visualize the resulting CPWL functions for 2D and 3D datasets.
-
Clone the repository:
git clone https://github.com/quentinplsrd/cpwl-nd-optimization.git cd cpwl-nd-optimization -
Create a virtual environment:
- Windows:
uv venv .venv source .venv\Scripts\activate uv sync uv pip install .
- Mac/Linux:
uv venv .venv source .venv/bin/activate uv sync uv pip install .
- Windows:
To run the main analysis script:
cd scripts
uv run run_case_studies.pyIf you have used this code for research purposes, you can cite our publication by:
BibTex:
@article{ploussardDoC2025,
title = {Tightening the Difference}-of-{Convex} {Formulation} for the {Piecewise} {Linear} {Approximation} in {General} {Dimensions}},
issn = {2575-1484, 2575-1492},
doi = {10.1287/ijoo.2025.0074},
journal = {INFORMS Journal on Optimization},
author = {Ploussard, Quentin and Li, Xiang and Pavičević, Matija},
month = dec,
year = {2025},
pages = {ijoo.2025.0074},
}