1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2009 Henrik Tidefelt
19 #include "quadratic_programs.h"
24 using namespace Shapes
;
27 Computation::QPSolverStatus::code_str( ) const
42 return "(QPSolverStatus::code_str: enum switch out of range)";
46 Computation::QPSolverStatus::sub_str( ) const
54 return "No negative lagrange multipliers.";
56 return "Cost absolute gap less than tolerance.";
58 return "Cost relative gap less than tolerance.";
60 return "Cost sufficiently bounded from above.";
62 return "Cost sufficiently bounded from below.";
68 case QP_WARNING_NEGATIVE_LM
:
69 return "Negative Lagrange multiplier.";
70 case QP_WARNING_EARLY_EXIT
:
77 case QP_ERROR_UNDEFINED
:
78 return "Undefined error.";
79 case QP_ERROR_ALLOCATE
:
80 return "Out of memory.";
81 case QP_ERROR_DIMENSIONS_X
:
82 return "Wrong dimension of output x.";
83 case QP_ERROR_DIMENSIONS_LM
:
84 return "Wrong dimension of output lm.";
91 return "Maximum number of iterations exceeded.";
97 case QP_BAD_INCONSISTENT_EQ
:
98 return "Inconsistent equality constraints.";
99 case QP_BAD_INCONSISTENT_INEQ
:
100 return "Inconsistent inequality constraints.";
101 case QP_BAD_INCONSISTENT_BOX
:
102 return "Inconsistent box constraints.";
103 case QP_BAD_INCONSISTENT_ACTIVE
:
104 return "Encountered inconsistent constraints.";
105 case QP_BAD_POSITIVE_DEFINITE
:
106 return "Objective function not positive definite.";
107 case QP_BAD_LINEAR_DEPENDENT
:
108 return "Linearly dependent constraints.";
109 case QP_BAD_INITIAL_INFEASIBLE
:
110 return "Infeasible initial point.";
114 return "(QPSolverStatus::str: enum switch out of range)";
119 Computation::polytope_distance_generator_form_write_data( std::ostream
& os
,
121 const size_t n1
, const double * g1
,
122 const size_t n2
, const double * g2
)
124 os
<< "Polytope distance problem in generator form." << std::endl
125 << "===" << std::endl
126 << dim
<< " " << n1
<< " " << n2
<< std::endl
127 << std::fixed
<< std::setprecision(6) ;
129 const double * begin
= g1
;
130 const double * end
= begin
+ dim
* n1
;
131 for( const double * src
= begin
; src
!= end
; ++src
)
142 const double * begin
= g2
;
143 const double * end
= begin
+ dim
* n2
;
144 for( const double * src
= begin
; src
!= end
; ++src
)
158 Computation::polytope_distance_generator_form_write_binary_data( const char * oFilename
,
160 const size_t n1
, const double * g1
,
161 const size_t n2
, const double * g2
)
163 std::ofstream
oFile( oFilename
, std::ios::out
| std::ios::binary
);
166 oFile
.write( reinterpret_cast< const char * >( & tmp
), sizeof( tmp
) );
168 oFile
.write( reinterpret_cast< const char * >( & tmp
), sizeof( tmp
) );
170 oFile
.write( reinterpret_cast< const char * >( & tmp
), sizeof( tmp
) );
172 const double * begin
= g1
;
173 const double * end
= begin
+ dim
* n1
;
174 for( const double * src
= begin
; src
!= end
; ++src
)
176 oFile
.write( reinterpret_cast< const char * >( src
), sizeof( *src
) );
180 const double * begin
= g2
;
181 const double * end
= begin
+ dim
* n2
;
182 for( const double * src
= begin
; src
!= end
; ++src
)
184 oFile
.write( reinterpret_cast< const char * >( src
), sizeof( *src
) );