G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsIpOpt.h
Go to the documentation of this file.
1 
14 #include <gsCore/gsLinearAlgebra.h>
17 
18 #pragma once
19 
20 namespace gismo
21 {
22 
23 template <typename T> class gsIpOptTNLP;
24 template <typename T> class gsIpOptPrivate;
29 template <typename T>
30 class gsIpOpt : public gsOptimizer<T>
31 {
32 public:
33  using Base = gsOptimizer<T>;
34 
35  friend class gsIpOptTNLP<T>;
36 
37 public:
38 
40  gsIpOpt(gsOptProblem<T> * problem);
41 
43  virtual ~gsIpOpt();
44 
45  // // Currently not used
46  // void defaultOptions()
47  // {
48  // using Base::defaultOptions;
49  // }
50 
51  void getOptions()
52  {
53  gsWarn<<"gsIpOpt.h has its options stored in filedata/options/ipopt.opt\n";
54  }
55 
56 public:
57 
58  const gsMatrix<T> & lambda() const { return m_lambda; }
59 
60 public:
61 
62  void solve (const gsMatrix<T> & initialGuess);
63 
64  std::ostream &print(std::ostream &os) const
65  {
66  os << "Design variables:" << m_op->numDesignVars()
67  << "\nNumber of constraints: " << m_op->numConstraints()
68  //<< "\ndesign lower:" << m_op->desLowerBounds().transpose()
69  //<< "\ndesign upper:" << m_op->desUpperBounds().transpose()
70  //<< "\nconstr lower:" << m_op->conLowerBounds().transpose()
71  //<< "\nconstr upper:" << m_op->conUpperBounds().transpose()
72  << "\nNumber of active sensitivities: " << m_op->numConJacNonZero()
73  << "\nSparsity of sensitivities: " <<std::fixed<<std::setprecision(2)
74  << (100.0*m_op->numConJacNonZero())/(m_op->numDesignVars()*m_op->numConstraints()) << " %"
75  //<< "\nm_op->conJacRows():" << m_op->conJacRows().transpose()
76  //<< "\nm_op->conJacCols():" << m_op->conJacCols().transpose()
77  //<< "\nm_op->curDesign():" << m_op->curDesign().transpose()
78  ;
79  return os;
80  }
81 
82 
83 protected:
84 
87 
88 protected:
89 
90 // Members taken from Base
91 protected:
92  using Base::m_op;
93  using Base::m_numIterations;
94  using Base::m_finalObjective;
95  using Base::m_curDesign;
96  using Base::m_options;
97  using Base::m_verbose;
98  using Base::m_maxIterations;
99 
100  using Base::defaultOptions;
101  using Base::getOptions;
102 
103  // Statistics
104 
105  gsIpOptPrivate<T> * m_data;
106 
107 private:
108 
120  gsIpOpt(const gsIpOpt & );
121  gsIpOpt& operator=(const gsIpOpt & );
123 };
124 
125 
126 } // end namespace gismo
127 
128 // note: statically compiled in header-only mode
129 #ifndef GISMO_BUILD_LIB
130 #include GISMO_HPP_HEADER(gsIpOpt.hpp)
131 #endif
Class defining an optimization problem.
Definition: gsOptProblem.h:24
gsIpOpt(gsOptProblem< T > *problem)
Definition: gsIpOpt.hpp:274
Class defining an optimizer.
Definition: gsOptimizer.h:27
gsOptionList m_options
Options.
Definition: gsOptimizer.h:108
Class defining an optimization problem.
Definition: gsIpOpt.h:30
gsMatrix< T > m_lambda
Lagrange multipliers (set in the finalize_solution method)
Definition: gsIpOpt.h:86
Provides declaration of an optimization problem.
This file is part of the G+Smo library.
virtual ~gsIpOpt()
Definition: gsIpOpt.hpp:268
#define gsWarn
Definition: gsDebug.h:50
This is the main header file that collects wrappers of Eigen for linear algebra.
gsMatrix< T > m_curDesign
Current design variables (and starting point )
Definition: gsOptimizer.h:105