example1b.py
Go to the documentation of this file.
1 
22 
23 ## Example adapted from examples/example1b.cpp.
24 ## author of this file: Sebastian F. Walter
25 
26 import numpy as np
27 from qpoases import PyQProblemB as QProblemB
28 from qpoases import PyBooleanType as BooleanType
29 from qpoases import PySubjectToStatus as SubjectToStatus
30 from qpoases import PyOptions as Options
31 
32 # Example for qpOASES main function using the QProblemB class.
33 
34 #Setup data of first QP.
35 
36 H = np.array([1.0, 0.0, 0.0, 0.5 ]).reshape((2,2))
37 g = np.array([1.5, 1.0 ])
38 lb = np.array([0.5, -2.0])
39 ub = np.array([5.0, 2.0 ])
40 
41 # Setup data of second QP.
42 
43 g_new = np.array([1.0, 1.5])
44 lb_new = np.array([0.0, -1.0])
45 ub_new = np.array([5.0, -0.5])
46 
47 
48 # Setting up QProblemB object.
49 example = QProblemB(2)
50 
51 options = Options()
52 options.enableFlippingBounds = BooleanType.FALSE
53 options.initialStatusBounds = SubjectToStatus.INACTIVE
54 options.numRefinementSteps = 1
55 
56 example.setOptions(options)
57 
58 # Solve first QP.
59 nWSR = np.array([10])
60 example.init(H, g, lb, ub, nWSR)
61 print("\nnWSR = %d\n\n"%nWSR)
62 
63 # Solve second QP.
64 nWSR = np.array([10])
65 example.hotstart(g_new, lb_new, ub_new, nWSR)
66 print("\nnWSR = %d\n\n"% nWSR)
67 
68 # Get and print solution of second QP.
69 xOpt = np.zeros(2)
70 example.getPrimalSolution(xOpt)
71 print("\nxOpt = [ %e, %e ]; objVal = %e\n\n" %(xOpt[0], xOpt[1],
72  example.getObjVal()))
Implements the online active set strategy for box-constrained QPs.
Provides a generic way to set and pass user-specified options.
Definition: options.hpp:65
BEGIN_NAMESPACE_QPOASES returnValue print(const real_t *const v, int n)


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Mon Jun 10 2019 12:34:33