qpmad
Eigen-based C++ QP solver.
demo.cpp
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4 
5  @copyright 2019 Alexander Sherikov. Licensed under the Apache License,
6  Version 2.0. (see LICENSE or http://www.apache.org/licenses/LICENSE-2.0)
7 
8  @brief
9 */
10 
11 #include <iostream>
12 
13 #include <qpmad/solver.h>
14 
15 
16 int main()
17 {
18  Eigen::VectorXd x;
19  Eigen::MatrixXd H;
20  Eigen::VectorXd h;
21  Eigen::MatrixXd A;
22  Eigen::VectorXd Alb;
23  Eigen::VectorXd Aub;
24  Eigen::VectorXd lb;
25  Eigen::VectorXd ub;
26 
27 
28  qpmad::MatrixIndex size = 20;
29  qpmad::MatrixIndex num_ctr = 1;
30 
31  H.setIdentity(size, size);
32  h.setOnes(size);
33 
34 
35  A.resize(num_ctr, size);
36  A.setOnes();
37  Alb.resize(num_ctr);
38  Aub.resize(num_ctr);
39  Alb << -1.5;
40  Aub << 1.5;
41 
42  lb.resize(size);
43  ub.resize(size);
44  lb << 1, 2, 3, 4, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5, -5;
45  ub << 1, 2, 3, 4, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5;
46 
47 
48  qpmad::Solver solver;
49 
50  qpmad::Solver::ReturnStatus status = solver.solve(x, H, h, lb, ub, A, Alb, Aub);
51  if (status != qpmad::Solver::OK)
52  {
53  std::cerr << "Error" << std::endl;
54  }
55 
56  return (0);
57 }
EIGEN_DEFAULT_DENSE_INDEX_TYPE MatrixIndex
Definition: common.h:32
ReturnStatus solve(Vector< t_rows_primal > &primal, Matrix< t_rows_H, t_cols_H > &H, const Vector< t_rows_h > &h, const Matrix< t_rows_A, t_cols_A > &A, const Vector< t_rows_Alb > &Alb, const Vector< t_rows_Aub > &Aub)
Definition: solver.h:154
int main()
Definition: demo.cpp:16