diff options
Diffstat (limited to 'thirdparty/linux/include')
29 files changed, 4178 insertions, 10 deletions
diff --git a/thirdparty/linux/include/coin/IpAlgBuilder.hpp b/thirdparty/linux/include/coin/IpAlgBuilder.hpp new file mode 100644 index 0000000..05692bb --- /dev/null +++ b/thirdparty/linux/include/coin/IpAlgBuilder.hpp @@ -0,0 +1,360 @@ +// Copyright (C) 2004, 2007 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpAlgBuilder.hpp 2666 2016-07-20 16:02:55Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-09-29 + +#ifndef __IPALGBUILDER_HPP__ +#define __IPALGBUILDER_HPP__ + +#include "IpIpoptAlg.hpp" +#include "IpReferenced.hpp" +#include "IpAugSystemSolver.hpp" +#include "IpPDSystemSolver.hpp" + +namespace Ipopt +{ + + // forward declarations + class IterationOutput; + class HessianUpdater; + class ConvergenceCheck; + class SearchDirectionCalculator; + class EqMultiplierCalculator; + class IterateInitializer; + class LineSearch; + class MuUpdate; + + /** Builder for creating a complete IpoptAlg object. This object + * contains all subelements (such as line search objects etc). How + * the resulting IpoptAlg object is built can be influenced by the + * options. + * + * More advanced customization can be achieved by subclassing this + * class and overloading the virtual methods that build the + * individual parts. The advantage of doing this is that it allows + * one to reuse the extensive amount of options processing that + * takes place, for instance, when generating the symmetric linear + * system solver. Another method for customizing the algorithm is + * using the optional custom_solver argument, which allows the + * expert user to provide a specialized linear solver for the + * augmented system (e.g., type GenAugSystemSolver), possibly for + * user-defined matrix objects. The optional custom_solver constructor + * argument is likely obsolete, however, as more control over this + * this process can be achieved by implementing a subclass of this + * AlgBuilder (e.g., by overloading the AugSystemSolverFactory method). + */ + class AlgorithmBuilder : public ReferencedObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Constructor */ + AlgorithmBuilder(SmartPtr<AugSystemSolver> custom_solver=NULL); + + /** Destructor */ + virtual ~AlgorithmBuilder() + {} + + //@} + + /** Methods for IpoptTypeInfo */ + //@{ + /** register the options used by the algorithm builder */ + static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); + //@} + + /** @name Convenience methods for building solvers without having + * to duplicate the significant amount of preprocessor flag and + * option checking that takes place. These solvers are used to + * create a number of core algorithm components across the + * different Build* methods, but depending on what options are + * chosen, the first method requiring the solver to be used can + * vary. Therefore, each of the Factory methods below is paired + * with a Getter method, which is called by all parts of this + * algorithm builder to ensure the Factory is only called once. */ + //@{ + + /** Create a solver that can be used to solve a symmetric linear + * system. + * Dependencies: None + */ + virtual SmartPtr<SymLinearSolver> + SymLinearSolverFactory(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Get the symmetric linear system solver for this + * algorithm. This method will call the SymLinearSolverFactory + * exactly once (the first time it is used), and store its + * instance on SymSolver_ for use in subsequent calls. + */ + SmartPtr<SymLinearSolver> GetSymLinearSolver(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Create a solver that can be used to solve an + * augmented system. + * Dependencies: + * -> GetSymLinearSolver() + * -> SymLinearSolverFactory() + * -> custom_solver_ + */ + virtual SmartPtr<AugSystemSolver> + AugSystemSolverFactory(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Get the augmented system solver for this algorithm. This + * method will call the AugSystemSolverFactory exactly once (the + * first time it is used), and store its instance on AugSolver_ + * for use in subsequent calls. + */ + SmartPtr<AugSystemSolver> GetAugSystemSolver(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Create a solver that can be used to solve a + * primal-dual system. + * Dependencies: + * -> GetAugSystemSolver() + * -> AugSystemSolverFactory() + * -> GetSymLinearSolver() + * -> SymLinearSolverFactory() + * -> custom_solver_ + */ + virtual SmartPtr<PDSystemSolver> + PDSystemSolverFactory(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Get the primal-dual system solver for this algorithm. This + * method will call the PDSystemSolverFactory exactly once (the + * first time it is used), and store its instance on PDSolver_ + * for use in subsequent calls. + */ + SmartPtr<PDSystemSolver> GetPDSystemSolver(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + //@} + + /** @name Methods to build parts of the algorithm */ + //@{ + /** Allocates memory for the IpoptNLP, IpoptData, and + * IpoptCalculatedQuanties arguments. + * Dependencies: None + */ + virtual void BuildIpoptObjects(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix, + const SmartPtr<NLP>& nlp, + SmartPtr<IpoptNLP>& ip_nlp, + SmartPtr<IpoptData>& ip_data, + SmartPtr<IpoptCalculatedQuantities>& ip_cq); + + /** Creates an instance of the IpoptAlgorithm class by building + * each of its required constructor arguments piece-by-piece. The + * default algorithm can be customized by overloading this method + * or by overloading one or more of the Build* methods called in + * this method's default implementation. Additional control can + * be achieved by overloading any of the *SolverFactory methods. + * This method will call (in this order): + * -> BuildIterationOutput() + * -> BuildHessianUpdater() + * -> BuildConvergenceCheck() + * -> BuildSearchDirectionCalculator() + * -> BuildEqMultiplierCalculator() + * -> BuildIterateInitializer() + * -> BuildLineSearch() + * -> BuildMuUpdate() + */ + virtual SmartPtr<IpoptAlgorithm> BuildBasicAlgorithm(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Creates an instance of the IterationOutput class. This method + * is called in the default implementation of + * BuildBasicAlgorithm. It can be overloaded to customize that + * portion the default algorithm. + * Dependencies: None + */ + virtual SmartPtr<IterationOutput> + BuildIterationOutput(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Creates an instance of the HessianUpdater class. This method + * is called in the default implementation of + * BuildBasicAlgorithm. It can be overloaded to customize that + * portion the default algorithm. + * Dependencies: None + */ + virtual SmartPtr<HessianUpdater> + BuildHessianUpdater(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Creates an instance of the ConvergenceCheck class. This method + * is called in the default implementation of + * BuildBasicAlgorithm. It can be overloaded to customize that + * portion the default algorithm. + * Dependencies: None + */ + virtual SmartPtr<ConvergenceCheck> + BuildConvergenceCheck(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Creates an instance of the SearchDirectionCalculator + * class. This method is called in the default implementation of + * BuildBasicAlgorithm. It can be overloaded to customize that + * portion the default algorithm. + * Dependencies: + * -> GetPDSystemSolver() + * -> PDSystemSolverFactory() + * -> GetAugSystemSolver() + * -> AugSystemSolverFactory() + * -> GetSymLinearSolver() + * -> SymLinearSolverFactory() + * -> custom_solver_ + */ + virtual SmartPtr<SearchDirectionCalculator> + BuildSearchDirectionCalculator(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Creates an instance of the EqMultiplierCalculator class. This + * method is called in the default implementation of + * BuildBasicAlgorithm. It can be overloaded to customize that + * portion the default algorithm. + * Dependencies: + * -> GetAugSystemSolver() + * -> AugSystemSolverFactory() + * -> GetSymLinearSolver() + * -> SymLinearSolverFactory() + * -> custom_solver_ + */ + virtual SmartPtr<EqMultiplierCalculator> + BuildEqMultiplierCalculator(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Creates an instance of the IterateInitializer class. This + * method is called in the default implementation of + * BuildBasicAlgorithm. It can be overloaded to customize that + * portion the default algorithm. + * Dependencies: + * -> EqMultCalculator_ + * -> GetAugSystemSolver() + * -> AugSystemSolverFactory() + * -> GetSymLinearSolver() + * -> SymLinearSolverFactory() + * -> custom_solver_ + */ + virtual SmartPtr<IterateInitializer> + BuildIterateInitializer(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Creates an instance of the LineSearch class. This method is + * called in the default implementation of BuildBasicAlgorithm. + * It can be overloaded to customize that portion the default + * algorithm. + * Dependencies: + * -> EqMultCalculator_ + * -> ConvCheck_ + * -> GetAugSystemSolver() + * -> AugSystemSolverFactory() + * -> GetSymLinearSolver() + * -> SymLinearSolverFactory() + * -> custom_solver_ + * -> GetPDSystemSolver() + * -> PDSystemSolverFactory() + * -> GetAugSystemSolver() + * -> AugSystemSolverFactory() + * -> GetSymLinearSolver() + * -> SymLinearSolverFactory() + * -> custom_solver_ + */ + virtual SmartPtr<LineSearch> BuildLineSearch(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + + /** Creates an instance of the MuUpdate class. This method is + * called in the default implementation of BuildBasicAlgorithm. + * It can be overloaded to customize that portion the default + * algorithm. + * Dependencies: + * -> LineSearch_ + * -> EqMultCalculator_ + * -> ConvCheck_ + * -> GetPDSystemSolver() + * -> PDSystemSolverFactory() + * -> GetAugSystemSolver() + * -> AugSystemSolverFactory() + * -> GetSymLinearSolver() + * -> SymLinearSolverFactory() + * -> custom_solver_ + */ + virtual SmartPtr<MuUpdate> BuildMuUpdate(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix); + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + //AlgorithmBuilder(); + + /** Copy Constructor */ + AlgorithmBuilder(const AlgorithmBuilder&); + + /** Overloaded Equals Operator */ + void operator=(const AlgorithmBuilder&); + //@} + + /** @name IpoptAlgorithm constructor arguments. + * These components are built in separate Build + * methods in the order defined by BuildBasicAlgorithm. + * A single core component may require one or more + * other core components in its constructor, so the + * this class holds pointers to each component for use + * between the separate Build methods. */ + //@{ + SmartPtr<IterationOutput> IterOutput_; + SmartPtr<HessianUpdater> HessUpdater_; + SmartPtr<ConvergenceCheck> ConvCheck_; + SmartPtr<SearchDirectionCalculator> SearchDirCalc_; + SmartPtr<EqMultiplierCalculator> EqMultCalculator_; + SmartPtr<IterateInitializer> IterInitializer_; + SmartPtr<LineSearch> LineSearch_; + SmartPtr<MuUpdate> MuUpdate_; + //@} + + /** @name Commonly used solver components + * for building core algorithm components. Each + * of these members is paired with a Factory/Getter + * method. */ + //@{ + SmartPtr<SymLinearSolver> SymSolver_; + SmartPtr<AugSystemSolver> AugSolver_; + SmartPtr<PDSystemSolver> PDSolver_; + //@} + + /** Optional pointer to AugSystemSolver. If this is set in the + * contructor, we will use this to solve the linear systems. */ + SmartPtr<AugSystemSolver> custom_solver_; + + }; +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpAlgStrategy.hpp b/thirdparty/linux/include/coin/IpAlgStrategy.hpp new file mode 100644 index 0000000..746a968 --- /dev/null +++ b/thirdparty/linux/include/coin/IpAlgStrategy.hpp @@ -0,0 +1,185 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpAlgStrategy.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPALGSTRATEGY_HPP__ +#define __IPALGSTRATEGY_HPP__ + +#include "IpOptionsList.hpp" +#include "IpJournalist.hpp" +#include "IpIpoptCalculatedQuantities.hpp" +#include "IpIpoptNLP.hpp" +#include "IpIpoptData.hpp" + +namespace Ipopt +{ + + /** This is the base class for all algorithm strategy objects. The + * AlgorithmStrategyObject base class implements a common interface + * for all algorithm strategy objects. A strategy object is a + * component of the algorithm for which different alternatives or + * implementations exists. It allows to compose the algorithm + * before execution for a particular configuration, without the + * need to call alternatives based on enums. For example, the + * LineSearch object is a strategy object, since different line + * search options might be used for different runs. + * + * This interface is used for + * things that are done to all strategy objects, like + * initialization and setting options. + */ + class AlgorithmStrategyObject : public ReferencedObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default Constructor */ + AlgorithmStrategyObject() + : + initialize_called_(false) + {} + + /** Default Destructor */ + virtual ~AlgorithmStrategyObject() + {} + //@} + + /** This method is called every time the algorithm starts again - + * it is used to reset any internal state. The pointers to the + * Journalist, as well as to the IpoptNLP, IpoptData, and + * IpoptCalculatedQuantities objects should be stored in the + * instanciation of this base class. This method is also used to + * get all required user options from the OptionsList. Here, if + * prefix is given, each tag (identifying the options) is first + * looked for with the prefix in front, and if not found, without + * the prefix. Note: you should not cue off of the iteration + * count to indicate the "start" of an algorithm! + * + * Do not overload this method, since it does some general + * initialization that is common for all strategy objects. + * Overload the protected InitializeImpl method instead. + */ + bool Initialize(const Journalist& jnlst, + IpoptNLP& ip_nlp, + IpoptData& ip_data, + IpoptCalculatedQuantities& ip_cq, + const OptionsList& options, + const std::string& prefix) + { + initialize_called_ = true; + // Copy the pointers for the problem defining objects + jnlst_ = &jnlst; + ip_nlp_ = &ip_nlp; + ip_data_ = &ip_data; + ip_cq_ = &ip_cq; + + bool retval = InitializeImpl(options, prefix); + if (!retval) { + initialize_called_ = false; + } + + return retval; + } + + /** Reduced version of the Initialize method, which does not + * require special Ipopt information. This is useful for + * algorithm objects that could be used outside Ipopt, such as + * linear solvers. */ + bool ReducedInitialize(const Journalist& jnlst, + const OptionsList& options, + const std::string& prefix) + { + initialize_called_ = true; + // Copy the pointers for the problem defining objects + jnlst_ = &jnlst; + ip_nlp_ = NULL; + ip_data_ = NULL; + ip_cq_ = NULL; + + bool retval = InitializeImpl(options, prefix); + if (!retval) { + initialize_called_ = false; + } + + return retval; + } + + protected: + /** Implementation of the initialization method that has to be + * overloaded by for each derived class. */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix)=0; + + /** @name Accessor methods for the problem defining objects. + * Those should be used by the derived classes. */ + //@{ + const Journalist& Jnlst() const + { + DBG_ASSERT(initialize_called_); + return *jnlst_; + } + IpoptNLP& IpNLP() const + { + DBG_ASSERT(initialize_called_); + DBG_ASSERT(IsValid(ip_nlp_)); + return *ip_nlp_; + } + IpoptData& IpData() const + { + DBG_ASSERT(initialize_called_); + DBG_ASSERT(IsValid(ip_data_)); + return *ip_data_; + } + IpoptCalculatedQuantities& IpCq() const + { + DBG_ASSERT(initialize_called_); + DBG_ASSERT(IsValid(ip_cq_)); + return *ip_cq_; + } + bool HaveIpData() const + { + return IsValid(ip_data_); + } + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + //AlgorithmStrategyObject(); + + + /** Copy Constructor */ + AlgorithmStrategyObject(const AlgorithmStrategyObject&); + + /** Overloaded Equals Operator */ + void operator=(const AlgorithmStrategyObject&); + //@} + + /** @name Pointers to objects defining a particular optimization + * problem */ + //@{ + SmartPtr<const Journalist> jnlst_; + SmartPtr<IpoptNLP> ip_nlp_; + SmartPtr<IpoptData> ip_data_; + SmartPtr<IpoptCalculatedQuantities> ip_cq_; + //@} + + /** flag indicating if Initialize method has been called (for + * debugging) */ + bool initialize_called_; + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpAugSystemSolver.hpp b/thirdparty/linux/include/coin/IpAugSystemSolver.hpp new file mode 100644 index 0000000..1396ce4 --- /dev/null +++ b/thirdparty/linux/include/coin/IpAugSystemSolver.hpp @@ -0,0 +1,200 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpAugSystemSolver.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IP_AUGSYSTEMSOLVER_HPP__ +#define __IP_AUGSYSTEMSOLVER_HPP__ + +#include "IpSymMatrix.hpp" +#include "IpSymLinearSolver.hpp" +#include "IpAlgStrategy.hpp" + +namespace Ipopt +{ + DECLARE_STD_EXCEPTION(FATAL_ERROR_IN_LINEAR_SOLVER); + + /** Base class for Solver for the augmented system. This is the + * base class for linear solvers that solve the augmented system, + * which is defined as + * + * \f$\left[\begin{array}{cccc} + * W + D_x + \delta_xI & 0 & J_c^T & J_d^T\\ + * 0 & D_s + \delta_sI & 0 & -I \\ + * J_c & 0 & D_c - \delta_cI & 0\\ + * J_d & -I & 0 & D_d - \delta_dI + * \end{array}\right] + * \left(\begin{array}{c}sol_x\\sol_s\\sol_c\\sol_d\end{array}\right)= + * \left(\begin{array}{c}rhs_x\\rhs_s\\rhs_c\\rhs_d\end{array}\right)\f$ + * + * Since this system might be solved repeatedly for different right + * hand sides, it is desirable to step the factorization of a + * direct linear solver if possible. + */ + class AugSystemSolver: public AlgorithmStrategyObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default constructor. */ + AugSystemSolver() + {} + /** Default destructor */ + virtual ~AugSystemSolver() + {} + //@} + + /** overloaded from AlgorithmStrategyObject */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix) = 0; + + /** Set up the augmented system and solve it for a given right hand + * side. If desired (i.e. if check_NegEVals is true), then the + * solution is only computed if the number of negative eigenvalues + * matches numberOfNegEVals. + * + * The return value is the return value of the linear solver object. + */ + 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) + { + std::vector<SmartPtr<const Vector> > rhs_xV(1); + rhs_xV[0] = &rhs_x; + std::vector<SmartPtr<const Vector> > rhs_sV(1); + rhs_sV[0] = &rhs_s; + std::vector<SmartPtr<const Vector> > rhs_cV(1); + rhs_cV[0] = &rhs_c; + std::vector<SmartPtr<const Vector> > rhs_dV(1); + rhs_dV[0] = &rhs_d; + std::vector<SmartPtr<Vector> > sol_xV(1); + sol_xV[0] = &sol_x; + std::vector<SmartPtr<Vector> > sol_sV(1); + sol_sV[0] = &sol_s; + std::vector<SmartPtr<Vector> > sol_cV(1); + sol_cV[0] = &sol_c; + std::vector<SmartPtr<Vector> > sol_dV(1); + sol_dV[0] = &sol_d; + return MultiSolve(W, W_factor, D_x, delta_x, D_s, delta_s, J_c, D_c, delta_c, + J_d, D_d, delta_d, rhs_xV, rhs_sV, rhs_cV, rhs_dV, + sol_xV, sol_sV, sol_cV, sol_dV, check_NegEVals, + numberOfNegEVals); + } + + /** Like Solve, but for multiple right hand sides. The inheriting + * class has to be overload at least one of Solve and + * MultiSolve. */ + 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) + { + // Solve for one right hand side after the other + Index nrhs = (Index)rhs_xV.size(); + DBG_ASSERT(nrhs>0); + DBG_ASSERT(nrhs==(Index)rhs_sV.size()); + DBG_ASSERT(nrhs==(Index)rhs_cV.size()); + DBG_ASSERT(nrhs==(Index)rhs_dV.size()); + DBG_ASSERT(nrhs==(Index)sol_xV.size()); + DBG_ASSERT(nrhs==(Index)sol_sV.size()); + DBG_ASSERT(nrhs==(Index)sol_cV.size()); + DBG_ASSERT(nrhs==(Index)sol_dV.size()); + + ESymSolverStatus retval=SYMSOLVER_SUCCESS; + for (Index i=0; i<nrhs; i++) { + retval = Solve(W, W_factor, D_x, delta_x, D_s, delta_s, J_c, D_c, delta_c, + J_d, D_d, delta_d, + *rhs_xV[i], *rhs_sV[i], *rhs_cV[i], *rhs_dV[i], + *sol_xV[i], *sol_sV[i], *sol_cV[i], *sol_dV[i], + check_NegEVals, numberOfNegEVals); + if (retval!=SYMSOLVER_SUCCESS) { + break; + } + } + return retval; + } + + /** Number of negative eigenvalues detected during last + * solve. Returns the number of negative eigenvalues of + * the most recent factorized matrix. This must not be called if + * the linear solver does not compute this quantities (see + * ProvidesInertia). + */ + virtual Index NumberOfNegEVals() const =0; + + /** Query whether inertia is computed by linear solver. + * Returns true, if linear solver provides inertia. + */ + virtual bool ProvidesInertia() const =0; + + /** Request to increase quality of solution for next solve. Ask + * underlying linear solver to increase quality of solution for + * the next solve (e.g. increase pivot tolerance). Returns + * false, if this is not possible (e.g. maximal pivot tolerance + * already used.) + */ + virtual bool IncreaseQuality() =0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + AugSystemSolver(const AugSystemSolver&); + + /** Overloaded Equals Operator */ + void operator=(const AugSystemSolver&); + //@} + + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpCompoundMatrix.hpp b/thirdparty/linux/include/coin/IpCompoundMatrix.hpp new file mode 100644 index 0000000..03e2e2a --- /dev/null +++ b/thirdparty/linux/include/coin/IpCompoundMatrix.hpp @@ -0,0 +1,340 @@ +// Copyright (C) 2004, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpCompoundMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPCOMPOUNDMATRIX_HPP__ +#define __IPCOMPOUNDMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpMatrix.hpp" + +namespace Ipopt +{ + + /* forward declarations */ + class CompoundMatrixSpace; + + /** Class for Matrices consisting of other matrices. This matrix is + * a matrix that consists of zero, one or more Matrices's which are + * arranged like this: \f$ M_{\rm compound} = + * \left(\begin{array}{cccc}M_{00} & M_{01} & \ldots & M_{0,{\rm + * ncomp\_cols}-1} \\ \dots &&&\dots \\ M_{{\rm ncomp\_rows}-1,0} & + * M_{{\rm ncomp\_rows}-1,1} & \dots & M_{{\rm ncomp\_rows}-1,{\rm + * ncomp\_cols}-1}\end{array}\right)\f$. The individual components + * can be associated to different MatrixSpaces. The individual + * components can also be const and non-const Matrices. If a + * component is not set (i.e., it's pointer is NULL), then this + * components is treated like a zero-matrix of appropriate + * dimensions. + */ + class CompoundMatrix : public Matrix + { + public: + + /**@name Constructors / Destructors */ + //@{ + + /** Constructor, taking the owner_space. The owner_space has to + * be defined, so that at each block row and column contain at + * least one non-NULL component. The individual components can + * be set afterwards with the SeteComp and SetCompNonConst + * methods. + */ + CompoundMatrix(const CompoundMatrixSpace* owner_space); + + /** Destructor */ + virtual ~CompoundMatrix(); + //@} + + /** Method for setting an individual component at position (irow, + * icol) in the compound matrix. The counting of indices starts + * at 0. */ + void SetComp(Index irow, Index jcol, const Matrix& matrix); + + /** Method to set a non-const Matrix entry */ + void SetCompNonConst(Index irow, Index jcol, Matrix& matrix); + + /** Method to create a new matrix from the space for this block */ + void CreateBlockFromSpace(Index irow, Index jcol); + + /** Method for retrieving one block from the compound matrix as a + * const Matrix. + */ + SmartPtr<const Matrix> GetComp(Index irow, Index jcol) const + { + return ConstComp(irow, jcol); + } + + /** Method for retrieving one block from the compound matrix as a + * non-const Matrix. Note that calling this method with mark the + * CompoundMatrix as changed. Therefore, only use this method if + * you are intending to change the Matrix that you receive. */ + SmartPtr<Matrix> GetCompNonConst(Index irow, Index jcol) + { + ObjectChanged(); + return Comp(irow, jcol); + } + + /** Number of block rows of this compound matrix. */ + inline Index NComps_Rows() const; + /** Number of block colmuns of this compound matrix. */ + inline Index NComps_Cols() const; + + protected: + /**@name Methods overloaded from Matrix */ + //@{ + virtual void MultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + virtual void TransMultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + /** X = beta*X + alpha*(Matrix S^{-1} Z). Specialized implementation. + */ + virtual void AddMSinvZImpl(Number alpha, const Vector& S, const Vector& Z, + Vector& X) const; + + /** X = S^{-1} (r + alpha*Z*M^Td). Specialized implementation. + */ + virtual void SinvBlrmZMTdBrImpl(Number alpha, const Vector& S, + const Vector& R, const Vector& Z, + const Vector& D, Vector& X) const; + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). */ + virtual bool HasValidNumbersImpl() const; + + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; + + virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const; + + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + CompoundMatrix(); + + /** Copy Constructor */ + CompoundMatrix(const CompoundMatrix&); + + /** Overloaded Equals Operator */ + void operator=(const CompoundMatrix&); + //@} + + /** Matrix of matrix's containing the components */ + std::vector<std::vector<SmartPtr<Matrix> > > comps_; + + /** Matrix of const matrix's containing the components */ + std::vector<std::vector<SmartPtr<const Matrix> > > const_comps_; + + /** Copy of the owner_space ptr as a CompoundMatrixSpace instead + * of MatrixSpace */ + const CompoundMatrixSpace* owner_space_; + + /** boolean indicating if the compound matrix is in a "valid" state */ + mutable bool matrices_valid_; + + /** Method to check whether or not the matrices are valid */ + bool MatricesValid() const; + + inline const Matrix* ConstComp(Index irow, Index jcol) const; + + inline Matrix* Comp(Index irow, Index jcol); + }; + + /** This is the matrix space for CompoundMatrix. Before a CompoundMatrix + * can be created, at least one MatrixSpace has to be set per block + * row and column. Individual component MatrixSpace's can be set + * with the SetComp method. + */ + class CompoundMatrixSpace : public MatrixSpace + { + public: + /** @name Constructors / Destructors */ + //@{ + /** Constructor, given the number of row and columns blocks, as + * well as the totel number of rows and columns. + */ + CompoundMatrixSpace(Index ncomps_rows, + Index ncomps_cols, + Index total_nRows, + Index total_nCols); + + /** Destructor */ + ~CompoundMatrixSpace() + {} + //@} + + /** @name Methods for setting information about the components. */ + //@{ + /** Set the number nrows of rows in row-block number irow. */ + void SetBlockRows(Index irow, Index nrows); + + /** Set the number ncols of columns in column-block number jcol. */ + void SetBlockCols(Index jcol, Index ncols); + + /** Get the number nrows of rows in row-block number irow. */ + Index GetBlockRows(Index irow) const; + + /** Set the number ncols of columns in column-block number jcol. */ + Index GetBlockCols(Index jcol) const; + + /** Set the component MatrixSpace. If auto_allocate is true, then + * a new CompoundMatrix created later with MakeNew will have this + * component automatically created with the Matrix's MakeNew. + * Otherwise, the corresponding component will be NULL and has to + * be set with the SetComp methods of the CompoundMatrix. + */ + void SetCompSpace(Index irow, Index jcol, + const MatrixSpace& mat_space, + bool auto_allocate = false); + //@} + + /** Obtain the component MatrixSpace in block row irow and block + * column jcol. + */ + SmartPtr<const MatrixSpace> GetCompSpace(Index irow, Index jcol) const + { + DBG_ASSERT(irow<NComps_Rows()); + DBG_ASSERT(jcol<NComps_Cols()); + return comp_spaces_[irow][jcol]; + } + + /** @name Accessor methods */ + //@{ + /** Number of block rows */ + Index NComps_Rows() const + { + return ncomps_rows_; + } + /** Number of block columns */ + Index NComps_Cols() const + { + return ncomps_cols_; + } + + /** True if the blocks lie on the diagonal - can make some operations faster */ + bool Diagonal() const + { + return diagonal_; + } + //@} + + /** Method for creating a new matrix of this specific type. */ + CompoundMatrix* MakeNewCompoundMatrix() const; + + /** Overloaded MakeNew method for the MatrixSpace base class. + */ + virtual Matrix* MakeNew() const + { + return MakeNewCompoundMatrix(); + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default constructor */ + CompoundMatrixSpace(); + + /** Copy Constructor */ + CompoundMatrixSpace(const CompoundMatrixSpace&); + + /** Overloaded Equals Operator */ + CompoundMatrixSpace& operator=(const CompoundMatrixSpace&); + //@} + + /** Number of block rows */ + Index ncomps_rows_; + + /** Number of block columns */ + Index ncomps_cols_; + + /** Store whether or not the dimensions are valid */ + mutable bool dimensions_set_; + + /** 2-dim std::vector of matrix spaces for the components */ + std::vector<std::vector<SmartPtr<const MatrixSpace> > > comp_spaces_; + + /** 2-dim std::vector of booleans deciding whether to + * allocate a new matrix for the blocks automagically */ + std::vector<std::vector< bool > > allocate_block_; + + /** Vector of the number of rows in each comp column */ + std::vector<Index> block_rows_; + + /** Vector of the number of cols in each comp row */ + std::vector<Index> block_cols_; + + /** true if the CompoundMatrixSpace only has Matrix spaces along the diagonal. + * this means that the CompoundMatrix will only have matrices along the + * diagonal and it could make some operations more efficient + */ + bool diagonal_; + + /** Auxilliary function for debugging to set if all block + * dimensions have been set. */ + bool DimensionsSet() const; + }; + + /* inline methods */ + inline + Index CompoundMatrix::NComps_Rows() const + { + return owner_space_->NComps_Rows(); + } + + inline + Index CompoundMatrix::NComps_Cols() const + { + return owner_space_->NComps_Cols(); + } + + inline + const Matrix* CompoundMatrix::ConstComp(Index irow, Index jcol) const + { + DBG_ASSERT(irow < NComps_Rows()); + DBG_ASSERT(jcol < NComps_Cols()); + if (IsValid(comps_[irow][jcol])) { + return GetRawPtr(comps_[irow][jcol]); + } + else if (IsValid(const_comps_[irow][jcol])) { + return GetRawPtr(const_comps_[irow][jcol]); + } + + return NULL; + } + + inline + Matrix* CompoundMatrix::Comp(Index irow, Index jcol) + { + DBG_ASSERT(irow < NComps_Rows()); + DBG_ASSERT(jcol < NComps_Cols()); + return GetRawPtr(comps_[irow][jcol]); + } + +} // namespace Ipopt +#endif diff --git a/thirdparty/linux/include/coin/IpCompoundSymMatrix.hpp b/thirdparty/linux/include/coin/IpCompoundSymMatrix.hpp new file mode 100644 index 0000000..4ca18fe --- /dev/null +++ b/thirdparty/linux/include/coin/IpCompoundSymMatrix.hpp @@ -0,0 +1,283 @@ +// Copyright (C) 2004, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpCompoundSymMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPCOMPOUNDSYMMATRIX_HPP__ +#define __IPCOMPOUNDSYMMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpSymMatrix.hpp" + +namespace Ipopt +{ + + /* forward declarations */ + class CompoundSymMatrixSpace; + + /** Class for symmetric matrices consisting of other matrices. + * Here, the lower left block of the matrix is stored. + */ + class CompoundSymMatrix : public SymMatrix + { + public: + + /**@name Constructors / Destructors */ + //@{ + + /** Constructor, taking only the number for block components into the + * row and column direction. The owner_space has to be defined, so + * that at each block row and column contain at least one non-NULL + * component. + */ + CompoundSymMatrix(const CompoundSymMatrixSpace* owner_space); + + /** Destructor */ + ~CompoundSymMatrix(); + //@} + + /** Method for setting an individual component at position (irow, + * icol) in the compound matrix. The counting of indices starts + * at 0. Since this only the lower left components are stored, we need + * to have jcol<=irow, and if irow==jcol, the matrix must be a SymMatrix */ + void SetComp(Index irow, Index jcol, const Matrix& matrix); + + /** Non const version of the same method */ + void SetCompNonConst(Index irow, Index jcol, Matrix& matrix); + + /** Method for retrieving one block from the compound matrix. + * Since this only the lower left components are stored, we need + * to have jcol<=irow */ + SmartPtr<const Matrix> GetComp(Index irow, Index jcol) const + { + return ConstComp(irow,jcol); + } + + /** Non const version of GetComp. You should only use this method + * if you are intending to change the matrix you receive, since + * this CompoundSymMatrix will be marked as changed. */ + SmartPtr<Matrix> GetCompNonConst(Index irow, Index jcol) + { + ObjectChanged(); + return Comp(irow,jcol); + } + + /** Method for creating a new matrix of this specific type. */ + SmartPtr<CompoundSymMatrix> MakeNewCompoundSymMatrix() const; + + // The following don't seem to be necessary + /* Number of block rows of this compound matrix. */ + // Index NComps_NRows() const { return NComps_Dim(); } + + /* Number of block colmuns of this compound matrix. */ + // Index NComps_NCols() const { return NComps_Dim(); } + + /** Number of block rows and columns */ + Index NComps_Dim() const; + + protected: + /**@name Methods overloaded from matrix */ + //@{ + virtual void MultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). */ + virtual bool HasValidNumbersImpl() const; + + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; + + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + CompoundSymMatrix(); + + /** Copy Constructor */ + CompoundSymMatrix(const CompoundSymMatrix&); + + /** Overloaded Equals Operator */ + void operator=(const CompoundSymMatrix&); + //@} + + /** Vector of vectors containing the components */ + std::vector<std::vector<SmartPtr<Matrix> > > comps_; + + /** Vector of vectors containing the const components */ + std::vector<std::vector<SmartPtr<const Matrix> > > const_comps_; + + /** Copy of the owner_space ptr as a CompoundSymMatrixSpace */ + const CompoundSymMatrixSpace* owner_space_; + + /** boolean indicating if the compound matrix is in a "valid" state */ + mutable bool matrices_valid_; + + /** method to check wether or not the matrices are valid */ + bool MatricesValid() const; + + /** Internal method to return a const pointer to one of the comps */ + const Matrix* ConstComp(Index irow, Index jcol) const + { + DBG_ASSERT(irow < NComps_Dim()); + DBG_ASSERT(jcol <= irow); + if (IsValid(comps_[irow][jcol])) { + return GetRawPtr(comps_[irow][jcol]); + } + else if (IsValid(const_comps_[irow][jcol])) { + return GetRawPtr(const_comps_[irow][jcol]); + } + + return NULL; + } + + /** Internal method to return a non-const pointer to one of the comps */ + Matrix* Comp(Index irow, Index jcol) + { + DBG_ASSERT(irow < NComps_Dim()); + DBG_ASSERT(jcol <= irow); + // We shouldn't be asking for a non-const if this entry holds a + // const one... + DBG_ASSERT(IsNull(const_comps_[irow][jcol])); + if (IsValid(comps_[irow][jcol])) { + return GetRawPtr(comps_[irow][jcol]); + } + + return NULL; + } + }; + + /** This is the matrix space for CompoundSymMatrix. Before a + * CompoundSymMatrix can be created, at least one SymMatrixSpace has + * to be set per block row and column. Individual component + * SymMatrixSpace's can be set with the SetComp method. + */ + class CompoundSymMatrixSpace : public SymMatrixSpace + { + public: + /** @name Constructors / Destructors */ + //@{ + /** Constructor, given the number of blocks (same for rows and + * columns), as well as the total dimension of the matrix. + */ + CompoundSymMatrixSpace(Index ncomp_spaces, Index total_dim); + + /** Destructor */ + ~CompoundSymMatrixSpace() + {} + //@} + + /** @name Methods for setting information about the components. */ + //@{ + /** Set the dimension dim for block row (or column) irow_jcol */ + void SetBlockDim(Index irow_jcol, Index dim); + + /** Get the dimension dim for block row (or column) irow_jcol */ + Index GetBlockDim(Index irow_jcol) const; + + /** Set the component SymMatrixSpace. If auto_allocate is true, then + * a new CompoundSymMatrix created later with MakeNew will have this + * component automatically created with the SymMatrix's MakeNew. + * Otherwise, the corresponding component will be NULL and has to + * be set with the SetComp methods of the CompoundSymMatrix. + */ + void SetCompSpace(Index irow, Index jcol, + const MatrixSpace& mat_space, + bool auto_allocate = false); + //@} + + /** Obtain the component MatrixSpace in block row irow and block + * column jcol. + */ + SmartPtr<const MatrixSpace> GetCompSpace(Index irow, Index jcol) const + { + DBG_ASSERT(irow<ncomp_spaces_); + DBG_ASSERT(jcol<=irow); + return comp_spaces_[irow][jcol]; + } + + /** @name Accessor methods */ + //@{ + Index NComps_Dim() const + { + return ncomp_spaces_; + } + //@} + + /** Method for creating a new matrix of this specific type. */ + CompoundSymMatrix* MakeNewCompoundSymMatrix() const; + + /** Overloaded MakeNew method for the SymMatrixSpace base class. + */ + virtual SymMatrix* MakeNewSymMatrix() const + { + return MakeNewCompoundSymMatrix(); + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default constructor */ + CompoundSymMatrixSpace(); + + /** Copy Constructor */ + CompoundSymMatrixSpace(const CompoundSymMatrix&); + + /** Overloaded Equals Operator */ + CompoundSymMatrixSpace& operator=(const CompoundSymMatrixSpace&); + //@} + + /** Number of components per row and column */ + Index ncomp_spaces_; + + /** Vector of the number of rows in each comp column, + * Since this is symmetric, this is also the number + * of columns in each row, hence, it is the dimension + * each of the diagonals */ + std::vector<Index> block_dim_; + + /** 2-dim std::vector of matrix spaces for the components. Only + * the lower right part is stored. */ + std::vector<std::vector<SmartPtr<const MatrixSpace> > > comp_spaces_; + + /** 2-dim std::vector of booleans deciding whether to + * allocate a new matrix for the blocks automagically */ + std::vector<std::vector< bool > > allocate_block_; + + /** boolean indicating if the compound matrix space is in a "valid" state */ + mutable bool dimensions_set_; + + /** Method to check whether or not the spaces are valid */ + bool DimensionsSet() const; + }; + + inline + SmartPtr<CompoundSymMatrix> CompoundSymMatrix::MakeNewCompoundSymMatrix() const + { + return owner_space_->MakeNewCompoundSymMatrix(); + } + +} // namespace Ipopt +#endif diff --git a/thirdparty/linux/include/coin/IpConvCheck.hpp b/thirdparty/linux/include/coin/IpConvCheck.hpp new file mode 100644 index 0000000..033fce4 --- /dev/null +++ b/thirdparty/linux/include/coin/IpConvCheck.hpp @@ -0,0 +1,87 @@ +// Copyright (C) 2004, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpConvCheck.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPCONVCHECK_HPP__ +#define __IPCONVCHECK_HPP__ + +#include "IpAlgStrategy.hpp" + +namespace Ipopt +{ + + /** Base class for checking the algorithm + * termination criteria. + */ + class ConvergenceCheck : public AlgorithmStrategyObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Constructor */ + ConvergenceCheck() + {} + + /** Default destructor */ + virtual ~ConvergenceCheck() + {} + //@} + + /** Convergence return enum */ + enum ConvergenceStatus { + CONTINUE, + CONVERGED, + CONVERGED_TO_ACCEPTABLE_POINT, + MAXITER_EXCEEDED, + CPUTIME_EXCEEDED, + DIVERGING, + USER_STOP, + FAILED + }; + + /** overloaded from AlgorithmStrategyObject */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix) = 0; + + /** Pure virtual method for performing the convergence test. If + * call_intermediate_callback is true, the user callback method + * in the NLP should be called in order to see if the user + * requests an early termination. */ + virtual ConvergenceStatus + CheckConvergence(bool call_intermediate_callback = true) = 0; + + /** Method for testing if the current iterate is considered to + * satisfy the "accptable level" of accuracy. The idea is that + * if the desired convergence tolerance cannot be achieved, the + * algorithm might stop after a number of acceptable points have + * been encountered. */ + virtual bool CurrentIsAcceptable()=0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + // ConvergenceCheck(); + + /** Copy Constructor */ + ConvergenceCheck(const ConvergenceCheck&); + + /** Overloaded Equals Operator */ + void operator=(const ConvergenceCheck&); + //@} + + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpDiagMatrix.hpp b/thirdparty/linux/include/coin/IpDiagMatrix.hpp new file mode 100644 index 0000000..d912e77 --- /dev/null +++ b/thirdparty/linux/include/coin/IpDiagMatrix.hpp @@ -0,0 +1,141 @@ +// Copyright (C) 2004, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpDiagMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPDIAGMATRIX_HPP__ +#define __IPDIAGMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpSymMatrix.hpp" + +namespace Ipopt +{ + + /** Class for diagonal matrices. The diagonal is stored as a + * Vector. */ + class DiagMatrix : public SymMatrix + { + public: + + /**@name Constructors / Destructors */ + //@{ + + /** Constructor, given the corresponding matrix space. */ + DiagMatrix(const SymMatrixSpace* owner_space); + + /** Destructor */ + ~DiagMatrix(); + //@} + + /** Method for setting the diagonal elements (as a Vector). */ + void SetDiag(const Vector& diag) + { + diag_ = &diag; + } + + /** Method for setting the diagonal elements. */ + SmartPtr<const Vector> GetDiag() const + { + return diag_; + } + + protected: + /**@name Methods overloaded from matrix */ + //@{ + virtual void MultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). */ + virtual bool HasValidNumbersImpl() const; + + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; + + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + DiagMatrix(); + + /** Copy Constructor */ + DiagMatrix(const DiagMatrix&); + + /** Overloaded Equals Operator */ + void operator=(const DiagMatrix&); + //@} + + /** Vector storing the diagonal elements */ + SmartPtr<const Vector> diag_; + }; + + /** This is the matrix space for DiagMatrix. */ + class DiagMatrixSpace : public SymMatrixSpace + { + public: + /** @name Constructors / Destructors */ + //@{ + /** Constructor, given the dimension of the matrix. */ + DiagMatrixSpace(Index dim) + : + SymMatrixSpace(dim) + {} + + /** Destructor */ + virtual ~DiagMatrixSpace() + {} + //@} + + /** Overloaded MakeNew method for the SymMatrixSpace base class. + */ + virtual SymMatrix* MakeNewSymMatrix() const + { + return MakeNewDiagMatrix(); + } + + /** Method for creating a new matrix of this specific type. */ + DiagMatrix* MakeNewDiagMatrix() const + { + return new DiagMatrix(this); + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + DiagMatrixSpace(); + + /** Copy Constructor */ + DiagMatrixSpace(const DiagMatrixSpace&); + + /** Overloaded Equals Operator */ + void operator=(const DiagMatrixSpace&); + //@} + + }; + +} // namespace Ipopt +#endif diff --git a/thirdparty/linux/include/coin/IpEqMultCalculator.hpp b/thirdparty/linux/include/coin/IpEqMultCalculator.hpp new file mode 100644 index 0000000..7c3cb20 --- /dev/null +++ b/thirdparty/linux/include/coin/IpEqMultCalculator.hpp @@ -0,0 +1,64 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpEqMultCalculator.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-09-23 + +#ifndef __IPEQMULTCALCULATOR_HPP__ +#define __IPEQMULTCALCULATOR_HPP__ + +#include "IpUtils.hpp" +#include "IpAlgStrategy.hpp" + +namespace Ipopt +{ + /** Base Class for objects that compute estimates for the equality + * constraint multipliers y_c and y_d. For example, this is the + * base class for objects for computing least square multipliers or + * coordinate multipliers. */ + class EqMultiplierCalculator: public AlgorithmStrategyObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default Constructor. */ + EqMultiplierCalculator() + {} + /** Default destructor */ + virtual ~EqMultiplierCalculator() + {} + //@} + + /** overloaded from AlgorithmStrategyObject */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix) = 0; + + /** This method computes the estimates for y_c and y_d at the + * current point. If the estimates cannot be computed (e.g. some + * linear system is singular), the return value of this method is + * false. */ + virtual bool CalculateMultipliers(Vector& y_c, + Vector& y_d) = 0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + EqMultiplierCalculator(const EqMultiplierCalculator&); + + /** Overloaded Equals Operator */ + void operator=(const EqMultiplierCalculator&); + //@} + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpGenTMatrix.hpp b/thirdparty/linux/include/coin/IpGenTMatrix.hpp new file mode 100644 index 0000000..059bfea --- /dev/null +++ b/thirdparty/linux/include/coin/IpGenTMatrix.hpp @@ -0,0 +1,264 @@ +// Copyright (C) 2004, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpGenTMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPGENTMATRIX_HPP__ +#define __IPGENTMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpMatrix.hpp" + +namespace Ipopt +{ + + /* forward declarations */ + class GenTMatrixSpace; + + /** Class for general matrices stored in triplet format. In the + * triplet format, the nonzeros elements of a general matrix is + * stored in three arrays, Irow, Jcol, and Values, all of length + * Nonzeros. The first two arrays indicate the location of a + * non-zero element (row and column indices), and the last array + * stores the value at that location. If nonzero elements are + * listed more than once, their values are added. + * + * The structure of the nonzeros (i.e. the arrays Irow and Jcol) + * cannot be changed after the matrix can been initialized. Only + * the values of the nonzero elements can be modified. + * + * Note that the first row and column of a matrix has index 1, not + * 0. + */ + class GenTMatrix : public Matrix + { + public: + + /**@name Constructors / Destructors */ + //@{ + + /** Constructor, taking the owner_space. + */ + GenTMatrix(const GenTMatrixSpace* owner_space); + + /** Destructor */ + ~GenTMatrix(); + //@} + + /**@name Changing the Values.*/ + //@{ + /** Set values of nonzero elements. The values of the nonzero + * elements are copied from the incoming Number array. Important: + * It is assume that the order of the values in Values + * corresponds to the one of Irn and Jcn given to one of the + * constructors above. */ + void SetValues(const Number* Values); + //@} + + /** @name Accessor Methods */ + //@{ + /** Number of nonzero entries */ + Index Nonzeros() const; + + /** Array with Row indices (counting starts at 1) */ + const Index* Irows() const; + + /** Array with Column indices (counting starts at 1) */ + const Index* Jcols() const; + + /** Array with nonzero values (const version). */ + const Number* Values() const + { + return values_; + } + + /** Array with the nonzero values of this matrix (non-const + * version). Use this method only if you are intending to change + * the values, because the GenTMatrix will be marked as changed. + */ + Number* Values() + { + ObjectChanged(); + initialized_ = true; + return values_; + } + //@} + + protected: + /**@name Overloaded methods from Matrix base class*/ + //@{ + virtual void MultVectorImpl(Number alpha, const Vector &x, Number beta, + Vector &y) const; + + virtual void TransMultVectorImpl(Number alpha, const Vector& x, Number beta, + Vector& y) const; + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). */ + virtual bool HasValidNumbersImpl() const; + + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; + + virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const; + + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const + { + PrintImplOffset(jnlst, level, category, name, indent, prefix, 0); + } + //@} + + void PrintImplOffset(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix, + Index offset) const; + + friend class ParGenMatrix; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + GenTMatrix(); + + /** Copy Constructor */ + GenTMatrix(const GenTMatrix&); + + /** Overloaded Equals Operator */ + void operator=(const GenTMatrix&); + //@} + + /** Copy of the owner space as a GenTMatrixSpace instead of + * a MatrixSpace + */ + const GenTMatrixSpace* owner_space_; + + /** Values of nonzeros */ + Number* values_; + + /** Flag for Initialization */ + bool initialized_; + + }; + + /** This is the matrix space for a GenTMatrix with fixed sparsity + * structure. The sparsity structure is stored here in the matrix + * space. + */ + class GenTMatrixSpace : public MatrixSpace + { + public: + /** @name Constructors / Destructors */ + //@{ + /** Constructor, given the number of rows and columns, as well as + * the number of nonzeros and the position of the nonzero + * elements. Note that the counting of the nonzeros starts a 1, + * i.e., iRows[i]==1 and jCols[i]==1 refers to the first element + * in the first row. This is in accordance with the HSL data + * structure. + */ + GenTMatrixSpace(Index nRows, Index nCols, + Index nonZeros, + const Index* iRows, const Index* jCols); + + /** Destructor */ + ~GenTMatrixSpace() + { + delete [] iRows_; + delete [] jCols_; + } + //@} + + /** Method for creating a new matrix of this specific type. */ + GenTMatrix* MakeNewGenTMatrix() const + { + return new GenTMatrix(this); + } + + /** Overloaded MakeNew method for the MatrixSpace base class. + */ + virtual Matrix* MakeNew() const + { + return MakeNewGenTMatrix(); + } + + /**@name Methods describing Matrix structure */ + //@{ + /** Number of non-zeros in the sparse matrix */ + Index Nonzeros() const + { + return nonZeros_; + } + + /** Row index of each non-zero element (counting starts at 1) */ + const Index* Irows() const + { + return iRows_; + } + + /** Column index of each non-zero element (counting starts at 1) */ + const Index* Jcols() const + { + return jCols_; + } + //@} + + private: + /** @name Sparsity structure of matrices generated by this matrix + * space. + */ + //@{ + const Index nonZeros_; + Index* jCols_; + Index* iRows_; + //@} + + /** This method is only for the GenTMatrix to call in order + * to allocate internal storage */ + Number* AllocateInternalStorage() const; + + /** This method is only for the GenTMatrix to call in order + * to de-allocate internal storage */ + void FreeInternalStorage(Number* values) const; + + friend class GenTMatrix; + }; + + /* inline methods */ + inline + Index GenTMatrix::Nonzeros() const + { + return owner_space_->Nonzeros(); + } + + inline + const Index* GenTMatrix::Irows() const + { + return owner_space_->Irows(); + } + + inline + const Index* GenTMatrix::Jcols() const + { + return owner_space_->Jcols(); + } + + +} // namespace Ipopt +#endif diff --git a/thirdparty/linux/include/coin/IpHessianUpdater.hpp b/thirdparty/linux/include/coin/IpHessianUpdater.hpp new file mode 100644 index 0000000..a3912d6 --- /dev/null +++ b/thirdparty/linux/include/coin/IpHessianUpdater.hpp @@ -0,0 +1,65 @@ +// Copyright (C) 2005, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpHessianUpdater.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Andreas Waechter IBM 2005-12-26 + +#ifndef __IPHESSIANUPDATER_HPP__ +#define __IPHESSIANUPDATER_HPP__ + +#include "IpAlgStrategy.hpp" + +namespace Ipopt +{ + + /** Abstract base class for objects responsible for updating the + * Hessian information. This can be done using exact second + * derivatives from the NLP, or by a quasi-Newton Option. The + * result is put into the W field in IpData. + */ + class HessianUpdater : public AlgorithmStrategyObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default Constructor */ + HessianUpdater() + {} + + /** Default destructor */ + virtual ~HessianUpdater() + {} + //@} + + /** overloaded from AlgorithmStrategyObject */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix) = 0; + + /** Update the Hessian based on the current information in IpData, + * and possibly on information from previous calls. + */ + virtual void UpdateHessian() = 0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + HessianUpdater(const HessianUpdater&); + + /** Overloaded Equals Operator */ + void operator=(const HessianUpdater&); + //@} + + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpIdentityMatrix.hpp b/thirdparty/linux/include/coin/IpIdentityMatrix.hpp new file mode 100644 index 0000000..8032306 --- /dev/null +++ b/thirdparty/linux/include/coin/IpIdentityMatrix.hpp @@ -0,0 +1,149 @@ +// Copyright (C) 2004, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpIdentityMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPIDENTITYMATRIX_HPP__ +#define __IPIDENTITYMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpSymMatrix.hpp" + +namespace Ipopt +{ + + /** Class for Matrices which are multiples of the identity matrix. + * + */ + class IdentityMatrix : public SymMatrix + { + public: + + /**@name Constructors / Destructors */ + //@{ + + /** Constructor, initializing with dimensions of the matrix + * (true identity matrix). + */ + IdentityMatrix(const SymMatrixSpace* owner_space); + + /** Destructor */ + ~IdentityMatrix(); + //@} + + /** Method for setting the factor for the identity matrix. */ + void SetFactor(Number factor) + { + factor_ = factor; + } + + /** Method for getting the factor for the identity matrix. */ + Number GetFactor() const + { + return factor_; + } + + /** Method for obtaining the dimention of the matrix. */ + Index Dim() const; + + protected: + /**@name Methods overloaded from matrix */ + //@{ + virtual void MultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + virtual void AddMSinvZImpl(Number alpha, const Vector& S, + const Vector& Z, Vector& X) const; + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). */ + virtual bool HasValidNumbersImpl() const; + + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; + + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + IdentityMatrix(); + + /** Copy Constructor */ + IdentityMatrix(const IdentityMatrix&); + + /** Overloaded Equals Operator */ + void operator=(const IdentityMatrix&); + //@} + + /** Scaling factor for this identity matrix */ + Number factor_; + }; + + /** This is the matrix space for IdentityMatrix. */ + class IdentityMatrixSpace : public SymMatrixSpace + { + public: + /** @name Constructors / Destructors */ + //@{ + /** Constructor, given the dimension of the matrix. */ + IdentityMatrixSpace(Index dim) + : + SymMatrixSpace(dim) + {} + + /** Destructor */ + virtual ~IdentityMatrixSpace() + {} + //@} + + /** Overloaded MakeNew method for the SymMatrixSpace base class. + */ + virtual SymMatrix* MakeNewSymMatrix() const + { + return MakeNewIdentityMatrix(); + } + + /** Method for creating a new matrix of this specific type. */ + IdentityMatrix* MakeNewIdentityMatrix() const + { + return new IdentityMatrix(this); + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + IdentityMatrixSpace(); + + /** Copy Constructor */ + IdentityMatrixSpace(const IdentityMatrixSpace&); + + /** Overloaded Equals Operator */ + void operator=(const IdentityMatrixSpace&); + //@} + }; + +} // namespace Ipopt +#endif diff --git a/thirdparty/linux/include/coin/IpIpoptAlg.hpp b/thirdparty/linux/include/coin/IpIpoptAlg.hpp new file mode 100644 index 0000000..60e3147 --- /dev/null +++ b/thirdparty/linux/include/coin/IpIpoptAlg.hpp @@ -0,0 +1,224 @@ +// Copyright (C) 2004, 2010 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpIpoptAlg.hpp 2167 2013-03-08 11:15:38Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPIPOPTALG_HPP__ +#define __IPIPOPTALG_HPP__ + +#include "IpIpoptNLP.hpp" +#include "IpAlgStrategy.hpp" +#include "IpSearchDirCalculator.hpp" +#include "IpLineSearch.hpp" +#include "IpMuUpdate.hpp" +#include "IpConvCheck.hpp" +#include "IpOptionsList.hpp" +#include "IpIterateInitializer.hpp" +#include "IpIterationOutput.hpp" +#include "IpAlgTypes.hpp" +#include "IpHessianUpdater.hpp" +#include "IpEqMultCalculator.hpp" + +namespace Ipopt +{ + + /** @name Exceptions */ + //@{ + DECLARE_STD_EXCEPTION(STEP_COMPUTATION_FAILED); + //@} + + /** The main ipopt algorithm class. + * Main Ipopt algorithm class, contains the main optimize method, + * handles the execution of the optimization. + * The constructor initializes the data structures through the nlp, + * and the Optimize method then assumes that everything is + * initialized and ready to go. + * After an optimization is complete, the user can access the + * solution through the passed in ip_data structure. + * Multiple calls to the Optimize method are allowed as long as the + * structure of the problem remains the same (i.e. starting point + * or nlp parameter changes only). + */ + class IpoptAlgorithm : public AlgorithmStrategyObject + { + public: + + /**@name Constructors/Destructors */ + //@{ + /** Constructor. (The IpoptAlgorithm uses smart pointers for these + * passed-in pieces to make sure that a user of IpoptAlgoroithm + * cannot pass in an object created on the stack!) + */ + IpoptAlgorithm(const SmartPtr<SearchDirectionCalculator>& search_dir_calculator, + const SmartPtr<LineSearch>& line_search, + const SmartPtr<MuUpdate>& mu_update, + const SmartPtr<ConvergenceCheck>& conv_check, + const SmartPtr<IterateInitializer>& iterate_initializer, + const SmartPtr<IterationOutput>& iter_output, + const SmartPtr<HessianUpdater>& hessian_updater, + const SmartPtr<EqMultiplierCalculator>& eq_multiplier_calculator = NULL); + + /** Default destructor */ + virtual ~IpoptAlgorithm(); + //@} + + + /** overloaded from AlgorithmStrategyObject */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix); + + /** Main solve method. */ + SolverReturn Optimize(bool isResto = false); + + /** Methods for IpoptType */ + //@{ + static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); + //@} + + /**@name Access to internal strategy objects */ + //@{ + SmartPtr<SearchDirectionCalculator> SearchDirCalc() + { + return search_dir_calculator_; + } + //@} + + static void print_copyright_message(const Journalist& jnlst); + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + IpoptAlgorithm(); + + /** Copy Constructor */ + IpoptAlgorithm(const IpoptAlgorithm&); + + /** Overloaded Equals Operator */ + void operator=(const IpoptAlgorithm&); + //@} + + /** @name Strategy objects */ + //@{ + SmartPtr<SearchDirectionCalculator> search_dir_calculator_; + SmartPtr<LineSearch> line_search_; + SmartPtr<MuUpdate> mu_update_; + SmartPtr<ConvergenceCheck> conv_check_; + SmartPtr<IterateInitializer> iterate_initializer_; + SmartPtr<IterationOutput> iter_output_; + SmartPtr<HessianUpdater> hessian_updater_; + /** The multipler calculator (for y_c and y_d) has to be set only + * if option recalc_y is set to true */ + SmartPtr<EqMultiplierCalculator> eq_multiplier_calculator_; + //@} + + /** @name Main steps of the algorthim */ + //@{ + /** Method for updating the current Hessian. This can either just + * evaluate the exact Hessian (based on the current iterate), or + * perform a quasi-Newton update. + */ + void UpdateHessian(); + + /** Method to update the barrier parameter. Returns false, if the + * algorithm can't continue with the regular procedure and needs + * to revert to a fallback mechanism in the line search (such as + * restoration phase) */ + bool UpdateBarrierParameter(); + + /** Method to setup the call to the PDSystemSolver. Returns + * false, if the algorithm can't continue with the regular + * procedure and needs to revert to a fallback mechanism in the + * line search (such as restoration phase) */ + bool ComputeSearchDirection(); + + /** Method computing the new iterate (usually vialine search). + * The acceptable point is the one in trial after return. + */ + void ComputeAcceptableTrialPoint(); + + /** Method for accepting the trial point as the new iteration, + * possibly after adjusting the variable bounds in the NLP. */ + void AcceptTrialPoint(); + + /** Do all the output for one iteration */ + void OutputIteration(); + + /** Sets up initial values for the iterates, + * Corrects the initial values for x and s (force in bounds) + */ + void InitializeIterates(); + + /** Print the problem size statistics */ + void PrintProblemStatistics(); + + /** Compute the Lagrangian multipliers for a feasibility problem*/ + void ComputeFeasibilityMultipliers(); + //@} + + /** @name internal flags */ + //@{ + /** Flag indicating if the statistic should not be printed */ + bool skip_print_problem_stats_; + //@} + + /** @name Algorithmic parameters */ + //@{ + /** safeguard factor for bound multipliers. If value >= 1, then + * the dual variables will never deviate from the primal estimate + * by more than the factors kappa_sigma and 1./kappa_sigma. + */ + Number kappa_sigma_; + /** Flag indicating whether the y multipliers should be + * recalculated with the eq_mutliplier_calculator object for each + * new point. */ + bool recalc_y_; + /** Feasibility threshold for recalc_y */ + Number recalc_y_feas_tol_; + /** Flag indicating if we want to do Mehrotras's algorithm. This + * means that a number of options are ignored, or have to be set + * (or are automatically set) to certain values. */ + bool mehrotra_algorithm_; + /** String specifying linear solver */ + std::string linear_solver_; + //@} + + /** @name auxiliary functions */ + //@{ + void calc_number_of_bounds( + const Vector& x, + const Vector& x_L, + const Vector& x_U, + const Matrix& Px_L, + const Matrix& Px_U, + Index& n_tot, + Index& n_only_lower, + Index& n_both, + Index& n_only_upper); + + /** Method for ensuring that the trial multipliers are not too far + * from the primal estime. If a correction is made, new_trial_z + * is a pointer to the corrected multiplier, and the return value + * of this method give the magnitutde of the largest correction + * that we done. If no correction was made, new_trial_z is just + * a pointer to trial_z, and the return value is zero. + */ + Number correct_bound_multiplier(const Vector& trial_z, + const Vector& trial_slack, + const Vector& trial_compl, + SmartPtr<const Vector>& new_trial_z); + //@} + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpIpoptApplication.hpp b/thirdparty/linux/include/coin/IpIpoptApplication.hpp index 5f59292..0febc94 100644 --- a/thirdparty/linux/include/coin/IpIpoptApplication.hpp +++ b/thirdparty/linux/include/coin/IpIpoptApplication.hpp @@ -2,7 +2,7 @@ // All Rights Reserved. // This code is published under the Eclipse Public License. // -// $Id: IpIpoptApplication.hpp 2398 2013-10-19 18:08:59Z stefan $ +// $Id: IpIpoptApplication.hpp 2617 2015-11-26 16:00:20Z stefan $ // // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 @@ -69,8 +69,10 @@ namespace Ipopt * problem in the initialization (such as an invalid option). * You should call one of the initialization methods at some * point before the first optimize call. + * Set @par allow_clobber to true if you want to allow + * overwriting options that are set by the input stream. */ - virtual ApplicationReturnStatus Initialize(std::istream& is); + virtual ApplicationReturnStatus Initialize(std::istream& is, bool allow_clobber = false); /** Initialization method. This method reads options from the * params file and initializes the journalists. It returns * something other than Solve_Succeeded if there was a @@ -79,16 +81,35 @@ namespace Ipopt * point before the first optimize call. * Note: You can skip the processing of a params file by * setting params_file to "". + * Set @par allow_clobber to true if you want to allow + * overwriting options that are set by the params file. */ - virtual ApplicationReturnStatus Initialize(std::string params_file); + virtual ApplicationReturnStatus Initialize(std::string params_file, bool allow_clobber = false); + /** Initialization method. This method reads options from the + * params file and initializes the journalists. It returns + * something other than Solve_Succeeded if there was a + * problem in the initialization (such as an invalid option). + * You should call one of the initialization methods at some + * point before the first optimize call. + * Note: You can skip the processing of a params file by + * setting params_file to "". + * Set @par allow_clobber to true if you want to allow + * overwriting options that are set by the params file. + */ + virtual ApplicationReturnStatus Initialize(const char* params_file, bool allow_clobber = false) + { + return Initialize(std::string(params_file), allow_clobber); + } /** Initialize method. This method reads the options file specified * by the option_file_name option and initializes the journalists. * You should call this method at some point before the first optimize * call. * It returns something other than Solve_Succeeded if there was a * problem in the initialization (such as an invalid option). + * Set @par allow_clobber to true if you want to allow + * overwriting options that are set by the options file. */ - virtual ApplicationReturnStatus Initialize(); + virtual ApplicationReturnStatus Initialize(bool allow_clobber = false); /**@name Solve methods */ //@{ diff --git a/thirdparty/linux/include/coin/IpIterateInitializer.hpp b/thirdparty/linux/include/coin/IpIterateInitializer.hpp new file mode 100644 index 0000000..d179651 --- /dev/null +++ b/thirdparty/linux/include/coin/IpIterateInitializer.hpp @@ -0,0 +1,64 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpIterateInitializer.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-09-24 + +#ifndef __IPITERATEINITIALIZER_HPP__ +#define __IPITERATEINITIALIZER_HPP__ + +#include "IpAlgStrategy.hpp" +#include "IpIpoptNLP.hpp" +#include "IpIpoptData.hpp" +#include "IpIpoptCalculatedQuantities.hpp" + +namespace Ipopt +{ + + /** Base class for all methods for initializing the iterates. + */ + class IterateInitializer: public AlgorithmStrategyObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default Constructor */ + IterateInitializer() + {} + + /** Default destructor */ + virtual ~IterateInitializer() + {} + //@} + + /** overloaded from AlgorithmStrategyObject */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix) = 0; + + /** Compute the initial iterates and set the into the curr field + * of the ip_data object. */ + virtual bool SetInitialIterates() = 0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + IterateInitializer(const IterateInitializer&); + + /** Overloaded Equals Operator */ + void operator=(const IterateInitializer&); + //@} + + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpIterationOutput.hpp b/thirdparty/linux/include/coin/IpIterationOutput.hpp new file mode 100644 index 0000000..95fd650 --- /dev/null +++ b/thirdparty/linux/include/coin/IpIterationOutput.hpp @@ -0,0 +1,71 @@ +// Copyright (C) 2004, 2011 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpIterationOutput.hpp 2020 2011-06-16 20:46:16Z andreasw $ +// +// Authors: Andreas Waechter, Carl Laird IBM 2004-09-27 + +#ifndef __IPITERATIONOUTPUT_HPP__ +#define __IPITERATIONOUTPUT_HPP__ + +#include "IpAlgStrategy.hpp" +#include "IpIpoptNLP.hpp" +#include "IpIpoptData.hpp" +#include "IpIpoptCalculatedQuantities.hpp" + +namespace Ipopt +{ + + /** Base class for objects that do the output summary per iteration. + */ + class IterationOutput: public AlgorithmStrategyObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default Constructor */ + IterationOutput() + {} + + /** Default destructor */ + virtual ~IterationOutput() + {} + //@} + + /** overloaded from AlgorithmStrategyObject */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix) = 0; + + /** Method to do all the summary output per iteration. This + * include the one-line summary output as well as writing the + * details about the iterates if desired */ + virtual void WriteOutput() = 0; + + protected: + /** enumeration for different inf_pr output options */ + enum InfPrOutput + { + INTERNAL=0, + ORIGINAL + }; + + private: + /**@name Default Compiler Generated Methods (Hidden to avoid + * implicit creation/calling). These methods are not implemented + * and we do not want the compiler to implement them for us, so we + * declare them private and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + IterationOutput(const IterationOutput&); + + /** Overloaded Equals Operator */ + void operator=(const IterationOutput&); + //@} + + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpLineSearch.hpp b/thirdparty/linux/include/coin/IpLineSearch.hpp new file mode 100644 index 0000000..70c11f1 --- /dev/null +++ b/thirdparty/linux/include/coin/IpLineSearch.hpp @@ -0,0 +1,96 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpLineSearch.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPLINESEARCH_HPP__ +#define __IPLINESEARCH_HPP__ + +#include "IpAlgStrategy.hpp" +#include "IpIpoptCalculatedQuantities.hpp" + +namespace Ipopt +{ + + /** Base class for line search objects. + */ + class LineSearch : public AlgorithmStrategyObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default Constructor */ + LineSearch() + {} + + /** Default destructor */ + virtual ~LineSearch() + {} + //@} + + /** Perform the line search. As search direction the delta + * in the data object is used + */ + virtual void FindAcceptableTrialPoint() = 0; + + /** Reset the line search. + * This function should be called if all previous information + * should be discarded when the line search is performed the + * next time. For example, this method should be called after + * the barrier parameter is changed. + */ + virtual void Reset() = 0; + + /** Set flag indicating whether a very rigorous line search should + * be performed. If this flag is set to true, the line search + * algorithm might decide to abort the line search and not to + * accept a new iterate. If the line search decided not to + * accept a new iterate, the return value of + * CheckSkippedLineSearch() is true at the next call. For + * example, in the non-monotone barrier parameter update + * procedure, the filter algorithm should not switch to the + * restoration phase in the free mode; instead, the algorithm + * should swtich to the fixed mode. + */ + virtual void SetRigorousLineSearch(bool rigorous) = 0; + + /** Check if the line search procedure didn't accept a new iterate + * during the last call of FindAcceptableTrialPoint(). + * + */ + virtual bool CheckSkippedLineSearch() = 0; + + /** This method should be called if the optimization process + * requires the line search object to switch to some fallback + * mechanism (like the restoration phase), when the regular + * optimization procedure cannot be continued (for example, + * because the search direction could not be computed). This + * will cause the line search object to immediately proceed with + * this mechanism when FindAcceptableTrialPoint() is call. This + * method returns false if no fallback mechanism is available. */ + virtual bool ActivateFallbackMechanism() = 0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Copy Constructor */ + LineSearch(const LineSearch&); + + /** Overloaded Equals Operator */ + void operator=(const LineSearch&); + //@} + + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpMuUpdate.hpp b/thirdparty/linux/include/coin/IpMuUpdate.hpp new file mode 100644 index 0000000..b6c1d9c --- /dev/null +++ b/thirdparty/linux/include/coin/IpMuUpdate.hpp @@ -0,0 +1,69 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpMuUpdate.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPMUUPDATE_HPP__ +#define __IPMUUPDATE_HPP__ + +#include "IpAlgStrategy.hpp" + +namespace Ipopt +{ + /** Abstract Base Class for classes that implement methods for computing + * the barrier and fraction-to-the-boundary rule parameter for the + * current iteration. + */ + class MuUpdate : public AlgorithmStrategyObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Default Constructor */ + MuUpdate() + {} + + /** Default destructor */ + virtual ~MuUpdate() + {} + //@} + + /** Initialize method - overloaded from AlgorithmStrategyObject */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix) = 0; + + /** Method for determining the barrier parameter for the next + * iteration. A LineSearch object is passed, so that this method + * can call the Reset method in the LineSearch object, for + * example when then barrier parameter is changed. This method is + * also responsible for setting the fraction-to-the-boundary + * parameter tau. This method returns false if the update could + * not be performed and the algorithm should revert to an + * emergency fallback mechanism. */ + virtual bool UpdateBarrierParameter() = 0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + + /** Copy Constructor */ + MuUpdate(const MuUpdate&); + + /** Overloaded Equals Operator */ + void operator=(const MuUpdate&); + //@} + + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpOptionsList.hpp b/thirdparty/linux/include/coin/IpOptionsList.hpp index 382428e..a17863f 100644 --- a/thirdparty/linux/include/coin/IpOptionsList.hpp +++ b/thirdparty/linux/include/coin/IpOptionsList.hpp @@ -2,7 +2,7 @@ // All Rights Reserved. // This code is published under the Eclipse Public License. // -// $Id: IpOptionsList.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// $Id: IpOptionsList.hpp 2613 2015-11-04 14:42:02Z stefan $ // // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 @@ -232,7 +232,7 @@ namespace Ipopt /** Read options from the stream is. Returns false if * an error was encountered. */ - virtual bool ReadFromStream(const Journalist& jnlst, std::istream& is); + virtual bool ReadFromStream(const Journalist& jnlst, std::istream& is, bool allow_clobber = false); private: /**@name Default Compiler Generated Methods diff --git a/thirdparty/linux/include/coin/IpPDSystemSolver.hpp b/thirdparty/linux/include/coin/IpPDSystemSolver.hpp new file mode 100644 index 0000000..b436e67 --- /dev/null +++ b/thirdparty/linux/include/coin/IpPDSystemSolver.hpp @@ -0,0 +1,130 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpPDSystemSolver.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPPDSYSTEMSOLVER_HPP__ +#define __IPPDSYSTEMSOLVER_HPP__ + +#include "IpUtils.hpp" +#include "IpSymMatrix.hpp" +#include "IpAlgStrategy.hpp" +#include "IpIteratesVector.hpp" + +namespace Ipopt +{ + + /** Pure Primal Dual System Solver Base Class. + * This is the base class for all derived Primal-Dual System Solver Types. + * + * Here, we understand the primal-dual system as the following linear + * system: + * + * \f$ + * \left[\begin{array}{cccccccc} + * W & 0 & J_c^T & J_d^T & -P^x_L & P^x_U & 0 & 0 \\ + * 0 & 0 & 0 & -I & 0 & 0 & -P_L^d & P_U^d \\ + * J_c & 0 & 0 & 0 & 0 & 0 & 0 & 0\\ + * J_d & -I & 0 & 0 & 0 & 0 & 0 & 0\\ + * Z_L(P_L^x)^T & 0 & 0 & 0 & Sl^x_L & 0 & 0 & 0\\ + * -Z_U(P_U^x)^T & 0 & 0 & 0 & 0 & Sl^x_U & 0 & 0\\ + * 0 & V_L(P_L^d)^T & 0 & 0 & 0 & 0 & Sl^s_L & 0 \\ + * 0 & -V_U(P_U^d)^T & 0 & 0 & 0 & 0 & 0 & Sl^s_U \\ + * \end{array}\right] + * \left(\begin{array}{c} + * sol_x\\ sol_s\\ sol_c\\ sol_d\\ sol^z_L\\ sol^z_U\\ sol^v_L\\ + * sol^v_U + * \end{array}\right) = + * \left(\begin{array}{c} + * rhs_x\\ rhs_s\\ rhs_c\\ rhs_d\\ rhs^z_L\\ rhs^z_U\\ rhs^v_L\\ + * rhs^v_U + * \end{array}\right) + * \f$ + * + * Here, \f$Sl^x_L = (P^x_L)^T x - x_L\f$, + * \f$Sl^x_U = x_U - (P^x_U)^T x\f$, \f$Sl^d_L = (P^d_L)^T d(x) - d_L\f$, + * \f$Sl^d_U = d_U - (P^d_U)^T d(x)\f$. The results returned to the + * caller is \f$res = \alpha * sol + \beta * res\f$. + * + * The solution of this linear system (in order to compute the search + * direction of the algorthim) usually requires a considerable amount of + * computation time. Therefore, it is important to tailor the solution + * of this system to the characteristics of the problem. The purpose of + * this base class is to provide a generic interface to the algorithm + * that it can use whenever it requires a solution of the above system. + * Particular implementation can then be written to provide the methods + * defined here. + * + * It is implicitly assumed here, that the upper left 2 by 2 block + * is possibly modified (implicitly or explicitly) so that its + * projection onto the null space of the overall constraint + * Jacobian \f$\left[\begin{array}{cc}J_c & 0\\J_d & + * -I\end{array}\right]\f$ is positive definite. This is necessary + * to guarantee certain descent properties of the resulting search + * direction. For example, in the full space implementation, a + * multiple of the identity might be added to the upper left 2 by 2 + * block. + * + * Note that the Solve method might be called several times for different + * right hand sides, but with identical data. Therefore, if possible, + * an implemetation of PDSystem should check whether the incoming data has + * changed, and not redo factorization etc. unless necessary. + */ + class PDSystemSolver: public AlgorithmStrategyObject + { + public: + /** @name /Destructor */ + //@{ + /** Default Constructor */ + PDSystemSolver() + {} + + /** Default destructor */ + virtual ~PDSystemSolver() + {} + //@} + + /** overloaded from AlgorithmStrategyObject */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix) = 0; + + /** Solve the primal dual system, given one right hand side. If + * the flag allow_inexact is set to true, it is not necessary to + * solve the system to best accuracy; for example, we don't want + * iterative refinement during the computation of the second + * order correction. On the other hand, if improve_solution is + * true, the solution given in res should be improved (here beta + * has to be zero, and res is assume to be the solution for the + * system using rhs, without the factor alpha...). THe return + * value is false, if a solution could not be computed (for + * example, when the Hessian regularization parameter becomes too + * large.) + */ + virtual bool Solve(Number alpha, + Number beta, + const IteratesVector& rhs, + IteratesVector& res, + bool allow_inexact=false, + bool improve_solution=false) =0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Overloaded Equals Operator */ + PDSystemSolver& operator=(const PDSystemSolver&); + //@} + }; + + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpScaledMatrix.hpp b/thirdparty/linux/include/coin/IpScaledMatrix.hpp new file mode 100644 index 0000000..c182a05 --- /dev/null +++ b/thirdparty/linux/include/coin/IpScaledMatrix.hpp @@ -0,0 +1,254 @@ +// Copyright (C) 2004, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpScaledMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPSCALEDMATRIX_HPP__ +#define __IPSCALEDMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpMatrix.hpp" + +namespace Ipopt +{ + + /* forward declarations */ + class ScaledMatrixSpace; + + /** Class for a Matrix in conjunction with its scaling factors for + * row and column scaling. Operations on the matrix are performed using + * the scaled matrix. You can pull out the pointer to the + * unscaled matrix for unscaled calculations. + */ + class ScaledMatrix : public Matrix + { + public: + + /**@name Constructors / Destructors */ + //@{ + + /** Constructor, taking the owner_space. + */ + ScaledMatrix(const ScaledMatrixSpace* owner_space); + + /** Destructor */ + ~ScaledMatrix(); + //@} + + /** Set the unscaled matrix */ + void SetUnscaledMatrix(const SmartPtr<const Matrix> unscaled_matrix); + + /** Set the unscaled matrix in a non-const version */ + void SetUnscaledMatrixNonConst(const SmartPtr<Matrix>& unscaled_matrix); + + /** Return the unscaled matrix in const form */ + SmartPtr<const Matrix> GetUnscaledMatrix() const; + + /** Return the unscaled matrix in non-const form */ + SmartPtr<Matrix> GetUnscaledMatrixNonConst(); + + /** return the vector for the row scaling */ + SmartPtr<const Vector> RowScaling() const; + + /** return the vector for the column scaling */ + SmartPtr<const Vector> ColumnScaling() const; + + protected: + /**@name Methods overloaded from Matrix */ + //@{ + virtual void MultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + virtual void TransMultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). It is assumed that the scaling factors are + * valid. */ + virtual bool HasValidNumbersImpl() const; + + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; + + virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const; + + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const; + + /** X = beta*X + alpha*(Matrix S^{-1} Z). Specialized + * implementation missing so far! + */ + virtual void AddMSinvZImpl(Number alpha, const Vector& S, const Vector& Z, + Vector& X) const; + + /** X = S^{-1} (r + alpha*Z*M^Td). Specialized implementation + * missing so far! + */ + virtual void SinvBlrmZMTdBrImpl(Number alpha, const Vector& S, + const Vector& R, const Vector& Z, + const Vector& D, Vector& X) const; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + ScaledMatrix(); + + /** Copy Constructor */ + ScaledMatrix(const ScaledMatrix&); + + /** Overloaded Equals Operator */ + void operator=(const ScaledMatrix&); + //@} + + /** const version of the unscaled matrix */ + SmartPtr<const Matrix> matrix_; + /** non-const version of the unscaled matrix */ + SmartPtr<Matrix> nonconst_matrix_; + + /** Matrix space stored as a ScaledMatrixSpace */ + SmartPtr<const ScaledMatrixSpace> owner_space_; + }; + + /** This is the matrix space for ScaledMatrix. + */ + class ScaledMatrixSpace : public MatrixSpace + { + public: + /** @name Constructors / Destructors */ + //@{ + /** Constructor, given the number of row and columns blocks, as + * well as the totel number of rows and columns. + */ + ScaledMatrixSpace(const SmartPtr<const Vector>& row_scaling, + bool row_scaling_reciprocal, + const SmartPtr<const MatrixSpace>& unscaled_matrix_space, + const SmartPtr<const Vector>& column_scaling, + bool column_scaling_reciprocal); + + /** Destructor */ + ~ScaledMatrixSpace() + {} + //@} + + /** Method for creating a new matrix of this specific type. */ + ScaledMatrix* MakeNewScaledMatrix(bool allocate_unscaled_matrix = false) const + { + ScaledMatrix* ret = new ScaledMatrix(this); + if (allocate_unscaled_matrix) { + SmartPtr<Matrix> unscaled_matrix = unscaled_matrix_space_->MakeNew(); + ret->SetUnscaledMatrixNonConst(unscaled_matrix); + } + return ret; + } + + /** Overloaded MakeNew method for the MatrixSpace base class. + */ + virtual Matrix* MakeNew() const + { + return MakeNewScaledMatrix(); + } + + /** return the vector for the row scaling */ + SmartPtr<const Vector> RowScaling() const + { + return ConstPtr(row_scaling_); + } + + /** return the matrix space for the unscaled matrix */ + SmartPtr<const MatrixSpace> UnscaledMatrixSpace() const + { + return unscaled_matrix_space_; + } + + /** return the vector for the column scaling */ + SmartPtr<const Vector> ColumnScaling() const + { + return ConstPtr(column_scaling_); + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default constructor */ + ScaledMatrixSpace(); + + /** Copy Constructor */ + ScaledMatrixSpace(const ScaledMatrixSpace&); + + /** Overloaded Equals Operator */ + ScaledMatrixSpace& operator=(const ScaledMatrixSpace&); + //@} + + /** Row scaling vector */ + SmartPtr<Vector> row_scaling_; + /** unscaled matrix space */ + SmartPtr<const MatrixSpace> unscaled_matrix_space_; + /** column scaling vector */ + SmartPtr<Vector> column_scaling_; + }; + + inline + void ScaledMatrix::SetUnscaledMatrix(const SmartPtr<const Matrix> unscaled_matrix) + { + matrix_ = unscaled_matrix; + nonconst_matrix_ = NULL; + ObjectChanged(); + } + + inline + void ScaledMatrix::SetUnscaledMatrixNonConst(const SmartPtr<Matrix>& unscaled_matrix) + { + nonconst_matrix_ = unscaled_matrix; + matrix_ = GetRawPtr(unscaled_matrix); + ObjectChanged(); + } + + inline + SmartPtr<const Matrix> ScaledMatrix::GetUnscaledMatrix() const + { + return matrix_; + } + + inline + SmartPtr<Matrix> ScaledMatrix::GetUnscaledMatrixNonConst() + { + DBG_ASSERT(IsValid(nonconst_matrix_)); + ObjectChanged(); + return nonconst_matrix_; + } + + inline + SmartPtr<const Vector> ScaledMatrix::RowScaling() const + { + return ConstPtr(owner_space_->RowScaling()); + } + + inline + SmartPtr<const Vector> ScaledMatrix::ColumnScaling() const + { + return ConstPtr(owner_space_->ColumnScaling()); + } + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpSearchDirCalculator.hpp b/thirdparty/linux/include/coin/IpSearchDirCalculator.hpp new file mode 100644 index 0000000..3425c43 --- /dev/null +++ b/thirdparty/linux/include/coin/IpSearchDirCalculator.hpp @@ -0,0 +1,65 @@ +// Copyright (C) 2005, 2007 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpSearchDirCalculator.hpp 1861 2010-12-21 21:34:47Z andreasw $ +// +// Authors: Andreas Waechter IBM 2005-10-13 + +#ifndef __IPSEARCHDIRCALCULATOR_HPP__ +#define __IPSEARCHDIRCALCULATOR_HPP__ + +#include "IpAlgStrategy.hpp" + +namespace Ipopt +{ + + /** Base class for computing the search direction for the line + * search. + */ + class SearchDirectionCalculator : public AlgorithmStrategyObject + { + public: + /**@name Constructors/Destructors */ + //@{ + /** Constructor */ + SearchDirectionCalculator() + {} + + /** Default destructor */ + virtual ~SearchDirectionCalculator() + {} + //@} + + /** overloaded from AlgorithmStrategyObject */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix) = 0; + + /** Pure virtual method for computing the search direction. The + * computed direction is stored in IpData().delta().*/ + virtual bool ComputeSearchDirection()=0; + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + // SearchDirectionCalculator(); + + /** Copy Constructor */ + SearchDirectionCalculator(const SearchDirectionCalculator&); + + /** Overloaded Equals Operator */ + void operator=(const SearchDirectionCalculator&); + //@} + + }; + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpSumSymMatrix.hpp b/thirdparty/linux/include/coin/IpSumSymMatrix.hpp new file mode 100644 index 0000000..42b1168 --- /dev/null +++ b/thirdparty/linux/include/coin/IpSumSymMatrix.hpp @@ -0,0 +1,152 @@ +// Copyright (C) 2004, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpSumSymMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPSUMSYMMATRIX_HPP__ +#define __IPSUMSYMMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpSymMatrix.hpp" + +namespace Ipopt +{ + + /* forward declarations */ + class SumSymMatrixSpace; + + /** Class for Matrices which are sum of symmetric matrices. + * For each term in the we store the matrix and a factor. + */ + class SumSymMatrix : public SymMatrix + { + public: + + /**@name Constructors / Destructors */ + //@{ + + /** Constructor, initializing with dimensions of the matrix and + * the number of terms in the sum. + */ + SumSymMatrix(const SumSymMatrixSpace* owner_space); + + /** Destructor */ + ~SumSymMatrix(); + //@} + + /** Method for setting term iterm for the sum. Note that counting + * of terms starts at 0. */ + void SetTerm(Index iterm, Number factor, const SymMatrix& matrix); + + /** Method for getting term iterm for the sum. Note that counting + * of terms starts at 0. */ + void GetTerm(Index iterm, Number& factor, SmartPtr<const SymMatrix>& matrix) const; + + /** Return the number of terms */ + Index NTerms() const; + + protected: + /**@name Methods overloaded from matrix */ + //@{ + virtual void MultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). */ + virtual bool HasValidNumbersImpl() const; + + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; + + virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const; + + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + SumSymMatrix(); + + /** Copy Constructor */ + SumSymMatrix(const SumSymMatrix&); + + /** Overloaded Equals Operator */ + void operator=(const SumSymMatrix&); + //@} + + /** std::vector storing the factors for each term. */ + std::vector<Number> factors_; + + /** std::vector storing the matrices for each term. */ + std::vector<SmartPtr<const SymMatrix> > matrices_; + + /** Copy of the owner_space as a SumSymMatrixSpace */ + const SumSymMatrixSpace* owner_space_; + }; + + /** Class for matrix space for SumSymMatrix */ + class SumSymMatrixSpace : public SymMatrixSpace + { + public: + /** @name Constructors / Destructors */ + //@{ + /** Constructor, given the dimension of the matrix and the number + * of terms in the sum. */ + SumSymMatrixSpace(Index ndim, Index nterms) + : + SymMatrixSpace(ndim), + nterms_(nterms) + {} + + /** Destructor */ + ~SumSymMatrixSpace() + {} + //@} + + /** @name Accessor functions */ + //@{ + /** Number of terms in the sum. */ + Index NTerms() const + { + return nterms_; + } + //@} + + /** Use this method to set the matrix spaces for the various terms. + * You will not be able to create a matrix until all these spaces + * are set. */ + void SetTermSpace(Index term_idx, const SymMatrixSpace& space); + + /** Get the matix space for a particular term */ + SmartPtr<const SymMatrixSpace> GetTermSpace(Index term_idx) const; + + /** Method for creating a new matrix of this specific type. */ + SumSymMatrix* MakeNewSumSymMatrix() const; + + /** Overloaded MakeNew method for the SymMatrixSpace base class. + */ + virtual SymMatrix* MakeNewSymMatrix() const; + + private: + Index nterms_; + + std::vector< SmartPtr<const SymMatrixSpace> > term_spaces_; + }; + +} // namespace Ipopt +#endif diff --git a/thirdparty/linux/include/coin/IpSymLinearSolver.hpp b/thirdparty/linux/include/coin/IpSymLinearSolver.hpp new file mode 100644 index 0000000..82e7dd4 --- /dev/null +++ b/thirdparty/linux/include/coin/IpSymLinearSolver.hpp @@ -0,0 +1,130 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpSymLinearSolver.hpp 2322 2013-06-12 17:45:57Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPSYMLINEARSOLVER_HPP__ +#define __IPSYMLINEARSOLVER_HPP__ + +#include "IpUtils.hpp" +#include "IpSymMatrix.hpp" +#include "IpAlgStrategy.hpp" +#include <vector> + +namespace Ipopt +{ + + /** Enum to report outcome of a linear solve */ + enum ESymSolverStatus { + /** Successful solve */ + SYMSOLVER_SUCCESS, + /** Matrix seems to be singular; solve was aborted */ + SYMSOLVER_SINGULAR, + /** The number of negative eigenvalues is not correct */ + SYMSOLVER_WRONG_INERTIA, + /** Call the solver interface again after the matrix values have + * been restored */ + SYMSOLVER_CALL_AGAIN, + /** Unrecoverable error in linear solver occurred. The + * optimization will be aborted. */ + SYMSOLVER_FATAL_ERROR + }; + + /** Base class for all derived symmetric linear + * solvers. In the full space version of Ipopt a large linear + * system has to be solved for the augmented system. This case is + * meant to be the base class for all derived linear solvers for + * symmetric matrices (of type SymMatrix). + * + * A linear solver can be used repeatedly for matrices with + * identical structure of nonzero elements. The nonzero structure + * of those matrices must not be changed between calls. + * + * The called might ask the solver to only solve the linear system + * if the system is nonsingular, and if the number of negative + * eigenvalues matches a given number. + */ + class SymLinearSolver: public AlgorithmStrategyObject + { + public: + /** @name Constructor/Destructor */ + //@{ + SymLinearSolver() + {} + + virtual ~SymLinearSolver() + {} + //@} + + /** overloaded from AlgorithmStrategyObject */ + virtual bool InitializeImpl(const OptionsList& options, + const std::string& prefix) = 0; + + /** @name Methods for requesting solution of the linear system. */ + //@{ + /** Solve operation for multiple right hand sides. Solves the + * linear system A * Sol = Rhs with multiple right hand sides. If + * necessary, A is factorized. Correct solutions are only + * guaranteed if the return values is SYMSOLVER_SUCCESS. The + * solver will return SYMSOLVER_SINGULAR if the linear system is + * singular, and it will return SYMSOLVER_WRONG_INERTIA if + * check_NegEVals is true and the number of negative eigenvalues + * in the matrix does not match numberOfNegEVals. + * + * check_NegEVals cannot be chosen true, if ProvidesInertia() + * returns false. + */ + virtual ESymSolverStatus MultiSolve(const SymMatrix &A, + std::vector<SmartPtr<const Vector> >& rhsV, + std::vector<SmartPtr<Vector> >& solV, + bool check_NegEVals, + Index numberOfNegEVals)=0; + + /** Solve operation for a single right hand side. Solves the + * linear system A * Sol = Rhs. See MultiSolve for more + * details. */ + ESymSolverStatus Solve(const SymMatrix &A, + const Vector& rhs, Vector& sol, + bool check_NegEVals, + Index numberOfNegEVals) + { + std::vector<SmartPtr<const Vector> > rhsV(1); + rhsV[0] = &rhs; + std::vector<SmartPtr<Vector> > solV(1); + solV[0] = / + return MultiSolve(A, rhsV, solV, check_NegEVals, + numberOfNegEVals); + } + + /** Number of negative eigenvalues detected during last + * factorization. Returns the number of negative eigenvalues of + * the most recent factorized matrix. This must not be called if + * the linear solver does not compute this quantities (see + * ProvidesInertia). + */ + virtual Index NumberOfNegEVals() const =0; + //@} + + //* @name Options of Linear solver */ + //@{ + /** Request to increase quality of solution for next solve. + * Ask linear solver to increase quality of solution for the next + * solve (e.g. increase pivot tolerance). Returns false, if this + * is not possible (e.g. maximal pivot tolerance already used.) + */ + virtual bool IncreaseQuality() =0; + + /** Query whether inertia is computed by linear solver. + * Returns true, if linear solver provides inertia. + */ + virtual bool ProvidesInertia() const =0; + //@} + }; + + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpSymScaledMatrix.hpp b/thirdparty/linux/include/coin/IpSymScaledMatrix.hpp new file mode 100644 index 0000000..d58742f --- /dev/null +++ b/thirdparty/linux/include/coin/IpSymScaledMatrix.hpp @@ -0,0 +1,230 @@ +// Copyright (C) 2004, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpSymScaledMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPSYMSCALEDMATRIX_HPP__ +#define __IPSYMSCALEDMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpSymMatrix.hpp" + +namespace Ipopt +{ + + /* forward declarations */ + class SymScaledMatrixSpace; + + /** Class for a Matrix in conjunction with its scaling factors for + * row and column scaling. Operations on the matrix are performed using + * the scaled matrix. You can pull out the pointer to the + * unscaled matrix for unscaled calculations. + */ + class SymScaledMatrix : public SymMatrix + { + public: + + /**@name Constructors / Destructors */ + //@{ + + /** Constructor, taking the owner_space. + */ + SymScaledMatrix(const SymScaledMatrixSpace* owner_space); + + /** Destructor */ + ~SymScaledMatrix(); + //@} + + /** Set the unscaled matrix */ + void SetUnscaledMatrix(const SmartPtr<const SymMatrix> unscaled_matrix); + + /** Set the unscaled matrix in a non-const version */ + void SetUnscaledMatrixNonConst(const SmartPtr<SymMatrix>& unscaled_matrix); + + /** Return the unscaled matrix in const form */ + SmartPtr<const SymMatrix> GetUnscaledMatrix() const; + + /** Return the unscaled matrix in non-const form */ + SmartPtr<SymMatrix> GetUnscaledMatrixNonConst(); + + /** return the vector for the row and column scaling */ + SmartPtr<const Vector> RowColScaling() const; + + protected: + /**@name Methods overloaded from Matrix */ + //@{ + virtual void MultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). It is assumed here that the scaling factors + * are always valid numbers. */ + virtual bool HasValidNumbersImpl() const; + + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; + + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + SymScaledMatrix(); + + /** Copy Constructor */ + SymScaledMatrix(const SymScaledMatrix&); + + /** Overloaded Equals Operator */ + void operator=(const SymScaledMatrix&); + //@} + + /** const version of the unscaled matrix */ + SmartPtr<const SymMatrix> matrix_; + /** non-const version of the unscaled matrix */ + SmartPtr<SymMatrix> nonconst_matrix_; + + /** Matrix space stored as a SymScaledMatrixSpace */ + SmartPtr<const SymScaledMatrixSpace> owner_space_; + }; + + /** This is the matrix space for SymScaledMatrix. + */ + class SymScaledMatrixSpace : public SymMatrixSpace + { + public: + /** @name Constructors / Destructors */ + //@{ + /** Constructor, given the number of row and columns blocks, as + * well as the totel number of rows and columns. + */ + SymScaledMatrixSpace(const SmartPtr<const Vector>& row_col_scaling, + bool row_col_scaling_reciprocal, + const SmartPtr<const SymMatrixSpace>& unscaled_matrix_space) + : + SymMatrixSpace(unscaled_matrix_space->Dim()), + unscaled_matrix_space_(unscaled_matrix_space) + { + scaling_ = row_col_scaling->MakeNewCopy(); + if (row_col_scaling_reciprocal) { + scaling_->ElementWiseReciprocal(); + } + } + + /** Destructor */ + ~SymScaledMatrixSpace() + {} + //@} + + /** Method for creating a new matrix of this specific type. */ + SymScaledMatrix* MakeNewSymScaledMatrix(bool allocate_unscaled_matrix = false) const + { + SymScaledMatrix* ret = new SymScaledMatrix(this); + if (allocate_unscaled_matrix) { + SmartPtr<SymMatrix> unscaled_matrix = unscaled_matrix_space_->MakeNewSymMatrix(); + ret->SetUnscaledMatrixNonConst(unscaled_matrix); + } + return ret; + } + + /** Overloaded method from SymMatrixSpace */ + virtual SymMatrix* MakeNewSymMatrix() const + { + return MakeNewSymScaledMatrix(); + } + /** Overloaded MakeNew method for the MatrixSpace base class. + */ + virtual Matrix* MakeNew() const + { + return MakeNewSymScaledMatrix(); + } + + /** return the vector for the row and column scaling */ + SmartPtr<const Vector> RowColScaling() const + { + return ConstPtr(scaling_); + } + + /** return the matrix space for the unscaled matrix */ + SmartPtr<const SymMatrixSpace> UnscaledMatrixSpace() const + { + return unscaled_matrix_space_; + } + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default constructor */ + SymScaledMatrixSpace(); + + /** Copy Constructor */ + SymScaledMatrixSpace(const SymScaledMatrixSpace&); + + /** Overloaded Equals Operator */ + SymScaledMatrixSpace& operator=(const SymScaledMatrixSpace&); + //@} + + /** Row scaling vector */ + SmartPtr<Vector> scaling_; + /** unscaled matrix space */ + SmartPtr<const SymMatrixSpace> unscaled_matrix_space_; + }; + + inline + void SymScaledMatrix::SetUnscaledMatrix(const SmartPtr<const SymMatrix> unscaled_matrix) + { + matrix_ = unscaled_matrix; + nonconst_matrix_ = NULL; + ObjectChanged(); + } + + inline + void SymScaledMatrix::SetUnscaledMatrixNonConst(const SmartPtr<SymMatrix>& unscaled_matrix) + { + nonconst_matrix_ = unscaled_matrix; + matrix_ = GetRawPtr(unscaled_matrix); + ObjectChanged(); + } + + inline + SmartPtr<const SymMatrix> SymScaledMatrix::GetUnscaledMatrix() const + { + return matrix_; + } + + inline + SmartPtr<SymMatrix> SymScaledMatrix::GetUnscaledMatrixNonConst() + { + DBG_ASSERT(IsValid(nonconst_matrix_)); + ObjectChanged(); + return nonconst_matrix_; + } + + inline SmartPtr<const Vector> SymScaledMatrix::RowColScaling() const + { + return ConstPtr(owner_space_->RowColScaling()); + } + +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpSymTMatrix.hpp b/thirdparty/linux/include/coin/IpSymTMatrix.hpp new file mode 100644 index 0000000..ead2d85 --- /dev/null +++ b/thirdparty/linux/include/coin/IpSymTMatrix.hpp @@ -0,0 +1,253 @@ +// Copyright (C) 2004, 2006 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpSymTMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPSYMTMATRIX_HPP__ +#define __IPSYMTMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpSymMatrix.hpp" + +namespace Ipopt +{ + + /* forward declarations */ + class SymTMatrixSpace; + + /** Class for symmetric matrices stored in triplet format. In the + * triplet format, the nonzeros elements of a symmetric matrix is + * stored in three arrays, Irn, Jcn, and Values, all of length + * Nonzeros. The first two arrays indicate the location of a + * non-zero element (as the row and column indices), and the last + * array stores the value at that location. Off-diagonal elements + * need to be stored only once since the matrix is symmetric. For + * example, the element \f$a_{1,2}=a_{2,1}\f$ would be stored only + * once, either with Irn[i]=1 and Jcn[i]=2, or with Irn[i]=2 and + * Jcn[i]=1. Both representations are identical. If nonzero + * elements (or their symmetric counter part) are listed more than + * once, their values are added. + * + * The structure of the nonzeros (i.e. the arrays Irn and Jcn) + * cannot be changed after the matrix can been initialized. Only + * the values of the nonzero elements can be modified. + * + * Note that the first row and column of a matrix has index 1, not + * 0. + * + */ + class SymTMatrix : public SymMatrix + { + public: + + /**@name Constructors / Destructors */ + //@{ + + /** Constructor, taking the corresponding matrix space. + */ + SymTMatrix(const SymTMatrixSpace* owner_space); + + /** Destructor */ + ~SymTMatrix(); + //@} + + /**@name Changing the Values.*/ + //@{ + /** Set values of nonzero elements. The values of the nonzero + * elements is copied from the incoming Number array. Important: + * It is assume that the order of the values in Values + * corresponds to the one of Irn and Jcn given to the matrix + * space. */ + void SetValues(const Number* Values); + //@} + + /** @name Accessor Methods */ + //@{ + /** Number of nonzero entries */ + Index Nonzeros() const; + + /** Obtain pointer to the internal Index array irn_ without the + * intention to change the matrix data (USE WITH CARE!). This + * does not produce a copy, and lifetime is not guaranteed! + */ + const Index* Irows() const; + + /** Obtain pointer to the internal Index array jcn_ without the + * intention to change the matrix data (USE WITH CARE!). This + * does not produce a copy, and lifetime is not guaranteed! + */ + const Index* Jcols() const; + + /** Obtain pointer to the internal Number array values_ with the + * intention to change the matrix data (USE WITH CARE!). This + * does not produce a copy, and lifetime is not guaranteed! + */ + Number* Values(); + /** Obtain pointer to the internal Number array values_ without the + * intention to change the matrix data (USE WITH CARE!). This + * does not produce a copy, and lifetime is not guaranteed! + */ + const Number* Values() const; + //@} + + /**@name Methods for providing copy of the matrix data */ + //@{ + /** Copy the nonzero structure into provided space */ + void FillStruct(ipfint* Irn, ipfint* Jcn) const; + + /** Copy the value data into provided space */ + void FillValues(Number* Values) const; + //@} + + protected: + /**@name Methods overloaded from matrix */ + //@{ + virtual void MultVectorImpl(Number alpha, const Vector& x, Number beta, + Vector& y) const; + + /** Method for determining if all stored numbers are valid (i.e., + * no Inf or Nan). */ + virtual bool HasValidNumbersImpl() const; + + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const; + + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + SymTMatrix(); + + /** Copy Constructor */ + SymTMatrix(const SymTMatrix&); + + /** Overloaded Equals Operator */ + void operator=(const SymTMatrix&); + //@} + + /** Copy of the owner_space ptr as a SymTMatrixSpace insteaqd + * of a MatrixSpace + */ + const SymTMatrixSpace* owner_space_; + + /** Values of nonzeros */ + Number* values_; + + /** Flag for Initialization */ + bool initialized_; + + }; + + /** This is the matrix space for a SymTMatrix with fixed sparsity + * structure. The sparsity structure is stored here in the matrix + * space. + */ + class SymTMatrixSpace : public SymMatrixSpace + { + public: + /** @name Constructors / Destructors */ + //@{ + /** Constructor, given the number of rows and columns (both as + * dim), as well as the number of nonzeros and the position of + * the nonzero elements. Note that the counting of the nonzeros + * starts a 1, i.e., iRows[i]==1 and jCols[i]==1 refers to the + * first element in the first row. This is in accordance with + * the HSL data structure. Off-diagonal elements are stored only + * once. + */ + SymTMatrixSpace(Index dim, Index nonZeros, const Index* iRows, + const Index* jCols); + + /** Destructor */ + ~SymTMatrixSpace(); + //@} + + /** Overloaded MakeNew method for the sYMMatrixSpace base class. + */ + virtual SymMatrix* MakeNewSymMatrix() const + { + return MakeNewSymTMatrix(); + } + + /** Method for creating a new matrix of this specific type. */ + SymTMatrix* MakeNewSymTMatrix() const + { + return new SymTMatrix(this); + } + + /**@name Methods describing Matrix structure */ + //@{ + /** Number of non-zeros in the sparse matrix */ + Index Nonzeros() const + { + return nonZeros_; + } + + /** Row index of each non-zero element */ + const Index* Irows() const + { + return iRows_; + } + + /** Column index of each non-zero element */ + const Index* Jcols() const + { + return jCols_; + } + //@} + + private: + /**@name Methods called by SymTMatrix for memory management */ + //@{ + /** Allocate internal storage for the SymTMatrix values */ + Number* AllocateInternalStorage() const; + + /** Deallocate internal storage for the SymTMatrix values */ + void FreeInternalStorage(Number* values) const; + //@} + + const Index nonZeros_; + Index* iRows_; + Index* jCols_; + + friend class SymTMatrix; + }; + + /* Inline Methods */ + inline + Index SymTMatrix::Nonzeros() const + { + return owner_space_->Nonzeros(); + } + + inline + const Index* SymTMatrix::Irows() const + { + return owner_space_->Irows(); + } + + inline + const Index* SymTMatrix::Jcols() const + { + return owner_space_->Jcols(); + } + + +} // namespace Ipopt +#endif diff --git a/thirdparty/linux/include/coin/IpTaggedObject.hpp b/thirdparty/linux/include/coin/IpTaggedObject.hpp index e81b065..7262c43 100644 --- a/thirdparty/linux/include/coin/IpTaggedObject.hpp +++ b/thirdparty/linux/include/coin/IpTaggedObject.hpp @@ -2,7 +2,7 @@ // All Rights Reserved. // This code is published under the Eclipse Public License. // -// $Id: IpTaggedObject.hpp 2491 2014-05-31 11:17:49Z stefan $ +// $Id: IpTaggedObject.hpp 2613 2015-11-04 14:42:02Z stefan $ // // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 @@ -17,12 +17,13 @@ /* keyword to declare a thread-local variable according to http://en.wikipedia.org/wiki/Thread-local_storage * GCC < 4.5 on MacOS X does not support TLS + * With Intel compiler on MacOS X, problems with TLS were reported. */ #ifndef IPOPT_THREAD_LOCAL #if defined(_MSC_VER) #define IPOPT_THREAD_LOCAL __declspec(thread) -#elif defined(__APPLE__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 405) +#elif defined(__APPLE__) && ((defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ < 405)) || defined(__INTEL_COMPILER)) #define IPOPT_THREAD_LOCAL #else #define IPOPT_THREAD_LOCAL __thread diff --git a/thirdparty/linux/include/coin/IpTripletHelper.hpp b/thirdparty/linux/include/coin/IpTripletHelper.hpp new file mode 100644 index 0000000..35424c0 --- /dev/null +++ b/thirdparty/linux/include/coin/IpTripletHelper.hpp @@ -0,0 +1,135 @@ +// Copyright (C) 2004, 2009 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpTripletHelper.hpp 2380 2013-09-06 22:57:49Z ghackebeil $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPTRIPLETHELPER_HPP__ +#define __IPTRIPLETHELPER_HPP__ + +#include "IpTypes.hpp" +#include "IpException.hpp" + +namespace Ipopt +{ + + DECLARE_STD_EXCEPTION(UNKNOWN_MATRIX_TYPE); + DECLARE_STD_EXCEPTION(UNKNOWN_VECTOR_TYPE); + + /** forward declarations */ + class Matrix; + class GenTMatrix; + class SymTMatrix; + class DiagMatrix; + class IdentityMatrix; + class ExpansionMatrix; + class ScaledMatrix; + class SymScaledMatrix; + class SumMatrix; + class SumSymMatrix; + class ZeroMatrix; + class ZeroSymMatrix; + class CompoundMatrix; + class CompoundSymMatrix; + class TransposeMatrix; + class ExpandedMultiVectorMatrix; + class Vector; + + class TripletHelper + { + public: + /**@name A set of recursive routines that help with the Triplet format. */ + //@{ + /** find the total number of triplet entries of a Matrix */ + static Index GetNumberEntries(const Matrix& matrix); + + /** fill the irows, jcols structure for the triplet format from the matrix */ + static void FillRowCol(Index n_entries, const Matrix& matrix, Index* iRow, Index* jCol, Index row_offset=0, Index col_offset=0); + + /** fill the values for the triplet format from the matrix */ + static void FillValues(Index n_entries, const Matrix& matrix, Number* values); + + /** fill the values from the vector into a dense double* structure */ + static void FillValuesFromVector(Index dim, const Vector& vector, Number* values); + + /** put the values from the double* back into the vector */ + static void PutValuesInVector(Index dim, const double* values, Vector& vector); + //@} + + private: + /** find the total number of triplet entries for the SumMatrix */ + static Index GetNumberEntries_(const SumMatrix& matrix); + + /** find the total number of triplet entries for the SumSymMatrix */ + static Index GetNumberEntries_(const SumSymMatrix& matrix); + + /** find the total number of triplet entries for the CompoundMatrix */ + static Index GetNumberEntries_(const CompoundMatrix& matrix); + + /** find the total number of triplet entries for the CompoundSymMatrix */ + static Index GetNumberEntries_(const CompoundSymMatrix& matrix); + + /** find the total number of triplet entries for the TransposeMatrix */ + static Index GetNumberEntries_(const TransposeMatrix& matrix); + + /** find the total number of triplet entries for the TransposeMatrix */ + static Index GetNumberEntries_(const ExpandedMultiVectorMatrix& matrix); + + static void FillRowCol_(Index n_entries, const GenTMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const GenTMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const SymTMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const SymTMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const DiagMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const DiagMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const IdentityMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const IdentityMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const ExpansionMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const ExpansionMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const SumMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const SumMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const SumSymMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const SumSymMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const CompoundMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const CompoundMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const CompoundSymMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const CompoundSymMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const ScaledMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const ScaledMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const SymScaledMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const SymScaledMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const TransposeMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const TransposeMatrix& matrix, Number* values); + + static void FillRowCol_(Index n_entries, const ExpandedMultiVectorMatrix& matrix, Index row_offset, Index col_offset, Index* iRow, Index* jCol); + + static void FillValues_(Index n_entries, const ExpandedMultiVectorMatrix& matrix, Number* values); + + }; +} // namespace Ipopt + +#endif diff --git a/thirdparty/linux/include/coin/IpZeroSymMatrix.hpp b/thirdparty/linux/include/coin/IpZeroSymMatrix.hpp new file mode 100644 index 0000000..35ad95e --- /dev/null +++ b/thirdparty/linux/include/coin/IpZeroSymMatrix.hpp @@ -0,0 +1,135 @@ +// Copyright (C) 2004, 2008 International Business Machines and others. +// All Rights Reserved. +// This code is published under the Eclipse Public License. +// +// $Id: IpZeroSymMatrix.hpp 2269 2013-05-05 11:32:40Z stefan $ +// +// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 + +#ifndef __IPZEROSYMMATRIX_HPP__ +#define __IPZEROSYMMATRIX_HPP__ + +#include "IpUtils.hpp" +#include "IpSymMatrix.hpp" + +namespace Ipopt +{ + + /** Class for Symmetric Matrices with only zero entries. + */ + class ZeroSymMatrix : public SymMatrix + { + public: + + /**@name Constructors / Destructors */ + //@{ + + /** Constructor, taking the corresponding matrix space. + */ + ZeroSymMatrix(const SymMatrixSpace* owner_space); + + /** Destructor */ + ~ZeroSymMatrix(); + //@} + + protected: + /**@name Methods overloaded from matrix */ + //@{ + virtual void MultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + virtual void TransMultVectorImpl(Number alpha, const Vector& x, + Number beta, Vector& y) const; + + virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const + {} + + virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const + {} + + virtual void PrintImpl(const Journalist& jnlst, + EJournalLevel level, + EJournalCategory category, + const std::string& name, + Index indent, + const std::string& prefix) const; + //@} + + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + ZeroSymMatrix(); + + /** Copy Constructor */ + ZeroSymMatrix(const ZeroSymMatrix&); + + /** Overloaded Equals Operator */ + void operator=(const ZeroSymMatrix&); + //@} + }; + + /** Class for matrix space for ZeroSymMatrix. */ + class ZeroSymMatrixSpace : public SymMatrixSpace + { + public: + /** @name Constructors / Destructors */ + //@{ + /** Constructor, given the number of row and columns. + */ + ZeroSymMatrixSpace(Index dim) + : + SymMatrixSpace(dim) + {} + + /** Destructor */ + virtual ~ZeroSymMatrixSpace() + {} + //@} + + /** Overloaded MakeNew method for the MatrixSpace base class. + */ + virtual Matrix* MakeNew() const + { + return MakeNewZeroSymMatrix(); + } + + /** Overloaded method from SymMatrixSpace base class + */ + virtual SymMatrix* MakeNewSymMatrix() const + { + return MakeNewZeroSymMatrix(); + } + + /** Method for creating a new matrix of this specific type. */ + ZeroSymMatrix* MakeNewZeroSymMatrix() const + { + return new ZeroSymMatrix(this); + } + private: + /**@name Default Compiler Generated Methods + * (Hidden to avoid implicit creation/calling). + * These methods are not implemented and + * we do not want the compiler to implement + * them for us, so we declare them private + * and do not define them. This ensures that + * they will not be implicitly created/called. */ + //@{ + /** Default Constructor */ + ZeroSymMatrixSpace(); + + /** Copy Constructor */ + ZeroSymMatrixSpace(const ZeroSymMatrixSpace&); + + /** Overloaded Equals Operator */ + void operator=(const ZeroSymMatrixSpace&); + //@} + }; +} // namespace Ipopt +#endif diff --git a/thirdparty/linux/include/coin/IpoptConfig.h b/thirdparty/linux/include/coin/IpoptConfig.h index e7de361..78dadd3 100644 --- a/thirdparty/linux/include/coin/IpoptConfig.h +++ b/thirdparty/linux/include/coin/IpoptConfig.h @@ -5,7 +5,7 @@ #define __CONFIG_IPOPT_H__ /* Version number of project */ -#define IPOPT_VERSION "3.12.4" +#define IPOPT_VERSION "3.12.7" /* Major Version number of project */ #define IPOPT_VERSION_MAJOR 3 @@ -14,7 +14,7 @@ #define IPOPT_VERSION_MINOR 12 /* Release Version number of project */ -#define IPOPT_VERSION_RELEASE 4 +#define IPOPT_VERSION_RELEASE 7 /* Define to the C type corresponding to Fortran INTEGER */ #define FORTRAN_INTEGER_TYPE int |