Skip to content

quentinplsrd/cpwl-nd-optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Continuous Piecewise Linear (CPWL) Fitting

Python License Code style: black

This project provides a robust Python environment for fitting optimal Continuous Piecewise Linear (CPWL) functions to datasets in general dimensions $nD$.

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.

Prerequisites

Installation

  1. Clone the repository:

    git clone https://github.com/quentinplsrd/cpwl-nd-optimization.git
    cd cpwl-nd-optimization
  2. 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 .

Usage

To run the main analysis script:

cd scripts
uv run run_case_studies.py

Citation:

If you have used this code for research purposes, you can cite our publication by:

Quentin Ploussard, Xiang Li, Matija Pavičević (2026) Tightening the Difference-of-Convex Formulation for the Piecewise Linear Approximation in General Dimensions. INFORMS Journal on Optimization 0(0). https://doi.org/10.1287/ijoo.2025.0074

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},
}

About

A python script to fit optimal continuous piecewise linear functions to data sets in general dimensions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages