From ddf031fc0ce6048429a160868ce85989bbe1fd35 Mon Sep 17 00:00:00 2001 From: Yuri Victorovich Date: Thu, 20 Feb 2025 23:48:40 -0800 Subject: [PATCH] math/py-daqp: New port: DAQP: A dual active-set QP solver --- math/Makefile | 1 + math/py-daqp/Makefile | 25 +++++++++++++++++++++++++ math/py-daqp/distinfo | 3 +++ math/py-daqp/files/test.py | 18 ++++++++++++++++++ math/py-daqp/pkg-descr | 7 +++++++ 5 files changed, 54 insertions(+) create mode 100644 math/py-daqp/Makefile create mode 100644 math/py-daqp/distinfo create mode 100644 math/py-daqp/files/test.py create mode 100644 math/py-daqp/pkg-descr diff --git a/math/Makefile b/math/Makefile index d12761d67496..f7af7e249796 100644 --- a/math/Makefile +++ b/math/Makefile @@ -958,6 +958,7 @@ SUBDIR += py-cvxpy SUBDIR += py-cyipopt SUBDIR += py-cypari2 + SUBDIR += py-daqp SUBDIR += py-deap SUBDIR += py-dgl SUBDIR += py-diffcp diff --git a/math/py-daqp/Makefile b/math/py-daqp/Makefile new file mode 100644 index 000000000000..7b3454730673 --- /dev/null +++ b/math/py-daqp/Makefile @@ -0,0 +1,25 @@ +PORTNAME= daqp +DISTVERSION= 0.6.0 +CATEGORIES= math python +MASTER_SITES= PYPI +PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} + +MAINTAINER= yuri@FreeBSD.org +COMMENT= DAQP: A dual active-set QP solver +WWW= https://github.com/darnstrom/daqp + +LICENSE= MIT +LICENSE_FILE= ${WRKSRC}/LICENSE + +USES= python +USE_PYTHON= distutils cython autoplist + +TEST_ENV= ${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} + +post-install: + @${STRIP_CMD} ${STAGEDIR}${PYTHON_SITELIBDIR}/daqp${PYTHON_EXT_SUFFIX}.so + +do-test: + @${SETENV} ${TEST_ENV} ${PYTHON_CMD} ${FILESDIR}/test.py + +.include diff --git a/math/py-daqp/distinfo b/math/py-daqp/distinfo new file mode 100644 index 000000000000..2d83e51a4bb4 --- /dev/null +++ b/math/py-daqp/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1740123369 +SHA256 (daqp-0.6.0.tar.gz) = baf8b25fe7cbdbb09da0783cb47479d2dcb2bc927ceffc15836766529d3c962f +SIZE (daqp-0.6.0.tar.gz) = 169992 diff --git a/math/py-daqp/files/test.py b/math/py-daqp/files/test.py new file mode 100644 index 000000000000..6d3f3e130863 --- /dev/null +++ b/math/py-daqp/files/test.py @@ -0,0 +1,18 @@ +# Import relevant modules +import daqp +import numpy as np +from ctypes import * +import ctypes.util + +# Define the problem +H = np.array([[1, 0], [0, 1]],dtype=c_double) +f = np.array([1, 1],dtype=c_double) +A = np.array([[1, 2], [1, -1]],dtype=c_double) +bupper = np.array([1,2,3,4],dtype=c_double) +blower = np.array([-1,-2,-3,-4],dtype=c_double) +sense = np.array([0,0,0,0],dtype=c_int) + +print('solving ...') +(xstar,fval,exitflag,info) = daqp.solve(H,f,A,bupper,blower,sense) + +print(f'solution: xstar={xstar} fval={fval} exitflag={exitflag} info={info}') diff --git a/math/py-daqp/pkg-descr b/math/py-daqp/pkg-descr new file mode 100644 index 000000000000..793451c91871 --- /dev/null +++ b/math/py-daqp/pkg-descr @@ -0,0 +1,7 @@ +DAQP is a dual active-set solver that solves convex quadratic programs +of the form: + +minimize 0.5 x' H x + f' x + +subject to l <= x <= u + bl <= Ax <= bu.