qpmad
Eigen-based C++ QP solver.
input_parser.h
Go to the documentation of this file.
1 /**
2  @file
3  @author Alexander Sherikov
4 
5  @copyright 2017 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 #pragma once
12 
13 namespace qpmad
14 {
16  {
17  protected:
22 
23 
24  protected:
26  {
27  primal_size_ = 0;
28  h_size_ = 0;
31  }
32 
33 
34  template< class t_MatrixType,
35  class t_VectorType>
36  void parseObjective( const t_MatrixType & H,
37  const t_VectorType & h)
38  {
39  primal_size_ = H.rows();
40  h_size_ = h.rows();
41 
43  primal_size_ > 0,
44  "Hessian must not be empty.");
46  primal_size_ == H.cols(),
47  "Hessian must be square.");
49  ((primal_size_ == h_size_) && (1 == h.cols()))
50  || (0 == h_size_),
51  "Wrong size of h.");
52  }
53 
54 
55  template< class t_VectorTypelb,
56  class t_VectorTypeub>
57  void parseSimpleBounds( const t_VectorTypelb & lb,
58  const t_VectorTypeub & ub)
59  {
60  num_simple_bounds_ = lb.rows();
61 
64  "Vector of lower simple bounds has wrong size.");
66  ub.rows() == num_simple_bounds_,
67  "Vector of upper simple bounds has wrong size1.");
68 
70  ((num_simple_bounds_ > 0) && (1 == lb.cols())) || (1 == lb.cols()),
71  "Vector of lower simple bounds has wrong size.");
73  ((num_simple_bounds_ > 0) && (1 == ub.cols())) || (1 == ub.cols()),
74  "Vector of upper simple bounds has wrong size2.");
75  }
76 
77 
78  template< class t_MatrixTypeA,
79  class t_VectorTypelb,
80  class t_VectorTypeub>
81  void parseGeneralConstraints(const t_MatrixTypeA & A,
82  const t_VectorTypelb & lb,
83  const t_VectorTypeub & ub)
84  {
85  num_general_constraints_ = A.rows();
86 
88  (A.cols() == primal_size_)
89  || ((0 == num_general_constraints_) && (0 == A.cols())),
90  "Matrix of general constraints has wrong size.");
91 
93  lb.rows() == num_general_constraints_,
94  "Vector of lower bounds of general constraints has wrong size.");
96  ub.rows() == num_general_constraints_,
97  "Vector of upper bounds of general constraints has wrong size.");
98 
100  ((num_general_constraints_ > 0) && (1 == lb.cols())) || (0 == lb.rows()),
101  "Vector of lower bounds of general constraints has wrong size.");
103  ((num_general_constraints_ > 0) && (1 == ub.cols())) || (0 == ub.rows()),
104  "Vector of upper bounds of general constraints has wrong size.");
105  }
106  };
107 }
void parseObjective(const t_MatrixType &H, const t_VectorType &h)
Definition: input_parser.h:36
MatrixIndex num_simple_bounds_
Definition: input_parser.h:20
#define QPMAD_UTILS_PERSISTENT_ASSERT(condition, message)
int MatrixIndex
Definition: common.h:32
MatrixIndex h_size_
Definition: input_parser.h:19
MatrixIndex num_general_constraints_
Definition: input_parser.h:21
MatrixIndex primal_size_
Definition: input_parser.h:18
void parseGeneralConstraints(const t_MatrixTypeA &A, const t_VectorTypelb &lb, const t_VectorTypeub &ub)
Definition: input_parser.h:81
void parseSimpleBounds(const t_VectorTypelb &lb, const t_VectorTypeub &ub)
Definition: input_parser.h:57