#include <IpTNLPAdapter.hpp>
This is an Adapter class (Design Patterns) that converts a TNLP to an NLP. This allows users to write to the "more convenient" TNLP interface.
Public Types | |
enum | FixedVariableTreatmentEnum { MAKE_PARAMETER = 0, MAKE_CONSTRAINT } |
Enum for treatment of fixed variables option. More... | |
enum | DerivativeTestEnum { NO_TEST = 0, FIRST_ORDER_TEST, SECOND_ORDER_TEST } |
Enum for specifying which derivative test is to be performed. More... | |
Public Member Functions | |
virtual void | GetQuasiNewtonApproximationSpaces (SmartPtr< VectorSpace > &approx_space, SmartPtr< Matrix > &P_approx) |
Method returning information on quasi-Newton approximation. | |
bool | CheckDerivatives (DerivativeTestEnum deriv_test) |
Method for performing the derivative test. | |
SmartPtr< TNLP > | tnlp () const |
Accessor method for the underlying TNLP. | |
Constructors/Destructors | |
TNLPAdapter (const SmartPtr< TNLP > tnlp, const SmartPtr< const Journalist > jnlst=NULL) | |
Default constructor. | |
virtual | ~TNLPAdapter () |
Default destructor. | |
Exceptions | |
DECLARE_STD_EXCEPTION (INVALID_TNLP) | |
DECLARE_STD_EXCEPTION (ERROR_IN_TNLP_DERIVATIVE_TEST) | |
TNLPAdapter Initialization. | |
virtual bool | ProcessOptions (const OptionsList &options, const std::string &prefix) |
Method for creating the derived vector / matrix types (Do not delete these, the ). | |
virtual bool | GetSpaces (SmartPtr< const VectorSpace > &x_space, SmartPtr< const VectorSpace > &c_space, SmartPtr< const VectorSpace > &d_space, SmartPtr< const VectorSpace > &x_l_space, SmartPtr< const MatrixSpace > &px_l_space, SmartPtr< const VectorSpace > &x_u_space, SmartPtr< const MatrixSpace > &px_u_space, SmartPtr< const VectorSpace > &d_l_space, SmartPtr< const MatrixSpace > &pd_l_space, SmartPtr< const VectorSpace > &d_u_space, SmartPtr< const MatrixSpace > &pd_u_space, SmartPtr< const MatrixSpace > &Jac_c_space, SmartPtr< const MatrixSpace > &Jac_d_space, SmartPtr< const SymMatrixSpace > &Hess_lagrangian_space) |
Method for creating the derived vector / matrix types (Do not delete these, the ). | |
virtual bool | GetBoundsInformation (const Matrix &Px_L, Vector &x_L, const Matrix &Px_U, Vector &x_U, const Matrix &Pd_L, Vector &d_L, const Matrix &Pd_U, Vector &d_U) |
Method for obtaining the bounds information. | |
virtual bool | GetStartingPoint (SmartPtr< Vector > x, bool need_x, SmartPtr< Vector > y_c, bool need_y_c, SmartPtr< Vector > y_d, bool need_y_d, SmartPtr< Vector > z_L, bool need_z_L, SmartPtr< Vector > z_U, bool need_z_U) |
Method for obtaining the starting point for all the iterates. | |
virtual bool | GetWarmStartIterate (IteratesVector &warm_start_iterate) |
Method for obtaining an entire iterate as a warmstart point. | |
TNLPAdapter evaluation routines. | |
virtual bool | Eval_f (const Vector &x, Number &f) |
virtual bool | Eval_grad_f (const Vector &x, Vector &g_f) |
virtual bool | Eval_c (const Vector &x, Vector &c) |
virtual bool | Eval_jac_c (const Vector &x, Matrix &jac_c) |
virtual bool | Eval_d (const Vector &x, Vector &d) |
virtual bool | Eval_jac_d (const Vector &x, Matrix &jac_d) |
virtual bool | Eval_h (const Vector &x, Number obj_factor, const Vector &yc, const Vector &yd, SymMatrix &h) |
virtual void | GetScalingParameters (const SmartPtr< const VectorSpace > x_space, const SmartPtr< const VectorSpace > c_space, const SmartPtr< const VectorSpace > d_space, Number &obj_scaling, SmartPtr< Vector > &x_scaling, SmartPtr< Vector > &c_scaling, SmartPtr< Vector > &d_scaling) const |
Routines to get the scaling parameters. | |
Solution Reporting Methods | |
virtual void | FinalizeSolution (SolverReturn status, const Vector &x, const Vector &z_L, const Vector &z_U, const Vector &c, const Vector &d, const Vector &y_c, const Vector &y_d, Number obj_value) |
This method is called at the very end of the optimization. | |
virtual bool | IntermediateCallBack (AlgorithmMode mode, Index iter, Number obj_value, Number inf_pr, Number inf_du, Number mu, Number d_norm, Number regularization_size, Number alpha_du, Number alpha_pr, Index ls_trials, const IpoptData *ip_data, IpoptCalculatedQuantities *ip_cq) |
This method is called once per iteration, after the iteration summary output has been printed. | |
Static Public Member Functions | |
Methods for IpoptType | |
static void | RegisterOptions (SmartPtr< RegisteredOptions > roptions) |
enum DerivativeTestEnum |
TNLPAdapter | ( | const SmartPtr< TNLP > | tnlp, | |
const SmartPtr< const Journalist > | jnlst = NULL | |||
) |
~TNLPAdapter | ( | ) | [virtual] |
Default destructor.
DECLARE_STD_EXCEPTION | ( | INVALID_TNLP | ) |
DECLARE_STD_EXCEPTION | ( | ERROR_IN_TNLP_DERIVATIVE_TEST | ) |
bool ProcessOptions | ( | const OptionsList & | options, | |
const std::string & | prefix | |||
) | [virtual] |
Method for creating the derived vector / matrix types (Do not delete these, the ).
Reimplemented from NLP.
References ASSERT_EXCEPTION, DBG_START_METH, OptionsList::GetBoolValue(), OptionsList::GetEnumValue(), and OptionsList::GetNumericValue().
bool GetSpaces | ( | SmartPtr< const VectorSpace > & | x_space, | |
SmartPtr< const VectorSpace > & | c_space, | |||
SmartPtr< const VectorSpace > & | d_space, | |||
SmartPtr< const VectorSpace > & | x_l_space, | |||
SmartPtr< const MatrixSpace > & | px_l_space, | |||
SmartPtr< const VectorSpace > & | x_u_space, | |||
SmartPtr< const MatrixSpace > & | px_u_space, | |||
SmartPtr< const VectorSpace > & | d_l_space, | |||
SmartPtr< const MatrixSpace > & | pd_l_space, | |||
SmartPtr< const VectorSpace > & | d_u_space, | |||
SmartPtr< const MatrixSpace > & | pd_u_space, | |||
SmartPtr< const MatrixSpace > & | Jac_c_space, | |||
SmartPtr< const MatrixSpace > & | Jac_d_space, | |||
SmartPtr< const SymMatrixSpace > & | Hess_lagrangian_space | |||
) | [virtual] |
Method for creating the derived vector / matrix types (Do not delete these, the ).
Implements NLP.
References ASSERT_EXCEPTION, TNLPAdapter::CheckDerivatives(), DBG_ASSERT, DBG_START_METH, Ipopt::EXACT, TNLP::FORTRAN_STYLE, Ipopt::GetRawPtr(), fkinkryx::i, Ipopt::IsValid(), Ipopt::J_DETAILED, Ipopt::J_ERROR, Ipopt::J_INITIALIZATION, Ipopt::J_ITERSUMMARY, Ipopt::J_STATISTICS, TNLPAdapter::MAKE_CONSTRAINT, TNLPAdapter::MAKE_PARAMETER, TNLPAdapter::NO_TEST, and THROW_EXCEPTION.
bool GetBoundsInformation | ( | const Matrix & | Px_L, | |
Vector & | x_L, | |||
const Matrix & | Px_U, | |||
Vector & | x_U, | |||
const Matrix & | Pd_L, | |||
Vector & | d_L, | |||
const Matrix & | Pd_U, | |||
Vector & | d_U | |||
) | [virtual] |
Method for obtaining the bounds information.
Implements NLP.
References DBG_ASSERT, ExpansionMatrix::ExpandedPosIndices(), fkinkryx::i, Ipopt::IsValid(), TNLPAdapter::MAKE_CONSTRAINT, TNLPAdapter::MAKE_PARAMETER, Matrix::NCols(), rhs, and DenseVector::Values().
bool GetStartingPoint | ( | SmartPtr< Vector > | x, | |
bool | need_x, | |||
SmartPtr< Vector > | y_c, | |||
bool | need_y_c, | |||
SmartPtr< Vector > | y_d, | |||
bool | need_y_d, | |||
SmartPtr< Vector > | z_L, | |||
bool | need_z_L, | |||
SmartPtr< Vector > | z_U, | |||
bool | need_z_U | |||
) | [virtual] |
Method for obtaining the starting point for all the iterates.
Implements NLP.
References DBG_ASSERT, dx, Ipopt::GetRawPtr(), fkinkryx::i, Ipopt::IpBlasDcopy(), Ipopt::IsValid(), TNLPAdapter::MAKE_CONSTRAINT, and DenseVector::Values().
bool GetWarmStartIterate | ( | IteratesVector & | warm_start_iterate | ) | [virtual] |
Method for obtaining an entire iterate as a warmstart point.
The incoming IteratesVector has to be filled.
Reimplemented from NLP.
Implements NLP.
References DBG_ASSERT, Vector::Dim(), fkinkryx::i, Ipopt::IsValid(), and DenseVector::Values().
Implements NLP.
References DBG_ASSERT, fkinkryx::i, TNLPAdapter::MAKE_CONSTRAINT, and DenseVector::Values().
Implements NLP.
References DBG_ASSERT, fkinkryx::i, Ipopt::IpBlasDcopy(), TNLPAdapter::MAKE_CONSTRAINT, and GenTMatrix::Values().
void GetScalingParameters | ( | const SmartPtr< const VectorSpace > | x_space, | |
const SmartPtr< const VectorSpace > | c_space, | |||
const SmartPtr< const VectorSpace > | d_space, | |||
Number & | obj_scaling, | |||
SmartPtr< Vector > & | x_scaling, | |||
SmartPtr< Vector > & | c_scaling, | |||
SmartPtr< Vector > & | d_scaling | |||
) | const [virtual] |
Routines to get the scaling parameters.
These do not need to be overloaded unless the options are set for User scaling
Reimplemented from NLP.
References DBG_ASSERT, Vector::Dim(), dx, Ipopt::GetRawPtr(), fkinkryx::i, Ipopt::IpBlasDcopy(), Ipopt::IsValid(), Ipopt::J_ERROR, Ipopt::J_INITIALIZATION, TNLPAdapter::MAKE_CONSTRAINT, THROW_EXCEPTION, and DenseVector::Values().
void FinalizeSolution | ( | SolverReturn | status, | |
const Vector & | x, | |||
const Vector & | z_L, | |||
const Vector & | z_U, | |||
const Vector & | c, | |||
const Vector & | d, | |||
const Vector & | y_c, | |||
const Vector & | y_d, | |||
Number | obj_value | |||
) | [virtual] |
This method is called at the very end of the optimization.
It provides the final iterate to the user, so that it can be stored as the solution. The status flag indicates the outcome of the optimization, where SolverReturn is defined in IpAlgTypes.hpp.
Reimplemented from NLP.
References DBG_ASSERT, DBG_START_METH, Vector::Dim(), fkinkryx::i, DenseVector::IsHomogeneous(), TNLPAdapter::MAKE_CONSTRAINT, Ipopt::Max(), and DenseVector::Values().
bool IntermediateCallBack | ( | AlgorithmMode | mode, | |
Index | iter, | |||
Number | obj_value, | |||
Number | inf_pr, | |||
Number | inf_du, | |||
Number | mu, | |||
Number | d_norm, | |||
Number | regularization_size, | |||
Number | alpha_du, | |||
Number | alpha_pr, | |||
Index | ls_trials, | |||
const IpoptData * | ip_data, | |||
IpoptCalculatedQuantities * | ip_cq | |||
) | [virtual] |
This method is called once per iteration, after the iteration summary output has been printed.
It provides the current information to the user to do with it anything she wants. It also allows the user to ask for a premature termination of the optimization by returning false, in which case Ipopt will terminate with a corresponding return status. The basic information provided in the argument list has the quantities values printed in the iteration summary line. If more information is required, a user can obtain it from the IpData and IpCalculatedQuantities objects. However, note that the provided quantities are all for the problem that Ipopt sees, i.e., the quantities might be scaled, fixed variables might be sorted out, etc. The status indicates things like whether the algorithm is in the restoration phase... In the restoration phase, the dual variables are probably not not changing.
Reimplemented from NLP.
void GetQuasiNewtonApproximationSpaces | ( | SmartPtr< VectorSpace > & | approx_space, | |
SmartPtr< Matrix > & | P_approx | |||
) | [virtual] |
Method returning information on quasi-Newton approximation.
Reimplemented from NLP.
References TNLP::FORTRAN_STYLE, fkinkryx::i, Ipopt::IsNull(), Ipopt::J_ERROR, Ipopt::J_INITIALIZATION, and THROW_EXCEPTION.
bool CheckDerivatives | ( | TNLPAdapter::DerivativeTestEnum | deriv_test | ) |
Method for performing the derivative test.
References ASSERT_EXCEPTION, TNLP::FORTRAN_STYLE, fkinkryx::i, Ipopt::IpBlasDcopy(), Ipopt::IsValid(), Ipopt::J_NLP, Ipopt::J_SUMMARY, Ipopt::J_WARNING, Ipopt::Max(), TNLPAdapter::NO_TEST, and TNLPAdapter::SECOND_ORDER_TEST.
Referenced by TNLPAdapter::GetSpaces().
void RegisterOptions | ( | SmartPtr< RegisteredOptions > | roptions | ) | [static] |
Referenced by Ipopt::RegisterOptions_Interfaces().