summaryrefslogtreecommitdiff
path: root/math/py-daqp
diff options
context:
space:
mode:
authorYuri Victorovich <yuri@FreeBSD.org>2025-02-20 23:48:40 -0800
committerYuri Victorovich <yuri@FreeBSD.org>2025-02-21 01:14:27 -0800
commitddf031fc0ce6048429a160868ce85989bbe1fd35 (patch)
tree88e1bbdcf2a40999853753943644711d18127dd3 /math/py-daqp
parenttextproc/zxing-cpp: Update to 2.3.0 (diff)
math/py-daqp: New port: DAQP: A dual active-set QP solver
Diffstat (limited to 'math/py-daqp')
-rw-r--r--math/py-daqp/Makefile25
-rw-r--r--math/py-daqp/distinfo3
-rw-r--r--math/py-daqp/files/test.py18
-rw-r--r--math/py-daqp/pkg-descr7
4 files changed, 53 insertions, 0 deletions
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 <bsd.port.mk>
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.