/
conic_impl.hpp
128 lines (99 loc) · 3.73 KB
/
conic_impl.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
* This file is part of CasADi.
*
* CasADi -- A symbolic framework for dynamic optimization.
* Copyright (C) 2010-2014 Joel Andersson, Joris Gillis, Moritz Diehl,
* K.U. Leuven. All rights reserved.
* Copyright (C) 2011-2014 Greg Horn
*
* CasADi is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* CasADi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with CasADi; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef CASADI_CONIC_IMPL_HPP
#define CASADI_CONIC_IMPL_HPP
#include "conic.hpp"
#include "function_internal.hpp"
#include "plugin_interface.hpp"
#include "../timing.hpp"
/// \cond INTERNAL
namespace casadi {
struct CASADI_EXPORT ConicMemory {
// Function specific statistics
std::map<std::string, FStats> fstats;
};
/// Internal class
class CASADI_EXPORT Conic : public FunctionInternal, public PluginInterface<Conic> {
public:
// Constructor
Conic(const std::string& name, const std::map<std::string, Sparsity> &st);
// Destructor
virtual ~Conic() = 0;
///@{
/** \brief Number of function inputs and outputs */
virtual size_t get_n_in() { return CONIC_NUM_IN;}
virtual size_t get_n_out() { return CONIC_NUM_OUT;}
///@}
/// @{
/** \brief Sparsities of function inputs and outputs */
virtual Sparsity get_sparsity_in(int i);
virtual Sparsity get_sparsity_out(int i);
/// @}
///@{
/** \brief Names of function input and outputs */
virtual std::string get_name_in(int i) { return conic_in(i);}
virtual std::string get_name_out(int i) { return conic_out(i);}
/// @}
///@{
/** \brief Options */
static Options options_;
virtual const Options& get_options() const { return options_;}
///@}
// Initialize
virtual void init(const Dict& opts);
/// \brief Check if the numerical values of the supplied bounds make sense
virtual void checkInputs(const double* lbx, const double* ubx,
const double* lba, const double* uba) const;
/** Generate native code in the interfaced language for debugging */
virtual void generateNativeCode(std::ostream& file) const;
// Creator function for internal class
typedef Conic* (*Creator)(const std::string& name,
const std::map<std::string, Sparsity>& st);
// No static functions exposed
struct Exposed{ };
/// Collection of solvers
static std::map<std::string, Plugin> solvers_;
/// Infix
static const std::string infix_;
/// Short name
static std::string shortname() { return "conic";}
/** \brief Get default input value */
virtual double default_in(int ind) const;
/// Can discrete variables be treated
virtual bool integer_support() const { return false;}
/// Print statistics
void print_fstats(const ConicMemory* m) const;
protected:
/// Options
std::vector<bool> discrete_;
/// Problem structure
Sparsity H_, A_;
/// Number of decision variables
int nx_;
/// The number of constraints (counting both equality and inequality) == A.size1()
int na_;
};
} // namespace casadi
/// \endcond
#endif // CASADI_CONIC_IMPL_HPP