Ipopt  3.12.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
IpAugSystemSolver.hpp
Go to the documentation of this file.
1 // Copyright (C) 2004, 2006 International Business Machines and others.
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 //
5 // $Id: IpAugSystemSolver.hpp 2269 2013-05-05 11:32:40Z stefan $
6 //
7 // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
8 
9 #ifndef __IP_AUGSYSTEMSOLVER_HPP__
10 #define __IP_AUGSYSTEMSOLVER_HPP__
11 
12 #include "IpSymMatrix.hpp"
13 #include "IpSymLinearSolver.hpp"
14 #include "IpAlgStrategy.hpp"
15 
16 namespace Ipopt
17 {
18  DECLARE_STD_EXCEPTION(FATAL_ERROR_IN_LINEAR_SOLVER);
19 
38  {
39  public:
44  {}
46  virtual ~AugSystemSolver()
47  {}
49 
51  virtual bool InitializeImpl(const OptionsList& options,
52  const std::string& prefix) = 0;
53 
62  const SymMatrix* W,
63  double W_factor,
64  const Vector* D_x,
65  double delta_x,
66  const Vector* D_s,
67  double delta_s,
68  const Matrix* J_c,
69  const Vector* D_c,
70  double delta_c,
71  const Matrix* J_d,
72  const Vector* D_d,
73  double delta_d,
74  const Vector& rhs_x,
75  const Vector& rhs_s,
76  const Vector& rhs_c,
77  const Vector& rhs_d,
78  Vector& sol_x,
79  Vector& sol_s,
80  Vector& sol_c,
81  Vector& sol_d,
82  bool check_NegEVals,
83  Index numberOfNegEVals)
84  {
85  std::vector<SmartPtr<const Vector> > rhs_xV(1);
86  rhs_xV[0] = &rhs_x;
87  std::vector<SmartPtr<const Vector> > rhs_sV(1);
88  rhs_sV[0] = &rhs_s;
89  std::vector<SmartPtr<const Vector> > rhs_cV(1);
90  rhs_cV[0] = &rhs_c;
91  std::vector<SmartPtr<const Vector> > rhs_dV(1);
92  rhs_dV[0] = &rhs_d;
93  std::vector<SmartPtr<Vector> > sol_xV(1);
94  sol_xV[0] = &sol_x;
95  std::vector<SmartPtr<Vector> > sol_sV(1);
96  sol_sV[0] = &sol_s;
97  std::vector<SmartPtr<Vector> > sol_cV(1);
98  sol_cV[0] = &sol_c;
99  std::vector<SmartPtr<Vector> > sol_dV(1);
100  sol_dV[0] = &sol_d;
101  return MultiSolve(W, W_factor, D_x, delta_x, D_s, delta_s, J_c, D_c, delta_c,
102  J_d, D_d, delta_d, rhs_xV, rhs_sV, rhs_cV, rhs_dV,
103  sol_xV, sol_sV, sol_cV, sol_dV, check_NegEVals,
104  numberOfNegEVals);
105  }
106 
111  const SymMatrix* W,
112  double W_factor,
113  const Vector* D_x,
114  double delta_x,
115  const Vector* D_s,
116  double delta_s,
117  const Matrix* J_c,
118  const Vector* D_c,
119  double delta_c,
120  const Matrix* J_d,
121  const Vector* D_d,
122  double delta_d,
123  std::vector<SmartPtr<const Vector> >& rhs_xV,
124  std::vector<SmartPtr<const Vector> >& rhs_sV,
125  std::vector<SmartPtr<const Vector> >& rhs_cV,
126  std::vector<SmartPtr<const Vector> >& rhs_dV,
127  std::vector<SmartPtr<Vector> >& sol_xV,
128  std::vector<SmartPtr<Vector> >& sol_sV,
129  std::vector<SmartPtr<Vector> >& sol_cV,
130  std::vector<SmartPtr<Vector> >& sol_dV,
131  bool check_NegEVals,
132  Index numberOfNegEVals)
133  {
134  // Solve for one right hand side after the other
135  Index nrhs = (Index)rhs_xV.size();
136  DBG_ASSERT(nrhs>0);
137  DBG_ASSERT(nrhs==(Index)rhs_sV.size());
138  DBG_ASSERT(nrhs==(Index)rhs_cV.size());
139  DBG_ASSERT(nrhs==(Index)rhs_dV.size());
140  DBG_ASSERT(nrhs==(Index)sol_xV.size());
141  DBG_ASSERT(nrhs==(Index)sol_sV.size());
142  DBG_ASSERT(nrhs==(Index)sol_cV.size());
143  DBG_ASSERT(nrhs==(Index)sol_dV.size());
144 
146  for (Index i=0; i<nrhs; i++) {
147  retval = Solve(W, W_factor, D_x, delta_x, D_s, delta_s, J_c, D_c, delta_c,
148  J_d, D_d, delta_d,
149  *rhs_xV[i], *rhs_sV[i], *rhs_cV[i], *rhs_dV[i],
150  *sol_xV[i], *sol_sV[i], *sol_cV[i], *sol_dV[i],
151  check_NegEVals, numberOfNegEVals);
152  if (retval!=SYMSOLVER_SUCCESS) {
153  break;
154  }
155  }
156  return retval;
157  }
158 
165  virtual Index NumberOfNegEVals() const =0;
166 
170  virtual bool ProvidesInertia() const =0;
171 
178  virtual bool IncreaseQuality() =0;
179 
180  private:
191 
193  void operator=(const AugSystemSolver&);
195 
196  };
197 
198 } // namespace Ipopt
199 
200 #endif
AugSystemSolver()
Default constructor.
virtual ~AugSystemSolver()
Default destructor.
ESymSolverStatus
Enum to report outcome of a linear solve.
This is the base class for all algorithm strategy objects.
virtual bool InitializeImpl(const OptionsList &options, const std::string &prefix)=0
overloaded from AlgorithmStrategyObject
Vector Base Class.
Definition: IpVector.hpp:47
virtual ESymSolverStatus Solve(const SymMatrix *W, double W_factor, const Vector *D_x, double delta_x, const Vector *D_s, double delta_s, const Matrix *J_c, const Vector *D_c, double delta_c, const Matrix *J_d, const Vector *D_d, double delta_d, const Vector &rhs_x, const Vector &rhs_s, const Vector &rhs_c, const Vector &rhs_d, Vector &sol_x, Vector &sol_s, Vector &sol_c, Vector &sol_d, bool check_NegEVals, Index numberOfNegEVals)
Set up the augmented system and solve it for a given right hand side.
This is the base class for all derived symmetric matrix types.
Definition: IpSymMatrix.hpp:23
Template class for Smart Pointers.
Definition: IpSmartPtr.hpp:172
This class stores a list of user set options.
Base class for Solver for the augmented system.
virtual ESymSolverStatus MultiSolve(const SymMatrix *W, double W_factor, const Vector *D_x, double delta_x, const Vector *D_s, double delta_s, const Matrix *J_c, const Vector *D_c, double delta_c, const Matrix *J_d, const Vector *D_d, double delta_d, std::vector< SmartPtr< const Vector > > &rhs_xV, std::vector< SmartPtr< const Vector > > &rhs_sV, std::vector< SmartPtr< const Vector > > &rhs_cV, std::vector< SmartPtr< const Vector > > &rhs_dV, std::vector< SmartPtr< Vector > > &sol_xV, std::vector< SmartPtr< Vector > > &sol_sV, std::vector< SmartPtr< Vector > > &sol_cV, std::vector< SmartPtr< Vector > > &sol_dV, bool check_NegEVals, Index numberOfNegEVals)
Like Solve, but for multiple right hand sides.
Matrix Base Class.
Definition: IpMatrix.hpp:27
virtual bool IncreaseQuality()=0
Request to increase quality of solution for next solve.
void operator=(const AugSystemSolver &)
Overloaded Equals Operator.
virtual bool ProvidesInertia() const =0
Query whether inertia is computed by linear solver.
int Index
Type of all indices of vectors, matrices etc.
Definition: IpTypes.hpp:19
#define DBG_ASSERT(test)
Definition: IpDebug.hpp:38
DECLARE_STD_EXCEPTION(SUFFIX_EMPTY)
virtual Index NumberOfNegEVals() const =0
Number of negative eigenvalues detected during last solve.