qpmad
Eigen-based C++ QP solver.
Loading...
Searching...
No Matches
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
16int 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}
ReturnStatus solve(t_primal &primal, t_H &H, const t_h &h, const t_A &A, const t_Alb &Alb, const t_Aub &Aub, QPMAD_UTILS_EIGEN_VECTOR_ENABLER(t_primal), QPMAD_UTILS_EIGEN_MATRIX_ENABLER(t_H), QPMAD_UTILS_EIGEN_VECTOR_ENABLER(t_h), QPMAD_UTILS_EIGEN_MATRIX_ENABLER(t_A), QPMAD_UTILS_EIGEN_VECTOR_ENABLER(t_Alb), QPMAD_UTILS_EIGEN_VECTOR_ENABLER(t_Aub))
Definition: solver.h:172
int main()
Definition: demo.cpp:16
EIGEN_DEFAULT_DENSE_INDEX_TYPE MatrixIndex
Definition: common.h:33