MPC.Adyn = [0.9993 -3.0083 -0.1131 -1.6081;
-0.0000 0.9862 0.0478 0.0000;
0.0000 2.0833 1.0089 -0.0000;
0.0000 0.0526 0.0498 1.0000];
MPC.Bdyn = [-0.0804 -0.6347;-0.0291 -0.0143;
-0.8679 -0.0917;-0.0216 -0.0022];
MPC.Q = diag([0,100,0,100]);
MPC.R = 0.01*eye(2);
MPC.gt = 1;
MPC.Cx = [0 1 0 0;0 0 0 1];
MPC.X.Ub = [0.5;100];
MPC.X.Lb = -[0.5;100];
MPC.X.soft = [1e5;1e5];
MPC.Cu = eye(2);
MPC.U.Ub = [25;25];
MPC.U.Lb = -[25;25];
MPC.N = 10;
opts.rel_tol = 1e-4;
[QP_reform,alg_data] = run_code_gen_MPC(MPC,opts);
Checking data....done!
Checking algorithm options....done!
Selecting remaining algorithm options....done!
Reformulating problem....done!
Computing preconditioner....
-----------------------------------------------------------------
iter | rel prim-res | rel prim-tol | rel dual-res | rel dual-tol
-----------------------------------------------------------------
50| 1.0585129e-03| 2.00e-05| 6.8133752e-04| 2.00e-05
100| 1.8951557e-04| 2.00e-05| 3.0141207e-03| 2.00e-05
150| 6.6607830e-06| 2.00e-05| 1.2941782e-03| 2.00e-05
200| 2.8744147e-05| 2.00e-05| 3.6638739e-04| 2.00e-05
250| 1.6035187e-05| 2.00e-05| 4.5949274e-05| 2.00e-05
300| 5.6701208e-06| 2.00e-05| 2.1109536e-05| 2.00e-05
350| 1.2492392e-06| 2.00e-05| 1.8529015e-05| 2.00e-05
done!
Generating algorithm data....done!
Generating C code...done!
-----------------------------------------------------------
C code generated with options (in opts struct):
rel_tol: 1.0000e-04
sparsity_threshold: 0.6500
alpha_relax: 1.8500
max_iter: 2000
check_opt_interval: 10
restart: 1
precision: 'double'
precond_Hess: 'K11'
rho: 1
t: 1
no_math_lib: 0
min_cond_rel_tol: 2.0000e-05
alg: 'FGMdual'
reform: 'original'
dense: 0
precond: 'min_cond_nbr'
min_cond_alg: 'ADMM'
Change any of these option using the function change_opts()
-----------------------------------------------------------
Generated files: QPgen.h (header file)
QPgen.c (main C file with solver qp())
qp_mex.c (mex gateway-file)
qp_mex.mex* (compiled mex-file)
-----------------------------------------------------------
Usage MATLAB: [sol,iter] = qp_mex(gt,bt);
-----------------------------------------------------------
Usage C:
- compile QPgen.c
- solve using function qp(gt,bt) with declaration:
void qp(double *sol, int *iter, double *gt,double *bt);
-----------------------------------------------------------
Input dimensions: size(gt) = 60x1, size(bt) = 4x1
-----------------------------------------------------------
Output dimensions: size(sol) = 60x1, size(iter) = 1x1
-----------------------------------------------------------