summaryrefslogtreecommitdiff
path: root/math/py-daqp/files/test.py
diff options
context:
space:
mode:
Diffstat (limited to 'math/py-daqp/files/test.py')
-rw-r--r--math/py-daqp/files/test.py18
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}')