diff options
author | Yuri Victorovich <yuri@FreeBSD.org> | 2025-02-20 23:48:40 -0800 |
---|---|---|
committer | Yuri Victorovich <yuri@FreeBSD.org> | 2025-02-21 01:14:27 -0800 |
commit | ddf031fc0ce6048429a160868ce85989bbe1fd35 (patch) | |
tree | 88e1bbdcf2a40999853753943644711d18127dd3 /math/py-daqp/files/test.py | |
parent | textproc/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/files/test.py')
-rw-r--r-- | math/py-daqp/files/test.py | 18 |
1 files changed, 18 insertions, 0 deletions
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}') |