pdaqp is a Python package for solving multi-parametric quadratic programs of the form
where
pdaqp is based on the Julia package ParametricDAQP.jl and the Python module juliacall. More information about the underlying algorithm and numerical experiments can be found in the paper "A High-Performant Multi-Parametric Quadratic Programming Solver".
pip install pdaqp
The following code solves the mpQP in Section 7.1 in Bemporad et al. 2002
import numpy
H = numpy.array([[1.5064, 0.4838], [0.4838, 1.5258]])
f = numpy.zeros((2,1))
F = numpy.array([[9.6652, 5.2115], [7.0732, -7.0879]])
A = numpy.array([[1.0, 0], [-1, 0], [0, 1], [0, -1]])
b = 2*numpy.ones((4,1));
B = numpy.zeros((4,2));
thmin = -1.5*numpy.ones(2)
thmax = 1.5*numpy.ones(2)
from pdaqp import MPQP
mpQP = MPQP(H,f,F,A,b,B,thmin,thmax)
mpQP.solve()
To construct a binary search tree for point location, and to generate corresponding C-code, run
mpQP.codegen(dir="codegen", fname="pointlocation")
which will create the following directory:
├── codegen
│ ├── pointlocation.c
│ └── pointlocation.h
The critical regions and the optimal solution can be plotted with the commands
mpQP.plot_regions()
mpQP.plot_solution()
which create the following plots