diff options
Diffstat (limited to 'thirdparty/windows/include/coin')
30 files changed, 8012 insertions, 8000 deletions
diff --git a/thirdparty/windows/include/coin/IpAlgTypes.hpp b/thirdparty/windows/include/coin/IpAlgTypes.hpp index 63abf41..b4a9656 100644 --- a/thirdparty/windows/include/coin/IpAlgTypes.hpp +++ b/thirdparty/windows/include/coin/IpAlgTypes.hpp @@ -1,64 +1,65 @@ -// Copyright (C) 2005, 2009 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpAlgTypes.hpp 1430 2009-04-20 20:58:25Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2005-07-19 - -#ifndef __IPALGTYPES_HPP__ -#define __IPALGTYPES_HPP__ - -#include "IpTypes.hpp" -#include "IpException.hpp" - -namespace Ipopt -{ - - /**@name Enumerations */ - //@{ - /** enum for the return from the optimize algorithm - * (obviously we need to add more) */ - enum SolverReturn { - SUCCESS, - MAXITER_EXCEEDED, - CPUTIME_EXCEEDED, - STOP_AT_TINY_STEP, - STOP_AT_ACCEPTABLE_POINT, - LOCAL_INFEASIBILITY, - USER_REQUESTED_STOP, - FEASIBLE_POINT_FOUND, - DIVERGING_ITERATES, - RESTORATION_FAILURE, - ERROR_IN_STEP_COMPUTATION, - INVALID_NUMBER_DETECTED, - TOO_FEW_DEGREES_OF_FREEDOM, - INVALID_OPTION, - OUT_OF_MEMORY, - INTERNAL_ERROR - }; - //@} - - /** @name Some exceptions used in multiple places */ - //@{ - DECLARE_STD_EXCEPTION(LOCALLY_INFEASIBLE); - DECLARE_STD_EXCEPTION(TOO_FEW_DOF); - DECLARE_STD_EXCEPTION(TINY_STEP_DETECTED); - DECLARE_STD_EXCEPTION(ACCEPTABLE_POINT_REACHED); - DECLARE_STD_EXCEPTION(FEASIBILITY_PROBLEM_SOLVED); - DECLARE_STD_EXCEPTION(INVALID_WARMSTART); - DECLARE_STD_EXCEPTION(INTERNAL_ABORT); - DECLARE_STD_EXCEPTION(NO_FREE_VARIABLES_BUT_FEASIBLE); - DECLARE_STD_EXCEPTION(NO_FREE_VARIABLES_AND_INFEASIBLE); - /** Exception FAILED_INITIALIZATION for problem during - * initialization of a strategy object (or other problems). This - * is thrown by a strategy object, if a problem arises during - * initialization, such as a value out of a feasible range. - */ - DECLARE_STD_EXCEPTION(FAILED_INITIALIZATION); - //@} - - -} - -#endif +// Copyright (C) 2005, 2010 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpAlgTypes.hpp 1861 2010-12-21 21:34:47Z andreasw $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2005-07-19
+
+#ifndef __IPALGTYPES_HPP__
+#define __IPALGTYPES_HPP__
+
+#include "IpTypes.hpp"
+#include "IpException.hpp"
+
+namespace Ipopt
+{
+
+ /**@name Enumerations */
+ //@{
+ /** enum for the return from the optimize algorithm
+ * (obviously we need to add more) */
+ enum SolverReturn {
+ SUCCESS,
+ MAXITER_EXCEEDED,
+ CPUTIME_EXCEEDED,
+ STOP_AT_TINY_STEP,
+ STOP_AT_ACCEPTABLE_POINT,
+ LOCAL_INFEASIBILITY,
+ USER_REQUESTED_STOP,
+ FEASIBLE_POINT_FOUND,
+ DIVERGING_ITERATES,
+ RESTORATION_FAILURE,
+ ERROR_IN_STEP_COMPUTATION,
+ INVALID_NUMBER_DETECTED,
+ TOO_FEW_DEGREES_OF_FREEDOM,
+ INVALID_OPTION,
+ OUT_OF_MEMORY,
+ INTERNAL_ERROR,
+ UNASSIGNED
+ };
+ //@}
+
+ /** @name Some exceptions used in multiple places */
+ //@{
+ DECLARE_STD_EXCEPTION(LOCALLY_INFEASIBLE);
+ DECLARE_STD_EXCEPTION(TOO_FEW_DOF);
+ DECLARE_STD_EXCEPTION(TINY_STEP_DETECTED);
+ DECLARE_STD_EXCEPTION(ACCEPTABLE_POINT_REACHED);
+ DECLARE_STD_EXCEPTION(FEASIBILITY_PROBLEM_SOLVED);
+ DECLARE_STD_EXCEPTION(INVALID_WARMSTART);
+ DECLARE_STD_EXCEPTION(INTERNAL_ABORT);
+ DECLARE_STD_EXCEPTION(NO_FREE_VARIABLES_BUT_FEASIBLE);
+ DECLARE_STD_EXCEPTION(NO_FREE_VARIABLES_AND_INFEASIBLE);
+ /** Exception FAILED_INITIALIZATION for problem during
+ * initialization of a strategy object (or other problems). This
+ * is thrown by a strategy object, if a problem arises during
+ * initialization, such as a value out of a feasible range.
+ */
+ DECLARE_STD_EXCEPTION(FAILED_INITIALIZATION);
+ //@}
+
+
+}
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpCachedResults.hpp b/thirdparty/windows/include/coin/IpCachedResults.hpp index bcc0d10..df5456f 100644 --- a/thirdparty/windows/include/coin/IpCachedResults.hpp +++ b/thirdparty/windows/include/coin/IpCachedResults.hpp @@ -1,781 +1,779 @@ -// Copyright (C) 2004, 2007 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpCachedResults.hpp 949 2007-03-27 00:41:26Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPCACHEDRESULTS_HPP__ -#define __IPCACHEDRESULTS_HPP__ - -#include "IpTaggedObject.hpp" -#include "IpObserver.hpp" -#include <algorithm> -#include <vector> -#include <list> - -namespace Ipopt - //#define IP_DEBUG_CACHE -#if COIN_IPOPT_CHECKLEVEL > 2 -# define IP_DEBUG_CACHE -#endif -#ifdef IP_DEBUG_CACHE -# include "IpDebug.hpp" -#endif -{ - - // Forward Declarations - - template <class T> - class DependentResult; - - // AW: I'm taking this out, since this is by far the most used - // class. We should keep it as simple as possible. - // /** Cache Priority Enum */ - // enum CachePriority - // { - // CP_Lowest, - // CP_Standard, - // CP_Trial, - // CP_Iterate - // }; - - /** Templated class for Chached Results. This class stores up to a - * given number of "results", entities that are stored here - * together with identifies, that can be used to later retrieve the - * information again. - * - * Typically, T is a SmartPtr for some calculated quantity that - * should be stored (such as a Vector). The identifiers (or - * dependencies) are a (possibly varying) number of Tags from - * TaggedObjects, and a number of Numbers. Results are added to - * the cache using the AddCachedResults methods, and the can be - * retrieved with the GetCachedResults methods. The second set of - * methods checks whether a result has been cached for the given - * identifiers. If a corresponding results is found, a copy of it - * is returned and the method evaluates to true, otherwise it - * evaluates to false. - * - * Note that cached results can become "stale", namely when a - * TaggedObject that is used to identify this CachedResult is - * changed. When this happens, the cached result can never be - * asked for again, so that there is no point in storing it any - * longer. For this purpose, a cached result, which is stored as a - * DependentResult, inherits off an Observer. This Observer - * retrieves notification whenever a TaggedObject dependency has - * changed. Stale results are later removed from the cache. - */ - template <class T> - class CachedResults - { - public: -#ifdef IP_DEBUG_CACHE - /** (Only if compiled in DEBUG mode): debug verbosity level */ - static const Index dbg_verbosity; -#endif - - /** @name Constructors and Destructors. */ - //@{ - /** Constructor, where max_cache_size is the maximal number of - * results that should be cached. If max_cache_size is negative, - * we allow an infinite abount of cache. - */ - CachedResults(Int max_cache_size); - - /** Destructor */ - virtual ~CachedResults(); - //@} - - /** @name Generic methods for adding and retrieving cached results. */ - //@{ - /** Generic method for adding a result to the cache, given a - * std::vector of TaggesObjects and a std::vector of Numbers. - */ - void AddCachedResult(const T& result, - const std::vector<const TaggedObject*>& dependents, - const std::vector<Number>& scalar_dependents); - - /** Generic method for retrieving a cached results, given the - * dependencies as a std::vector of TaggesObjects and a - * std::vector of Numbers. - */ - bool GetCachedResult(T& retResult, - const std::vector<const TaggedObject*>& dependents, - const std::vector<Number>& scalar_dependents) const; - - /** Method for adding a result, providing only a std::vector of - * TaggedObjects. - */ - void AddCachedResult(const T& result, - const std::vector<const TaggedObject*>& dependents); - - /** Method for retrieving a cached result, providing only a - * std::vector of TaggedObjects. - */ - bool GetCachedResult(T& retResult, - const std::vector<const TaggedObject*>& dependents) const; - //@} - - /** @name Pointer-based methods for adding and retrieving cached - * results, providing dependencies explicitly. - */ - //@{ - /** Method for adding a result to the cache, proving one - * dependency as a TaggedObject explicitly. - */ - void AddCachedResult1Dep(const T& result, - const TaggedObject* dependent1); - - /** Method for retrieving a cached result, proving one dependency - * as a TaggedObject explicitly. - */ - bool GetCachedResult1Dep(T& retResult, const TaggedObject* dependent1); - - /** Method for adding a result to the cache, proving two - * dependencies as a TaggedObject explicitly. - */ - void AddCachedResult2Dep(const T& result, - const TaggedObject* dependent1, - const TaggedObject* dependent2); - - /** Method for retrieving a cached result, proving two - * dependencies as a TaggedObject explicitly. - */ - bool GetCachedResult2Dep(T& retResult, - const TaggedObject* dependent1, - const TaggedObject* dependent2); - - /** Method for adding a result to the cache, proving three - * dependencies as a TaggedObject explicitly. - */ - void AddCachedResult3Dep(const T& result, - const TaggedObject* dependent1, - const TaggedObject* dependent2, - const TaggedObject* dependent3); - - /** Method for retrieving a cached result, proving three - * dependencies as a TaggedObject explicitly. - */ - bool GetCachedResult3Dep(T& retResult, - const TaggedObject* dependent1, - const TaggedObject* dependent2, - const TaggedObject* dependent3); - - /** @name Pointer-free version of the Add and Get methods */ - //@{ - bool GetCachedResult1Dep(T& retResult, const TaggedObject& dependent1) - { - return GetCachedResult1Dep(retResult, &dependent1); - } - bool GetCachedResult2Dep(T& retResult, - const TaggedObject& dependent1, - const TaggedObject& dependent2) - { - return GetCachedResult2Dep(retResult, &dependent1, &dependent2); - } - bool GetCachedResult3Dep(T& retResult, - const TaggedObject& dependent1, - const TaggedObject& dependent2, - const TaggedObject& dependent3) - { - return GetCachedResult3Dep(retResult, &dependent1, &dependent2, &dependent3); - } - void AddCachedResult1Dep(const T& result, - const TaggedObject& dependent1) - { - AddCachedResult1Dep(result, &dependent1); - } - void AddCachedResult2Dep(const T& result, - const TaggedObject& dependent1, - const TaggedObject& dependent2) - { - AddCachedResult2Dep(result, &dependent1, &dependent2); - } - void AddCachedResult3Dep(const T& result, - const TaggedObject& dependent1, - const TaggedObject& dependent2, - const TaggedObject& dependent3) - { - AddCachedResult3Dep(result, &dependent1, &dependent2, &dependent3); - } - //@} - - /** Invalidates the result for given dependecies. Sets the stale - * flag for the corresponding cached result to true if it is - * found. Returns true, if the result was found. */ - bool InvalidateResult(const std::vector<const TaggedObject*>& dependents, - const std::vector<Number>& scalar_dependents); - - /** Invalidates all cached results */ - void Clear(); - - /** Invalidate all cached results and changes max_cache_size */ - void Clear(Int max_cache_size); - - 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 */ - CachedResults(); - - /** Copy Constructor */ - CachedResults(const CachedResults&); - - /** Overloaded Equals Operator */ - void operator=(const CachedResults&); - //@} - - /** maximum number of cached results */ - Int max_cache_size_; - - /** list of currently cached results. */ - mutable std::list<DependentResult<T>*>* cached_results_; - - /** internal method for removing stale DependentResults from the - * list. It is called at the beginning of every - * GetDependentResult method. - */ - void CleanupInvalidatedResults() const; - - /** Print list of currently cached results */ - void DebugPrintCachedResults() const; - }; - - /** Templated class which stores one entry for the CachedResult - * class. It stores the result (of type T), together with its - * dependencies (vector of TaggedObjects and vector of Numbers). - * It also stores a priority. - */ - template <class T> - class DependentResult : public Observer - { - public: - -#ifdef IP_DEBUG_CACHE - - static const Index dbg_verbosity; -#endif - - /** @name Constructor, Destructors */ - //@{ - /** Constructor, given all information about the result. */ - DependentResult(const T& result, const std::vector<const TaggedObject*>& dependents, - const std::vector<Number>& scalar_dependents); - - /** Destructor. */ - ~DependentResult(); - //@} - - /** @name Accessor method. */ - //@{ - /** This returns true, if the DependentResult is no longer valid. */ - bool IsStale() const; - - /** Invalidates the cached result. */ - void Invalidate(); - - /** Returns the cached result. */ - const T& GetResult() const; - //@} - - /** This method returns true if the dependencies provided to this - * function are identical to the ones stored with the - * DependentResult. - */ - bool DependentsIdentical(const std::vector<const TaggedObject*>& dependents, - const std::vector<Number>& scalar_dependents) const; - - /** Print information about this DependentResults. */ - void DebugPrint() const; - - protected: - /** This method is overloading the pure virtual method from the - * Observer base class. This method is called when a Subject - * registered for this Observer sends a notification. In this - * particular case, if this method is called with - * notify_type==NT_Changed or NT_BeingDeleted, then this results - * is marked as stale. - */ - virtual void RecieveNotification(NotifyType notify_type, const Subject* subject); - - 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 */ - DependentResult(); - - /** Copy Constructor */ - DependentResult(const DependentResult&); - - /** Overloaded Equals Operator */ - void operator=(const DependentResult&); - //@} - - /** Flag indicating, if the cached result is still valid. A - result becomes invalid, if the RecieveNotification method is - called with NT_Changed */ - bool stale_; - /** The value of the dependent results */ - const T result_; - /** Dependencies in form of TaggedObjects */ - std::vector<TaggedObject::Tag> dependent_tags_; - /** Dependencies in form a Numbers */ - std::vector<Number> scalar_dependents_; - }; - -#ifdef IP_DEBUG_CACHE - - template <class T> - const Index CachedResults<T>::dbg_verbosity = 0; - - template <class T> - const Index DependentResult<T>::dbg_verbosity = 0; -#endif - - template <class T> - DependentResult<T>::DependentResult( - const T& result, - const std::vector<const TaggedObject*>& dependents, - const std::vector<Number>& scalar_dependents) - : - stale_(false), - result_(result), - dependent_tags_(dependents.size()), - scalar_dependents_(scalar_dependents) - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("DependentResult<T>::DependentResult()", dbg_verbosity); -#endif - - for (Index i=0; i<(Index)dependents.size(); i++) { - if (dependents[i]) { - // Call the RequestAttach method of the Observer base class. - // This will add this dependent result in the Observer list - // for the Subject dependents[i]. As a consequence, the - // RecieveNotification method of this DependentResult will be - // called with notify_type=NT_Changed, whenever the - // TaggedResult dependents[i] is changed (i.e. its HasChanged - // method is called). - RequestAttach(NT_Changed, dependents[i]); - dependent_tags_[i] = dependents[i]->GetTag(); - } - else { - dependent_tags_[i] = 0; - } - } - } - - template <class T> - DependentResult<T>::~DependentResult() - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("DependentResult<T>::~DependentResult()", dbg_verbosity); - //DBG_ASSERT(stale_ == true); -#endif - // Nothing to be done here, destructor - // of T should sufficiently remove - // any memory, etc. - } - - template <class T> - bool DependentResult<T>::IsStale() const - { - return stale_; - } - - template <class T> - void DependentResult<T>::Invalidate() - { - stale_ = true; - } - - template <class T> - void DependentResult<T>::RecieveNotification(NotifyType notify_type, const Subject* subject) - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("DependentResult<T>::RecieveNotification", dbg_verbosity); -#endif - - if (notify_type == NT_Changed || notify_type==NT_BeingDestroyed) { - stale_ = true; - // technically, I could unregister the notifications here, but they - // aren't really hurting anything - } - } - - template <class T> - bool DependentResult<T>::DependentsIdentical(const std::vector<const TaggedObject*>& dependents, - const std::vector<Number>& scalar_dependents) const - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("DependentResult<T>::DependentsIdentical", dbg_verbosity); - DBG_ASSERT(stale_ == false); - DBG_ASSERT(dependents.size() == dependent_tags_.size()); -#endif - - bool retVal = true; - - if (dependents.size() != dependent_tags_.size() - || scalar_dependents.size() != scalar_dependents_.size()) { - retVal = false; - } - else { - for (Index i=0; i<(Index)dependents.size(); i++) { - if ( (dependents[i] && dependents[i]->GetTag() != dependent_tags_[i]) - || (!dependents[i] && dependent_tags_[i] != 0) ) { - retVal = false; - break; - } - } - if (retVal) { - for (Index i=0; i<(Index)scalar_dependents.size(); i++) { - if (scalar_dependents[i] != scalar_dependents_[i]) { - retVal = false; - break; - } - } - } - } - - return retVal; - } - - template <class T> - const T& DependentResult<T>::GetResult() const - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("DependentResult<T>::GetResult()", dbg_verbosity); - DBG_ASSERT(stale_ == false); -#endif - - return result_; - } - - template <class T> - void DependentResult<T>::DebugPrint() const - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("DependentResult<T>::DebugPrint", dbg_verbosity); -#endif - - } - - template <class T> - CachedResults<T>::CachedResults(Int max_cache_size) - : - max_cache_size_(max_cache_size), - cached_results_(NULL) - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::CachedResults", dbg_verbosity); -#endif - - } - - template <class T> - CachedResults<T>::~CachedResults() - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::!CachedResults()", dbg_verbosity); -#endif - - if (cached_results_) { - for (typename std::list< DependentResult<T>* >::iterator iter = cached_results_-> - begin(); - iter != cached_results_->end(); - iter++) { - delete *iter; - } - delete cached_results_; - } - /* - while (!cached_results_.empty()) { - DependentResult<T>* result = cached_results_.back(); - cached_results_.pop_back(); - delete result; - } - */ - } - - template <class T> - void CachedResults<T>::AddCachedResult(const T& result, - const std::vector<const TaggedObject*>& dependents, - const std::vector<Number>& scalar_dependents) - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::AddCachedResult", dbg_verbosity); -#endif - - CleanupInvalidatedResults(); - - // insert the new one here - DependentResult<T>* newResult = new DependentResult<T>(result, dependents, scalar_dependents); - if (!cached_results_) { - cached_results_ = new std::list<DependentResult<T>*>; - } - cached_results_->push_front(newResult); - - // keep the list small enough - if (max_cache_size_ >= 0) { // if negative, allow infinite cache - // non-negative - limit size of list to max_cache_size - DBG_ASSERT((Int)cached_results_->size()<=max_cache_size_+1); - if ((Int)cached_results_->size() > max_cache_size_) { - delete cached_results_->back(); - cached_results_->pop_back(); - } - } - -#ifdef IP_DEBUG_CACHE - DBG_EXEC(2, DebugPrintCachedResults()); -#endif - - } - - template <class T> - void CachedResults<T>::AddCachedResult(const T& result, - const std::vector<const TaggedObject*>& dependents) - { - std::vector<Number> scalar_dependents; - AddCachedResult(result, dependents, scalar_dependents); - } - - template <class T> - bool CachedResults<T>::GetCachedResult(T& retResult, const std::vector<const TaggedObject*>& dependents, - const std::vector<Number>& scalar_dependents) const - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::GetCachedResult", dbg_verbosity); -#endif - - if (!cached_results_) - return false; - - CleanupInvalidatedResults(); - - bool retValue = false; - typename std::list< DependentResult<T>* >::const_iterator iter; - for (iter = cached_results_->begin(); iter != cached_results_->end(); iter++) { - if ((*iter)->DependentsIdentical(dependents, scalar_dependents)) { - retResult = (*iter)->GetResult(); - retValue = true; - break; - } - } - -#ifdef IP_DEBUG_CACHE - DBG_EXEC(2, DebugPrintCachedResults()); -#endif - - return retValue; - } - - template <class T> - bool CachedResults<T>::GetCachedResult( - T& retResult, const std::vector<const TaggedObject*>& dependents) const - { - std::vector<Number> scalar_dependents; - return GetCachedResult(retResult, dependents, scalar_dependents); - } - - template <class T> - void CachedResults<T>::AddCachedResult1Dep(const T& result, - const TaggedObject* dependent1) - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::AddCachedResult1Dep", dbg_verbosity); -#endif - - std::vector<const TaggedObject*> dependents(1); - dependents[0] = dependent1; - - AddCachedResult(result, dependents); - } - - template <class T> - bool CachedResults<T>::GetCachedResult1Dep(T& retResult, const TaggedObject* dependent1) - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::GetCachedResult1Dep", dbg_verbosity); -#endif - - std::vector<const TaggedObject*> dependents(1); - dependents[0] = dependent1; - - return GetCachedResult(retResult, dependents); - } - - template <class T> - void CachedResults<T>::AddCachedResult2Dep(const T& result, const TaggedObject* dependent1, - const TaggedObject* dependent2) - - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::AddCachedResult2dDep", dbg_verbosity); -#endif - - std::vector<const TaggedObject*> dependents(2); - dependents[0] = dependent1; - dependents[1] = dependent2; - - AddCachedResult(result, dependents); - } - - template <class T> - bool CachedResults<T>::GetCachedResult2Dep(T& retResult, const TaggedObject* dependent1, const TaggedObject* dependent2) - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::GetCachedResult2Dep", dbg_verbosity); -#endif - - std::vector<const TaggedObject*> dependents(2); - dependents[0] = dependent1; - dependents[1] = dependent2; - - return GetCachedResult(retResult, dependents); - } - - template <class T> - void CachedResults<T>::AddCachedResult3Dep(const T& result, const TaggedObject* dependent1, - const TaggedObject* dependent2, - const TaggedObject* dependent3) - - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::AddCachedResult2dDep", dbg_verbosity); -#endif - - std::vector<const TaggedObject*> dependents(3); - dependents[0] = dependent1; - dependents[1] = dependent2; - dependents[2] = dependent3; - - AddCachedResult(result, dependents); - } - - template <class T> - bool CachedResults<T>::GetCachedResult3Dep(T& retResult, const TaggedObject* dependent1, - const TaggedObject* dependent2, - const TaggedObject* dependent3) - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::GetCachedResult2Dep", dbg_verbosity); -#endif - - std::vector<const TaggedObject*> dependents(3); - dependents[0] = dependent1; - dependents[1] = dependent2; - dependents[2] = dependent3; - - return GetCachedResult(retResult, dependents); - } - - template <class T> - bool CachedResults<T>::InvalidateResult(const std::vector<const TaggedObject*>& dependents, - const std::vector<Number>& scalar_dependents) - { - if (!cached_results_) - return false; - - CleanupInvalidatedResults(); - - bool retValue = false; - typename std::list< DependentResult<T>* >::const_iterator iter; - for (iter = cached_results_->begin(); iter != cached_results_->end(); - iter++) { - if ((*iter)->DependentsIdentical(dependents, scalar_dependents)) { - (*iter)->Invalidate(); - retValue = true; - break; - } - } - - return retValue; - } - - template <class T> - void CachedResults<T>::Clear() - { - if (!cached_results_) - return; - - typename std::list< DependentResult<T>* >::const_iterator iter; - for (iter = cached_results_->begin(); iter != cached_results_->end(); - iter++) { - (*iter)->Invalidate(); - } - - CleanupInvalidatedResults(); - } - - template <class T> - void CachedResults<T>::Clear(Int max_cache_size) - { - Clear(); - max_cache_size_ = max_cache_size; - } - - template <class T> - void CachedResults<T>::CleanupInvalidatedResults() const - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::CleanupInvalidatedResults", dbg_verbosity); -#endif - - if (!cached_results_) - return; - - typename std::list< DependentResult<T>* >::iterator iter; - iter = cached_results_->begin(); - while (iter != cached_results_->end()) { - if ((*iter)->IsStale()) { - typename std::list< DependentResult<T>* >::iterator - iter_to_remove = iter; - iter++; - DependentResult<T>* result_to_delete = (*iter_to_remove); - cached_results_->erase(iter_to_remove); - delete result_to_delete; - } - else { - iter++; - } - } - } - - template <class T> - void CachedResults<T>::DebugPrintCachedResults() const - { -#ifdef IP_DEBUG_CACHE - DBG_START_METH("CachedResults<T>::DebugPrintCachedResults", dbg_verbosity); - if (DBG_VERBOSITY()>=2 ) { - if (!chached_results_) { - DBG_PRINT((2," DependentResult:0x%x\n", (*iter))); - } - else { - typename std::list< DependentResult<T>* >::const_iterator iter; - DBG_PRINT((2,"Current set of cached results:\n")); - for (iter = cached_results_->begin(); iter != cached_results_->end(); iter++) { - DBG_PRINT((2," DependentResult:0x%x\n", (*iter))); - } - } - } -#endif - - } - -} // namespace Ipopt - -#endif +// Copyright (C) 2004, 2011 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpCachedResults.hpp 2276 2013-05-05 12:33:44Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPCACHEDRESULTS_HPP__
+#define __IPCACHEDRESULTS_HPP__
+
+#include "IpTaggedObject.hpp"
+#include "IpObserver.hpp"
+#include <algorithm>
+#include <vector>
+#include <list>
+
+namespace Ipopt
+{
+
+#if COIN_IPOPT_CHECKLEVEL > 2
+# define IP_DEBUG_CACHE
+#endif
+#ifdef IP_DEBUG_CACHE
+# include "IpDebug.hpp"
+#endif
+
+ // Forward Declarations
+
+ template <class T>
+ class DependentResult;
+
+ // AW: I'm taking this out, since this is by far the most used
+ // class. We should keep it as simple as possible.
+ // /** Cache Priority Enum */
+ // enum CachePriority
+ // {
+ // CP_Lowest,
+ // CP_Standard,
+ // CP_Trial,
+ // CP_Iterate
+ // };
+
+ /** Templated class for Cached Results. This class stores up to a
+ * given number of "results", entities that are stored here
+ * together with identifiers, that can be used to later retrieve the
+ * information again.
+ *
+ * Typically, T is a SmartPtr for some calculated quantity that
+ * should be stored (such as a Vector). The identifiers (or
+ * dependencies) are a (possibly varying) number of Tags from
+ * TaggedObjects, and a number of Numbers. Results are added to
+ * the cache using the AddCachedResults methods, and the can be
+ * retrieved with the GetCachedResults methods. The second set of
+ * methods checks whether a result has been cached for the given
+ * identifiers. If a corresponding result is found, a copy of it
+ * is returned and the method evaluates to true, otherwise it
+ * evaluates to false.
+ *
+ * Note that cached results can become "stale", namely when a
+ * TaggedObject that is used to identify this CachedResult is
+ * changed. When this happens, the cached result can never be
+ * asked for again, so that there is no point in storing it any
+ * longer. For this purpose, a cached result, which is stored as a
+ * DependentResult, inherits off an Observer. This Observer
+ * retrieves notification whenever a TaggedObject dependency has
+ * changed. Stale results are later removed from the cache.
+ */
+ template <class T>
+ class CachedResults
+ {
+ public:
+#ifdef IP_DEBUG_CACHE
+ /** (Only if compiled in DEBUG mode): debug verbosity level */
+ static const Index dbg_verbosity;
+#endif
+
+ /** @name Constructors and Destructors. */
+ //@{
+ /** Constructor, where max_cache_size is the maximal number of
+ * results that should be cached. If max_cache_size is negative,
+ * we allow an infinite amount of cache.
+ */
+ CachedResults(Int max_cache_size);
+
+ /** Destructor */
+ virtual ~CachedResults();
+ //@}
+
+ /** @name Generic methods for adding and retrieving cached results. */
+ //@{
+ /** Generic method for adding a result to the cache, given a
+ * std::vector of TaggesObjects and a std::vector of Numbers.
+ */
+ void AddCachedResult(const T& result,
+ const std::vector<const TaggedObject*>& dependents,
+ const std::vector<Number>& scalar_dependents);
+
+ /** Generic method for retrieving a cached results, given the
+ * dependencies as a std::vector of TaggesObjects and a
+ * std::vector of Numbers.
+ */
+ bool GetCachedResult(T& retResult,
+ const std::vector<const TaggedObject*>& dependents,
+ const std::vector<Number>& scalar_dependents) const;
+
+ /** Method for adding a result, providing only a std::vector of
+ * TaggedObjects.
+ */
+ void AddCachedResult(const T& result,
+ const std::vector<const TaggedObject*>& dependents);
+
+ /** Method for retrieving a cached result, providing only a
+ * std::vector of TaggedObjects.
+ */
+ bool GetCachedResult(T& retResult,
+ const std::vector<const TaggedObject*>& dependents) const;
+ //@}
+
+ /** @name Pointer-based methods for adding and retrieving cached
+ * results, providing dependencies explicitly.
+ */
+ //@{
+ /** Method for adding a result to the cache, proving one
+ * dependency as a TaggedObject explicitly.
+ */
+ void AddCachedResult1Dep(const T& result,
+ const TaggedObject* dependent1);
+
+ /** Method for retrieving a cached result, proving one dependency
+ * as a TaggedObject explicitly.
+ */
+ bool GetCachedResult1Dep(T& retResult, const TaggedObject* dependent1);
+
+ /** Method for adding a result to the cache, proving two
+ * dependencies as a TaggedObject explicitly.
+ */
+ void AddCachedResult2Dep(const T& result,
+ const TaggedObject* dependent1,
+ const TaggedObject* dependent2);
+
+ /** Method for retrieving a cached result, proving two
+ * dependencies as a TaggedObject explicitly.
+ */
+ bool GetCachedResult2Dep(T& retResult,
+ const TaggedObject* dependent1,
+ const TaggedObject* dependent2);
+
+ /** Method for adding a result to the cache, proving three
+ * dependencies as a TaggedObject explicitly.
+ */
+ void AddCachedResult3Dep(const T& result,
+ const TaggedObject* dependent1,
+ const TaggedObject* dependent2,
+ const TaggedObject* dependent3);
+
+ /** Method for retrieving a cached result, proving three
+ * dependencies as a TaggedObject explicitly.
+ */
+ bool GetCachedResult3Dep(T& retResult,
+ const TaggedObject* dependent1,
+ const TaggedObject* dependent2,
+ const TaggedObject* dependent3);
+
+ /** @name Pointer-free version of the Add and Get methods */
+ //@{
+ bool GetCachedResult1Dep(T& retResult, const TaggedObject& dependent1)
+ {
+ return GetCachedResult1Dep(retResult, &dependent1);
+ }
+ bool GetCachedResult2Dep(T& retResult,
+ const TaggedObject& dependent1,
+ const TaggedObject& dependent2)
+ {
+ return GetCachedResult2Dep(retResult, &dependent1, &dependent2);
+ }
+ bool GetCachedResult3Dep(T& retResult,
+ const TaggedObject& dependent1,
+ const TaggedObject& dependent2,
+ const TaggedObject& dependent3)
+ {
+ return GetCachedResult3Dep(retResult, &dependent1, &dependent2, &dependent3);
+ }
+ void AddCachedResult1Dep(const T& result,
+ const TaggedObject& dependent1)
+ {
+ AddCachedResult1Dep(result, &dependent1);
+ }
+ void AddCachedResult2Dep(const T& result,
+ const TaggedObject& dependent1,
+ const TaggedObject& dependent2)
+ {
+ AddCachedResult2Dep(result, &dependent1, &dependent2);
+ }
+ void AddCachedResult3Dep(const T& result,
+ const TaggedObject& dependent1,
+ const TaggedObject& dependent2,
+ const TaggedObject& dependent3)
+ {
+ AddCachedResult3Dep(result, &dependent1, &dependent2, &dependent3);
+ }
+ //@}
+
+ /** Invalidates the result for given dependencies. Sets the stale
+ * flag for the corresponding cached result to true if it is
+ * found. Returns true, if the result was found. */
+ bool InvalidateResult(const std::vector<const TaggedObject*>& dependents,
+ const std::vector<Number>& scalar_dependents);
+
+ /** Invalidates all cached results */
+ void Clear();
+
+ /** Invalidate all cached results and changes max_cache_size */
+ void Clear(Int max_cache_size);
+
+ 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 */
+ CachedResults();
+
+ /** Copy Constructor */
+ CachedResults(const CachedResults&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const CachedResults&);
+ //@}
+
+ /** maximum number of cached results */
+ Int max_cache_size_;
+
+ /** list of currently cached results. */
+ mutable std::list<DependentResult<T>*>* cached_results_;
+
+ /** internal method for removing stale DependentResults from the
+ * list. It is called at the beginning of every
+ * GetDependentResult method.
+ */
+ void CleanupInvalidatedResults() const;
+
+ /** Print list of currently cached results */
+ void DebugPrintCachedResults() const;
+ };
+
+ /** Templated class which stores one entry for the CachedResult
+ * class. It stores the result (of type T), together with its
+ * dependencies (vector of TaggedObjects and vector of Numbers).
+ * It also stores a priority.
+ */
+ template <class T>
+ class DependentResult : public Observer
+ {
+ public:
+
+#ifdef IP_DEBUG_CACHE
+ static const Index dbg_verbosity;
+#endif
+
+ /** @name Constructor, Destructors */
+ //@{
+ /** Constructor, given all information about the result. */
+ DependentResult(const T& result, const std::vector<const TaggedObject*>& dependents,
+ const std::vector<Number>& scalar_dependents);
+
+ /** Destructor. */
+ ~DependentResult();
+ //@}
+
+ /** @name Accessor method. */
+ //@{
+ /** This returns true, if the DependentResult is no longer valid. */
+ bool IsStale() const;
+
+ /** Invalidates the cached result. */
+ void Invalidate();
+
+ /** Returns the cached result. */
+ const T& GetResult() const;
+ //@}
+
+ /** This method returns true if the dependencies provided to this
+ * function are identical to the ones stored with the
+ * DependentResult.
+ */
+ bool DependentsIdentical(const std::vector<const TaggedObject*>& dependents,
+ const std::vector<Number>& scalar_dependents) const;
+
+ /** Print information about this DependentResults. */
+ void DebugPrint() const;
+
+ protected:
+ /** This method is overloading the pure virtual method from the
+ * Observer base class. This method is called when a Subject
+ * registered for this Observer sends a notification. In this
+ * particular case, if this method is called with
+ * notify_type==NT_Changed or NT_BeingDeleted, then this results
+ * is marked as stale.
+ */
+ virtual void RecieveNotification(NotifyType notify_type, const Subject* subject);
+
+ 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 */
+ DependentResult();
+
+ /** Copy Constructor */
+ DependentResult(const DependentResult&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const DependentResult&);
+ //@}
+
+ /** Flag indicating, if the cached result is still valid. A
+ result becomes invalid, if the RecieveNotification method is
+ called with NT_Changed */
+ bool stale_;
+ /** The value of the dependent results */
+ const T result_;
+ /** Dependencies in form of TaggedObjects */
+ std::vector<TaggedObject::Tag> dependent_tags_;
+ /** Dependencies in form a Numbers */
+ std::vector<Number> scalar_dependents_;
+ };
+
+#ifdef IP_DEBUG_CACHE
+ template <class T>
+ const Index CachedResults<T>::dbg_verbosity = 0;
+
+ template <class T>
+ const Index DependentResult<T>::dbg_verbosity = 0;
+#endif
+
+ template <class T>
+ DependentResult<T>::DependentResult(
+ const T& result,
+ const std::vector<const TaggedObject*>& dependents,
+ const std::vector<Number>& scalar_dependents)
+ :
+ stale_(false),
+ result_(result),
+ dependent_tags_(dependents.size()),
+ scalar_dependents_(scalar_dependents)
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("DependentResult<T>::DependentResult()", dbg_verbosity);
+#endif
+
+ for (Index i=0; i<(Index)dependents.size(); i++) {
+ if (dependents[i]) {
+ // Call the RequestAttach method of the Observer base class.
+ // This will add this dependent result in the Observer list
+ // for the Subject dependents[i]. As a consequence, the
+ // RecieveNotification method of this DependentResult will be
+ // called with notify_type=NT_Changed, whenever the
+ // TaggedResult dependents[i] is changed (i.e. its HasChanged
+ // method is called).
+ RequestAttach(NT_Changed, dependents[i]);
+ dependent_tags_[i] = dependents[i]->GetTag();
+ }
+ else {
+ dependent_tags_[i] = TaggedObject::Tag();
+ }
+ }
+ }
+
+ template <class T>
+ DependentResult<T>::~DependentResult()
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("DependentResult<T>::~DependentResult()", dbg_verbosity);
+ //DBG_ASSERT(stale_ == true);
+#endif
+ // Nothing to be done here, destructor
+ // of T should sufficiently remove
+ // any memory, etc.
+ }
+
+ template <class T>
+ bool DependentResult<T>::IsStale() const
+ {
+ return stale_;
+ }
+
+ template <class T>
+ void DependentResult<T>::Invalidate()
+ {
+ stale_ = true;
+ }
+
+ template <class T>
+ void DependentResult<T>::RecieveNotification(NotifyType notify_type, const Subject* subject)
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("DependentResult<T>::RecieveNotification", dbg_verbosity);
+#endif
+
+ if (notify_type == NT_Changed || notify_type==NT_BeingDestroyed) {
+ stale_ = true;
+ // technically, I could unregister the notifications here, but they
+ // aren't really hurting anything
+ }
+ }
+
+ template <class T>
+ bool DependentResult<T>::DependentsIdentical(const std::vector<const TaggedObject*>& dependents,
+ const std::vector<Number>& scalar_dependents) const
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("DependentResult<T>::DependentsIdentical", dbg_verbosity);
+ DBG_ASSERT(stale_ == false);
+ DBG_ASSERT(dependents.size() == dependent_tags_.size());
+#endif
+
+ bool retVal = true;
+
+ if (dependents.size() != dependent_tags_.size()
+ || scalar_dependents.size() != scalar_dependents_.size()) {
+ retVal = false;
+ }
+ else {
+ for (Index i=0; i<(Index)dependents.size(); i++) {
+ if ( (dependents[i] && dependents[i]->GetTag() != dependent_tags_[i])
+ || (!dependents[i] && dependent_tags_[i] != TaggedObject::Tag()) ) {
+ retVal = false;
+ break;
+ }
+ }
+ if (retVal) {
+ for (Index i=0; i<(Index)scalar_dependents.size(); i++) {
+ if (scalar_dependents[i] != scalar_dependents_[i]) {
+ retVal = false;
+ break;
+ }
+ }
+ }
+ }
+
+ return retVal;
+ }
+
+ template <class T>
+ const T& DependentResult<T>::GetResult() const
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("DependentResult<T>::GetResult()", dbg_verbosity);
+ DBG_ASSERT(stale_ == false);
+#endif
+
+ return result_;
+ }
+
+ template <class T>
+ void DependentResult<T>::DebugPrint() const
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("DependentResult<T>::DebugPrint", dbg_verbosity);
+#endif
+
+ }
+
+ template <class T>
+ CachedResults<T>::CachedResults(Int max_cache_size)
+ :
+ max_cache_size_(max_cache_size),
+ cached_results_(NULL)
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::CachedResults", dbg_verbosity);
+#endif
+
+ }
+
+ template <class T>
+ CachedResults<T>::~CachedResults()
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::!CachedResults()", dbg_verbosity);
+#endif
+
+ if (cached_results_) {
+ for (typename std::list< DependentResult<T>* >::iterator iter = cached_results_->
+ begin();
+ iter != cached_results_->end();
+ iter++) {
+ delete *iter;
+ }
+ delete cached_results_;
+ }
+ /*
+ while (!cached_results_.empty()) {
+ DependentResult<T>* result = cached_results_.back();
+ cached_results_.pop_back();
+ delete result;
+ }
+ */
+ }
+
+ template <class T>
+ void CachedResults<T>::AddCachedResult(const T& result,
+ const std::vector<const TaggedObject*>& dependents,
+ const std::vector<Number>& scalar_dependents)
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::AddCachedResult", dbg_verbosity);
+#endif
+
+ CleanupInvalidatedResults();
+
+ // insert the new one here
+ DependentResult<T>* newResult = new DependentResult<T>(result, dependents, scalar_dependents);
+ if (!cached_results_) {
+ cached_results_ = new std::list<DependentResult<T>*>;
+ }
+ cached_results_->push_front(newResult);
+
+ // keep the list small enough
+ if (max_cache_size_ >= 0) { // if negative, allow infinite cache
+ // non-negative - limit size of list to max_cache_size
+ DBG_ASSERT((Int)cached_results_->size()<=max_cache_size_+1);
+ if ((Int)cached_results_->size() > max_cache_size_) {
+ delete cached_results_->back();
+ cached_results_->pop_back();
+ }
+ }
+
+#ifdef IP_DEBUG_CACHE
+ DBG_EXEC(2, DebugPrintCachedResults());
+#endif
+
+ }
+
+ template <class T>
+ void CachedResults<T>::AddCachedResult(const T& result,
+ const std::vector<const TaggedObject*>& dependents)
+ {
+ std::vector<Number> scalar_dependents;
+ AddCachedResult(result, dependents, scalar_dependents);
+ }
+
+ template <class T>
+ bool CachedResults<T>::GetCachedResult(T& retResult, const std::vector<const TaggedObject*>& dependents,
+ const std::vector<Number>& scalar_dependents) const
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::GetCachedResult", dbg_verbosity);
+#endif
+
+ if (!cached_results_)
+ return false;
+
+ CleanupInvalidatedResults();
+
+ bool retValue = false;
+ typename std::list< DependentResult<T>* >::const_iterator iter;
+ for (iter = cached_results_->begin(); iter != cached_results_->end(); iter++) {
+ if ((*iter)->DependentsIdentical(dependents, scalar_dependents)) {
+ retResult = (*iter)->GetResult();
+ retValue = true;
+ break;
+ }
+ }
+
+#ifdef IP_DEBUG_CACHE
+ DBG_EXEC(2, DebugPrintCachedResults());
+#endif
+
+ return retValue;
+ }
+
+ template <class T>
+ bool CachedResults<T>::GetCachedResult(
+ T& retResult, const std::vector<const TaggedObject*>& dependents) const
+ {
+ std::vector<Number> scalar_dependents;
+ return GetCachedResult(retResult, dependents, scalar_dependents);
+ }
+
+ template <class T>
+ void CachedResults<T>::AddCachedResult1Dep(const T& result,
+ const TaggedObject* dependent1)
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::AddCachedResult1Dep", dbg_verbosity);
+#endif
+
+ std::vector<const TaggedObject*> dependents(1);
+ dependents[0] = dependent1;
+
+ AddCachedResult(result, dependents);
+ }
+
+ template <class T>
+ bool CachedResults<T>::GetCachedResult1Dep(T& retResult, const TaggedObject* dependent1)
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::GetCachedResult1Dep", dbg_verbosity);
+#endif
+
+ std::vector<const TaggedObject*> dependents(1);
+ dependents[0] = dependent1;
+
+ return GetCachedResult(retResult, dependents);
+ }
+
+ template <class T>
+ void CachedResults<T>::AddCachedResult2Dep(const T& result, const TaggedObject* dependent1,
+ const TaggedObject* dependent2)
+
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::AddCachedResult2dDep", dbg_verbosity);
+#endif
+
+ std::vector<const TaggedObject*> dependents(2);
+ dependents[0] = dependent1;
+ dependents[1] = dependent2;
+
+ AddCachedResult(result, dependents);
+ }
+
+ template <class T>
+ bool CachedResults<T>::GetCachedResult2Dep(T& retResult, const TaggedObject* dependent1, const TaggedObject* dependent2)
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::GetCachedResult2Dep", dbg_verbosity);
+#endif
+
+ std::vector<const TaggedObject*> dependents(2);
+ dependents[0] = dependent1;
+ dependents[1] = dependent2;
+
+ return GetCachedResult(retResult, dependents);
+ }
+
+ template <class T>
+ void CachedResults<T>::AddCachedResult3Dep(const T& result, const TaggedObject* dependent1,
+ const TaggedObject* dependent2,
+ const TaggedObject* dependent3)
+
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::AddCachedResult2dDep", dbg_verbosity);
+#endif
+
+ std::vector<const TaggedObject*> dependents(3);
+ dependents[0] = dependent1;
+ dependents[1] = dependent2;
+ dependents[2] = dependent3;
+
+ AddCachedResult(result, dependents);
+ }
+
+ template <class T>
+ bool CachedResults<T>::GetCachedResult3Dep(T& retResult, const TaggedObject* dependent1,
+ const TaggedObject* dependent2,
+ const TaggedObject* dependent3)
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::GetCachedResult2Dep", dbg_verbosity);
+#endif
+
+ std::vector<const TaggedObject*> dependents(3);
+ dependents[0] = dependent1;
+ dependents[1] = dependent2;
+ dependents[2] = dependent3;
+
+ return GetCachedResult(retResult, dependents);
+ }
+
+ template <class T>
+ bool CachedResults<T>::InvalidateResult(const std::vector<const TaggedObject*>& dependents,
+ const std::vector<Number>& scalar_dependents)
+ {
+ if (!cached_results_)
+ return false;
+
+ CleanupInvalidatedResults();
+
+ bool retValue = false;
+ typename std::list< DependentResult<T>* >::const_iterator iter;
+ for (iter = cached_results_->begin(); iter != cached_results_->end();
+ iter++) {
+ if ((*iter)->DependentsIdentical(dependents, scalar_dependents)) {
+ (*iter)->Invalidate();
+ retValue = true;
+ break;
+ }
+ }
+
+ return retValue;
+ }
+
+ template <class T>
+ void CachedResults<T>::Clear()
+ {
+ if (!cached_results_)
+ return;
+
+ typename std::list< DependentResult<T>* >::const_iterator iter;
+ for (iter = cached_results_->begin(); iter != cached_results_->end();
+ iter++) {
+ (*iter)->Invalidate();
+ }
+
+ CleanupInvalidatedResults();
+ }
+
+ template <class T>
+ void CachedResults<T>::Clear(Int max_cache_size)
+ {
+ Clear();
+ max_cache_size_ = max_cache_size;
+ }
+
+ template <class T>
+ void CachedResults<T>::CleanupInvalidatedResults() const
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::CleanupInvalidatedResults", dbg_verbosity);
+#endif
+
+ if (!cached_results_)
+ return;
+
+ typename std::list< DependentResult<T>* >::iterator iter;
+ iter = cached_results_->begin();
+ while (iter != cached_results_->end()) {
+ if ((*iter)->IsStale()) {
+ typename std::list< DependentResult<T>* >::iterator
+ iter_to_remove = iter;
+ iter++;
+ DependentResult<T>* result_to_delete = (*iter_to_remove);
+ cached_results_->erase(iter_to_remove);
+ delete result_to_delete;
+ }
+ else {
+ iter++;
+ }
+ }
+ }
+
+ template <class T>
+ void CachedResults<T>::DebugPrintCachedResults() const
+ {
+#ifdef IP_DEBUG_CACHE
+ DBG_START_METH("CachedResults<T>::DebugPrintCachedResults", dbg_verbosity);
+ if (DBG_VERBOSITY()>=2 ) {
+ if (!cached_results_) {
+ DBG_PRINT((2,"Currentlt no cached results:\n"));
+ }
+ else {
+ typename std::list< DependentResult<T>* >::const_iterator iter;
+ DBG_PRINT((2,"Current set of cached results:\n"));
+ for (iter = cached_results_->begin(); iter != cached_results_->end(); iter++) {
+ DBG_PRINT((2," DependentResult:0x%x\n", (*iter)));
+ }
+ }
+ }
+#endif
+
+ }
+
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpDebug.hpp b/thirdparty/windows/include/coin/IpDebug.hpp index 9716f5d..f117c89 100644 --- a/thirdparty/windows/include/coin/IpDebug.hpp +++ b/thirdparty/windows/include/coin/IpDebug.hpp @@ -1,142 +1,150 @@ -// Copyright (C) 2004, 2007 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpDebug.hpp 1000 2007-06-16 06:52:34Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPDEBUG_HPP__ -#define __IPDEBUG_HPP__ - -#include "IpoptConfig.h" -#include "IpTypes.hpp" - -#ifdef HAVE_CASSERT -# include <cassert> -#else -# ifdef HAVE_ASSERT_H -# include <assert.h> -# else -# error "don't have header file for assert" -# endif -#endif - -#if COIN_IPOPT_CHECKLEVEL > 0 -# ifdef NDEBUG -# undef NDEBUG -# endif -# define DBG_ASSERT(test) assert(test) -# define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg) \ - ASSERT_EXCEPTION( (__condition), __except_type, __msg); -# define DBG_DO(__cmd) __cmd -#else -# define DBG_ASSERT(test) -# define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg) -# define DBG_DO(__cmd) -#endif - -#if COIN_IPOPT_VERBOSITY < 1 -# define DBG_START_FUN(__func_name, __verbose_level) -# define DBG_START_METH(__func_name, __verbose_level) -# define DBG_PRINT(__printf_args) -# define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec) -# define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat) -# define DBG_EXEC(__verbosity, __cmd) -# define DBG_VERBOSITY() 0 -#else -#include <string> - -namespace Ipopt -{ - // forward definition - class Journalist; - - /** Class that lives throughout the execution of a method or - * function for which debug output is to be generated. The output - * is sent to the unique debug journalist that is set with - * SetJournalist at the beginning of program execution. */ - class DebugJournalistWrapper - { - public: - /** @name Constructors/Destructors. */ - //@{ - DebugJournalistWrapper(std::string func_name, Index verbose_level); - DebugJournalistWrapper(std::string func_name, Index verbose_level, - const void* const method_owner); - ~DebugJournalistWrapper(); - //@} - - /** @name accessor methods */ - //@{ - Index Verbosity() - { - return verbose_level_; - } - const Journalist* Jnlst() - { - return jrnl_; - } - Index IndentationLevel() - { - return indentation_level_; - } - //@} - - /** Printing */ - void DebugPrintf(Index verbosity, const char* pformat, ...); - - /* Method for initialization of the static GLOBAL journalist, - * through with all debug printout is to be written. This needs - * to be set before any debug printout can be done. */ - static void SetJournalist(Journalist* jrnl); - - 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 */ - DebugJournalistWrapper(); - - /** copy contructor */ - DebugJournalistWrapper(const DebugJournalistWrapper&); - - /** Overloaded Equals Operator */ - DebugJournalistWrapper& operator=(const DebugJournalistWrapper&); - //@} - - static Index indentation_level_; - std::string func_name_; - Index verbose_level_; - const void* method_owner_; - - static Journalist* jrnl_; - }; -} - -# define DBG_START_FUN(__func_name, __verbose_level) \ - DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level)); \ - -# define DBG_START_METH(__func_name, __verbose_level) \ - DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level), this); - -# define DBG_PRINT(__args) \ - dbg_jrnl.DebugPrintf __args; - -# define DBG_EXEC(__verbose_level, __cmd) \ - if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \ - (__cmd); \ - } - -# define DBG_VERBOSITY() \ - dbg_jrnl.Verbosity() - -#endif - - -#endif +// Copyright (C) 2004, 2007 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpDebug.hpp 2005 2011-06-06 12:55:16Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPDEBUG_HPP__
+#define __IPDEBUG_HPP__
+
+#include "IpoptConfig.h"
+#include "IpTypes.hpp"
+
+#ifdef COIN_IPOPT_CHECKLEVEL
+#ifdef HAVE_CASSERT
+# include <cassert>
+#else
+# ifdef HAVE_ASSERT_H
+# include <assert.h>
+# else
+# error "don't have header file for assert"
+# endif
+#endif
+#else
+#define COIN_IPOPT_CHECKLEVEL 0
+#endif
+
+#if COIN_IPOPT_CHECKLEVEL > 0
+# ifdef NDEBUG
+# undef NDEBUG
+# endif
+# define DBG_ASSERT(test) assert(test)
+# define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg) \
+ ASSERT_EXCEPTION( (__condition), __except_type, __msg);
+# define DBG_DO(__cmd) __cmd
+#else
+# define DBG_ASSERT(test)
+# define DBG_ASSERT_EXCEPTION(__condition, __except_type, __msg)
+# define DBG_DO(__cmd)
+#endif
+
+#ifndef COIN_IPOPT_VERBOSITY
+#define COIN_IPOPT_VERBOSITY 0
+#endif
+
+#if COIN_IPOPT_VERBOSITY < 1
+# define DBG_START_FUN(__func_name, __verbose_level)
+# define DBG_START_METH(__func_name, __verbose_level)
+# define DBG_PRINT(__printf_args)
+# define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec)
+# define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat)
+# define DBG_EXEC(__verbosity, __cmd)
+# define DBG_VERBOSITY() 0
+#else
+#include <string>
+
+namespace Ipopt
+{
+ // forward definition
+ class Journalist;
+
+ /** Class that lives throughout the execution of a method or
+ * function for which debug output is to be generated. The output
+ * is sent to the unique debug journalist that is set with
+ * SetJournalist at the beginning of program execution. */
+ class DebugJournalistWrapper
+ {
+ public:
+ /** @name Constructors/Destructors. */
+ //@{
+ DebugJournalistWrapper(std::string func_name, Index verbose_level);
+ DebugJournalistWrapper(std::string func_name, Index verbose_level,
+ const void* const method_owner);
+ ~DebugJournalistWrapper();
+ //@}
+
+ /** @name accessor methods */
+ //@{
+ Index Verbosity()
+ {
+ return verbose_level_;
+ }
+ const Journalist* Jnlst()
+ {
+ return jrnl_;
+ }
+ Index IndentationLevel()
+ {
+ return indentation_level_;
+ }
+ //@}
+
+ /** Printing */
+ void DebugPrintf(Index verbosity, const char* pformat, ...);
+
+ /* Method for initialization of the static GLOBAL journalist,
+ * through with all debug printout is to be written. This needs
+ * to be set before any debug printout can be done. */
+ static void SetJournalist(Journalist* jrnl);
+
+ 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 */
+ DebugJournalistWrapper();
+
+ /** copy contructor */
+ DebugJournalistWrapper(const DebugJournalistWrapper&);
+
+ /** Overloaded Equals Operator */
+ DebugJournalistWrapper& operator=(const DebugJournalistWrapper&);
+ //@}
+
+ static Index indentation_level_;
+ std::string func_name_;
+ Index verbose_level_;
+ const void* method_owner_;
+
+ static Journalist* jrnl_;
+ };
+}
+
+# define DBG_START_FUN(__func_name, __verbose_level) \
+ DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level)); \
+
+# define DBG_START_METH(__func_name, __verbose_level) \
+ DebugJournalistWrapper dbg_jrnl((__func_name), (__verbose_level), this);
+
+# define DBG_PRINT(__args) \
+ dbg_jrnl.DebugPrintf __args;
+
+# define DBG_EXEC(__verbose_level, __cmd) \
+ if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \
+ (__cmd); \
+ }
+
+# define DBG_VERBOSITY() \
+ dbg_jrnl.Verbosity()
+
+#endif
+
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpException.hpp b/thirdparty/windows/include/coin/IpException.hpp index d5fd944..7832a73 100644 --- a/thirdparty/windows/include/coin/IpException.hpp +++ b/thirdparty/windows/include/coin/IpException.hpp @@ -1,147 +1,147 @@ -// Copyright (C) 2004, 2006 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpException.hpp 1019 2007-06-24 03:52:34Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPEXCEPTION_HPP__ -#define __IPEXCEPTION_HPP__ - -#include "IpUtils.hpp" -#include "IpJournalist.hpp" - -/* This file contains a base class for all exceptions - * and a set of macros to help with exceptions - */ - -namespace Ipopt -{ - - /** This is the base class for all exceptions. The easiest way to - * use this class is by means of the following macros: - * - * \verbatim - - DECLARE_STD_EXCEPTION(ExceptionType); - \endverbatim - * - * This macro defines a new class with the name ExceptionType, - * inherited from the base class IpoptException. After this, - * exceptions of this type can be thrown using - * - * \verbatim - - THROW_EXCEPTION(ExceptionType, Message); - \endverbatim - * - * where Message is a std::string with a message that gives an - * indication of what caused the exception. Exceptions can also be - * thrown using the macro - * - * \verbatim - - ASSERT_EXCEPTION(Condition, ExceptionType, Message); - \endverbatim - * - * where Conditions is an expression. If Condition evaluates to - * false, then the exception of the type ExceptionType is thrown - * with Message. - * - * When an exception is caught, the method ReportException can be - * used to write the information about the exception to the - * Journalist, using the level J_ERROR and the category J_MAIN. - * - */ - class IpoptException - { - public: - /**@name Constructors/Destructors */ - //@{ - /** Constructor */ - IpoptException(std::string msg, std::string file_name, Index line_number, std::string type="IpoptException") - : - msg_(msg), - file_name_(file_name), - line_number_(line_number), - type_(type) - {} - - /** Copy Constructor */ - IpoptException(const IpoptException& copy) - : - msg_(copy.msg_), - file_name_(copy.file_name_), - line_number_(copy.line_number_), - type_(copy.type_) - {} - - /** Default destructor */ - virtual ~IpoptException() - {} - //@} - - /** Method to report the exception to a journalist */ - void ReportException(const Journalist& jnlst, - EJournalLevel level = J_ERROR) const - { - jnlst.Printf(level, J_MAIN, - "Exception of type: %s in file \"%s\" at line %d:\n Exception message: %s\n", - type_.c_str(), file_name_.c_str(), line_number_, msg_.c_str()); - } - - const std::string& Message() const - { - return msg_; - } - - 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 */ - IpoptException(); - - /** Overloaded Equals Operator */ - void operator=(const IpoptException&); - //@} - - std::string msg_; - std::string file_name_; - Index line_number_; - std::string type_; - }; - -#define THROW_EXCEPTION(__except_type, __msg) \ - throw __except_type( (__msg), (__FILE__), (__LINE__) ); - -#define ASSERT_EXCEPTION(__condition, __except_type, __msg) \ - if (! (__condition) ) { \ - std::string newmsg = #__condition; \ - newmsg += " evaluated false: "; \ - newmsg += __msg; \ - throw __except_type( (newmsg), (__FILE__), (__LINE__) ); \ - } - -#define DECLARE_STD_EXCEPTION(__except_type) \ - class __except_type : public IpoptException \ - { \ - public: \ - __except_type(std::string msg, std::string fname, Index line) \ - : IpoptException(msg,fname,line, #__except_type) {} \ - __except_type(const __except_type& copy) \ - : IpoptException(copy) {} \ - private: \ - __except_type(); \ - void operator=(const __except_type&); \ - } - -} // namespace Ipopt - -#endif +// Copyright (C) 2004, 2006 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpException.hpp 2023 2011-06-18 18:49:49Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPEXCEPTION_HPP__
+#define __IPEXCEPTION_HPP__
+
+#include "IpUtils.hpp"
+#include "IpJournalist.hpp"
+
+/* This file contains a base class for all exceptions
+ * and a set of macros to help with exceptions
+ */
+
+namespace Ipopt
+{
+
+ /** This is the base class for all exceptions. The easiest way to
+ * use this class is by means of the following macros:
+ *
+ * \verbatim
+
+ DECLARE_STD_EXCEPTION(ExceptionType);
+ \endverbatim
+ *
+ * This macro defines a new class with the name ExceptionType,
+ * inherited from the base class IpoptException. After this,
+ * exceptions of this type can be thrown using
+ *
+ * \verbatim
+
+ THROW_EXCEPTION(ExceptionType, Message);
+ \endverbatim
+ *
+ * where Message is a std::string with a message that gives an
+ * indication of what caused the exception. Exceptions can also be
+ * thrown using the macro
+ *
+ * \verbatim
+
+ ASSERT_EXCEPTION(Condition, ExceptionType, Message);
+ \endverbatim
+ *
+ * where Conditions is an expression. If Condition evaluates to
+ * false, then the exception of the type ExceptionType is thrown
+ * with Message.
+ *
+ * When an exception is caught, the method ReportException can be
+ * used to write the information about the exception to the
+ * Journalist, using the level J_ERROR and the category J_MAIN.
+ *
+ */
+ class IpoptException
+ {
+ public:
+ /**@name Constructors/Destructors */
+ //@{
+ /** Constructor */
+ IpoptException(std::string msg, std::string file_name, Index line_number, std::string type="IpoptException")
+ :
+ msg_(msg),
+ file_name_(file_name),
+ line_number_(line_number),
+ type_(type)
+ {}
+
+ /** Copy Constructor */
+ IpoptException(const IpoptException& copy)
+ :
+ msg_(copy.msg_),
+ file_name_(copy.file_name_),
+ line_number_(copy.line_number_),
+ type_(copy.type_)
+ {}
+
+ /** Default destructor */
+ virtual ~IpoptException()
+ {}
+ //@}
+
+ /** Method to report the exception to a journalist */
+ void ReportException(const Journalist& jnlst,
+ EJournalLevel level = J_ERROR) const
+ {
+ jnlst.Printf(level, J_MAIN,
+ "Exception of type: %s in file \"%s\" at line %d:\n Exception message: %s\n",
+ type_.c_str(), file_name_.c_str(), line_number_, msg_.c_str());
+ }
+
+ const std::string& Message() const
+ {
+ return msg_;
+ }
+
+ 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 */
+ IpoptException();
+
+ /** Overloaded Equals Operator */
+ void operator=(const IpoptException&);
+ //@}
+
+ std::string msg_;
+ std::string file_name_;
+ Index line_number_;
+ std::string type_;
+ };
+
+} // namespace Ipopt
+
+#define THROW_EXCEPTION(__except_type, __msg) \
+ throw __except_type( (__msg), (__FILE__), (__LINE__) );
+
+#define ASSERT_EXCEPTION(__condition, __except_type, __msg) \
+ if (! (__condition) ) { \
+ std::string newmsg = #__condition; \
+ newmsg += " evaluated false: "; \
+ newmsg += __msg; \
+ throw __except_type( (newmsg), (__FILE__), (__LINE__) ); \
+ }
+
+#define DECLARE_STD_EXCEPTION(__except_type) \
+ class __except_type : public Ipopt::IpoptException \
+ { \
+ public: \
+ __except_type(std::string msg, std::string fname, Ipopt::Index line) \
+ : Ipopt::IpoptException(msg,fname,line, #__except_type) {} \
+ __except_type(const __except_type& copy) \
+ : Ipopt::IpoptException(copy) {} \
+ private: \
+ __except_type(); \
+ void operator=(const __except_type&); \
+ }
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpIpoptApplication.hpp b/thirdparty/windows/include/coin/IpIpoptApplication.hpp index d2bcf27..6729c7a 100644 --- a/thirdparty/windows/include/coin/IpIpoptApplication.hpp +++ b/thirdparty/windows/include/coin/IpIpoptApplication.hpp @@ -1,240 +1,243 @@ -// Copyright (C) 2004, 2009 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpIpoptApplication.hpp 1587 2009-10-27 16:09:21Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPIPOPTAPPLICATION_HPP__ -#define __IPIPOPTAPPLICATION_HPP__ - -#ifndef IPOPT_EXPORT -#ifdef _MSC_VER -#ifdef IPOPT_DLL -#define IPOPT_EXPORT(type) __declspec(dllexport) type __cdecl -#else -#define IPOPT_EXPORT(type) type __cdecl -#endif -#else -#define IPOPT_EXPORT(type) type -#endif -#endif - -#include <iostream> - -#include "IpJournalist.hpp" -#include "IpTNLP.hpp" -#include "IpNLP.hpp" -/* Return codes for the Optimize call for an application */ -#include "IpReturnCodes.hpp" - -namespace Ipopt -{ - DECLARE_STD_EXCEPTION(IPOPT_APPLICATION_ERROR); - - /* forward declarations */ - class IpoptAlgorithm; - class IpoptNLP; - class IpoptData; - class IpoptCalculatedQuantities; - class AlgorithmBuilder; - class RegisteredOptions; - class OptionsList; - class SolveStatistics; - - /** This is the main application class for making calls to Ipopt. */ - class IpoptApplication : public ReferencedObject - { - public: - IpoptApplication(bool create_console_out = true, - bool create_empty = false); - - /** Another constructor that assumes that the code in the - * (default) constructor has already been executed */ - IpoptApplication(SmartPtr<RegisteredOptions> reg_options, - SmartPtr<OptionsList> options, - SmartPtr<Journalist> jnlst); - - virtual ~IpoptApplication(); - - /** Method for creating a new IpoptApplication that uses the same - * journalist and registered options, and a copy of the options - list. */ - virtual SmartPtr<IpoptApplication> clone(); - - /** Initialize method. This method reads the params file and - * initializes the journalists. You should call this method at - * some point before the first optimize call. Note: you can skip - * the processing of a params file by setting params_file to "". - * It returns something other than Solve_Succeeded if there was a - * problem in the initialization (such as an invalid option). - */ - virtual ApplicationReturnStatus Initialize(std::string params_file = "ipopt.opt"); - virtual ApplicationReturnStatus Initialize(std::istream& is); - - /**@name Solve methods */ - //@{ - /** Solve a problem that inherits from TNLP */ - virtual ApplicationReturnStatus OptimizeTNLP(const SmartPtr<TNLP>& tnlp); - - /** Solve a problem that inherits from NLP */ - virtual ApplicationReturnStatus OptimizeNLP(const SmartPtr<NLP>& nlp); - - /** Solve a problem that inherits from NLP */ - virtual ApplicationReturnStatus OptimizeNLP(const SmartPtr<NLP>& nlp, SmartPtr<AlgorithmBuilder>& alg_builder); - - /** Solve a problem (that inherits from TNLP) for a repeated time. - * The OptimizeTNLP method must have been called before. The - * TNLP must be the same object, and the structure (number of - * variables and constraints and position of nonzeros in Jacobian - * and Hessian must be the same). */ - virtual ApplicationReturnStatus ReOptimizeTNLP(const SmartPtr<TNLP>& tnlp); - - /** Solve a problem (that inherits from NLP) for a repeated time. - * The OptimizeNLP method must have been called before. The - * NLP must be the same object, and the structure (number of - * variables and constraints and position of nonzeros in Jacobian - * and Hessian must be the same). */ - virtual ApplicationReturnStatus ReOptimizeNLP(const SmartPtr<NLP>& nlp); - //@} - - /** Method for opening an output file with given print_level. - * Returns false if there was a problem. */ - virtual bool OpenOutputFile(std::string file_name, EJournalLevel print_level); - - /**@name Accessor methods */ - //@{ - /** Get the Journalist for printing output */ - virtual SmartPtr<Journalist> Jnlst() - { - return jnlst_; - } - - /** Get a pointer to RegisteredOptions object to - * add new options */ - virtual SmartPtr<RegisteredOptions> RegOptions() - { - return reg_options_; - } - - /** Get the options list for setting options */ - virtual SmartPtr<OptionsList> Options() - { - return options_; - } - - /** Get the options list for setting options (const version) */ - virtual SmartPtr<const OptionsList> Options() const - { - return ConstPtr(options_); - } - - /** Get the object with the statistics about the most recent - * optimization run. */ - virtual SmartPtr<SolveStatistics> Statistics(); - - /** Get the IpoptNLP Object */ - virtual SmartPtr<IpoptNLP> IpoptNLPObject(); - - /** Get the IpoptData Object */ - SmartPtr<IpoptData> IpoptDataObject(); - - /** Get the IpoptCQ Object */ - virtual SmartPtr<IpoptCalculatedQuantities> IpoptCQObject(); - - /** Get the Algorithm Object */ - SmartPtr<IpoptAlgorithm> AlgorithmObject(); - //@} - - /** @name Methods for IpoptTypeInfo */ - //@{ - static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); - //@} - - /** Method to registering all Ipopt options. */ - static void - RegisterAllIpoptOptions(const SmartPtr<RegisteredOptions>& roptions); - - 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 */ - // IpoptApplication(); - - /** Copy Constructor */ - IpoptApplication(const IpoptApplication&); - - /** Overloaded Equals Operator */ - void operator=(const IpoptApplication&); - //@} - - /** Method for the actual optimize call of the Ipopt algorithm. - * This is used both for Optimize and ReOptimize */ - ApplicationReturnStatus call_optimize(); - - /**@name Variables that customize the application behavior */ - //@{ - /** Decide whether or not the ipopt.opt file should be read */ - bool read_params_dat_; - //@} - - /** Journalist for reporting output */ - SmartPtr<Journalist> jnlst_; - - /** RegisteredOptions */ - SmartPtr<RegisteredOptions> reg_options_; - - /** OptionsList used for the application */ - SmartPtr<OptionsList> options_; - - /** Object for storing statistics about the most recent - * optimization run. */ - SmartPtr<SolveStatistics> statistics_; - - /** Object with the algorithm sceleton. - */ - SmartPtr<IpoptAlgorithm> alg_; - - /** IpoptNLP Object for the NLP. We keep this around for a - * ReOptimize warm start. */ - SmartPtr<IpoptNLP> ip_nlp_; - - /** IpoptData Object for the NLP. We keep this around for a - * ReOptimize warm start. - */ - SmartPtr<IpoptData> ip_data_; - - /** IpoptCalculatedQuantities Object for the NLP. We keep this - * around for a ReOptimize warm start. - */ - SmartPtr<IpoptCalculatedQuantities> ip_cq_; - - /** Pointer to the TNLPAdapter used to convert the TNLP to an NLP. - * We keep this around for the ReOptimizerTNLP call. */ - SmartPtr<NLP> nlp_adapter_; - - /** @name Algorithmic parameters */ - //@{ - /** Flag indicating if we are to use the inexact linear solver option */ - bool inexact_algorithm_; - /** Flag indicating if all bounds should be replaced by inequality - * constraints. This is necessary for the inexact algorithm. */ - bool replace_bounds_; - /** Flag indicating if the NLP:FinalizeSolution method should not - * be called after optimization. */ - bool skip_finalize_solution_call_; - //@} - }; - -} // namespace Ipopt - -extern "C" IPOPT_EXPORT(class Ipopt::IpoptApplication *) IpoptApplicationFactory(); - -#endif +// Copyright (C) 2004, 2010 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpIpoptApplication.hpp 2173 2013-03-30 17:25:39Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPIPOPTAPPLICATION_HPP__
+#define __IPIPOPTAPPLICATION_HPP__
+
+#ifndef IPOPT_EXPORT
+#ifdef _MSC_VER
+#ifdef IPOPT_DLL
+#define IPOPT_EXPORT(type) __declspec(dllexport) type __cdecl
+#else
+#define IPOPT_EXPORT(type) type __cdecl
+#endif
+#else
+#define IPOPT_EXPORT(type) type
+#endif
+#endif
+
+#include <iostream>
+
+#include "IpJournalist.hpp"
+#include "IpTNLP.hpp"
+#include "IpNLP.hpp"
+/* Return codes for the Optimize call for an application */
+#include "IpReturnCodes.hpp"
+
+namespace Ipopt
+{
+ DECLARE_STD_EXCEPTION(IPOPT_APPLICATION_ERROR);
+
+ /* forward declarations */
+ class IpoptAlgorithm;
+ class IpoptNLP;
+ class IpoptData;
+ class IpoptCalculatedQuantities;
+ class AlgorithmBuilder;
+ class RegisteredOptions;
+ class OptionsList;
+ class SolveStatistics;
+
+ /** This is the main application class for making calls to Ipopt. */
+ class IpoptApplication : public ReferencedObject
+ {
+ public:
+ IpoptApplication(bool create_console_out = true,
+ bool create_empty = false);
+
+ /** Another constructor that assumes that the code in the
+ * (default) constructor has already been executed */
+ IpoptApplication(SmartPtr<RegisteredOptions> reg_options,
+ SmartPtr<OptionsList> options,
+ SmartPtr<Journalist> jnlst);
+
+ virtual ~IpoptApplication();
+
+ /** Method for creating a new IpoptApplication that uses the same
+ * journalist and registered options, and a copy of the options
+ list. */
+ virtual SmartPtr<IpoptApplication> clone();
+
+ /** Initialize method. This method reads the params file and
+ * initializes the journalists. You should call this method at
+ * some point before the first optimize call. Note: you can skip
+ * the processing of a params file by setting params_file to "".
+ * It returns something other than Solve_Succeeded if there was a
+ * problem in the initialization (such as an invalid option).
+ */
+ virtual ApplicationReturnStatus Initialize(std::string params_file = "ipopt.opt");
+ virtual ApplicationReturnStatus Initialize(std::istream& is);
+
+ /**@name Solve methods */
+ //@{
+ /** Solve a problem that inherits from TNLP */
+ virtual ApplicationReturnStatus OptimizeTNLP(const SmartPtr<TNLP>& tnlp);
+
+ /** Solve a problem that inherits from NLP */
+ virtual ApplicationReturnStatus OptimizeNLP(const SmartPtr<NLP>& nlp);
+
+ /** Solve a problem that inherits from NLP */
+ virtual ApplicationReturnStatus OptimizeNLP(const SmartPtr<NLP>& nlp, SmartPtr<AlgorithmBuilder>& alg_builder);
+
+ /** Solve a problem (that inherits from TNLP) for a repeated time.
+ * The OptimizeTNLP method must have been called before. The
+ * TNLP must be the same object, and the structure (number of
+ * variables and constraints and position of nonzeros in Jacobian
+ * and Hessian must be the same). */
+ virtual ApplicationReturnStatus ReOptimizeTNLP(const SmartPtr<TNLP>& tnlp);
+
+ /** Solve a problem (that inherits from NLP) for a repeated time.
+ * The OptimizeNLP method must have been called before. The
+ * NLP must be the same object, and the structure (number of
+ * variables and constraints and position of nonzeros in Jacobian
+ * and Hessian must be the same). */
+ virtual ApplicationReturnStatus ReOptimizeNLP(const SmartPtr<NLP>& nlp);
+ //@}
+
+ /** Method for opening an output file with given print_level.
+ * Returns false if there was a problem. */
+ virtual bool OpenOutputFile(std::string file_name, EJournalLevel print_level);
+
+ /**@name Accessor methods */
+ //@{
+ /** Get the Journalist for printing output */
+ virtual SmartPtr<Journalist> Jnlst()
+ {
+ return jnlst_;
+ }
+
+ /** Get a pointer to RegisteredOptions object to
+ * add new options */
+ virtual SmartPtr<RegisteredOptions> RegOptions()
+ {
+ return reg_options_;
+ }
+
+ /** Get the options list for setting options */
+ virtual SmartPtr<OptionsList> Options()
+ {
+ return options_;
+ }
+
+ /** Get the options list for setting options (const version) */
+ virtual SmartPtr<const OptionsList> Options() const
+ {
+ return ConstPtr(options_);
+ }
+
+ /** Get the object with the statistics about the most recent
+ * optimization run. */
+ virtual SmartPtr<SolveStatistics> Statistics();
+
+ /** Get the IpoptNLP Object */
+ virtual SmartPtr<IpoptNLP> IpoptNLPObject();
+
+ /** Get the IpoptData Object */
+ SmartPtr<IpoptData> IpoptDataObject();
+
+ /** Get the IpoptCQ Object */
+ virtual SmartPtr<IpoptCalculatedQuantities> IpoptCQObject();
+
+ /** Get the Algorithm Object */
+ SmartPtr<IpoptAlgorithm> AlgorithmObject();
+ //@}
+
+ /** Method for printing Ipopt copyright message now instead of
+ * just before the optimization. If you want to have the copy
+ * right message printed earlier than by default, call this
+ * method at the convenient time. */
+ void PrintCopyrightMessage();
+
+ /** @name Methods for IpoptTypeInfo */
+ //@{
+ static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
+ //@}
+
+ /** Method to registering all Ipopt options. */
+ static void
+ RegisterAllIpoptOptions(const SmartPtr<RegisteredOptions>& roptions);
+
+ 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 */
+ // IpoptApplication();
+
+ /** Copy Constructor */
+ IpoptApplication(const IpoptApplication&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const IpoptApplication&);
+ //@}
+
+ /** Method for the actual optimize call of the Ipopt algorithm.
+ * This is used both for Optimize and ReOptimize */
+ ApplicationReturnStatus call_optimize();
+
+ /**@name Variables that customize the application behavior */
+ //@{
+ /** Decide whether or not the ipopt.opt file should be read */
+ bool read_params_dat_;
+ //@}
+
+ /** Journalist for reporting output */
+ SmartPtr<Journalist> jnlst_;
+
+ /** RegisteredOptions */
+ SmartPtr<RegisteredOptions> reg_options_;
+
+ /** OptionsList used for the application */
+ SmartPtr<OptionsList> options_;
+
+ /** Object for storing statistics about the most recent
+ * optimization run. */
+ SmartPtr<SolveStatistics> statistics_;
+
+ /** Object with the algorithm sceleton.
+ */
+ SmartPtr<IpoptAlgorithm> alg_;
+
+ /** IpoptNLP Object for the NLP. We keep this around for a
+ * ReOptimize warm start. */
+ SmartPtr<IpoptNLP> ip_nlp_;
+
+ /** IpoptData Object for the NLP. We keep this around for a
+ * ReOptimize warm start.
+ */
+ SmartPtr<IpoptData> ip_data_;
+
+ /** IpoptCalculatedQuantities Object for the NLP. We keep this
+ * around for a ReOptimize warm start.
+ */
+ SmartPtr<IpoptCalculatedQuantities> ip_cq_;
+
+ /** Pointer to the TNLPAdapter used to convert the TNLP to an NLP.
+ * We keep this around for the ReOptimizerTNLP call. */
+ SmartPtr<NLP> nlp_adapter_;
+
+ /** @name Algorithmic parameters */
+ //@{
+ /** Flag indicating if we are to use the inexact linear solver option */
+ bool inexact_algorithm_;
+ /** Flag indicating if all bounds should be replaced by inequality
+ * constraints. This is necessary for the inexact algorithm. */
+ bool replace_bounds_;
+ //@}
+ };
+
+} // namespace Ipopt
+
+extern "C" IPOPT_EXPORT(class Ipopt::IpoptApplication *) IpoptApplicationFactory();
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpIpoptCalculatedQuantities.hpp b/thirdparty/windows/include/coin/IpIpoptCalculatedQuantities.hpp index 986a299..e102308 100644 --- a/thirdparty/windows/include/coin/IpIpoptCalculatedQuantities.hpp +++ b/thirdparty/windows/include/coin/IpIpoptCalculatedQuantities.hpp @@ -1,742 +1,751 @@ -// Copyright (C) 2004, 2008 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpIpoptCalculatedQuantities.hpp 1586 2009-10-27 15:55:03Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPIPOPTCALCULATEDQUANTITIES_HPP__ -#define __IPIPOPTCALCULATEDQUANTITIES_HPP__ - -#include "IpSmartPtr.hpp" -#include "IpCachedResults.hpp" - -#include <string> - -namespace Ipopt -{ - class IpoptNLP; - class IpoptData; - class Vector; - class Matrix; - class SymMatrix; - class Journalist; - class OptionsList; - class RegisteredOptions; - - /** Norm types */ - enum ENormType { - NORM_1=0, - NORM_2, - NORM_MAX - }; - - /** Base class for additional calculated quantities that is special - * to a particular type of algorithm, such as the CG penalty - * function, or using iterative linear solvers. The regular - * IpoptCalculatedQuantities object should be given a derivation of - * this base class when it is created. */ - class IpoptAdditionalCq : public ReferencedObject - { - public: - /**@name Constructors/Destructors */ - //@{ - /** Default Constructor */ - IpoptAdditionalCq() - {} - - /** Default destructor */ - virtual ~IpoptAdditionalCq() - {} - //@} - - /** This method is called to initialize the global algorithmic - * parameters. The parameters are taken from the OptionsList - * object. */ - virtual bool Initialize(const Journalist& jnlst, - const OptionsList& options, - const std::string& prefix) = 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 */ - IpoptAdditionalCq(const IpoptAdditionalCq&); - - /** Overloaded Equals Operator */ - void operator=(const IpoptAdditionalCq&); - //@} - }; - - /** Class for all IPOPT specific calculated quantities. - * - */ - class IpoptCalculatedQuantities : public ReferencedObject - { - public: - - /**@name Constructors/Destructors */ - //@{ - /** Constructor */ - IpoptCalculatedQuantities(const SmartPtr<IpoptNLP>& ip_nlp, - const SmartPtr<IpoptData>& ip_data); - /** Default destructor */ - virtual ~IpoptCalculatedQuantities(); - //@} - - /** Method for setting pointer for additional calculated - * quantities. This needs to be called before Initialized. */ - void SetAddCq(SmartPtr<IpoptAdditionalCq> add_cq) - { - DBG_ASSERT(!HaveAddCq()); - add_cq_ = add_cq; - } - - /** Method detecting if additional object for calculated - * quantities has already been set */ - bool HaveAddCq() - { - return IsValid(add_cq_); - } - - /** This method must be called to initialize the global - * algorithmic parameters. The parameters are taken from the - * OptionsList object. */ - bool Initialize(const Journalist& jnlst, - const OptionsList& options, - const std::string& prefix); - - /** @name Slacks */ - //@{ - /** Slacks for x_L (at current iterate) */ - SmartPtr<const Vector> curr_slack_x_L(); - /** Slacks for x_U (at current iterate) */ - SmartPtr<const Vector> curr_slack_x_U(); - /** Slacks for s_L (at current iterate) */ - SmartPtr<const Vector> curr_slack_s_L(); - /** Slacks for s_U (at current iterate) */ - SmartPtr<const Vector> curr_slack_s_U(); - /** Slacks for x_L (at trial point) */ - SmartPtr<const Vector> trial_slack_x_L(); - /** Slacks for x_U (at trial point) */ - SmartPtr<const Vector> trial_slack_x_U(); - /** Slacks for s_L (at trial point) */ - SmartPtr<const Vector> trial_slack_s_L(); - /** Slacks for s_U (at trial point) */ - SmartPtr<const Vector> trial_slack_s_U(); - /** Indicating whether or not we "fudged" the slacks */ - Index AdjustedTrialSlacks(); - /** Reset the flags for "fudged" slacks */ - void ResetAdjustedTrialSlacks(); - //@} - - /** @name Objective function */ - //@{ - /** Value of objective function (at current point) */ - virtual Number curr_f(); - /** Unscaled value of the objective function (at the current point) */ - virtual Number unscaled_curr_f(); - /** Value of objective function (at trial point) */ - virtual Number trial_f(); - /** Unscaled value of the objective function (at the trial point) */ - virtual Number unscaled_trial_f(); - /** Gradient of objective function (at current point) */ - SmartPtr<const Vector> curr_grad_f(); - /** Gradient of objective function (at trial point) */ - SmartPtr<const Vector> trial_grad_f(); - //@} - - /** @name Barrier Objective Function */ - //@{ - /** Barrier Objective Function Value - * (at current iterate with current mu) - */ - virtual Number curr_barrier_obj(); - /** Barrier Objective Function Value - * (at trial point with current mu) - */ - virtual Number trial_barrier_obj(); - - /** Gradient of barrier objective function with respect to x - * (at current point with current mu) */ - SmartPtr<const Vector> curr_grad_barrier_obj_x(); - /** Gradient of barrier objective function with respect to s - * (at current point with current mu) */ - SmartPtr<const Vector> curr_grad_barrier_obj_s(); - - /** Gradient of the damping term with respect to x (times - * kappa_d) */ - SmartPtr<const Vector> grad_kappa_times_damping_x(); - /** Gradient of the damping term with respect to s (times - * kappa_d) */ - SmartPtr<const Vector> grad_kappa_times_damping_s(); - //@} - - /** @name Constraints */ - //@{ - /** c(x) (at current point) */ - SmartPtr<const Vector> curr_c(); - /** unscaled c(x) (at current point) */ - SmartPtr<const Vector> unscaled_curr_c(); - /** c(x) (at trial point) */ - SmartPtr<const Vector> trial_c(); - /** d(x) (at current point) */ - SmartPtr<const Vector> curr_d(); - /** unscaled d(x) (at current point) */ - SmartPtr<const Vector> unscaled_curr_d(); - /** d(x) (at trial point) */ - SmartPtr<const Vector> trial_d(); - /** d(x) - s (at current point) */ - SmartPtr<const Vector> curr_d_minus_s(); - /** d(x) - s (at trial point) */ - SmartPtr<const Vector> trial_d_minus_s(); - /** Jacobian of c (at current point) */ - SmartPtr<const Matrix> curr_jac_c(); - /** Jacobian of c (at trial point) */ - SmartPtr<const Matrix> trial_jac_c(); - /** Jacobian of d (at current point) */ - SmartPtr<const Matrix> curr_jac_d(); - /** Jacobian of d (at trial point) */ - SmartPtr<const Matrix> trial_jac_d(); - /** Product of Jacobian (evaluated at current point) of C - * transpose with general vector */ - SmartPtr<const Vector> curr_jac_cT_times_vec(const Vector& vec); - /** Product of Jacobian (evaluated at trial point) of C - * transpose with general vector */ - SmartPtr<const Vector> trial_jac_cT_times_vec(const Vector& vec); - /** Product of Jacobian (evaluated at current point) of D - * transpose with general vector */ - SmartPtr<const Vector> curr_jac_dT_times_vec(const Vector& vec); - /** Product of Jacobian (evaluated at trial point) of D - * transpose with general vector */ - SmartPtr<const Vector> trial_jac_dT_times_vec(const Vector& vec); - /** Product of Jacobian (evaluated at current point) of C - * transpose with current y_c */ - SmartPtr<const Vector> curr_jac_cT_times_curr_y_c(); - /** Product of Jacobian (evaluated at trial point) of C - * transpose with trial y_c */ - SmartPtr<const Vector> trial_jac_cT_times_trial_y_c(); - /** Product of Jacobian (evaluated at current point) of D - * transpose with current y_d */ - SmartPtr<const Vector> curr_jac_dT_times_curr_y_d(); - /** Product of Jacobian (evaluated at trial point) of D - * transpose with trial y_d */ - SmartPtr<const Vector> trial_jac_dT_times_trial_y_d(); - /** Product of Jacobian (evaluated at current point) of C - * with general vector */ - SmartPtr<const Vector> curr_jac_c_times_vec(const Vector& vec); - /** Product of Jacobian (evaluated at current point) of D - * with general vector */ - SmartPtr<const Vector> curr_jac_d_times_vec(const Vector& vec); - /** Constraint Violation (at current iterate). This value should - * be used in the line search, and not curr_primal_infeasibility(). - * What type of norm is used depends on constr_viol_normtype */ - virtual Number curr_constraint_violation(); - /** Constraint Violation (at trial point). This value should - * be used in the line search, and not curr_primal_infeasibility(). - * What type of norm is used depends on constr_viol_normtype */ - virtual Number trial_constraint_violation(); - /** Real constraint violation in a given norm (at current - * iterate). This considers the inequality constraints without - * slacks. */ - virtual Number curr_nlp_constraint_violation(ENormType NormType); - /** Unscaled real constraint violation in a given norm (at current - * iterate). This considers the inequality constraints without - * slacks. */ - virtual Number unscaled_curr_nlp_constraint_violation(ENormType NormType); - //@} - - /** @name Hessian matrices */ - //@{ - /** exact Hessian at current iterate (uncached) */ - SmartPtr<const SymMatrix> curr_exact_hessian(); - //@} - - /** @name primal-dual error and its components */ - //@{ - /** x-part of gradient of Lagrangian function (at current point) */ - SmartPtr<const Vector> curr_grad_lag_x(); - /** x-part of gradient of Lagrangian function (at trial point) */ - SmartPtr<const Vector> trial_grad_lag_x(); - /** s-part of gradient of Lagrangian function (at current point) */ - SmartPtr<const Vector> curr_grad_lag_s(); - /** s-part of gradient of Lagrangian function (at trial point) */ - SmartPtr<const Vector> trial_grad_lag_s(); - /** x-part of gradient of Lagrangian function (at current point) - including linear damping term */ - SmartPtr<const Vector> curr_grad_lag_with_damping_x(); - /** s-part of gradient of Lagrangian function (at current point) - including linear damping term */ - SmartPtr<const Vector> curr_grad_lag_with_damping_s(); - /** Complementarity for x_L (for current iterate) */ - SmartPtr<const Vector> curr_compl_x_L(); - /** Complementarity for x_U (for current iterate) */ - SmartPtr<const Vector> curr_compl_x_U(); - /** Complementarity for s_L (for current iterate) */ - SmartPtr<const Vector> curr_compl_s_L(); - /** Complementarity for s_U (for current iterate) */ - SmartPtr<const Vector> curr_compl_s_U(); - /** Complementarity for x_L (for trial iterate) */ - SmartPtr<const Vector> trial_compl_x_L(); - /** Complementarity for x_U (for trial iterate) */ - SmartPtr<const Vector> trial_compl_x_U(); - /** Complementarity for s_L (for trial iterate) */ - SmartPtr<const Vector> trial_compl_s_L(); - /** Complementarity for s_U (for trial iterate) */ - SmartPtr<const Vector> trial_compl_s_U(); - /** Relaxed complementarity for x_L (for current iterate and current mu) */ - SmartPtr<const Vector> curr_relaxed_compl_x_L(); - /** Relaxed complementarity for x_U (for current iterate and current mu) */ - SmartPtr<const Vector> curr_relaxed_compl_x_U(); - /** Relaxed complementarity for s_L (for current iterate and current mu) */ - SmartPtr<const Vector> curr_relaxed_compl_s_L(); - /** Relaxed complementarity for s_U (for current iterate and current mu) */ - SmartPtr<const Vector> curr_relaxed_compl_s_U(); - - /** Primal infeasibility in a given norm (at current iterate). */ - virtual Number curr_primal_infeasibility(ENormType NormType); - /** Primal infeasibility in a given norm (at trial point) */ - virtual Number trial_primal_infeasibility(ENormType NormType); - - /** Dual infeasibility in a given norm (at current iterate) */ - virtual Number curr_dual_infeasibility(ENormType NormType); - /** Dual infeasibility in a given norm (at trial iterate) */ - virtual Number trial_dual_infeasibility(ENormType NormType); - /** Unscaled dual infeasibility in a given norm (at current iterate) */ - virtual Number unscaled_curr_dual_infeasibility(ENormType NormType); - - /** Complementarity (for all complementarity conditions together) - * in a given norm (at current iterate) */ - virtual Number curr_complementarity(Number mu, ENormType NormType); - /** Complementarity (for all complementarity conditions together) - * in a given norm (at trial iterate) */ - virtual Number trial_complementarity(Number mu, ENormType NormType); - /** Complementarity (for all complementarity conditions together) - * in a given norm (at current iterate) without NLP scaling. */ - virtual Number unscaled_curr_complementarity(Number mu, ENormType NormType); - - /** Centrality measure (in spirit of the -infinity-neighborhood. */ - Number CalcCentralityMeasure(const Vector& compl_x_L, - const Vector& compl_x_U, - const Vector& compl_s_L, - const Vector& compl_s_U); - /** Centrality measure at current point */ - virtual Number curr_centrality_measure(); - - /** Total optimality error for the original NLP at the current - * iterate, using scaling factors based on multipliers. Note - * that here the constraint violation is measured without slacks - * (nlp_constraint_violation) */ - virtual Number curr_nlp_error(); - /** Total optimality error for the original NLP at the current - * iterate, but using no scaling based on multipliers, and no - * scaling for the NLP. Note that here the constraint violation - * is measured without slacks (nlp_constraint_violation) */ - virtual Number unscaled_curr_nlp_error(); - - /** Total optimality error for the barrier problem at the - * current iterate, using scaling factors based on multipliers. */ - virtual Number curr_barrier_error(); - - /** Norm of the primal-dual system for a given mu (at current - * iterate). The norm is defined as the sum of the 1-norms of - * dual infeasibiliy, primal infeasibility, and complementarity, - * all divided by the number of elements of the vectors of which - * the norm is taken. - */ - virtual Number curr_primal_dual_system_error(Number mu); - /** Norm of the primal-dual system for a given mu (at trial - * iterate). The norm is defined as the sum of the 1-norms of - * dual infeasibiliy, primal infeasibility, and complementarity, - * all divided by the number of elements of the vectors of which - * the norm is taken. - */ - virtual Number trial_primal_dual_system_error(Number mu); - //@} - - /** @name Computing fraction-to-the-boundary step sizes */ - //@{ - /** Fraction to the boundary from (current) primal variables x and s - * for a given step */ - Number primal_frac_to_the_bound(Number tau, - const Vector& delta_x, - const Vector& delta_s); - /** Fraction to the boundary from (current) primal variables x and s - * for internal (current) step */ - Number curr_primal_frac_to_the_bound(Number tau); - /** Fraction to the boundary from (current) dual variables z and v - * for a given step */ - Number dual_frac_to_the_bound(Number tau, - const Vector& delta_z_L, - const Vector& delta_z_U, - const Vector& delta_v_L, - const Vector& delta_v_U); - /** Fraction to the boundary from (current) dual variables z and v - * for a given step, without caching */ - Number uncached_dual_frac_to_the_bound(Number tau, - const Vector& delta_z_L, - const Vector& delta_z_U, - const Vector& delta_v_L, - const Vector& delta_v_U); - /** Fraction to the boundary from (current) dual variables z and v - * for internal (current) step */ - Number curr_dual_frac_to_the_bound(Number tau); - /** Fraction to the boundary from (current) slacks for a given - * step in the slacks. Usually, one will use the - * primal_frac_to_the_bound method to compute the primal fraction - * to the boundary step size, but if it is cheaper to provide the - * steps in the slacks directly (e.g. when the primal step sizes - * are only temporary), the this method is more efficient. This - * method does not cache computations. */ - Number uncached_slack_frac_to_the_bound(Number tau, - const Vector& delta_x_L, - const Vector& delta_x_U, - const Vector& delta_s_L, - const Vector& delta_s_U); - //@} - - /** @name Sigma matrices */ - //@{ - SmartPtr<const Vector> curr_sigma_x(); - SmartPtr<const Vector> curr_sigma_s(); - //@} - - /** average of current values of the complementarities */ - Number curr_avrg_compl(); - /** average of trial values of the complementarities */ - Number trial_avrg_compl(); - - /** inner_product of current barrier obj. fn. gradient with - * current search direction */ - Number curr_gradBarrTDelta(); - - /** Compute the norm of a specific type of a set of vectors (uncached) */ - Number - CalcNormOfType(ENormType NormType, - std::vector<SmartPtr<const Vector> > vecs); - - /** Compute the norm of a specific type of two vectors (uncached) */ - Number - CalcNormOfType(ENormType NormType, - const Vector& vec1, const Vector& vec2); - - /** Norm type used for calculating constraint violation */ - ENormType constr_viol_normtype() const - { - return constr_viol_normtype_; - } - - /** Method returning true if this is a square problem */ - bool IsSquareProblem() const; - - /** Method returning the IpoptNLP object. This should only be - * used with care! */ - SmartPtr<IpoptNLP>& GetIpoptNLP() - { - return ip_nlp_; - } - - IpoptAdditionalCq& AdditionalCq() - { - DBG_ASSERT(IsValid(add_cq_)); - return *add_cq_; - } - - /** Methods for IpoptType */ - //@{ - /** Called by IpoptType to register the options */ - static void RegisterOptions(SmartPtr<RegisteredOptions> roptions); - //@} - - 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 */ - IpoptCalculatedQuantities(); - - /** Copy Constructor */ - IpoptCalculatedQuantities(const IpoptCalculatedQuantities&); - - /** Overloaded Equals Operator */ - void operator=(const IpoptCalculatedQuantities&); - //@} - - /** @name Pointers for easy access to data and NLP information */ - //@{ - /** Ipopt NLP object */ - SmartPtr<IpoptNLP> ip_nlp_; - /** Ipopt Data object */ - SmartPtr<IpoptData> ip_data_; - /** Chen-Goldfarb specific calculated quantities */ - SmartPtr<IpoptAdditionalCq> add_cq_; - //@} - - /** @name Algorithmic Parameters that can be set throught the - * options list. Those parameters are initialize by calling the - * Initialize method.*/ - //@{ - /** Parameter in formula for computing overall primal-dual - * optimality error */ - Number s_max_; - /** Weighting factor for the linear damping term added to the - * barrier objective funciton. */ - Number kappa_d_; - /** fractional movement allowed in bounds */ - Number slack_move_; - /** Norm type to be used when calculating the constraint violation */ - ENormType constr_viol_normtype_; - /** Flag indicating whether the TNLP with identical structure has - * already been solved before. */ - bool warm_start_same_structure_; - //@} - - /** @name Caches for slacks */ - //@{ - CachedResults< SmartPtr<Vector> > curr_slack_x_L_cache_; - CachedResults< SmartPtr<Vector> > curr_slack_x_U_cache_; - CachedResults< SmartPtr<Vector> > curr_slack_s_L_cache_; - CachedResults< SmartPtr<Vector> > curr_slack_s_U_cache_; - CachedResults< SmartPtr<Vector> > trial_slack_x_L_cache_; - CachedResults< SmartPtr<Vector> > trial_slack_x_U_cache_; - CachedResults< SmartPtr<Vector> > trial_slack_s_L_cache_; - CachedResults< SmartPtr<Vector> > trial_slack_s_U_cache_; - Index num_adjusted_slack_x_L_; - Index num_adjusted_slack_x_U_; - Index num_adjusted_slack_s_L_; - Index num_adjusted_slack_s_U_; - //@} - - /** @name Cached for objective function stuff */ - //@{ - CachedResults<Number> curr_f_cache_; - CachedResults<Number> trial_f_cache_; - CachedResults< SmartPtr<const Vector> > curr_grad_f_cache_; - CachedResults< SmartPtr<const Vector> > trial_grad_f_cache_; - //@} - - /** @name Caches for barrier function stuff */ - //@{ - CachedResults<Number> curr_barrier_obj_cache_; - CachedResults<Number> trial_barrier_obj_cache_; - CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_x_cache_; - CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_s_cache_; - CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_x_cache_; - CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_s_cache_; - //@} - - /** @name Caches for constraint stuff */ - //@{ - CachedResults< SmartPtr<const Vector> > curr_c_cache_; - CachedResults< SmartPtr<const Vector> > trial_c_cache_; - CachedResults< SmartPtr<const Vector> > curr_d_cache_; - CachedResults< SmartPtr<const Vector> > trial_d_cache_; - CachedResults< SmartPtr<const Vector> > curr_d_minus_s_cache_; - CachedResults< SmartPtr<const Vector> > trial_d_minus_s_cache_; - CachedResults< SmartPtr<const Matrix> > curr_jac_c_cache_; - CachedResults< SmartPtr<const Matrix> > trial_jac_c_cache_; - CachedResults< SmartPtr<const Matrix> > curr_jac_d_cache_; - CachedResults< SmartPtr<const Matrix> > trial_jac_d_cache_; - CachedResults< SmartPtr<const Vector> > curr_jac_cT_times_vec_cache_; - CachedResults< SmartPtr<const Vector> > trial_jac_cT_times_vec_cache_; - CachedResults< SmartPtr<const Vector> > curr_jac_dT_times_vec_cache_; - CachedResults< SmartPtr<const Vector> > trial_jac_dT_times_vec_cache_; - CachedResults< SmartPtr<const Vector> > curr_jac_c_times_vec_cache_; - CachedResults< SmartPtr<const Vector> > curr_jac_d_times_vec_cache_; - CachedResults<Number> curr_constraint_violation_cache_; - CachedResults<Number> trial_constraint_violation_cache_; - CachedResults<Number> curr_nlp_constraint_violation_cache_; - CachedResults<Number> unscaled_curr_nlp_constraint_violation_cache_; - //@} - - /** Cache for the exact Hessian */ - CachedResults< SmartPtr<const SymMatrix> > curr_exact_hessian_cache_; - - /** @name Components of primal-dual error */ - //@{ - CachedResults< SmartPtr<const Vector> > curr_grad_lag_x_cache_; - CachedResults< SmartPtr<const Vector> > trial_grad_lag_x_cache_; - CachedResults< SmartPtr<const Vector> > curr_grad_lag_s_cache_; - CachedResults< SmartPtr<const Vector> > trial_grad_lag_s_cache_; - CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_x_cache_; - CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_s_cache_; - CachedResults< SmartPtr<const Vector> > curr_compl_x_L_cache_; - CachedResults< SmartPtr<const Vector> > curr_compl_x_U_cache_; - CachedResults< SmartPtr<const Vector> > curr_compl_s_L_cache_; - CachedResults< SmartPtr<const Vector> > curr_compl_s_U_cache_; - CachedResults< SmartPtr<const Vector> > trial_compl_x_L_cache_; - CachedResults< SmartPtr<const Vector> > trial_compl_x_U_cache_; - CachedResults< SmartPtr<const Vector> > trial_compl_s_L_cache_; - CachedResults< SmartPtr<const Vector> > trial_compl_s_U_cache_; - CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_L_cache_; - CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_U_cache_; - CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_L_cache_; - CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_U_cache_; - CachedResults<Number> curr_primal_infeasibility_cache_; - CachedResults<Number> trial_primal_infeasibility_cache_; - CachedResults<Number> curr_dual_infeasibility_cache_; - CachedResults<Number> trial_dual_infeasibility_cache_; - CachedResults<Number> unscaled_curr_dual_infeasibility_cache_; - CachedResults<Number> curr_complementarity_cache_; - CachedResults<Number> trial_complementarity_cache_; - CachedResults<Number> curr_centrality_measure_cache_; - CachedResults<Number> curr_nlp_error_cache_; - CachedResults<Number> unscaled_curr_nlp_error_cache_; - CachedResults<Number> curr_barrier_error_cache_; - CachedResults<Number> curr_primal_dual_system_error_cache_; - CachedResults<Number> trial_primal_dual_system_error_cache_; - //@} - - /** @name Caches for fraction to the boundary step sizes */ - //@{ - CachedResults<Number> primal_frac_to_the_bound_cache_; - CachedResults<Number> dual_frac_to_the_bound_cache_; - //@} - - /** @name Caches for sigma matrices */ - //@{ - CachedResults< SmartPtr<const Vector> > curr_sigma_x_cache_; - CachedResults< SmartPtr<const Vector> > curr_sigma_s_cache_; - //@} - - /** Cache for average of current complementarity */ - CachedResults<Number> curr_avrg_compl_cache_; - /** Cache for average of trial complementarity */ - CachedResults<Number> trial_avrg_compl_cache_; - - /** Cache for grad barrier obj. fn inner product with step */ - CachedResults<Number> curr_gradBarrTDelta_cache_; - - /** @name Indicator vectors required for the linear damping terms - * to handle unbounded solution sets. */ - //@{ - /** Indicator vector for selecting the elements in x that have - * only lower bounds. */ - SmartPtr<Vector> dampind_x_L_; - /** Indicator vector for selecting the elements in x that have - * only upper bounds. */ - SmartPtr<Vector> dampind_x_U_; - /** Indicator vector for selecting the elements in s that have - * only lower bounds. */ - SmartPtr<Vector> dampind_s_L_; - /** Indicator vector for selecting the elements in s that have - * only upper bounds. */ - SmartPtr<Vector> dampind_s_U_; - //@} - - /** @name Temporary vectors for intermediate calcuations. We keep - * these around to avoid unnecessarily many new allocations of - * Vectors. */ - //@{ - SmartPtr<Vector> tmp_x_; - SmartPtr<Vector> tmp_s_; - SmartPtr<Vector> tmp_c_; - SmartPtr<Vector> tmp_d_; - SmartPtr<Vector> tmp_x_L_; - SmartPtr<Vector> tmp_x_U_; - SmartPtr<Vector> tmp_s_L_; - SmartPtr<Vector> tmp_s_U_; - - /** Accessor methods for the temporary vectors */ - Vector& Tmp_x(); - Vector& Tmp_s(); - Vector& Tmp_c(); - Vector& Tmp_d(); - Vector& Tmp_x_L(); - Vector& Tmp_x_U(); - Vector& Tmp_s_L(); - Vector& Tmp_s_U(); - //@} - - /** flag indicating if Initialize method has been called (for - * debugging) */ - bool initialize_called_; - - /** @name Auxiliary functions */ - //@{ - /** Compute new vector containing the slack to a lower bound - * (uncached) - */ - SmartPtr<Vector> CalcSlack_L(const Matrix& P, - const Vector& x, - const Vector& x_bound); - /** Compute new vector containing the slack to a upper bound - * (uncached) - */ - SmartPtr<Vector> CalcSlack_U(const Matrix& P, - const Vector& x, - const Vector& x_bound); - /** Compute barrier term at given point - * (uncached) - */ - Number CalcBarrierTerm(Number mu, - const Vector& slack_x_L, - const Vector& slack_x_U, - const Vector& slack_s_L, - const Vector& slack_s_U); - - /** Compute complementarity for slack / multiplier pair */ - SmartPtr<const Vector> CalcCompl(const Vector& slack, - const Vector& mult); - - /** Compute fraction to the boundary parameter for lower and upper bounds */ - Number CalcFracToBound(const Vector& slack_L, - Vector& tmp_L, - const Matrix& P_L, - const Vector& slack_U, - Vector& tmp_U, - const Matrix& P_U, - const Vector& delta, - Number tau); - - /** Compute the scaling factors for the optimality error. */ - void ComputeOptimalityErrorScaling(const Vector& y_c, const Vector& y_d, - const Vector& z_L, const Vector& z_U, - const Vector& v_L, const Vector& v_U, - Number s_max, - Number& s_d, Number& s_c); - - /** Check if slacks are becoming too small. If slacks are - * becoming too small, they are change. The return value is the - * number of corrected slacks. */ - Index CalculateSafeSlack(SmartPtr<Vector>& slack, - const SmartPtr<const Vector>& bound, - const SmartPtr<const Vector>& curr_point, - const SmartPtr<const Vector>& multiplier); - - /** Computes the indicator vectors that can be used to filter out - * those entries in the slack_... variables, that correspond to - * variables with only lower and upper bounds. This is required - * for the linear damping term in the barrier objective function - * to handle unbounded solution sets. */ - void ComputeDampingIndicators(SmartPtr<const Vector>& dampind_x_L, - SmartPtr<const Vector>& dampind_x_U, - SmartPtr<const Vector>& dampind_s_L, - SmartPtr<const Vector>& dampind_s_U); - - /** Check if we are in the restoration phase. Returns true, if the - * ip_nlp is of the type RestoIpoptNLP. ToDo: We probably want to - * handle this more elegant and don't have an explicit dependency - * here. Now I added this because otherwise the caching doesn't - * work properly since the restoration phase objective function - * depends on the current barrier parameter. */ - bool in_restoration_phase(); - - //@} - }; - -} // namespace Ipopt - -#endif +// Copyright (C) 2004, 2011 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpIpoptCalculatedQuantities.hpp 2020 2011-06-16 20:46:16Z andreasw $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPIPOPTCALCULATEDQUANTITIES_HPP__
+#define __IPIPOPTCALCULATEDQUANTITIES_HPP__
+
+#include "IpSmartPtr.hpp"
+#include "IpCachedResults.hpp"
+
+#include <string>
+
+namespace Ipopt
+{
+ class IpoptNLP;
+ class IpoptData;
+ class Vector;
+ class Matrix;
+ class SymMatrix;
+ class Journalist;
+ class OptionsList;
+ class RegisteredOptions;
+
+ /** Norm types */
+ enum ENormType {
+ NORM_1=0,
+ NORM_2,
+ NORM_MAX
+ };
+
+ /** Base class for additional calculated quantities that is special
+ * to a particular type of algorithm, such as the CG penalty
+ * function, or using iterative linear solvers. The regular
+ * IpoptCalculatedQuantities object should be given a derivation of
+ * this base class when it is created. */
+ class IpoptAdditionalCq : public ReferencedObject
+ {
+ public:
+ /**@name Constructors/Destructors */
+ //@{
+ /** Default Constructor */
+ IpoptAdditionalCq()
+ {}
+
+ /** Default destructor */
+ virtual ~IpoptAdditionalCq()
+ {}
+ //@}
+
+ /** This method is called to initialize the global algorithmic
+ * parameters. The parameters are taken from the OptionsList
+ * object. */
+ virtual bool Initialize(const Journalist& jnlst,
+ const OptionsList& options,
+ const std::string& prefix) = 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 */
+ IpoptAdditionalCq(const IpoptAdditionalCq&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const IpoptAdditionalCq&);
+ //@}
+ };
+
+ /** Class for all IPOPT specific calculated quantities.
+ *
+ */
+ class IpoptCalculatedQuantities : public ReferencedObject
+ {
+ public:
+
+ /**@name Constructors/Destructors */
+ //@{
+ /** Constructor */
+ IpoptCalculatedQuantities(const SmartPtr<IpoptNLP>& ip_nlp,
+ const SmartPtr<IpoptData>& ip_data);
+ /** Default destructor */
+ virtual ~IpoptCalculatedQuantities();
+ //@}
+
+ /** Method for setting pointer for additional calculated
+ * quantities. This needs to be called before Initialized. */
+ void SetAddCq(SmartPtr<IpoptAdditionalCq> add_cq)
+ {
+ DBG_ASSERT(!HaveAddCq());
+ add_cq_ = add_cq;
+ }
+
+ /** Method detecting if additional object for calculated
+ * quantities has already been set */
+ bool HaveAddCq()
+ {
+ return IsValid(add_cq_);
+ }
+
+ /** This method must be called to initialize the global
+ * algorithmic parameters. The parameters are taken from the
+ * OptionsList object. */
+ bool Initialize(const Journalist& jnlst,
+ const OptionsList& options,
+ const std::string& prefix);
+
+ /** @name Slacks */
+ //@{
+ /** Slacks for x_L (at current iterate) */
+ SmartPtr<const Vector> curr_slack_x_L();
+ /** Slacks for x_U (at current iterate) */
+ SmartPtr<const Vector> curr_slack_x_U();
+ /** Slacks for s_L (at current iterate) */
+ SmartPtr<const Vector> curr_slack_s_L();
+ /** Slacks for s_U (at current iterate) */
+ SmartPtr<const Vector> curr_slack_s_U();
+ /** Slacks for x_L (at trial point) */
+ SmartPtr<const Vector> trial_slack_x_L();
+ /** Slacks for x_U (at trial point) */
+ SmartPtr<const Vector> trial_slack_x_U();
+ /** Slacks for s_L (at trial point) */
+ SmartPtr<const Vector> trial_slack_s_L();
+ /** Slacks for s_U (at trial point) */
+ SmartPtr<const Vector> trial_slack_s_U();
+ /** Indicating whether or not we "fudged" the slacks */
+ Index AdjustedTrialSlacks();
+ /** Reset the flags for "fudged" slacks */
+ void ResetAdjustedTrialSlacks();
+ //@}
+
+ /** @name Objective function */
+ //@{
+ /** Value of objective function (at current point) */
+ virtual Number curr_f();
+ /** Unscaled value of the objective function (at the current point) */
+ virtual Number unscaled_curr_f();
+ /** Value of objective function (at trial point) */
+ virtual Number trial_f();
+ /** Unscaled value of the objective function (at the trial point) */
+ virtual Number unscaled_trial_f();
+ /** Gradient of objective function (at current point) */
+ SmartPtr<const Vector> curr_grad_f();
+ /** Gradient of objective function (at trial point) */
+ SmartPtr<const Vector> trial_grad_f();
+ //@}
+
+ /** @name Barrier Objective Function */
+ //@{
+ /** Barrier Objective Function Value
+ * (at current iterate with current mu)
+ */
+ virtual Number curr_barrier_obj();
+ /** Barrier Objective Function Value
+ * (at trial point with current mu)
+ */
+ virtual Number trial_barrier_obj();
+
+ /** Gradient of barrier objective function with respect to x
+ * (at current point with current mu) */
+ SmartPtr<const Vector> curr_grad_barrier_obj_x();
+ /** Gradient of barrier objective function with respect to s
+ * (at current point with current mu) */
+ SmartPtr<const Vector> curr_grad_barrier_obj_s();
+
+ /** Gradient of the damping term with respect to x (times
+ * kappa_d) */
+ SmartPtr<const Vector> grad_kappa_times_damping_x();
+ /** Gradient of the damping term with respect to s (times
+ * kappa_d) */
+ SmartPtr<const Vector> grad_kappa_times_damping_s();
+ //@}
+
+ /** @name Constraints */
+ //@{
+ /** c(x) (at current point) */
+ SmartPtr<const Vector> curr_c();
+ /** unscaled c(x) (at current point) */
+ SmartPtr<const Vector> unscaled_curr_c();
+ /** c(x) (at trial point) */
+ SmartPtr<const Vector> trial_c();
+ /** unscaled c(x) (at trial point) */
+ SmartPtr<const Vector> unscaled_trial_c();
+ /** d(x) (at current point) */
+ SmartPtr<const Vector> curr_d();
+ /** unscaled d(x) (at current point) */
+ SmartPtr<const Vector> unscaled_curr_d();
+ /** d(x) (at trial point) */
+ SmartPtr<const Vector> trial_d();
+ /** d(x) - s (at current point) */
+ SmartPtr<const Vector> curr_d_minus_s();
+ /** d(x) - s (at trial point) */
+ SmartPtr<const Vector> trial_d_minus_s();
+ /** Jacobian of c (at current point) */
+ SmartPtr<const Matrix> curr_jac_c();
+ /** Jacobian of c (at trial point) */
+ SmartPtr<const Matrix> trial_jac_c();
+ /** Jacobian of d (at current point) */
+ SmartPtr<const Matrix> curr_jac_d();
+ /** Jacobian of d (at trial point) */
+ SmartPtr<const Matrix> trial_jac_d();
+ /** Product of Jacobian (evaluated at current point) of C
+ * transpose with general vector */
+ SmartPtr<const Vector> curr_jac_cT_times_vec(const Vector& vec);
+ /** Product of Jacobian (evaluated at trial point) of C
+ * transpose with general vector */
+ SmartPtr<const Vector> trial_jac_cT_times_vec(const Vector& vec);
+ /** Product of Jacobian (evaluated at current point) of D
+ * transpose with general vector */
+ SmartPtr<const Vector> curr_jac_dT_times_vec(const Vector& vec);
+ /** Product of Jacobian (evaluated at trial point) of D
+ * transpose with general vector */
+ SmartPtr<const Vector> trial_jac_dT_times_vec(const Vector& vec);
+ /** Product of Jacobian (evaluated at current point) of C
+ * transpose with current y_c */
+ SmartPtr<const Vector> curr_jac_cT_times_curr_y_c();
+ /** Product of Jacobian (evaluated at trial point) of C
+ * transpose with trial y_c */
+ SmartPtr<const Vector> trial_jac_cT_times_trial_y_c();
+ /** Product of Jacobian (evaluated at current point) of D
+ * transpose with current y_d */
+ SmartPtr<const Vector> curr_jac_dT_times_curr_y_d();
+ /** Product of Jacobian (evaluated at trial point) of D
+ * transpose with trial y_d */
+ SmartPtr<const Vector> trial_jac_dT_times_trial_y_d();
+ /** Product of Jacobian (evaluated at current point) of C
+ * with general vector */
+ SmartPtr<const Vector> curr_jac_c_times_vec(const Vector& vec);
+ /** Product of Jacobian (evaluated at current point) of D
+ * with general vector */
+ SmartPtr<const Vector> curr_jac_d_times_vec(const Vector& vec);
+ /** Constraint Violation (at current iterate). This value should
+ * be used in the line search, and not curr_primal_infeasibility().
+ * What type of norm is used depends on constr_viol_normtype */
+ virtual Number curr_constraint_violation();
+ /** Constraint Violation (at trial point). This value should
+ * be used in the line search, and not curr_primal_infeasibility().
+ * What type of norm is used depends on constr_viol_normtype */
+ virtual Number trial_constraint_violation();
+ /** Real constraint violation in a given norm (at current
+ * iterate). This considers the inequality constraints without
+ * slacks. */
+ virtual Number curr_nlp_constraint_violation(ENormType NormType);
+ /** Unscaled real constraint violation in a given norm (at current
+ * iterate). This considers the inequality constraints without
+ * slacks. */
+ virtual Number unscaled_curr_nlp_constraint_violation(ENormType NormType);
+ /** Unscaled real constraint violation in a given norm (at trial
+ * iterate). This considers the inequality constraints without
+ * slacks. */
+ virtual Number unscaled_trial_nlp_constraint_violation(ENormType NormType);
+ //@}
+
+ /** @name Hessian matrices */
+ //@{
+ /** exact Hessian at current iterate (uncached) */
+ SmartPtr<const SymMatrix> curr_exact_hessian();
+ //@}
+
+ /** @name primal-dual error and its components */
+ //@{
+ /** x-part of gradient of Lagrangian function (at current point) */
+ SmartPtr<const Vector> curr_grad_lag_x();
+ /** x-part of gradient of Lagrangian function (at trial point) */
+ SmartPtr<const Vector> trial_grad_lag_x();
+ /** s-part of gradient of Lagrangian function (at current point) */
+ SmartPtr<const Vector> curr_grad_lag_s();
+ /** s-part of gradient of Lagrangian function (at trial point) */
+ SmartPtr<const Vector> trial_grad_lag_s();
+ /** x-part of gradient of Lagrangian function (at current point)
+ including linear damping term */
+ SmartPtr<const Vector> curr_grad_lag_with_damping_x();
+ /** s-part of gradient of Lagrangian function (at current point)
+ including linear damping term */
+ SmartPtr<const Vector> curr_grad_lag_with_damping_s();
+ /** Complementarity for x_L (for current iterate) */
+ SmartPtr<const Vector> curr_compl_x_L();
+ /** Complementarity for x_U (for current iterate) */
+ SmartPtr<const Vector> curr_compl_x_U();
+ /** Complementarity for s_L (for current iterate) */
+ SmartPtr<const Vector> curr_compl_s_L();
+ /** Complementarity for s_U (for current iterate) */
+ SmartPtr<const Vector> curr_compl_s_U();
+ /** Complementarity for x_L (for trial iterate) */
+ SmartPtr<const Vector> trial_compl_x_L();
+ /** Complementarity for x_U (for trial iterate) */
+ SmartPtr<const Vector> trial_compl_x_U();
+ /** Complementarity for s_L (for trial iterate) */
+ SmartPtr<const Vector> trial_compl_s_L();
+ /** Complementarity for s_U (for trial iterate) */
+ SmartPtr<const Vector> trial_compl_s_U();
+ /** Relaxed complementarity for x_L (for current iterate and current mu) */
+ SmartPtr<const Vector> curr_relaxed_compl_x_L();
+ /** Relaxed complementarity for x_U (for current iterate and current mu) */
+ SmartPtr<const Vector> curr_relaxed_compl_x_U();
+ /** Relaxed complementarity for s_L (for current iterate and current mu) */
+ SmartPtr<const Vector> curr_relaxed_compl_s_L();
+ /** Relaxed complementarity for s_U (for current iterate and current mu) */
+ SmartPtr<const Vector> curr_relaxed_compl_s_U();
+
+ /** Primal infeasibility in a given norm (at current iterate). */
+ virtual Number curr_primal_infeasibility(ENormType NormType);
+ /** Primal infeasibility in a given norm (at trial point) */
+ virtual Number trial_primal_infeasibility(ENormType NormType);
+
+ /** Dual infeasibility in a given norm (at current iterate) */
+ virtual Number curr_dual_infeasibility(ENormType NormType);
+ /** Dual infeasibility in a given norm (at trial iterate) */
+ virtual Number trial_dual_infeasibility(ENormType NormType);
+ /** Unscaled dual infeasibility in a given norm (at current iterate) */
+ virtual Number unscaled_curr_dual_infeasibility(ENormType NormType);
+
+ /** Complementarity (for all complementarity conditions together)
+ * in a given norm (at current iterate) */
+ virtual Number curr_complementarity(Number mu, ENormType NormType);
+ /** Complementarity (for all complementarity conditions together)
+ * in a given norm (at trial iterate) */
+ virtual Number trial_complementarity(Number mu, ENormType NormType);
+ /** Complementarity (for all complementarity conditions together)
+ * in a given norm (at current iterate) without NLP scaling. */
+ virtual Number unscaled_curr_complementarity(Number mu, ENormType NormType);
+
+ /** Centrality measure (in spirit of the -infinity-neighborhood. */
+ Number CalcCentralityMeasure(const Vector& compl_x_L,
+ const Vector& compl_x_U,
+ const Vector& compl_s_L,
+ const Vector& compl_s_U);
+ /** Centrality measure at current point */
+ virtual Number curr_centrality_measure();
+
+ /** Total optimality error for the original NLP at the current
+ * iterate, using scaling factors based on multipliers. Note
+ * that here the constraint violation is measured without slacks
+ * (nlp_constraint_violation) */
+ virtual Number curr_nlp_error();
+ /** Total optimality error for the original NLP at the current
+ * iterate, but using no scaling based on multipliers, and no
+ * scaling for the NLP. Note that here the constraint violation
+ * is measured without slacks (nlp_constraint_violation) */
+ virtual Number unscaled_curr_nlp_error();
+
+ /** Total optimality error for the barrier problem at the
+ * current iterate, using scaling factors based on multipliers. */
+ virtual Number curr_barrier_error();
+
+ /** Norm of the primal-dual system for a given mu (at current
+ * iterate). The norm is defined as the sum of the 1-norms of
+ * dual infeasibiliy, primal infeasibility, and complementarity,
+ * all divided by the number of elements of the vectors of which
+ * the norm is taken.
+ */
+ virtual Number curr_primal_dual_system_error(Number mu);
+ /** Norm of the primal-dual system for a given mu (at trial
+ * iterate). The norm is defined as the sum of the 1-norms of
+ * dual infeasibiliy, primal infeasibility, and complementarity,
+ * all divided by the number of elements of the vectors of which
+ * the norm is taken.
+ */
+ virtual Number trial_primal_dual_system_error(Number mu);
+ //@}
+
+ /** @name Computing fraction-to-the-boundary step sizes */
+ //@{
+ /** Fraction to the boundary from (current) primal variables x and s
+ * for a given step */
+ Number primal_frac_to_the_bound(Number tau,
+ const Vector& delta_x,
+ const Vector& delta_s);
+ /** Fraction to the boundary from (current) primal variables x and s
+ * for internal (current) step */
+ Number curr_primal_frac_to_the_bound(Number tau);
+ /** Fraction to the boundary from (current) dual variables z and v
+ * for a given step */
+ Number dual_frac_to_the_bound(Number tau,
+ const Vector& delta_z_L,
+ const Vector& delta_z_U,
+ const Vector& delta_v_L,
+ const Vector& delta_v_U);
+ /** Fraction to the boundary from (current) dual variables z and v
+ * for a given step, without caching */
+ Number uncached_dual_frac_to_the_bound(Number tau,
+ const Vector& delta_z_L,
+ const Vector& delta_z_U,
+ const Vector& delta_v_L,
+ const Vector& delta_v_U);
+ /** Fraction to the boundary from (current) dual variables z and v
+ * for internal (current) step */
+ Number curr_dual_frac_to_the_bound(Number tau);
+ /** Fraction to the boundary from (current) slacks for a given
+ * step in the slacks. Usually, one will use the
+ * primal_frac_to_the_bound method to compute the primal fraction
+ * to the boundary step size, but if it is cheaper to provide the
+ * steps in the slacks directly (e.g. when the primal step sizes
+ * are only temporary), the this method is more efficient. This
+ * method does not cache computations. */
+ Number uncached_slack_frac_to_the_bound(Number tau,
+ const Vector& delta_x_L,
+ const Vector& delta_x_U,
+ const Vector& delta_s_L,
+ const Vector& delta_s_U);
+ //@}
+
+ /** @name Sigma matrices */
+ //@{
+ SmartPtr<const Vector> curr_sigma_x();
+ SmartPtr<const Vector> curr_sigma_s();
+ //@}
+
+ /** average of current values of the complementarities */
+ Number curr_avrg_compl();
+ /** average of trial values of the complementarities */
+ Number trial_avrg_compl();
+
+ /** inner_product of current barrier obj. fn. gradient with
+ * current search direction */
+ Number curr_gradBarrTDelta();
+
+ /** Compute the norm of a specific type of a set of vectors (uncached) */
+ Number
+ CalcNormOfType(ENormType NormType,
+ std::vector<SmartPtr<const Vector> > vecs);
+
+ /** Compute the norm of a specific type of two vectors (uncached) */
+ Number
+ CalcNormOfType(ENormType NormType,
+ const Vector& vec1, const Vector& vec2);
+
+ /** Norm type used for calculating constraint violation */
+ ENormType constr_viol_normtype() const
+ {
+ return constr_viol_normtype_;
+ }
+
+ /** Method returning true if this is a square problem */
+ bool IsSquareProblem() const;
+
+ /** Method returning the IpoptNLP object. This should only be
+ * used with care! */
+ SmartPtr<IpoptNLP>& GetIpoptNLP()
+ {
+ return ip_nlp_;
+ }
+
+ IpoptAdditionalCq& AdditionalCq()
+ {
+ DBG_ASSERT(IsValid(add_cq_));
+ return *add_cq_;
+ }
+
+ /** Methods for IpoptType */
+ //@{
+ /** Called by IpoptType to register the options */
+ static void RegisterOptions(SmartPtr<RegisteredOptions> roptions);
+ //@}
+
+ 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 */
+ IpoptCalculatedQuantities();
+
+ /** Copy Constructor */
+ IpoptCalculatedQuantities(const IpoptCalculatedQuantities&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const IpoptCalculatedQuantities&);
+ //@}
+
+ /** @name Pointers for easy access to data and NLP information */
+ //@{
+ /** Ipopt NLP object */
+ SmartPtr<IpoptNLP> ip_nlp_;
+ /** Ipopt Data object */
+ SmartPtr<IpoptData> ip_data_;
+ /** Chen-Goldfarb specific calculated quantities */
+ SmartPtr<IpoptAdditionalCq> add_cq_;
+ //@}
+
+ /** @name Algorithmic Parameters that can be set throught the
+ * options list. Those parameters are initialize by calling the
+ * Initialize method.*/
+ //@{
+ /** Parameter in formula for computing overall primal-dual
+ * optimality error */
+ Number s_max_;
+ /** Weighting factor for the linear damping term added to the
+ * barrier objective funciton. */
+ Number kappa_d_;
+ /** fractional movement allowed in bounds */
+ Number slack_move_;
+ /** Norm type to be used when calculating the constraint violation */
+ ENormType constr_viol_normtype_;
+ /** Flag indicating whether the TNLP with identical structure has
+ * already been solved before. */
+ bool warm_start_same_structure_;
+ /** Desired value of the barrier parameter */
+ Number mu_target_;
+ //@}
+
+ /** @name Caches for slacks */
+ //@{
+ CachedResults< SmartPtr<Vector> > curr_slack_x_L_cache_;
+ CachedResults< SmartPtr<Vector> > curr_slack_x_U_cache_;
+ CachedResults< SmartPtr<Vector> > curr_slack_s_L_cache_;
+ CachedResults< SmartPtr<Vector> > curr_slack_s_U_cache_;
+ CachedResults< SmartPtr<Vector> > trial_slack_x_L_cache_;
+ CachedResults< SmartPtr<Vector> > trial_slack_x_U_cache_;
+ CachedResults< SmartPtr<Vector> > trial_slack_s_L_cache_;
+ CachedResults< SmartPtr<Vector> > trial_slack_s_U_cache_;
+ Index num_adjusted_slack_x_L_;
+ Index num_adjusted_slack_x_U_;
+ Index num_adjusted_slack_s_L_;
+ Index num_adjusted_slack_s_U_;
+ //@}
+
+ /** @name Cached for objective function stuff */
+ //@{
+ CachedResults<Number> curr_f_cache_;
+ CachedResults<Number> trial_f_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_grad_f_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_grad_f_cache_;
+ //@}
+
+ /** @name Caches for barrier function stuff */
+ //@{
+ CachedResults<Number> curr_barrier_obj_cache_;
+ CachedResults<Number> trial_barrier_obj_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_x_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_grad_barrier_obj_s_cache_;
+ CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_x_cache_;
+ CachedResults< SmartPtr<const Vector> > grad_kappa_times_damping_s_cache_;
+ //@}
+
+ /** @name Caches for constraint stuff */
+ //@{
+ CachedResults< SmartPtr<const Vector> > curr_c_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_c_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_d_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_d_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_d_minus_s_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_d_minus_s_cache_;
+ CachedResults< SmartPtr<const Matrix> > curr_jac_c_cache_;
+ CachedResults< SmartPtr<const Matrix> > trial_jac_c_cache_;
+ CachedResults< SmartPtr<const Matrix> > curr_jac_d_cache_;
+ CachedResults< SmartPtr<const Matrix> > trial_jac_d_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_jac_cT_times_vec_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_jac_cT_times_vec_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_jac_dT_times_vec_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_jac_dT_times_vec_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_jac_c_times_vec_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_jac_d_times_vec_cache_;
+ CachedResults<Number> curr_constraint_violation_cache_;
+ CachedResults<Number> trial_constraint_violation_cache_;
+ CachedResults<Number> curr_nlp_constraint_violation_cache_;
+ CachedResults<Number> unscaled_curr_nlp_constraint_violation_cache_;
+ CachedResults<Number> unscaled_trial_nlp_constraint_violation_cache_;
+ //@}
+
+ /** Cache for the exact Hessian */
+ CachedResults< SmartPtr<const SymMatrix> > curr_exact_hessian_cache_;
+
+ /** @name Components of primal-dual error */
+ //@{
+ CachedResults< SmartPtr<const Vector> > curr_grad_lag_x_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_grad_lag_x_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_grad_lag_s_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_grad_lag_s_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_x_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_grad_lag_with_damping_s_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_compl_x_L_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_compl_x_U_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_compl_s_L_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_compl_s_U_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_compl_x_L_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_compl_x_U_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_compl_s_L_cache_;
+ CachedResults< SmartPtr<const Vector> > trial_compl_s_U_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_L_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_x_U_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_L_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_relaxed_compl_s_U_cache_;
+ CachedResults<Number> curr_primal_infeasibility_cache_;
+ CachedResults<Number> trial_primal_infeasibility_cache_;
+ CachedResults<Number> curr_dual_infeasibility_cache_;
+ CachedResults<Number> trial_dual_infeasibility_cache_;
+ CachedResults<Number> unscaled_curr_dual_infeasibility_cache_;
+ CachedResults<Number> curr_complementarity_cache_;
+ CachedResults<Number> trial_complementarity_cache_;
+ CachedResults<Number> curr_centrality_measure_cache_;
+ CachedResults<Number> curr_nlp_error_cache_;
+ CachedResults<Number> unscaled_curr_nlp_error_cache_;
+ CachedResults<Number> curr_barrier_error_cache_;
+ CachedResults<Number> curr_primal_dual_system_error_cache_;
+ CachedResults<Number> trial_primal_dual_system_error_cache_;
+ //@}
+
+ /** @name Caches for fraction to the boundary step sizes */
+ //@{
+ CachedResults<Number> primal_frac_to_the_bound_cache_;
+ CachedResults<Number> dual_frac_to_the_bound_cache_;
+ //@}
+
+ /** @name Caches for sigma matrices */
+ //@{
+ CachedResults< SmartPtr<const Vector> > curr_sigma_x_cache_;
+ CachedResults< SmartPtr<const Vector> > curr_sigma_s_cache_;
+ //@}
+
+ /** Cache for average of current complementarity */
+ CachedResults<Number> curr_avrg_compl_cache_;
+ /** Cache for average of trial complementarity */
+ CachedResults<Number> trial_avrg_compl_cache_;
+
+ /** Cache for grad barrier obj. fn inner product with step */
+ CachedResults<Number> curr_gradBarrTDelta_cache_;
+
+ /** @name Indicator vectors required for the linear damping terms
+ * to handle unbounded solution sets. */
+ //@{
+ /** Indicator vector for selecting the elements in x that have
+ * only lower bounds. */
+ SmartPtr<Vector> dampind_x_L_;
+ /** Indicator vector for selecting the elements in x that have
+ * only upper bounds. */
+ SmartPtr<Vector> dampind_x_U_;
+ /** Indicator vector for selecting the elements in s that have
+ * only lower bounds. */
+ SmartPtr<Vector> dampind_s_L_;
+ /** Indicator vector for selecting the elements in s that have
+ * only upper bounds. */
+ SmartPtr<Vector> dampind_s_U_;
+ //@}
+
+ /** @name Temporary vectors for intermediate calcuations. We keep
+ * these around to avoid unnecessarily many new allocations of
+ * Vectors. */
+ //@{
+ SmartPtr<Vector> tmp_x_;
+ SmartPtr<Vector> tmp_s_;
+ SmartPtr<Vector> tmp_c_;
+ SmartPtr<Vector> tmp_d_;
+ SmartPtr<Vector> tmp_x_L_;
+ SmartPtr<Vector> tmp_x_U_;
+ SmartPtr<Vector> tmp_s_L_;
+ SmartPtr<Vector> tmp_s_U_;
+
+ /** Accessor methods for the temporary vectors */
+ Vector& Tmp_x();
+ Vector& Tmp_s();
+ Vector& Tmp_c();
+ Vector& Tmp_d();
+ Vector& Tmp_x_L();
+ Vector& Tmp_x_U();
+ Vector& Tmp_s_L();
+ Vector& Tmp_s_U();
+ //@}
+
+ /** flag indicating if Initialize method has been called (for
+ * debugging) */
+ bool initialize_called_;
+
+ /** @name Auxiliary functions */
+ //@{
+ /** Compute new vector containing the slack to a lower bound
+ * (uncached)
+ */
+ SmartPtr<Vector> CalcSlack_L(const Matrix& P,
+ const Vector& x,
+ const Vector& x_bound);
+ /** Compute new vector containing the slack to a upper bound
+ * (uncached)
+ */
+ SmartPtr<Vector> CalcSlack_U(const Matrix& P,
+ const Vector& x,
+ const Vector& x_bound);
+ /** Compute barrier term at given point
+ * (uncached)
+ */
+ Number CalcBarrierTerm(Number mu,
+ const Vector& slack_x_L,
+ const Vector& slack_x_U,
+ const Vector& slack_s_L,
+ const Vector& slack_s_U);
+
+ /** Compute complementarity for slack / multiplier pair */
+ SmartPtr<const Vector> CalcCompl(const Vector& slack,
+ const Vector& mult);
+
+ /** Compute fraction to the boundary parameter for lower and upper bounds */
+ Number CalcFracToBound(const Vector& slack_L,
+ Vector& tmp_L,
+ const Matrix& P_L,
+ const Vector& slack_U,
+ Vector& tmp_U,
+ const Matrix& P_U,
+ const Vector& delta,
+ Number tau);
+
+ /** Compute the scaling factors for the optimality error. */
+ void ComputeOptimalityErrorScaling(const Vector& y_c, const Vector& y_d,
+ const Vector& z_L, const Vector& z_U,
+ const Vector& v_L, const Vector& v_U,
+ Number s_max,
+ Number& s_d, Number& s_c);
+
+ /** Check if slacks are becoming too small. If slacks are
+ * becoming too small, they are change. The return value is the
+ * number of corrected slacks. */
+ Index CalculateSafeSlack(SmartPtr<Vector>& slack,
+ const SmartPtr<const Vector>& bound,
+ const SmartPtr<const Vector>& curr_point,
+ const SmartPtr<const Vector>& multiplier);
+
+ /** Computes the indicator vectors that can be used to filter out
+ * those entries in the slack_... variables, that correspond to
+ * variables with only lower and upper bounds. This is required
+ * for the linear damping term in the barrier objective function
+ * to handle unbounded solution sets. */
+ void ComputeDampingIndicators(SmartPtr<const Vector>& dampind_x_L,
+ SmartPtr<const Vector>& dampind_x_U,
+ SmartPtr<const Vector>& dampind_s_L,
+ SmartPtr<const Vector>& dampind_s_U);
+
+ /** Check if we are in the restoration phase. Returns true, if the
+ * ip_nlp is of the type RestoIpoptNLP. ToDo: We probably want to
+ * handle this more elegant and don't have an explicit dependency
+ * here. Now I added this because otherwise the caching doesn't
+ * work properly since the restoration phase objective function
+ * depends on the current barrier parameter. */
+ bool in_restoration_phase();
+
+ //@}
+ };
+
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpJournalist.hpp b/thirdparty/windows/include/coin/IpJournalist.hpp index 25ccef9..7e1b69a 100644 --- a/thirdparty/windows/include/coin/IpJournalist.hpp +++ b/thirdparty/windows/include/coin/IpJournalist.hpp @@ -1,487 +1,497 @@ -// Copyright (C) 2004, 2009 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpJournalist.hpp 1587 2009-10-27 16:09:21Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPJOURNALIST_HPP__ -#define __IPJOURNALIST_HPP__ - -#include "IpoptConfig.h" -#include "IpTypes.hpp" -#include "IpReferenced.hpp" -#include "IpSmartPtr.hpp" - -#ifdef HAVE_CSTDARG -# include <cstdarg> -#else -# ifdef HAVE_STDARG_H -# include <stdarg.h> -# else -# error "don't have header file for stdarg" -# endif -#endif - -#include <string> -#include <vector> -#include <ostream> - -namespace Ipopt -{ - - // forward declarations - class Journal; - class FileJournal; - - /**@name Journalist Enumerations. */ - //@{ - /** Print Level Enum. */ - enum EJournalLevel { - J_INSUPPRESSIBLE=-1, - J_NONE=0, - J_ERROR, - J_STRONGWARNING, - J_SUMMARY, - J_WARNING, - J_ITERSUMMARY, - J_DETAILED, - J_MOREDETAILED, - J_VECTOR, - J_MOREVECTOR, - J_MATRIX, - J_MOREMATRIX, - J_ALL, - J_LAST_LEVEL - }; - - /** Category Selection Enum. */ - enum EJournalCategory { - J_DBG=0, - J_STATISTICS, - J_MAIN, - J_INITIALIZATION, - J_BARRIER_UPDATE, - J_SOLVE_PD_SYSTEM, - J_FRAC_TO_BOUND, - J_LINEAR_ALGEBRA, - J_LINE_SEARCH, - J_HESSIAN_APPROXIMATION, - J_SOLUTION, - J_DOCUMENTATION, - J_NLP, - J_TIMING_STATISTICS, - J_USER_APPLICATION /** This can be used by the user's application*/ , - J_USER1 /** This can be used by the user's application*/ , - J_USER2 /** This can be used by the user's application*/ , - J_USER3 /** This can be used by the user's application*/ , - J_USER4 /** This can be used by the user's application*/ , - J_USER5 /** This can be used by the user's application*/ , - J_USER6 /** This can be used by the user's application*/ , - J_USER7 /** This can be used by the user's application*/ , - J_USER8 /** This can be used by the user's application*/ , - J_USER9 /** This can be used by the user's application*/ , - J_USER10 /** This can be used by the user's application*/ , - J_USER11 /** This can be used by the user's application*/ , - J_USER12 /** This can be used by the user's application*/ , - J_USER13 /** This can be used by the user's application*/ , - J_USER14 /** This can be used by the user's application*/ , - J_USER15 /** This can be used by the user's application*/ , - J_USER16 /** This can be used by the user's application*/ , - J_USER17 /** This can be used by the user's application*/ , - J_LAST_CATEGORY - }; - //@} - - /** Class responsible for all message output. - * This class is responsible for all messaging and output. - * The "printing" code or "author" should send ALL messages to the - * Journalist, indicating an appropriate category and print level. - * The journalist then decides, based on reader specified - * acceptance criteria, which message is actually printed in which - * journals. - * This allows the printing code to send everything, while the - * "reader" can decide what they really want to see. - * - * Authors: - * Authors use the - * Journals: You can add as many Journals as you like to the - * Journalist with the AddJournal or the AddFileJournal methods. - * Each one represents a different printing location (or file). - * Then, you can call the "print" methods of the Journalist to output - * information to each of the journals. - * - * Acceptance Criteria: Each print message should be flagged - * appropriately with an EJournalCategory and EJournalLevel. - * - * The AddFileJournal - * method returns a pointer to the newly created Journal object - * (if successful) so you can set Acceptance criteria for that - * particular location. - * - */ - class Journalist : public ReferencedObject - { - public: - /**@name Constructor / Desructor. */ - //@{ - /** Constructor. */ - Journalist(); - - /** Destructor... */ - virtual ~Journalist(); - //@} - - /**@name Author Methods. - * These methods are used by authoring code, or code that wants - * to report some information. - */ - //@{ - /** Method to print a formatted string */ - virtual void Printf(EJournalLevel level, EJournalCategory category, - const char* format, ...) const; - - /** Method to print a long string including indentation. The - * string is printed starting at the current position. If the - * position (counting started at the current position) exceeds - * max_length, a new line is inserted, and indent_spaces many - * spaces are printed before the string is continued. This is - * for example used during the printing of the option - * documentation. */ - virtual void PrintStringOverLines(EJournalLevel level, EJournalCategory category, - Index indent_spaces, Index max_length, - const std::string& line) const; - - /** Method to print a formatted string with indentation */ - virtual void PrintfIndented(EJournalLevel level, - EJournalCategory category, - Index indent_level, - const char* format, ...) const; - - /** Method to print a formatted string - * using the va_list argument. */ - virtual void VPrintf(EJournalLevel level, - EJournalCategory category, - const char* pformat, - va_list ap) const; - - /** Method to print a formatted string with indentation, - * using the va_list argument. */ - virtual void VPrintfIndented(EJournalLevel level, - EJournalCategory category, - Index indent_level, - const char* pformat, - va_list ap) const; - - /** Method that returns true if there is a Journal that would - * write output for the given JournalLevel and JournalCategory. - * This is useful if expensive computation would be required for - * a particular output. The author code can check with this - * method if the computations are indeed required. - */ - virtual bool ProduceOutput(EJournalLevel level, - EJournalCategory category) const; - - - /** Method that flushes the current buffer for all Journalists. - Calling this method after one optimization run helps to avoid - cluttering output with that produced by other parts of the - program (e.g. written in Fortran) */ - virtual void FlushBuffer() const; - //@} - - /**@name Reader Methods. - * These methods are used by the reader. The reader will setup the - * journalist with each output file and the acceptance - * criteria for that file. - * - * Use these methods to setup the journals (files or other output). - * These are the internal objects that keep track of the print levels - * for each category. Then use the internal Journal objects to - * set specific print levels for each category (or keep defaults). - * - */ - //@{ - /** Add a new journal. The location_name is a string identifier, - * which can be used to obtain the pointer to the new Journal at - * a later point using the GetJournal method. - * The default_level is - * used to initialize the * printing level for all categories. - */ - virtual bool AddJournal(const SmartPtr<Journal> jrnl); - - /** Add a new FileJournal. fname is the name - * of the * file to which this Journal corresponds. Use - * fname="stdout" * for stdout, and use fname="stderr" for - * stderr. This method * returns the Journal pointer so you can - * set specific acceptance criteria. It returns NULL if there - * was a problem creating a new Journal. - */ - virtual SmartPtr<Journal> AddFileJournal( - const std::string& location_name, /** identifier */ - const std::string& fname, - EJournalLevel default_level = J_WARNING - ); - - /** Get an existing journal. You can use this method to change - * the acceptance criteria at runtime. - */ - virtual SmartPtr<Journal> GetJournal(const std::string& location_name); - - /** Delete all journals curently known by the journalist. */ - virtual void DeleteAllJournals(); - //@} - - 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 */ - Journalist(const Journalist&); - - /** Overloaded Equals Operator */ - void operator=(const Journalist&); - //@} - - //** Private Data Members. */ - //@{ - std::vector< SmartPtr<Journal> > journals_; - //@} - }; - - /** Journal class (part of the Journalist implementation.). This - * class is the base class for all Journals. It controls the - * acceptance criteria for print statements etc. Derived classes - * like the FileJournal - output those messages to specific locations - */ - class Journal : public ReferencedObject - { - public: - /** Constructor. */ - Journal(const std::string& name, EJournalLevel default_level); - - /** Destructor. */ - virtual ~Journal(); - - /** Get the name of the Journal */ - virtual std::string Name(); - - /** Set the print level for a particular category. */ - virtual void SetPrintLevel( - EJournalCategory category, EJournalLevel level - ); - - /** Set the print level for all category. */ - virtual void SetAllPrintLevels( - EJournalLevel level - ); - - /**@name Journal Output Methods. These methods are called by the - * Journalist who first checks if the output print level and category - * are acceptable. - * Calling the Print methods explicitly (instead of through the - * Journalist will output the message regardless of print level - * and category. You should use the Journalist to print & flush instead - */ - //@{ - /** Ask if a particular print level/category is accepted by the - * journal. - */ - virtual bool IsAccepted( - EJournalCategory category, EJournalLevel level - ) const; - - /** Print to the designated output location */ - virtual void Print(EJournalCategory category, EJournalLevel level, - const char* str) - { - PrintImpl(category, level, str); - } - - /** Printf to the designated output location */ - virtual void Printf(EJournalCategory category, EJournalLevel level, - const char* pformat, va_list ap) - { - PrintfImpl(category, level, pformat, ap); - } - - /** Flush output buffer.*/ - virtual void FlushBuffer() - { - FlushBufferImpl(); - } - //@} - - protected: - /**@name Implementation version of Print methods. Derived classes - * should overload the Impl methods. - */ - //@{ - /** Print to the designated output location */ - virtual void PrintImpl(EJournalCategory category, EJournalLevel level, - const char* str)=0; - - /** Printf to the designated output location */ - virtual void PrintfImpl(EJournalCategory category, EJournalLevel level, - const char* pformat, va_list ap)=0; - - /** Flush output buffer.*/ - virtual void FlushBufferImpl()=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 */ - Journal(); - - /** Copy Constructor */ - Journal(const Journal&); - - /** Overloaded Equals Operator */ - void operator=(const Journal&); - //@} - - /** Name of the output location */ - std::string name_; - - /** vector of integers indicating the level for each category */ - Index print_levels_[J_LAST_CATEGORY]; - }; - - - /** FileJournal class. This is a particular Journal implementation that - * writes to a file for output. It can write to (stdout, stderr, or disk) - * by using "stdout" and "stderr" as filenames. - */ - class FileJournal : public Journal - { - public: - /** Constructor. */ - FileJournal(const std::string& name, EJournalLevel default_level); - - /** Destructor. */ - virtual ~FileJournal(); - - /** Open a new file for the output location. - * Special Names: stdout means stdout, - * : stderr means stderr. - * - * Return code is false only if the file with the given name - * could not be opened. - */ - virtual bool Open(const char* fname); - - protected: - /**@name Implementation version of Print methods - Overloaded from - * Journal base class. - */ - //@{ - /** Print to the designated output location */ - virtual void PrintImpl(EJournalCategory category, EJournalLevel level, - const char* str); - - /** Printf to the designated output location */ - virtual void PrintfImpl(EJournalCategory category, EJournalLevel level, - const char* pformat, va_list ap); - - /** Flush output buffer.*/ - virtual void FlushBufferImpl(); - //@} - - 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 */ - FileJournal(); - - /** Copy Constructor */ - FileJournal(const FileJournal&); - - /** Overloaded Equals Operator */ - void operator=(const FileJournal&); - //@} - - /** FILE pointer for the output destination */ - FILE* file_; - }; - - /** StreamJournal class. This is a particular Journal implementation that - * writes to a stream for output. - */ - class StreamJournal : public Journal - { - public: - /** Constructor. */ - StreamJournal(const std::string& name, EJournalLevel default_level); - - /** Destructor. */ - virtual ~StreamJournal() - {} - - /** Setting the output stream pointer */ - void SetOutputStream(std::ostream* os); - - protected: - /**@name Implementation version of Print methods - Overloaded from - * Journal base class. - */ - //@{ - /** Print to the designated output location */ - virtual void PrintImpl(EJournalCategory category, EJournalLevel level, - const char* str); - - /** Printf to the designated output location */ - virtual void PrintfImpl(EJournalCategory category, EJournalLevel level, - const char* pformat, va_list ap); - - /** Flush output buffer.*/ - virtual void FlushBufferImpl(); - //@} - - 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 */ - StreamJournal(); - - /** Copy Constructor */ - StreamJournal(const StreamJournal&); - - /** Overloaded Equals Operator */ - void operator=(const StreamJournal&); - //@} - - /** pointer to output stream for the output destination */ - std::ostream* os_; - - /** buffer for sprintf. Being generous in size here... */ - char buffer_[32768]; - }; -} - -#endif +// Copyright (C) 2004, 2009 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpJournalist.hpp 2204 2013-04-13 13:49:26Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPJOURNALIST_HPP__
+#define __IPJOURNALIST_HPP__
+
+#include "IpoptConfig.h"
+#include "IpTypes.hpp"
+#include "IpReferenced.hpp"
+#include "IpSmartPtr.hpp"
+
+#ifdef HAVE_CSTDARG
+# include <cstdarg>
+#else
+# ifdef HAVE_STDARG_H
+# include <stdarg.h>
+# else
+# include <cstdarg> // if this header is included by someone who does not define HAVE_CSTDARG or HAVE_STDARG, let's hope that cstdarg is available
+# endif
+#endif
+
+#ifdef HAVE_CSTDIO
+# include <cstdio>
+#else
+# ifdef HAVE_STDIO_H
+# include <stdio.h>
+# else
+# include <cstdio> // if this header is included by someone who does not define HAVE_CSTDIO or HAVE_STDIO, let's hope that cstdio is available
+# endif
+#endif
+
+#include <string>
+#include <vector>
+#include <ostream>
+
+namespace Ipopt
+{
+
+ // forward declarations
+ class Journal;
+ class FileJournal;
+
+ /**@name Journalist Enumerations. */
+ //@{
+ /** Print Level Enum. */
+ enum EJournalLevel {
+ J_INSUPPRESSIBLE=-1,
+ J_NONE=0,
+ J_ERROR,
+ J_STRONGWARNING,
+ J_SUMMARY,
+ J_WARNING,
+ J_ITERSUMMARY,
+ J_DETAILED,
+ J_MOREDETAILED,
+ J_VECTOR,
+ J_MOREVECTOR,
+ J_MATRIX,
+ J_MOREMATRIX,
+ J_ALL,
+ J_LAST_LEVEL
+ };
+
+ /** Category Selection Enum. */
+ enum EJournalCategory {
+ J_DBG=0,
+ J_STATISTICS,
+ J_MAIN,
+ J_INITIALIZATION,
+ J_BARRIER_UPDATE,
+ J_SOLVE_PD_SYSTEM,
+ J_FRAC_TO_BOUND,
+ J_LINEAR_ALGEBRA,
+ J_LINE_SEARCH,
+ J_HESSIAN_APPROXIMATION,
+ J_SOLUTION,
+ J_DOCUMENTATION,
+ J_NLP,
+ J_TIMING_STATISTICS,
+ J_USER_APPLICATION /** This can be used by the user's application*/ ,
+ J_USER1 /** This can be used by the user's application*/ ,
+ J_USER2 /** This can be used by the user's application*/ ,
+ J_USER3 /** This can be used by the user's application*/ ,
+ J_USER4 /** This can be used by the user's application*/ ,
+ J_USER5 /** This can be used by the user's application*/ ,
+ J_USER6 /** This can be used by the user's application*/ ,
+ J_USER7 /** This can be used by the user's application*/ ,
+ J_USER8 /** This can be used by the user's application*/ ,
+ J_USER9 /** This can be used by the user's application*/ ,
+ J_USER10 /** This can be used by the user's application*/ ,
+ J_USER11 /** This can be used by the user's application*/ ,
+ J_USER12 /** This can be used by the user's application*/ ,
+ J_USER13 /** This can be used by the user's application*/ ,
+ J_USER14 /** This can be used by the user's application*/ ,
+ J_USER15 /** This can be used by the user's application*/ ,
+ J_USER16 /** This can be used by the user's application*/ ,
+ J_USER17 /** This can be used by the user's application*/ ,
+ J_LAST_CATEGORY
+ };
+ //@}
+
+ /** Class responsible for all message output.
+ * This class is responsible for all messaging and output.
+ * The "printing" code or "author" should send ALL messages to the
+ * Journalist, indicating an appropriate category and print level.
+ * The journalist then decides, based on reader specified
+ * acceptance criteria, which message is actually printed in which
+ * journals.
+ * This allows the printing code to send everything, while the
+ * "reader" can decide what they really want to see.
+ *
+ * Authors:
+ * Authors use the
+ * Journals: You can add as many Journals as you like to the
+ * Journalist with the AddJournal or the AddFileJournal methods.
+ * Each one represents a different printing location (or file).
+ * Then, you can call the "print" methods of the Journalist to output
+ * information to each of the journals.
+ *
+ * Acceptance Criteria: Each print message should be flagged
+ * appropriately with an EJournalCategory and EJournalLevel.
+ *
+ * The AddFileJournal
+ * method returns a pointer to the newly created Journal object
+ * (if successful) so you can set Acceptance criteria for that
+ * particular location.
+ *
+ */
+ class Journalist : public ReferencedObject
+ {
+ public:
+ /**@name Constructor / Desructor. */
+ //@{
+ /** Constructor. */
+ Journalist();
+
+ /** Destructor... */
+ virtual ~Journalist();
+ //@}
+
+ /**@name Author Methods.
+ * These methods are used by authoring code, or code that wants
+ * to report some information.
+ */
+ //@{
+ /** Method to print a formatted string */
+ virtual void Printf(EJournalLevel level, EJournalCategory category,
+ const char* format, ...) const;
+
+ /** Method to print a long string including indentation. The
+ * string is printed starting at the current position. If the
+ * position (counting started at the current position) exceeds
+ * max_length, a new line is inserted, and indent_spaces many
+ * spaces are printed before the string is continued. This is
+ * for example used during the printing of the option
+ * documentation. */
+ virtual void PrintStringOverLines(EJournalLevel level, EJournalCategory category,
+ Index indent_spaces, Index max_length,
+ const std::string& line) const;
+
+ /** Method to print a formatted string with indentation */
+ virtual void PrintfIndented(EJournalLevel level,
+ EJournalCategory category,
+ Index indent_level,
+ const char* format, ...) const;
+
+ /** Method to print a formatted string
+ * using the va_list argument. */
+ virtual void VPrintf(EJournalLevel level,
+ EJournalCategory category,
+ const char* pformat,
+ va_list ap) const;
+
+ /** Method to print a formatted string with indentation,
+ * using the va_list argument. */
+ virtual void VPrintfIndented(EJournalLevel level,
+ EJournalCategory category,
+ Index indent_level,
+ const char* pformat,
+ va_list ap) const;
+
+ /** Method that returns true if there is a Journal that would
+ * write output for the given JournalLevel and JournalCategory.
+ * This is useful if expensive computation would be required for
+ * a particular output. The author code can check with this
+ * method if the computations are indeed required.
+ */
+ virtual bool ProduceOutput(EJournalLevel level,
+ EJournalCategory category) const;
+
+
+ /** Method that flushes the current buffer for all Journalists.
+ Calling this method after one optimization run helps to avoid
+ cluttering output with that produced by other parts of the
+ program (e.g. written in Fortran) */
+ virtual void FlushBuffer() const;
+ //@}
+
+ /**@name Reader Methods.
+ * These methods are used by the reader. The reader will setup the
+ * journalist with each output file and the acceptance
+ * criteria for that file.
+ *
+ * Use these methods to setup the journals (files or other output).
+ * These are the internal objects that keep track of the print levels
+ * for each category. Then use the internal Journal objects to
+ * set specific print levels for each category (or keep defaults).
+ *
+ */
+ //@{
+ /** Add a new journal. The location_name is a string identifier,
+ * which can be used to obtain the pointer to the new Journal at
+ * a later point using the GetJournal method.
+ * The default_level is
+ * used to initialize the * printing level for all categories.
+ */
+ virtual bool AddJournal(const SmartPtr<Journal> jrnl);
+
+ /** Add a new FileJournal. fname is the name
+ * of the * file to which this Journal corresponds. Use
+ * fname="stdout" * for stdout, and use fname="stderr" for
+ * stderr. This method * returns the Journal pointer so you can
+ * set specific acceptance criteria. It returns NULL if there
+ * was a problem creating a new Journal.
+ */
+ virtual SmartPtr<Journal> AddFileJournal(
+ const std::string& location_name, /**< journal identifier */
+ const std::string& fname, /**< file name */
+ EJournalLevel default_level = J_WARNING /**< default journal level */
+ );
+
+ /** Get an existing journal. You can use this method to change
+ * the acceptance criteria at runtime.
+ */
+ virtual SmartPtr<Journal> GetJournal(const std::string& location_name);
+
+ /** Delete all journals curently known by the journalist. */
+ virtual void DeleteAllJournals();
+ //@}
+
+ 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 */
+ Journalist(const Journalist&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const Journalist&);
+ //@}
+
+ //** Private Data Members. */
+ //@{
+ std::vector< SmartPtr<Journal> > journals_;
+ //@}
+ };
+
+ /** Journal class (part of the Journalist implementation.). This
+ * class is the base class for all Journals. It controls the
+ * acceptance criteria for print statements etc. Derived classes
+ * like the FileJournal - output those messages to specific locations
+ */
+ class Journal : public ReferencedObject
+ {
+ public:
+ /** Constructor. */
+ Journal(const std::string& name, EJournalLevel default_level);
+
+ /** Destructor. */
+ virtual ~Journal();
+
+ /** Get the name of the Journal */
+ virtual std::string Name();
+
+ /** Set the print level for a particular category. */
+ virtual void SetPrintLevel(
+ EJournalCategory category, EJournalLevel level
+ );
+
+ /** Set the print level for all category. */
+ virtual void SetAllPrintLevels(
+ EJournalLevel level
+ );
+
+ /**@name Journal Output Methods. These methods are called by the
+ * Journalist who first checks if the output print level and category
+ * are acceptable.
+ * Calling the Print methods explicitly (instead of through the
+ * Journalist will output the message regardless of print level
+ * and category. You should use the Journalist to print & flush instead
+ */
+ //@{
+ /** Ask if a particular print level/category is accepted by the
+ * journal.
+ */
+ virtual bool IsAccepted(
+ EJournalCategory category, EJournalLevel level
+ ) const;
+
+ /** Print to the designated output location */
+ virtual void Print(EJournalCategory category, EJournalLevel level,
+ const char* str)
+ {
+ PrintImpl(category, level, str);
+ }
+
+ /** Printf to the designated output location */
+ virtual void Printf(EJournalCategory category, EJournalLevel level,
+ const char* pformat, va_list ap)
+ {
+ PrintfImpl(category, level, pformat, ap);
+ }
+
+ /** Flush output buffer.*/
+ virtual void FlushBuffer()
+ {
+ FlushBufferImpl();
+ }
+ //@}
+
+ protected:
+ /**@name Implementation version of Print methods. Derived classes
+ * should overload the Impl methods.
+ */
+ //@{
+ /** Print to the designated output location */
+ virtual void PrintImpl(EJournalCategory category, EJournalLevel level,
+ const char* str)=0;
+
+ /** Printf to the designated output location */
+ virtual void PrintfImpl(EJournalCategory category, EJournalLevel level,
+ const char* pformat, va_list ap)=0;
+
+ /** Flush output buffer.*/
+ virtual void FlushBufferImpl()=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 */
+ Journal();
+
+ /** Copy Constructor */
+ Journal(const Journal&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const Journal&);
+ //@}
+
+ /** Name of the output location */
+ std::string name_;
+
+ /** vector of integers indicating the level for each category */
+ Index print_levels_[J_LAST_CATEGORY];
+ };
+
+
+ /** FileJournal class. This is a particular Journal implementation that
+ * writes to a file for output. It can write to (stdout, stderr, or disk)
+ * by using "stdout" and "stderr" as filenames.
+ */
+ class FileJournal : public Journal
+ {
+ public:
+ /** Constructor. */
+ FileJournal(const std::string& name, EJournalLevel default_level);
+
+ /** Destructor. */
+ virtual ~FileJournal();
+
+ /** Open a new file for the output location.
+ * Special Names: stdout means stdout,
+ * : stderr means stderr.
+ *
+ * Return code is false only if the file with the given name
+ * could not be opened.
+ */
+ virtual bool Open(const char* fname);
+
+ protected:
+ /**@name Implementation version of Print methods - Overloaded from
+ * Journal base class.
+ */
+ //@{
+ /** Print to the designated output location */
+ virtual void PrintImpl(EJournalCategory category, EJournalLevel level,
+ const char* str);
+
+ /** Printf to the designated output location */
+ virtual void PrintfImpl(EJournalCategory category, EJournalLevel level,
+ const char* pformat, va_list ap);
+
+ /** Flush output buffer.*/
+ virtual void FlushBufferImpl();
+ //@}
+
+ 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 */
+ FileJournal();
+
+ /** Copy Constructor */
+ FileJournal(const FileJournal&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const FileJournal&);
+ //@}
+
+ /** FILE pointer for the output destination */
+ FILE* file_;
+ };
+
+ /** StreamJournal class. This is a particular Journal implementation that
+ * writes to a stream for output.
+ */
+ class StreamJournal : public Journal
+ {
+ public:
+ /** Constructor. */
+ StreamJournal(const std::string& name, EJournalLevel default_level);
+
+ /** Destructor. */
+ virtual ~StreamJournal()
+ {}
+
+ /** Setting the output stream pointer */
+ void SetOutputStream(std::ostream* os);
+
+ protected:
+ /**@name Implementation version of Print methods - Overloaded from
+ * Journal base class.
+ */
+ //@{
+ /** Print to the designated output location */
+ virtual void PrintImpl(EJournalCategory category, EJournalLevel level,
+ const char* str);
+
+ /** Printf to the designated output location */
+ virtual void PrintfImpl(EJournalCategory category, EJournalLevel level,
+ const char* pformat, va_list ap);
+
+ /** Flush output buffer.*/
+ virtual void FlushBufferImpl();
+ //@}
+
+ 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 */
+ StreamJournal();
+
+ /** Copy Constructor */
+ StreamJournal(const StreamJournal&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const StreamJournal&);
+ //@}
+
+ /** pointer to output stream for the output destination */
+ std::ostream* os_;
+
+ /** buffer for sprintf. Being generous in size here... */
+ char buffer_[32768];
+ };
+}
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpMatrix.hpp b/thirdparty/windows/include/coin/IpMatrix.hpp index 93b04e1..1f90e31 100644 --- a/thirdparty/windows/include/coin/IpMatrix.hpp +++ b/thirdparty/windows/include/coin/IpMatrix.hpp @@ -1,342 +1,344 @@ -// Copyright (C) 2004, 2008 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpMatrix.hpp 1280 2008-08-10 21:19:31Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPMATRIX_HPP__ -#define __IPMATRIX_HPP__ - -#include "IpVector.hpp" - -namespace Ipopt -{ - - /* forward declarations */ - class MatrixSpace; - - /** Matrix Base Class. This is the base class for all derived matrix - * types. All Matrices, such as Jacobian and Hessian matrices, as - * well as possibly the iteration matrices needed for the step - * computation, are of this type. - * - * Deriving from Matrix: Overload the protected XXX_Impl method. - */ - class Matrix : public TaggedObject - { - public: - /** @name Constructor/Destructor */ - //@{ - /** Constructor. It has to be given a pointer to the - * corresponding MatrixSpace. - */ - Matrix(const MatrixSpace* owner_space) - : - TaggedObject(), - owner_space_(owner_space), - valid_cache_tag_(0) - {} - - /** Destructor */ - virtual ~Matrix() - {} - //@} - - /**@name Operations of the Matrix on a Vector */ - //@{ - /** Matrix-vector multiply. Computes y = alpha * Matrix * x + - * beta * y. Do not overload. Overload MultVectorImpl instead. - */ - void MultVector(Number alpha, const Vector& x, Number beta, - Vector& y) const - { - MultVectorImpl(alpha, x, beta, y); - } - - /** Matrix(transpose) vector multiply. Computes y = alpha * - * Matrix^T * x + beta * y. Do not overload. Overload - * TransMultVectorImpl instead. - */ - void TransMultVector(Number alpha, const Vector& x, Number beta, - Vector& y) const - { - TransMultVectorImpl(alpha, x, beta, y); - } - //@} - - /** @name Methods for specialized operations. A prototype - * implementation is provided, but for efficient implementation - * those should be specially implemented. - */ - //@{ - /** X = X + alpha*(Matrix S^{-1} Z). Should be implemented - * efficiently for the ExansionMatrix - */ - void AddMSinvZ(Number alpha, const Vector& S, const Vector& Z, - Vector& X) const; - - /** X = S^{-1} (r + alpha*Z*M^Td). Should be implemented - * efficiently for the ExansionMatrix - */ - void SinvBlrmZMTdBr(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). */ - bool HasValidNumbers() const; - - /** @name Information about the size of the matrix */ - //@{ - /** Number of rows */ - Index NRows() const; - - /** Number of columns */ - Index NCols() const; - //@} - - /** @name Norms of the individual rows and columns */ - //@{ - /** Compute the max-norm of the rows in the matrix. The result is - * stored in rows_norms. The vector is assumed to be initialized - * of init is false. */ - void ComputeRowAMax(Vector& rows_norms, bool init=true) const - { - DBG_ASSERT(NRows() == rows_norms.Dim()); - if (init) rows_norms.Set(0.); - ComputeRowAMaxImpl(rows_norms, init); - } - /** Compute the max-norm of the columns in the matrix. The result - * is stored in cols_norms The vector is assumed to be initialized - * of init is false. */ - void ComputeColAMax(Vector& cols_norms, bool init=true) const - { - DBG_ASSERT(NCols() == cols_norms.Dim()); - if (init) cols_norms.Set(0.); - ComputeColAMaxImpl(cols_norms, init); - } - //@} - - /** Print detailed information about the matrix. Do not overload. - * Overload PrintImpl instead. - */ - //@{ - virtual void Print(SmartPtr<const Journalist> jnlst, - EJournalLevel level, - EJournalCategory category, - const std::string& name, - Index indent=0, - const std::string& prefix="") const; - virtual void Print(const Journalist& jnlst, - EJournalLevel level, - EJournalCategory category, - const std::string& name, - Index indent=0, - const std::string& prefix="") const; - //@} - - /** Return the owner MatrixSpace*/ - SmartPtr<const MatrixSpace> OwnerSpace() const; - - protected: - /** @name implementation methods (derived classes MUST - * overload these pure virtual protected methods. - */ - //@{ - /** Matrix-vector multiply. Computes y = alpha * Matrix * x + - * beta * y - */ - virtual void MultVectorImpl(Number alpha, const Vector& x, Number beta, Vector& y) const =0; - - /** Matrix(transpose) vector multiply. - * Computes y = alpha * Matrix^T * x + beta * y - */ - virtual void TransMultVectorImpl(Number alpha, const Vector& x, Number beta, Vector& y) const =0; - - /** X = X + alpha*(Matrix S^{-1} Z). Prototype for this - * specialize method is provided, but for efficient - * implementation it should be overloaded for the expansion matrix. - */ - virtual void AddMSinvZImpl(Number alpha, const Vector& S, const Vector& Z, - Vector& X) const; - - /** X = S^{-1} (r + alpha*Z*M^Td). Should be implemented - * efficiently for the ExpansionMatrix. - */ - 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). A default implementation always returning true - * is provided, but if possible it should be implemented. */ - virtual bool HasValidNumbersImpl() const - { - return true; - } - - /** Compute the max-norm of the rows in the matrix. The result is - * stored in rows_norms. The vector is assumed to be - * initialized. */ - virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const = 0; - /** Compute the max-norm of the columns in the matrix. The result - * is stored in cols_norms. The vector is assumed to be - * initialized. */ - virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const = 0; - - /** Print detailed information about the matrix. */ - virtual void PrintImpl(const Journalist& jnlst, - EJournalLevel level, - EJournalCategory category, - const std::string& name, - Index indent, - const std::string& prefix) const =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 */ - Matrix(); - - /** Copy constructor */ - Matrix(const Matrix&); - - /** Overloaded Equals Operator */ - Matrix& operator=(const Matrix&); - //@} - - const SmartPtr<const MatrixSpace> owner_space_; - - /**@name CachedResults data members */ - //@{ - mutable TaggedObject::Tag valid_cache_tag_; - mutable bool cached_valid_; - //@} - }; - - - /** MatrixSpace base class, corresponding to the Matrix base class. - * For each Matrix implementation, a corresponding MatrixSpace has - * to be implemented. A MatrixSpace is able to create new Matrices - * of a specific type. The MatrixSpace should also store - * information that is common to all Matrices of that type. For - * example, the dimensions of a Matrix is stored in the MatrixSpace - * base class. - */ - class MatrixSpace : public ReferencedObject - { - public: - /** @name Constructors/Destructors */ - //@{ - /** Constructor, given the number rows and columns of all matrices - * generated by this MatrixSpace. - */ - MatrixSpace(Index nRows, Index nCols) - : - nRows_(nRows), - nCols_(nCols) - {} - - /** Destructor */ - virtual ~MatrixSpace() - {} - //@} - - /** Pure virtual method for creating a new Matrix of the - * corresponding type. - */ - virtual Matrix* MakeNew() const=0; - - /** Accessor function for the number of rows. */ - Index NRows() const - { - return nRows_; - } - /** Accessor function for the number of columns. */ - Index NCols() const - { - return nCols_; - } - - /** Method to test if a given matrix belongs to a particular - * matrix space. - */ - bool IsMatrixFromSpace(const Matrix& matrix) const - { - return (matrix.OwnerSpace() == 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 */ - MatrixSpace(); - - /** Copy constructor */ - MatrixSpace(const MatrixSpace&); - - /** Overloaded Equals Operator */ - MatrixSpace& operator=(const MatrixSpace&); - //@} - - /** Number of rows for all matrices of this type. */ - const Index nRows_; - /** Number of columns for all matrices of this type. */ - const Index nCols_; - }; - - - /* Inline Methods */ - inline - Index Matrix::NRows() const - { - return owner_space_->NRows(); - } - - inline - Index Matrix::NCols() const - { - return owner_space_->NCols(); - } - - inline - SmartPtr<const MatrixSpace> Matrix::OwnerSpace() const - { - return owner_space_; - } - -} // namespace Ipopt - -// Macro definitions for debugging matrices -#if COIN_IPOPT_VERBOSITY == 0 -# define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat) -#else -# define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat) \ - if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \ - if (dbg_jrnl.Jnlst()!=NULL) { \ - (__mat).Print(dbg_jrnl.Jnlst(), \ - J_ERROR, J_DBG, \ - __mat_name, \ - dbg_jrnl.IndentationLevel()*2, \ - "# "); \ - } \ - } -#endif // #if COIN_IPOPT_VERBOSITY == 0 - -#endif +// Copyright (C) 2004, 2008 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpMatrix.hpp 2276 2013-05-05 12:33:44Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPMATRIX_HPP__
+#define __IPMATRIX_HPP__
+
+#include "IpVector.hpp"
+
+namespace Ipopt
+{
+
+ /* forward declarations */
+ class MatrixSpace;
+
+ /** Matrix Base Class. This is the base class for all derived matrix
+ * types. All Matrices, such as Jacobian and Hessian matrices, as
+ * well as possibly the iteration matrices needed for the step
+ * computation, are of this type.
+ *
+ * Deriving from Matrix: Overload the protected XXX_Impl method.
+ */
+ class Matrix : public TaggedObject
+ {
+ public:
+ /** @name Constructor/Destructor */
+ //@{
+ /** Constructor. It has to be given a pointer to the
+ * corresponding MatrixSpace.
+ */
+ Matrix(const MatrixSpace* owner_space)
+ :
+ TaggedObject(),
+ owner_space_(owner_space)
+ {}
+
+ /** Destructor */
+ virtual ~Matrix()
+ {}
+ //@}
+
+ /**@name Operations of the Matrix on a Vector */
+ //@{
+ /** Matrix-vector multiply. Computes y = alpha * Matrix * x +
+ * beta * y. Do not overload. Overload MultVectorImpl instead.
+ */
+ void MultVector(Number alpha, const Vector& x, Number beta,
+ Vector& y) const
+ {
+ MultVectorImpl(alpha, x, beta, y);
+ }
+
+ /** Matrix(transpose) vector multiply. Computes y = alpha *
+ * Matrix^T * x + beta * y. Do not overload. Overload
+ * TransMultVectorImpl instead.
+ */
+ void TransMultVector(Number alpha, const Vector& x, Number beta,
+ Vector& y) const
+ {
+ TransMultVectorImpl(alpha, x, beta, y);
+ }
+ //@}
+
+ /** @name Methods for specialized operations. A prototype
+ * implementation is provided, but for efficient implementation
+ * those should be specially implemented.
+ */
+ //@{
+ /** X = X + alpha*(Matrix S^{-1} Z). Should be implemented
+ * efficiently for the ExansionMatrix
+ */
+ void AddMSinvZ(Number alpha, const Vector& S, const Vector& Z,
+ Vector& X) const;
+
+ /** X = S^{-1} (r + alpha*Z*M^Td). Should be implemented
+ * efficiently for the ExansionMatrix
+ */
+ void SinvBlrmZMTdBr(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). */
+ bool HasValidNumbers() const;
+
+ /** @name Information about the size of the matrix */
+ //@{
+ /** Number of rows */
+ inline
+ Index NRows() const;
+
+ /** Number of columns */
+ inline
+ Index NCols() const;
+ //@}
+
+ /** @name Norms of the individual rows and columns */
+ //@{
+ /** Compute the max-norm of the rows in the matrix. The result is
+ * stored in rows_norms. The vector is assumed to be initialized
+ * of init is false. */
+ void ComputeRowAMax(Vector& rows_norms, bool init=true) const
+ {
+ DBG_ASSERT(NRows() == rows_norms.Dim());
+ if (init) rows_norms.Set(0.);
+ ComputeRowAMaxImpl(rows_norms, init);
+ }
+ /** Compute the max-norm of the columns in the matrix. The result
+ * is stored in cols_norms The vector is assumed to be initialized
+ * of init is false. */
+ void ComputeColAMax(Vector& cols_norms, bool init=true) const
+ {
+ DBG_ASSERT(NCols() == cols_norms.Dim());
+ if (init) cols_norms.Set(0.);
+ ComputeColAMaxImpl(cols_norms, init);
+ }
+ //@}
+
+ /** Print detailed information about the matrix. Do not overload.
+ * Overload PrintImpl instead.
+ */
+ //@{
+ virtual void Print(SmartPtr<const Journalist> jnlst,
+ EJournalLevel level,
+ EJournalCategory category,
+ const std::string& name,
+ Index indent=0,
+ const std::string& prefix="") const;
+ virtual void Print(const Journalist& jnlst,
+ EJournalLevel level,
+ EJournalCategory category,
+ const std::string& name,
+ Index indent=0,
+ const std::string& prefix="") const;
+ //@}
+
+ /** Return the owner MatrixSpace*/
+ inline
+ SmartPtr<const MatrixSpace> OwnerSpace() const;
+
+ protected:
+ /** @name implementation methods (derived classes MUST
+ * overload these pure virtual protected methods.
+ */
+ //@{
+ /** Matrix-vector multiply. Computes y = alpha * Matrix * x +
+ * beta * y
+ */
+ virtual void MultVectorImpl(Number alpha, const Vector& x, Number beta, Vector& y) const =0;
+
+ /** Matrix(transpose) vector multiply.
+ * Computes y = alpha * Matrix^T * x + beta * y
+ */
+ virtual void TransMultVectorImpl(Number alpha, const Vector& x, Number beta, Vector& y) const =0;
+
+ /** X = X + alpha*(Matrix S^{-1} Z). Prototype for this
+ * specialize method is provided, but for efficient
+ * implementation it should be overloaded for the expansion matrix.
+ */
+ virtual void AddMSinvZImpl(Number alpha, const Vector& S, const Vector& Z,
+ Vector& X) const;
+
+ /** X = S^{-1} (r + alpha*Z*M^Td). Should be implemented
+ * efficiently for the ExpansionMatrix.
+ */
+ 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). A default implementation always returning true
+ * is provided, but if possible it should be implemented. */
+ virtual bool HasValidNumbersImpl() const
+ {
+ return true;
+ }
+
+ /** Compute the max-norm of the rows in the matrix. The result is
+ * stored in rows_norms. The vector is assumed to be
+ * initialized. */
+ virtual void ComputeRowAMaxImpl(Vector& rows_norms, bool init) const = 0;
+ /** Compute the max-norm of the columns in the matrix. The result
+ * is stored in cols_norms. The vector is assumed to be
+ * initialized. */
+ virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const = 0;
+
+ /** Print detailed information about the matrix. */
+ virtual void PrintImpl(const Journalist& jnlst,
+ EJournalLevel level,
+ EJournalCategory category,
+ const std::string& name,
+ Index indent,
+ const std::string& prefix) const =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 */
+ Matrix();
+
+ /** Copy constructor */
+ Matrix(const Matrix&);
+
+ /** Overloaded Equals Operator */
+ Matrix& operator=(const Matrix&);
+ //@}
+
+ const SmartPtr<const MatrixSpace> owner_space_;
+
+ /**@name CachedResults data members */
+ //@{
+ mutable TaggedObject::Tag valid_cache_tag_;
+ mutable bool cached_valid_;
+ //@}
+ };
+
+
+ /** MatrixSpace base class, corresponding to the Matrix base class.
+ * For each Matrix implementation, a corresponding MatrixSpace has
+ * to be implemented. A MatrixSpace is able to create new Matrices
+ * of a specific type. The MatrixSpace should also store
+ * information that is common to all Matrices of that type. For
+ * example, the dimensions of a Matrix is stored in the MatrixSpace
+ * base class.
+ */
+ class MatrixSpace : public ReferencedObject
+ {
+ public:
+ /** @name Constructors/Destructors */
+ //@{
+ /** Constructor, given the number rows and columns of all matrices
+ * generated by this MatrixSpace.
+ */
+ MatrixSpace(Index nRows, Index nCols)
+ :
+ nRows_(nRows),
+ nCols_(nCols)
+ {}
+
+ /** Destructor */
+ virtual ~MatrixSpace()
+ {}
+ //@}
+
+ /** Pure virtual method for creating a new Matrix of the
+ * corresponding type.
+ */
+ virtual Matrix* MakeNew() const=0;
+
+ /** Accessor function for the number of rows. */
+ Index NRows() const
+ {
+ return nRows_;
+ }
+ /** Accessor function for the number of columns. */
+ Index NCols() const
+ {
+ return nCols_;
+ }
+
+ /** Method to test if a given matrix belongs to a particular
+ * matrix space.
+ */
+ bool IsMatrixFromSpace(const Matrix& matrix) const
+ {
+ return (matrix.OwnerSpace() == 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 */
+ MatrixSpace();
+
+ /** Copy constructor */
+ MatrixSpace(const MatrixSpace&);
+
+ /** Overloaded Equals Operator */
+ MatrixSpace& operator=(const MatrixSpace&);
+ //@}
+
+ /** Number of rows for all matrices of this type. */
+ const Index nRows_;
+ /** Number of columns for all matrices of this type. */
+ const Index nCols_;
+ };
+
+
+ /* Inline Methods */
+ inline
+ Index Matrix::NRows() const
+ {
+ return owner_space_->NRows();
+ }
+
+ inline
+ Index Matrix::NCols() const
+ {
+ return owner_space_->NCols();
+ }
+
+ inline
+ SmartPtr<const MatrixSpace> Matrix::OwnerSpace() const
+ {
+ return owner_space_;
+ }
+
+} // namespace Ipopt
+
+// Macro definitions for debugging matrices
+#if COIN_IPOPT_VERBOSITY == 0
+# define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat)
+#else
+# define DBG_PRINT_MATRIX(__verbose_level, __mat_name, __mat) \
+ if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \
+ if (dbg_jrnl.Jnlst()!=NULL) { \
+ (__mat).Print(dbg_jrnl.Jnlst(), \
+ J_ERROR, J_DBG, \
+ __mat_name, \
+ dbg_jrnl.IndentationLevel()*2, \
+ "# "); \
+ } \
+ }
+#endif // #if COIN_IPOPT_VERBOSITY == 0
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpNLP.hpp b/thirdparty/windows/include/coin/IpNLP.hpp index 20ee64b..814f089 100644 --- a/thirdparty/windows/include/coin/IpNLP.hpp +++ b/thirdparty/windows/include/coin/IpNLP.hpp @@ -1,243 +1,243 @@ -// Copyright (C) 2004, 2006 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpNLP.hpp 1312 2008-08-29 22:21:40Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPNLP_HPP__ -#define __IPNLP_HPP__ - -#include "IpUtils.hpp" -#include "IpVector.hpp" -#include "IpSmartPtr.hpp" -#include "IpMatrix.hpp" -#include "IpSymMatrix.hpp" -#include "IpOptionsList.hpp" -#include "IpAlgTypes.hpp" -#include "IpReturnCodes.hpp" - -namespace Ipopt -{ - // forward declarations - class IpoptData; - class IpoptCalculatedQuantities; - class IteratesVector; - - /** Brief Class Description. - * Detailed Class Description. - */ - class NLP : public ReferencedObject - { - public: - /**@name Constructors/Destructors */ - //@{ - /** Default constructor */ - NLP() - {} - - /** Default destructor */ - virtual ~NLP() - {} - //@} - - /** Exceptions */ - //@{ - DECLARE_STD_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED); - DECLARE_STD_EXCEPTION(INVALID_NLP); - //@} - - /** @name NLP Initialization (overload in - * derived classes).*/ - //@{ - /** Overload if you want the chance to process options or parameters that - * may be specific to the NLP */ - virtual bool ProcessOptions(const OptionsList& options, - const std::string& prefix) - { - return true; - } - - /** Method for creating the derived vector / matrix types. The - * Hess_lagrangian_space pointer can be NULL if a quasi-Newton - * options is chosen. */ - virtual bool GetSpaces(SmartPtr<const VectorSpace>& x_space, - SmartPtr<const VectorSpace>& c_space, - SmartPtr<const VectorSpace>& d_space, - SmartPtr<const VectorSpace>& x_l_space, - SmartPtr<const MatrixSpace>& px_l_space, - SmartPtr<const VectorSpace>& x_u_space, - SmartPtr<const MatrixSpace>& px_u_space, - SmartPtr<const VectorSpace>& d_l_space, - SmartPtr<const MatrixSpace>& pd_l_space, - SmartPtr<const VectorSpace>& d_u_space, - SmartPtr<const MatrixSpace>& pd_u_space, - SmartPtr<const MatrixSpace>& Jac_c_space, - SmartPtr<const MatrixSpace>& Jac_d_space, - SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space)=0; - - /** Method for obtaining the bounds information */ - virtual bool GetBoundsInformation(const Matrix& Px_L, - Vector& x_L, - const Matrix& Px_U, - Vector& x_U, - const Matrix& Pd_L, - Vector& d_L, - const Matrix& Pd_U, - Vector& d_U)=0; - - /** Method for obtaining the starting point for all the - * iterates. ToDo it might not make sense to ask for initial - * values for v_L and v_U? */ - virtual bool GetStartingPoint( - SmartPtr<Vector> x, - bool need_x, - SmartPtr<Vector> y_c, - bool need_y_c, - SmartPtr<Vector> y_d, - bool need_y_d, - SmartPtr<Vector> z_L, - bool need_z_L, - SmartPtr<Vector> z_U, - bool need_z_U - )=0; - - /** Method for obtaining an entire iterate as a warmstart point. - * The incoming IteratesVector has to be filled. The default - * dummy implementation returns false. */ - virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate) - { - return false; - } - //@} - - /** @name NLP evaluation routines (overload - * in derived classes. */ - //@{ - virtual bool Eval_f(const Vector& x, Number& f) = 0; - - virtual bool Eval_grad_f(const Vector& x, Vector& g_f) = 0; - - virtual bool Eval_c(const Vector& x, Vector& c) = 0; - - virtual bool Eval_jac_c(const Vector& x, Matrix& jac_c) = 0; - - virtual bool Eval_d(const Vector& x, Vector& d) = 0; - - virtual bool Eval_jac_d(const Vector& x, Matrix& jac_d) = 0; - - virtual bool Eval_h(const Vector& x, - Number obj_factor, - const Vector& yc, - const Vector& yd, - SymMatrix& h) = 0; - //@} - - /** @name NLP solution routines. Have default dummy - * implementations that can be overloaded. */ - //@{ - /** This method is called at the very end of the optimization. It - * provides the final iterate to the user, so that it can be - * stored as the solution. The status flag indicates the outcome - * of the optimization, where SolverReturn is defined in - * IpAlgTypes.hpp. */ - virtual void FinalizeSolution(SolverReturn status, - const Vector& x, const Vector& z_L, - const Vector& z_U, - const Vector& c, const Vector& d, - const Vector& y_c, const Vector& y_d, - Number obj_value, - const IpoptData* ip_data, - IpoptCalculatedQuantities* ip_cq) - {} - - /** This method is called once per iteration, after the iteration - * summary output has been printed. It provides the current - * information to the user to do with it anything she wants. It - * also allows the user to ask for a premature termination of the - * optimization by returning false, in which case Ipopt will - * terminate with a corresponding return status. The basic - * information provided in the argument list has the quantities - * values printed in the iteration summary line. If more - * information is required, a user can obtain it from the IpData - * and IpCalculatedQuantities objects. However, note that the - * provided quantities are all for the problem that Ipopt sees, - * i.e., the quantities might be scaled, fixed variables might be - * sorted out, etc. The status indicates things like whether the - * algorithm is in the restoration phase... In the restoration - * phase, the dual variables are probably not not changing. */ - virtual bool IntermediateCallBack(AlgorithmMode mode, - Index iter, Number obj_value, - Number inf_pr, Number inf_du, - Number mu, Number d_norm, - Number regularization_size, - Number alpha_du, Number alpha_pr, - Index ls_trials, - const IpoptData* ip_data, - IpoptCalculatedQuantities* ip_cq) - { - return true; - } - //@} - - /** Routines to get the scaling parameters. These do not need to - * be overloaded unless the options are set for User scaling - */ - //@{ - virtual void GetScalingParameters( - const SmartPtr<const VectorSpace> x_space, - const SmartPtr<const VectorSpace> c_space, - const SmartPtr<const VectorSpace> d_space, - Number& obj_scaling, - SmartPtr<Vector>& x_scaling, - SmartPtr<Vector>& c_scaling, - SmartPtr<Vector>& d_scaling) const - { - THROW_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED, - "You have set options for user provided scaling, but have" - " not implemented GetScalingParameters in the NLP interface"); - } - //@} - - /** Method for obtaining the subspace in which the limited-memory - * Hessian approximation should be done. This is only called if - * the limited-memory Hessian approximation is chosen. Since the - * Hessian is zero in the space of all variables that appear in - * the problem functions only linearly, this allows the user to - * provide a VectorSpace for all nonlinear variables, and an - * ExpansionMatrix to lift from this VectorSpace to the - * VectorSpace of the primal variables x. If the returned values - * are NULL, it is assumed that the Hessian is to be approximated - * in the space of all x variables. The default instantiation of - * this method returns NULL, and a user only has to overwrite - * this method if the approximation is to be done only in a - * subspace. */ - virtual void - GetQuasiNewtonApproximationSpaces(SmartPtr<VectorSpace>& approx_space, - SmartPtr<Matrix>& P_approx) - { - approx_space = NULL; - P_approx = NULL; - } - - 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 */ - NLP(const NLP&); - - /** Overloaded Equals Operator */ - void operator=(const NLP&); - //@} - }; - -} // namespace Ipopt - -#endif +// Copyright (C) 2004, 2006 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpNLP.hpp 1861 2010-12-21 21:34:47Z andreasw $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPNLP_HPP__
+#define __IPNLP_HPP__
+
+#include "IpUtils.hpp"
+#include "IpVector.hpp"
+#include "IpSmartPtr.hpp"
+#include "IpMatrix.hpp"
+#include "IpSymMatrix.hpp"
+#include "IpOptionsList.hpp"
+#include "IpAlgTypes.hpp"
+#include "IpReturnCodes.hpp"
+
+namespace Ipopt
+{
+ // forward declarations
+ class IpoptData;
+ class IpoptCalculatedQuantities;
+ class IteratesVector;
+
+ /** Brief Class Description.
+ * Detailed Class Description.
+ */
+ class NLP : public ReferencedObject
+ {
+ public:
+ /**@name Constructors/Destructors */
+ //@{
+ /** Default constructor */
+ NLP()
+ {}
+
+ /** Default destructor */
+ virtual ~NLP()
+ {}
+ //@}
+
+ /** Exceptions */
+ //@{
+ DECLARE_STD_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED);
+ DECLARE_STD_EXCEPTION(INVALID_NLP);
+ //@}
+
+ /** @name NLP Initialization (overload in
+ * derived classes).*/
+ //@{
+ /** Overload if you want the chance to process options or parameters that
+ * may be specific to the NLP */
+ virtual bool ProcessOptions(const OptionsList& options,
+ const std::string& prefix)
+ {
+ return true;
+ }
+
+ /** Method for creating the derived vector / matrix types. The
+ * Hess_lagrangian_space pointer can be NULL if a quasi-Newton
+ * options is chosen. */
+ virtual bool GetSpaces(SmartPtr<const VectorSpace>& x_space,
+ SmartPtr<const VectorSpace>& c_space,
+ SmartPtr<const VectorSpace>& d_space,
+ SmartPtr<const VectorSpace>& x_l_space,
+ SmartPtr<const MatrixSpace>& px_l_space,
+ SmartPtr<const VectorSpace>& x_u_space,
+ SmartPtr<const MatrixSpace>& px_u_space,
+ SmartPtr<const VectorSpace>& d_l_space,
+ SmartPtr<const MatrixSpace>& pd_l_space,
+ SmartPtr<const VectorSpace>& d_u_space,
+ SmartPtr<const MatrixSpace>& pd_u_space,
+ SmartPtr<const MatrixSpace>& Jac_c_space,
+ SmartPtr<const MatrixSpace>& Jac_d_space,
+ SmartPtr<const SymMatrixSpace>& Hess_lagrangian_space)=0;
+
+ /** Method for obtaining the bounds information */
+ virtual bool GetBoundsInformation(const Matrix& Px_L,
+ Vector& x_L,
+ const Matrix& Px_U,
+ Vector& x_U,
+ const Matrix& Pd_L,
+ Vector& d_L,
+ const Matrix& Pd_U,
+ Vector& d_U)=0;
+
+ /** Method for obtaining the starting point for all the
+ * iterates. ToDo it might not make sense to ask for initial
+ * values for v_L and v_U? */
+ virtual bool GetStartingPoint(
+ SmartPtr<Vector> x,
+ bool need_x,
+ SmartPtr<Vector> y_c,
+ bool need_y_c,
+ SmartPtr<Vector> y_d,
+ bool need_y_d,
+ SmartPtr<Vector> z_L,
+ bool need_z_L,
+ SmartPtr<Vector> z_U,
+ bool need_z_U
+ )=0;
+
+ /** Method for obtaining an entire iterate as a warmstart point.
+ * The incoming IteratesVector has to be filled. The default
+ * dummy implementation returns false. */
+ virtual bool GetWarmStartIterate(IteratesVector& warm_start_iterate)
+ {
+ return false;
+ }
+ //@}
+
+ /** @name NLP evaluation routines (overload
+ * in derived classes. */
+ //@{
+ virtual bool Eval_f(const Vector& x, Number& f) = 0;
+
+ virtual bool Eval_grad_f(const Vector& x, Vector& g_f) = 0;
+
+ virtual bool Eval_c(const Vector& x, Vector& c) = 0;
+
+ virtual bool Eval_jac_c(const Vector& x, Matrix& jac_c) = 0;
+
+ virtual bool Eval_d(const Vector& x, Vector& d) = 0;
+
+ virtual bool Eval_jac_d(const Vector& x, Matrix& jac_d) = 0;
+
+ virtual bool Eval_h(const Vector& x,
+ Number obj_factor,
+ const Vector& yc,
+ const Vector& yd,
+ SymMatrix& h) = 0;
+ //@}
+
+ /** @name NLP solution routines. Have default dummy
+ * implementations that can be overloaded. */
+ //@{
+ /** This method is called at the very end of the optimization. It
+ * provides the final iterate to the user, so that it can be
+ * stored as the solution. The status flag indicates the outcome
+ * of the optimization, where SolverReturn is defined in
+ * IpAlgTypes.hpp. */
+ virtual void FinalizeSolution(SolverReturn status,
+ const Vector& x, const Vector& z_L,
+ const Vector& z_U,
+ const Vector& c, const Vector& d,
+ const Vector& y_c, const Vector& y_d,
+ Number obj_value,
+ const IpoptData* ip_data,
+ IpoptCalculatedQuantities* ip_cq)
+ {}
+
+ /** This method is called once per iteration, after the iteration
+ * summary output has been printed. It provides the current
+ * information to the user to do with it anything she wants. It
+ * also allows the user to ask for a premature termination of the
+ * optimization by returning false, in which case Ipopt will
+ * terminate with a corresponding return status. The basic
+ * information provided in the argument list has the quantities
+ * values printed in the iteration summary line. If more
+ * information is required, a user can obtain it from the IpData
+ * and IpCalculatedQuantities objects. However, note that the
+ * provided quantities are all for the problem that Ipopt sees,
+ * i.e., the quantities might be scaled, fixed variables might be
+ * sorted out, etc. The status indicates things like whether the
+ * algorithm is in the restoration phase... In the restoration
+ * phase, the dual variables are probably not not changing. */
+ virtual bool IntermediateCallBack(AlgorithmMode mode,
+ Index iter, Number obj_value,
+ Number inf_pr, Number inf_du,
+ Number mu, Number d_norm,
+ Number regularization_size,
+ Number alpha_du, Number alpha_pr,
+ Index ls_trials,
+ const IpoptData* ip_data,
+ IpoptCalculatedQuantities* ip_cq)
+ {
+ return true;
+ }
+ //@}
+
+ /** Routines to get the scaling parameters. These do not need to
+ * be overloaded unless the options are set for User scaling
+ */
+ //@{
+ virtual void GetScalingParameters(
+ const SmartPtr<const VectorSpace> x_space,
+ const SmartPtr<const VectorSpace> c_space,
+ const SmartPtr<const VectorSpace> d_space,
+ Number& obj_scaling,
+ SmartPtr<Vector>& x_scaling,
+ SmartPtr<Vector>& c_scaling,
+ SmartPtr<Vector>& d_scaling) const
+ {
+ THROW_EXCEPTION(USER_SCALING_NOT_IMPLEMENTED,
+ "You have set options for user provided scaling, but have"
+ " not implemented GetScalingParameters in the NLP interface");
+ }
+ //@}
+
+ /** Method for obtaining the subspace in which the limited-memory
+ * Hessian approximation should be done. This is only called if
+ * the limited-memory Hessian approximation is chosen. Since the
+ * Hessian is zero in the space of all variables that appear in
+ * the problem functions only linearly, this allows the user to
+ * provide a VectorSpace for all nonlinear variables, and an
+ * ExpansionMatrix to lift from this VectorSpace to the
+ * VectorSpace of the primal variables x. If the returned values
+ * are NULL, it is assumed that the Hessian is to be approximated
+ * in the space of all x variables. The default instantiation of
+ * this method returns NULL, and a user only has to overwrite
+ * this method if the approximation is to be done only in a
+ * subspace. */
+ virtual void
+ GetQuasiNewtonApproximationSpaces(SmartPtr<VectorSpace>& approx_space,
+ SmartPtr<Matrix>& P_approx)
+ {
+ approx_space = NULL;
+ P_approx = NULL;
+ }
+
+ 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 */
+ NLP(const NLP&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const NLP&);
+ //@}
+ };
+
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpObserver.hpp b/thirdparty/windows/include/coin/IpObserver.hpp index 55ef738..4c8ff7b 100644 --- a/thirdparty/windows/include/coin/IpObserver.hpp +++ b/thirdparty/windows/include/coin/IpObserver.hpp @@ -1,358 +1,366 @@ -// Copyright (C) 2004, 2006 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpObserver.hpp 1019 2007-06-24 03:52:34Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPOBSERVER_HPP__ -#define __IPOBSERVER_HPP__ - -#include "IpUtils.hpp" -#include <vector> -#include <algorithm> - -//#define IP_DEBUG_OBSERVER -#if COIN_IPOPT_CHECKLEVEL > 2 -# define IP_DEBUG_OBSERVER -#endif -#ifdef IP_DEBUG_OBSERVER -# include "IpDebug.hpp" -#endif - -namespace Ipopt -{ - /** Forward declarations */ - class Subject; - - /** Slight Variation of the Observer Design Pattern. - * This class implements the Observer class of the - * Observer Design Pattern. An Observer "Attach"es - * to a Subject, indicating that it would like to - * be notified of changes in the Subject. - * Any derived class wishing to recieve notifications - * from a Subject should inherit off of - * Observer and overload the protected method, - * RecieveNotification_(...). - */ - class Observer - { - public: -#ifdef IP_DEBUG_OBSERVER - - static const Index dbg_verbosity; -#endif - - /**@name Constructors/Destructors */ - //@{ - /** Default Constructor */ - Observer() - {} - - /** Default destructor */ - virtual ~Observer(); - //@} - - /** Enumeration specifying the type of notification */ - enum NotifyType - { - NT_All, - NT_BeingDestroyed, - NT_Changed - }; - - protected: - /** Derived classes should call this method - * to request an "Attach" to a Subject. Do - * not call "Attach" explicitly on the Subject - * since further processing is done here - */ - void RequestAttach(NotifyType notify_type, const Subject* subject); - - /** Derived classes should call this method - * to request a "Detach" to a Subject. Do - * not call "Detach" explicitly on the Subject - * since further processing is done here - */ - void RequestDetach(NotifyType notify_type, const Subject* subject); - - /** Derived classes should overload this method to - * recieve the requested notification from - * attached Subjects - */ - virtual void RecieveNotification(NotifyType notify_type, const Subject* subject)=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 */ - Observer(const Observer&); - - /** Overloaded Equals Operator */ - void operator=(const Observer&); - //@} - - /** A list of the subjects currently being - * observed. */ - std::vector<const Subject*> subjects_; - - /** Private Method for Recieving Notification - * should only be called by the friend class - * Subject. This method will, in turn, call - * the overloaded RecieveNotification method - * for the derived class to process. - */ - void ProcessNotification(NotifyType notify_type, const Subject* subject); - - friend class Subject; - }; - - /** Slight Variation of the Observer Design Pattern (Subject part). - * This class implements the Subject class of the Observer Design - * Pattern. An Observer "Attach"es to a Subject, indicating that it - * would like to be notified of changes in the Subject. Any - * derived class that is to be observed has to inherit off the - * Subject base class. If the subject needs to notify the - * Observer, it calls the Notify method. - */ - class Subject - { - public: -#ifdef IP_DEBUG_OBSERVER - - static const Index dbg_verbosity; -#endif - - /**@name Constructors/Destructors */ - //@{ - /** Default Constructor */ - Subject() - {} - - /** Default destructor */ - virtual ~Subject(); - //@} - - /**@name Methods to Add and Remove Observers. - * Currently, the notify_type flags are not used, - * and Observers are attached in general and will - * recieve all notifications (of the type requested - * and possibly of types not requested). It is - * up to the observer to ignore the types they - * are not interested in. The NotifyType in the - * parameter list is so a more efficient mechanism - * depending on type could be implemented later if - * necessary.*/ - //@{ - - /** Attach the specified observer - * (i.e., begin recieving notifications). */ - void AttachObserver(Observer::NotifyType notify_type, Observer* observer) const; - - /** Detach the specified observer - * (i.e., no longer recieve notifications). */ - void DetachObserver(Observer::NotifyType notify_type, Observer* observer) const; - //@} - - protected: - - void Notify(Observer::NotifyType notify_type) 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. */ - //@{ - /** Copy Constructor */ - Subject(const Subject&); - - /** Overloaded Equals Operator */ - void operator=(const Subject&); - //@} - - mutable std::vector<Observer*> observers_; - - }; - - /* inline methods */ - inline - Observer::~Observer() - { -#ifdef IP_DEBUG_OBSERVER - DBG_START_METH("Observer::~Observer", dbg_verbosity); - if (DBG_VERBOSITY()>=1) { - for (Index i=0; i<(Index)subjects_.size(); i++) { - DBG_PRINT((1,"subjects_[%d] = 0x%x\n", i, subjects_[i])); - } - } -#endif - // Detach all subjects - for (Int i=(Int)(subjects_.size()-1); i>=0; i--) { -#ifdef IP_DEBUG_OBSERVER - DBG_PRINT((1,"About to detach subjects_[%d] = 0x%x\n", i, subjects_[i])); -#endif - - RequestDetach(NT_All, subjects_[i]); - } - } - - inline - void Observer::RequestAttach(NotifyType notify_type, const Subject* subject) - { -#ifdef IP_DEBUG_OBSERVER - DBG_START_METH("Observer::RequestAttach", dbg_verbosity); - - // Add the subject to the list if it does not already exist - std::vector<const Subject*>::iterator attached_subject; - attached_subject = std::find(subjects_.begin(), subjects_.end(), subject); - DBG_ASSERT(attached_subject == subjects_.end()); - DBG_ASSERT(subject); -#endif - - // add the subject to the list - subjects_.push_back(subject); - // Attach the observer to the subject - subject->AttachObserver(notify_type, this); - } - - inline - void Observer::RequestDetach(NotifyType notify_type, const Subject* subject) - { -#ifdef IP_DEBUG_OBSERVER - DBG_START_METH("Observer::RequestDetach", dbg_verbosity); - DBG_PRINT((1, "Requesting detach of subject: 0x%x\n", subject)); - DBG_ASSERT(subject); -#endif - - if (subject) { - std::vector<const Subject*>::iterator attached_subject; - attached_subject = std::find(subjects_.begin(), subjects_.end(), subject); -#ifdef IP_DEBUG_OBSERVER - - DBG_ASSERT(attached_subject != subjects_.end()); -#endif - - if (attached_subject != subjects_.end()) { -#ifdef IP_DEBUG_OBSERVER - DBG_PRINT((1, "Removing subject: 0x%x from the list\n", subject)); -#endif - - subjects_.erase(attached_subject); - } - - // Detach the observer from the subject - subject->DetachObserver(notify_type, this); - } - } - - inline - void Observer::ProcessNotification(NotifyType notify_type, const Subject* subject) - { -#ifdef IP_DEBUG_OBSERVER - DBG_START_METH("Observer::ProcessNotification", dbg_verbosity); - DBG_ASSERT(subject); -#endif - - if (subject) { - std::vector<const Subject*>::iterator attached_subject; - attached_subject = std::find(subjects_.begin(), subjects_.end(), subject); - - // We must be processing a notification for a - // subject that was previously attached. -#ifdef IP_DEBUG_OBSERVER - - DBG_ASSERT(attached_subject != subjects_.end()); -#endif - - this->RecieveNotification(notify_type, subject); - - if (notify_type == NT_BeingDestroyed) { - // the subject is going away, remove it from our list - subjects_.erase(attached_subject); - } - } - } - - inline - Subject::~Subject() - { -#ifdef IP_DEBUG_OBSERVER - DBG_START_METH("Subject::~Subject", dbg_verbosity); -#endif - - std::vector<Observer*>::iterator iter; - for (iter = observers_.begin(); iter != observers_.end(); iter++) { - (*iter)->ProcessNotification(Observer::NT_BeingDestroyed, this); - } - } - - inline - void Subject::AttachObserver(Observer::NotifyType notify_type, Observer* observer) const - { -#ifdef IP_DEBUG_OBSERVER - DBG_START_METH("Subject::AttachObserver", dbg_verbosity); - // current implementation notifies all observers of everything - // they must filter the notifications that they are not interested - // in (i.e. a hub, not a router) - DBG_ASSERT(observer); - - std::vector<Observer*>::iterator attached_observer; - attached_observer = std::find(observers_.begin(), observers_.end(), observer); - DBG_ASSERT(attached_observer == observers_.end()); - - DBG_ASSERT(observer); -#endif - - observers_.push_back(observer); - } - - inline - void Subject::DetachObserver(Observer::NotifyType notify_type, Observer* observer) const - { -#ifdef IP_DEBUG_OBSERVER - DBG_START_METH("Subject::DetachObserver", dbg_verbosity); - DBG_ASSERT(observer); -#endif - - if (observer) { - std::vector<Observer*>::iterator attached_observer; - attached_observer = std::find(observers_.begin(), observers_.end(), observer); -#ifdef IP_DEBUG_OBSERVER - - DBG_ASSERT(attached_observer != observers_.end()); -#endif - - if (attached_observer != observers_.end()) { - observers_.erase(attached_observer); - } - } - } - - inline - void Subject::Notify(Observer::NotifyType notify_type) const - { -#ifdef IP_DEBUG_OBSERVER - DBG_START_METH("Subject::Notify", dbg_verbosity); -#endif - - std::vector<Observer*>::iterator iter; - for (iter = observers_.begin(); iter != observers_.end(); iter++) { - (*iter)->ProcessNotification(notify_type, this); - } - } - - -} // namespace Ipopt - -#endif +// Copyright (C) 2004, 2006 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpObserver.hpp 2161 2013-01-01 20:39:05Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPOBSERVER_HPP__
+#define __IPOBSERVER_HPP__
+
+#include "IpUtils.hpp"
+#include <vector>
+#include <algorithm>
+
+//#define IP_DEBUG_OBSERVER
+#if COIN_IPOPT_CHECKLEVEL > 2
+# define IP_DEBUG_OBSERVER
+#endif
+#ifdef IP_DEBUG_OBSERVER
+# include "IpDebug.hpp"
+#endif
+
+namespace Ipopt
+{
+ /** Forward declarations */
+ class Subject;
+
+ /** Slight Variation of the Observer Design Pattern.
+ * This class implements the Observer class of the
+ * Observer Design Pattern. An Observer "Attach"es
+ * to a Subject, indicating that it would like to
+ * be notified of changes in the Subject.
+ * Any derived class wishing to recieve notifications
+ * from a Subject should inherit off of
+ * Observer and overload the protected method,
+ * RecieveNotification_(...).
+ */
+ class Observer
+ {
+ public:
+#ifdef IP_DEBUG_OBSERVER
+
+ static const Index dbg_verbosity;
+#endif
+
+ /**@name Constructors/Destructors */
+ //@{
+ /** Default Constructor */
+ Observer()
+ {}
+
+ /** Default destructor */
+ inline
+ virtual ~Observer();
+ //@}
+
+ /** Enumeration specifying the type of notification */
+ enum NotifyType
+ {
+ NT_All,
+ NT_BeingDestroyed,
+ NT_Changed
+ };
+
+ protected:
+ /** Derived classes should call this method
+ * to request an "Attach" to a Subject. Do
+ * not call "Attach" explicitly on the Subject
+ * since further processing is done here
+ */
+ inline
+ void RequestAttach(NotifyType notify_type, const Subject* subject);
+
+ /** Derived classes should call this method
+ * to request a "Detach" to a Subject. Do
+ * not call "Detach" explicitly on the Subject
+ * since further processing is done here
+ */
+ inline
+ void RequestDetach(NotifyType notify_type, const Subject* subject);
+
+ /** Derived classes should overload this method to
+ * recieve the requested notification from
+ * attached Subjects
+ */
+ virtual void RecieveNotification(NotifyType notify_type, const Subject* subject)=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 */
+ Observer(const Observer&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const Observer&);
+ //@}
+
+ /** A list of the subjects currently being
+ * observed. */
+ std::vector<const Subject*> subjects_;
+
+ /** Private Method for Recieving Notification
+ * should only be called by the friend class
+ * Subject. This method will, in turn, call
+ * the overloaded RecieveNotification method
+ * for the derived class to process.
+ */
+ inline
+ void ProcessNotification(NotifyType notify_type, const Subject* subject);
+
+ friend class Subject;
+ };
+
+ /** Slight Variation of the Observer Design Pattern (Subject part).
+ * This class implements the Subject class of the Observer Design
+ * Pattern. An Observer "Attach"es to a Subject, indicating that it
+ * would like to be notified of changes in the Subject. Any
+ * derived class that is to be observed has to inherit off the
+ * Subject base class. If the subject needs to notify the
+ * Observer, it calls the Notify method.
+ */
+ class Subject
+ {
+ public:
+#ifdef IP_DEBUG_OBSERVER
+
+ static const Index dbg_verbosity;
+#endif
+
+ /**@name Constructors/Destructors */
+ //@{
+ /** Default Constructor */
+ Subject()
+ {}
+
+ /** Default destructor */
+ inline
+ virtual ~Subject();
+ //@}
+
+ /**@name Methods to Add and Remove Observers.
+ * Currently, the notify_type flags are not used,
+ * and Observers are attached in general and will
+ * recieve all notifications (of the type requested
+ * and possibly of types not requested). It is
+ * up to the observer to ignore the types they
+ * are not interested in. The NotifyType in the
+ * parameter list is so a more efficient mechanism
+ * depending on type could be implemented later if
+ * necessary.*/
+ //@{
+
+ /** Attach the specified observer
+ * (i.e., begin recieving notifications). */
+ inline
+ void AttachObserver(Observer::NotifyType notify_type, Observer* observer) const;
+
+ /** Detach the specified observer
+ * (i.e., no longer recieve notifications). */
+ inline
+ void DetachObserver(Observer::NotifyType notify_type, Observer* observer) const;
+ //@}
+
+ protected:
+
+ inline
+ void Notify(Observer::NotifyType notify_type) 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. */
+ //@{
+ /** Copy Constructor */
+ Subject(const Subject&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const Subject&);
+ //@}
+
+ mutable std::vector<Observer*> observers_;
+
+ };
+
+ /* inline methods */
+ inline
+ Observer::~Observer()
+ {
+#ifdef IP_DEBUG_OBSERVER
+ DBG_START_METH("Observer::~Observer", dbg_verbosity);
+ if (DBG_VERBOSITY()>=1) {
+ for (Index i=0; i<(Index)subjects_.size(); i++) {
+ DBG_PRINT((1,"subjects_[%d] = 0x%x\n", i, subjects_[i]));
+ }
+ }
+#endif
+ // Detach all subjects
+ for (Int i=(Int)(subjects_.size()-1); i>=0; i--) {
+#ifdef IP_DEBUG_OBSERVER
+ DBG_PRINT((1,"About to detach subjects_[%d] = 0x%x\n", i, subjects_[i]));
+#endif
+
+ RequestDetach(NT_All, subjects_[i]);
+ }
+ }
+
+ inline
+ void Observer::RequestAttach(NotifyType notify_type, const Subject* subject)
+ {
+#ifdef IP_DEBUG_OBSERVER
+ DBG_START_METH("Observer::RequestAttach", dbg_verbosity);
+
+ // Add the subject to the list if it does not already exist
+ std::vector<const Subject*>::iterator attached_subject;
+ attached_subject = std::find(subjects_.begin(), subjects_.end(), subject);
+ DBG_ASSERT(attached_subject == subjects_.end());
+ DBG_ASSERT(subject);
+#endif
+
+ // add the subject to the list
+ subjects_.push_back(subject);
+ // Attach the observer to the subject
+ subject->AttachObserver(notify_type, this);
+ }
+
+ inline
+ void Observer::RequestDetach(NotifyType notify_type, const Subject* subject)
+ {
+#ifdef IP_DEBUG_OBSERVER
+ DBG_START_METH("Observer::RequestDetach", dbg_verbosity);
+ DBG_PRINT((1, "Requesting detach of subject: 0x%x\n", subject));
+ DBG_ASSERT(subject);
+#endif
+
+ if (subject) {
+ std::vector<const Subject*>::iterator attached_subject;
+ attached_subject = std::find(subjects_.begin(), subjects_.end(), subject);
+#ifdef IP_DEBUG_OBSERVER
+
+ DBG_ASSERT(attached_subject != subjects_.end());
+#endif
+
+ if (attached_subject != subjects_.end()) {
+#ifdef IP_DEBUG_OBSERVER
+ DBG_PRINT((1, "Removing subject: 0x%x from the list\n", subject));
+#endif
+
+ subjects_.erase(attached_subject);
+ }
+
+ // Detach the observer from the subject
+ subject->DetachObserver(notify_type, this);
+ }
+ }
+
+ inline
+ void Observer::ProcessNotification(NotifyType notify_type, const Subject* subject)
+ {
+#ifdef IP_DEBUG_OBSERVER
+ DBG_START_METH("Observer::ProcessNotification", dbg_verbosity);
+ DBG_ASSERT(subject);
+#endif
+
+ if (subject) {
+ std::vector<const Subject*>::iterator attached_subject;
+ attached_subject = std::find(subjects_.begin(), subjects_.end(), subject);
+
+ // We must be processing a notification for a
+ // subject that was previously attached.
+#ifdef IP_DEBUG_OBSERVER
+
+ DBG_ASSERT(attached_subject != subjects_.end());
+#endif
+
+ this->RecieveNotification(notify_type, subject);
+
+ if (notify_type == NT_BeingDestroyed) {
+ // the subject is going away, remove it from our list
+ subjects_.erase(attached_subject);
+ }
+ }
+ }
+
+ inline
+ Subject::~Subject()
+ {
+#ifdef IP_DEBUG_OBSERVER
+ DBG_START_METH("Subject::~Subject", dbg_verbosity);
+#endif
+
+ std::vector<Observer*>::iterator iter;
+ for (iter = observers_.begin(); iter != observers_.end(); iter++) {
+ (*iter)->ProcessNotification(Observer::NT_BeingDestroyed, this);
+ }
+ }
+
+ inline
+ void Subject::AttachObserver(Observer::NotifyType notify_type, Observer* observer) const
+ {
+#ifdef IP_DEBUG_OBSERVER
+ DBG_START_METH("Subject::AttachObserver", dbg_verbosity);
+ // current implementation notifies all observers of everything
+ // they must filter the notifications that they are not interested
+ // in (i.e. a hub, not a router)
+ DBG_ASSERT(observer);
+
+ std::vector<Observer*>::iterator attached_observer;
+ attached_observer = std::find(observers_.begin(), observers_.end(), observer);
+ DBG_ASSERT(attached_observer == observers_.end());
+
+ DBG_ASSERT(observer);
+#endif
+
+ observers_.push_back(observer);
+ }
+
+ inline
+ void Subject::DetachObserver(Observer::NotifyType notify_type, Observer* observer) const
+ {
+#ifdef IP_DEBUG_OBSERVER
+ DBG_START_METH("Subject::DetachObserver", dbg_verbosity);
+ DBG_ASSERT(observer);
+#endif
+
+ if (observer) {
+ std::vector<Observer*>::iterator attached_observer;
+ attached_observer = std::find(observers_.begin(), observers_.end(), observer);
+#ifdef IP_DEBUG_OBSERVER
+
+ DBG_ASSERT(attached_observer != observers_.end());
+#endif
+
+ if (attached_observer != observers_.end()) {
+ observers_.erase(attached_observer);
+ }
+ }
+ }
+
+ inline
+ void Subject::Notify(Observer::NotifyType notify_type) const
+ {
+#ifdef IP_DEBUG_OBSERVER
+ DBG_START_METH("Subject::Notify", dbg_verbosity);
+#endif
+
+ std::vector<Observer*>::iterator iter;
+ for (iter = observers_.begin(); iter != observers_.end(); iter++) {
+ (*iter)->ProcessNotification(notify_type, this);
+ }
+ }
+
+
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpOptionsList.hpp b/thirdparty/windows/include/coin/IpOptionsList.hpp index 098174a..a4c7c36 100644 --- a/thirdparty/windows/include/coin/IpOptionsList.hpp +++ b/thirdparty/windows/include/coin/IpOptionsList.hpp @@ -1,289 +1,289 @@ -// Copyright (C) 2004, 2006 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpOptionsList.hpp 1587 2009-10-27 16:09:21Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPOPTLIST_HPP__ -#define __IPOPTLIST_HPP__ - -#include "IpUtils.hpp" -#include "IpReferenced.hpp" -#include "IpException.hpp" -#include "IpRegOptions.hpp" - -#include <iostream> -#include <map> - -namespace Ipopt -{ - /** Exception that can be used to indicate errors with options */ - DECLARE_STD_EXCEPTION(OPTION_INVALID); - - /** This class stores a list of user set options. Each options is - * identified by a case-insensitive keyword (tag). Its value is - * stored internally as a string (always lower case), but for - * convenience set and get methods are provided to obtain Index and - * Number type values. For each keyword we also keep track of how - * often the value of an option has been requested by a get method. - */ - class OptionsList : public ReferencedObject - { - /** Class for storing the value and counter for each option in - * OptionsList. */ - class OptionValue - { - public: - /**@name Constructors/Destructors */ - //@{ - /** Default constructor (needed for the map) */ - OptionValue() - : - initialized_(false) - {} - - /** Constructor given the value */ - OptionValue(std::string value, bool allow_clobber, bool dont_print) - : - value_(value), - counter_(0), - initialized_(true), - allow_clobber_(allow_clobber), - dont_print_(dont_print) - {} - - /** Copy Constructor */ - OptionValue(const OptionValue& copy) - : - value_(copy.value_), - counter_(copy.counter_), - initialized_(copy.initialized_), - allow_clobber_(copy.allow_clobber_), - dont_print_(copy.dont_print_) - {} - - /** Equals operator */ - void operator=(const OptionValue& copy) - { - value_=copy.value_; - counter_=copy.counter_; - initialized_=copy.initialized_; - allow_clobber_=copy.allow_clobber_; - dont_print_=copy.dont_print_; - } - - /** Default Destructor */ - ~OptionValue() - {} - //@} - - /** Method for retrieving the value of an option. Calling this - * method will increase the counter by one. */ - std::string GetValue() const - { - DBG_ASSERT(initialized_); - counter_++; - return value_; - } - - /** Method for retrieving the value without increasing the - * counter */ - std::string Value() const - { - DBG_ASSERT(initialized_); - return value_; - } - - /** Method for accessing current value of the request counter */ - Index Counter() const - { - DBG_ASSERT(initialized_); - return counter_; - } - - /** True if the option can be overwritten */ - bool AllowClobber() const - { - DBG_ASSERT(initialized_); - return allow_clobber_; - } - - /** True if this option is not to show up in the - * print_user_options output */ - bool DontPrint() const - { - DBG_ASSERT(initialized_); - return dont_print_; - } - - private: - /** Value for this option */ - std::string value_; - - /** Counter for requests */ - mutable Index counter_; - - /** for debugging */ - bool initialized_; - - /** True if the option can be overwritten */ - bool allow_clobber_; - - /** True if this option is not to show up in the - * print_user_options output */ - bool dont_print_; - }; - - public: - /**@name Constructors/Destructors */ - //@{ - OptionsList(SmartPtr<RegisteredOptions> reg_options, SmartPtr<Journalist> jnlst) - : reg_options_(reg_options), jnlst_(jnlst) - {} - - OptionsList() - {} - - /** Copy Constructor */ - OptionsList(const OptionsList& copy) - { - // copy all the option strings and values - options_ = copy.options_; - // copy the registered options pointer - reg_options_ = copy.reg_options_; - } - - /** Default destructor */ - virtual ~OptionsList() - {} - - /** Overloaded Equals Operator */ - virtual void operator=(const OptionsList& source) - { - options_ = source.options_; - reg_options_ = source.reg_options_; - jnlst_ = source.jnlst_; - } - //@} - - /** Method for clearing all previously set options */ - virtual void clear() - { - options_.clear(); - } - - /** @name Get / Set Methods */ - //@{ - virtual void SetRegisteredOptions(const SmartPtr<RegisteredOptions> reg_options) - { - reg_options_ = reg_options; - } - virtual void SetJournalist(const SmartPtr<Journalist> jnlst) - { - jnlst_ = jnlst; - } - //@} - /** @name Methods for setting options */ - //@{ - virtual bool SetStringValue(const std::string& tag, const std::string& value, - bool allow_clobber = true, bool dont_print = false); - virtual bool SetNumericValue(const std::string& tag, Number value, - bool allow_clobber = true, bool dont_print = false); - virtual bool SetIntegerValue(const std::string& tag, Index value, - bool allow_clobber = true, bool dont_print = false); - //@} - - /** @name Methods for setting options only if they have not been - * set before*/ - //@{ - virtual bool SetStringValueIfUnset(const std::string& tag, const std::string& value, - bool allow_clobber = true, bool dont_print = false); - virtual bool SetNumericValueIfUnset(const std::string& tag, Number value, - bool allow_clobber = true, bool dont_print = false); - virtual bool SetIntegerValueIfUnset(const std::string& tag, Index value, - bool allow_clobber = true, bool dont_print = false); - //@} - - /** @name Methods for retrieving values from the options list. If - * a tag is not found, the methods return false, and value is set - * to the default value defined in the registered options. */ - //@{ - virtual bool GetStringValue(const std::string& tag, std::string& value, - const std::string& prefix) const; - virtual bool GetEnumValue(const std::string& tag, Index& value, - const std::string& prefix) const; - virtual bool GetBoolValue(const std::string& tag, bool& value, - const std::string& prefix) const; - virtual bool GetNumericValue(const std::string& tag, Number& value, - const std::string& prefix) const; - virtual bool GetIntegerValue(const std::string& tag, Index& value, - const std::string& prefix) const; - //@} - - /** Get a string with the list of all options (tag, value, counter) */ - virtual void PrintList(std::string& list) const; - - /** Get a string with the list of all options set by the user - * (tag, value, use/notused). Here, options with dont_print flag - * set to true are not printed. */ - virtual void PrintUserOptions(std::string& list) const; - - /** Read options from the stream is. Returns false if - * an error was encountered. */ - virtual bool ReadFromStream(const Journalist& jnlst, std::istream& is); - - 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 */ - // OptionsList(); - - //@} - - /** map for storing the options */ - std::map< std::string, OptionValue > options_; - - /** list of all the registered options to validate against */ - SmartPtr<RegisteredOptions> reg_options_; - - /** Journalist for writing error messages, etc. */ - SmartPtr<Journalist> jnlst_; - - /** auxilliary method for converting sting to all lower-case - * letters */ - const std::string& lowercase(const std::string tag) const; - - /** auxilliary method for finding the value for a tag in the - * options list. This method first looks for the concatenated - * string prefix+tag (if prefix is not ""), and if this is not - * found, it looks for tag. The return value is true iff - * prefix+tag or tag is found. In that case, the corresponding - * string value is copied into value. */ - bool find_tag(const std::string& tag, const std::string& prefix, - std::string& value) const; - - /** tells whether or not we can clobber a particular option. - * returns true if the option does not already exist, or if - * the option exists but is set to allow_clobber - */ - bool will_allow_clobber(const std::string& tag) const; - - /** read the next token from stream is. Returns false, if EOF was - * reached before a tokens was ecountered. */ - bool readnexttoken(std::istream& is, std::string& token); - - /** auxilliary string set by lowercase method */ - mutable std::string lowercase_buffer_; - }; - -} // namespace Ipopt - -#endif +// Copyright (C) 2004, 2006 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpOptionsList.hpp 1861 2010-12-21 21:34:47Z andreasw $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPOPTLIST_HPP__
+#define __IPOPTLIST_HPP__
+
+#include "IpUtils.hpp"
+#include "IpReferenced.hpp"
+#include "IpException.hpp"
+#include "IpRegOptions.hpp"
+
+#include <iostream>
+#include <map>
+
+namespace Ipopt
+{
+ /** Exception that can be used to indicate errors with options */
+ DECLARE_STD_EXCEPTION(OPTION_INVALID);
+
+ /** This class stores a list of user set options. Each options is
+ * identified by a case-insensitive keyword (tag). Its value is
+ * stored internally as a string (always lower case), but for
+ * convenience set and get methods are provided to obtain Index and
+ * Number type values. For each keyword we also keep track of how
+ * often the value of an option has been requested by a get method.
+ */
+ class OptionsList : public ReferencedObject
+ {
+ /** Class for storing the value and counter for each option in
+ * OptionsList. */
+ class OptionValue
+ {
+ public:
+ /**@name Constructors/Destructors */
+ //@{
+ /** Default constructor (needed for the map) */
+ OptionValue()
+ :
+ initialized_(false)
+ {}
+
+ /** Constructor given the value */
+ OptionValue(std::string value, bool allow_clobber, bool dont_print)
+ :
+ value_(value),
+ counter_(0),
+ initialized_(true),
+ allow_clobber_(allow_clobber),
+ dont_print_(dont_print)
+ {}
+
+ /** Copy Constructor */
+ OptionValue(const OptionValue& copy)
+ :
+ value_(copy.value_),
+ counter_(copy.counter_),
+ initialized_(copy.initialized_),
+ allow_clobber_(copy.allow_clobber_),
+ dont_print_(copy.dont_print_)
+ {}
+
+ /** Equals operator */
+ void operator=(const OptionValue& copy)
+ {
+ value_=copy.value_;
+ counter_=copy.counter_;
+ initialized_=copy.initialized_;
+ allow_clobber_=copy.allow_clobber_;
+ dont_print_=copy.dont_print_;
+ }
+
+ /** Default Destructor */
+ ~OptionValue()
+ {}
+ //@}
+
+ /** Method for retrieving the value of an option. Calling this
+ * method will increase the counter by one. */
+ std::string GetValue() const
+ {
+ DBG_ASSERT(initialized_);
+ counter_++;
+ return value_;
+ }
+
+ /** Method for retrieving the value without increasing the
+ * counter */
+ std::string Value() const
+ {
+ DBG_ASSERT(initialized_);
+ return value_;
+ }
+
+ /** Method for accessing current value of the request counter */
+ Index Counter() const
+ {
+ DBG_ASSERT(initialized_);
+ return counter_;
+ }
+
+ /** True if the option can be overwritten */
+ bool AllowClobber() const
+ {
+ DBG_ASSERT(initialized_);
+ return allow_clobber_;
+ }
+
+ /** True if this option is not to show up in the
+ * print_user_options output */
+ bool DontPrint() const
+ {
+ DBG_ASSERT(initialized_);
+ return dont_print_;
+ }
+
+ private:
+ /** Value for this option */
+ std::string value_;
+
+ /** Counter for requests */
+ mutable Index counter_;
+
+ /** for debugging */
+ bool initialized_;
+
+ /** True if the option can be overwritten */
+ bool allow_clobber_;
+
+ /** True if this option is not to show up in the
+ * print_user_options output */
+ bool dont_print_;
+ };
+
+ public:
+ /**@name Constructors/Destructors */
+ //@{
+ OptionsList(SmartPtr<RegisteredOptions> reg_options, SmartPtr<Journalist> jnlst)
+ : reg_options_(reg_options), jnlst_(jnlst)
+ {}
+
+ OptionsList()
+ {}
+
+ /** Copy Constructor */
+ OptionsList(const OptionsList& copy)
+ {
+ // copy all the option strings and values
+ options_ = copy.options_;
+ // copy the registered options pointer
+ reg_options_ = copy.reg_options_;
+ }
+
+ /** Default destructor */
+ virtual ~OptionsList()
+ {}
+
+ /** Overloaded Equals Operator */
+ virtual void operator=(const OptionsList& source)
+ {
+ options_ = source.options_;
+ reg_options_ = source.reg_options_;
+ jnlst_ = source.jnlst_;
+ }
+ //@}
+
+ /** Method for clearing all previously set options */
+ virtual void clear()
+ {
+ options_.clear();
+ }
+
+ /** @name Get / Set Methods */
+ //@{
+ virtual void SetRegisteredOptions(const SmartPtr<RegisteredOptions> reg_options)
+ {
+ reg_options_ = reg_options;
+ }
+ virtual void SetJournalist(const SmartPtr<Journalist> jnlst)
+ {
+ jnlst_ = jnlst;
+ }
+ //@}
+ /** @name Methods for setting options */
+ //@{
+ virtual bool SetStringValue(const std::string& tag, const std::string& value,
+ bool allow_clobber = true, bool dont_print = false);
+ virtual bool SetNumericValue(const std::string& tag, Number value,
+ bool allow_clobber = true, bool dont_print = false);
+ virtual bool SetIntegerValue(const std::string& tag, Index value,
+ bool allow_clobber = true, bool dont_print = false);
+ //@}
+
+ /** @name Methods for setting options only if they have not been
+ * set before*/
+ //@{
+ virtual bool SetStringValueIfUnset(const std::string& tag, const std::string& value,
+ bool allow_clobber = true, bool dont_print = false);
+ virtual bool SetNumericValueIfUnset(const std::string& tag, Number value,
+ bool allow_clobber = true, bool dont_print = false);
+ virtual bool SetIntegerValueIfUnset(const std::string& tag, Index value,
+ bool allow_clobber = true, bool dont_print = false);
+ //@}
+
+ /** @name Methods for retrieving values from the options list. If
+ * a tag is not found, the methods return false, and value is set
+ * to the default value defined in the registered options. */
+ //@{
+ virtual bool GetStringValue(const std::string& tag, std::string& value,
+ const std::string& prefix) const;
+ virtual bool GetEnumValue(const std::string& tag, Index& value,
+ const std::string& prefix) const;
+ virtual bool GetBoolValue(const std::string& tag, bool& value,
+ const std::string& prefix) const;
+ virtual bool GetNumericValue(const std::string& tag, Number& value,
+ const std::string& prefix) const;
+ virtual bool GetIntegerValue(const std::string& tag, Index& value,
+ const std::string& prefix) const;
+ //@}
+
+ /** Get a string with the list of all options (tag, value, counter) */
+ virtual void PrintList(std::string& list) const;
+
+ /** Get a string with the list of all options set by the user
+ * (tag, value, use/notused). Here, options with dont_print flag
+ * set to true are not printed. */
+ virtual void PrintUserOptions(std::string& list) const;
+
+ /** Read options from the stream is. Returns false if
+ * an error was encountered. */
+ virtual bool ReadFromStream(const Journalist& jnlst, std::istream& is);
+
+ 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 */
+ // OptionsList();
+
+ //@}
+
+ /** map for storing the options */
+ std::map< std::string, OptionValue > options_;
+
+ /** list of all the registered options to validate against */
+ SmartPtr<RegisteredOptions> reg_options_;
+
+ /** Journalist for writing error messages, etc. */
+ SmartPtr<Journalist> jnlst_;
+
+ /** auxilliary method for converting sting to all lower-case
+ * letters */
+ const std::string& lowercase(const std::string tag) const;
+
+ /** auxilliary method for finding the value for a tag in the
+ * options list. This method first looks for the concatenated
+ * string prefix+tag (if prefix is not ""), and if this is not
+ * found, it looks for tag. The return value is true iff
+ * prefix+tag or tag is found. In that case, the corresponding
+ * string value is copied into value. */
+ bool find_tag(const std::string& tag, const std::string& prefix,
+ std::string& value) const;
+
+ /** tells whether or not we can clobber a particular option.
+ * returns true if the option does not already exist, or if
+ * the option exists but is set to allow_clobber
+ */
+ bool will_allow_clobber(const std::string& tag) const;
+
+ /** read the next token from stream is. Returns false, if EOF was
+ * reached before a tokens was ecountered. */
+ bool readnexttoken(std::istream& is, std::string& token);
+
+ /** auxilliary string set by lowercase method */
+ mutable std::string lowercase_buffer_;
+ };
+
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpReferenced.hpp b/thirdparty/windows/include/coin/IpReferenced.hpp index 6f40e3e..aa4ce79 100644 --- a/thirdparty/windows/include/coin/IpReferenced.hpp +++ b/thirdparty/windows/include/coin/IpReferenced.hpp @@ -1,249 +1,258 @@ -// Copyright (C) 2004, 2006 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpReferenced.hpp 1019 2007-06-24 03:52:34Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPREFERENCED_HPP__ -#define __IPREFERENCED_HPP__ - -#include "IpTypes.hpp" -#include "IpDebug.hpp" - -#include <list> - -namespace Ipopt -{ - - /** Psydo-class, from which everything has to inherit that wants to - * use be registered as a Referencer for a ReferencedObject. - */ - class Referencer - {} - ; - - /** ReferencedObject class. - * This is part of the implementation of an intrusive smart pointer - * design. This class stores the reference count of all the smart - * pointers that currently reference it. See the documentation for - * the SmartPtr class for more details. - * - * A SmartPtr behaves much like a raw pointer, but manages the lifetime - * of an object, deleting the object automatically. This class implements - * a reference-counting, intrusive smart pointer design, where all - * objects pointed to must inherit off of ReferencedObject, which - * stores the reference count. Although this is intrusive (native types - * and externally authored classes require wrappers to be referenced - * by smart pointers), it is a safer design. A more detailed discussion of - * these issues follows after the usage information. - * - * Usage Example: - * Note: to use the SmartPtr, all objects to which you point MUST - * inherit off of ReferencedObject. - * - * \verbatim - * - * In MyClass.hpp... - * - * #include "IpReferenced.hpp" - - * namespace Ipopt { - * - * class MyClass : public ReferencedObject // must derive from ReferencedObject - * { - * ... - * } - * } // namespace Ipopt - * - * - * In my_usage.cpp... - * - * #include "IpSmartPtr.hpp" - * #include "MyClass.hpp" - * - * void func(AnyObject& obj) - * { - * SmartPtr<MyClass> ptr_to_myclass = new MyClass(...); - * // ptr_to_myclass now points to a new MyClass, - * // and the reference count is 1 - * - * ... - * - * obj.SetMyClass(ptr_to_myclass); - * // Here, let's assume that AnyObject uses a - * // SmartPtr<MyClass> internally here. - * // Now, both ptr_to_myclass and the internal - * // SmartPtr in obj point to the same MyClass object - * // and its reference count is 2. - * - * ... - * - * // No need to delete ptr_to_myclass, this - * // will be done automatically when the - * // reference count drops to zero. - * - * } - * - * \endverbatim - * - * Other Notes: - * The SmartPtr implements both dereference operators -> & *. - * The SmartPtr does NOT implement a conversion operator to - * the raw pointer. Use the GetRawPtr() method when this - * is necessary. Make sure that the raw pointer is NOT - * deleted. - * The SmartPtr implements the comparison operators == & != - * for a variety of types. Use these instead of - * \verbatim - * if (GetRawPtr(smrt_ptr) == ptr) // Don't use this - * \endverbatim - * SmartPtr's, as currently implemented, do NOT handle circular references. - * For example: consider a higher level object using SmartPtrs to point to - * A and B, but A and B also point to each other (i.e. A has a SmartPtr - * to B and B has a SmartPtr to A). In this scenario, when the higher - * level object is finished with A and B, their reference counts will - * never drop to zero (since they reference each other) and they - * will not be deleted. This can be detected by memory leak tools like - * valgrind. If the circular reference is necessary, the problem can be - * overcome by a number of techniques: - * - * 1) A and B can have a method that "releases" each other, that is - * they set their internal SmartPtrs to NULL. - * \verbatim - * void AClass::ReleaseCircularReferences() - * { - * smart_ptr_to_B = NULL; - * } - * \endverbatim - * Then, the higher level class can call these methods before - * it is done using A & B. - * - * 2) Raw pointers can be used in A and B to reference each other. - * Here, an implicit assumption is made that the lifetime is - * controlled by the higher level object and that A and B will - * both exist in a controlled manner. Although this seems - * dangerous, in many situations, this type of referencing - * is very controlled and this is reasonably safe. - * - * 3) This SmartPtr class could be redesigned with the Weak/Strong - * design concept. Here, the SmartPtr is identified as being - * Strong (controls lifetime of the object) or Weak (merely - * referencing the object). The Strong SmartPtr increments - * (and decrements) the reference count in ReferencedObject - * but the Weak SmartPtr does not. In the example above, - * the higher level object would have Strong SmartPtrs to - * A and B, but A and B would have Weak SmartPtrs to each - * other. Then, when the higher level object was done with - * A and B, they would be deleted. The Weak SmartPtrs in A - * and B would not decrement the reference count and would, - * of course, not delete the object. This idea is very similar - * to item (2), where it is implied that the sequence of events - * is controlled such that A and B will not call anything using - * their pointers following the higher level delete (i.e. in - * their destructors!). This is somehow safer, however, because - * code can be written (however expensive) to perform run-time - * detection of this situation. For example, the ReferencedObject - * could store pointers to all Weak SmartPtrs that are referencing - * it and, in its destructor, tell these pointers that it is - * dying. They could then set themselves to NULL, or set an - * internal flag to detect usage past this point. - * - * Comments on Non-Intrusive Design: - * In a non-intrusive design, the reference count is stored somewhere other - * than the object being referenced. This means, unless the reference - * counting pointer is the first referencer, it must get a pointer to the - * referenced object from another smart pointer (so it has access to the - * reference count location). In this non-intrusive design, if we are - * pointing to an object with a smart pointer (or a number of smart - * pointers), and we then give another smart pointer the address through - * a RAW pointer, we will have two independent, AND INCORRECT, reference - * counts. To avoid this pitfall, we use an intrusive reference counting - * technique where the reference count is stored in the object being - * referenced. - */ - class ReferencedObject - { - public: - ReferencedObject() - : - reference_count_(0) - {} - - virtual ~ReferencedObject() - { - DBG_ASSERT(reference_count_ == 0); - } - - Index ReferenceCount() const; - - void AddRef(const Referencer* referencer) const; - - void ReleaseRef(const Referencer* referencer) const; - - private: - mutable Index reference_count_; - -# ifdef REF_DEBUG - - mutable std::list<const Referencer*> referencers_; -# endif - - }; - - /* inline methods */ - inline - Index ReferencedObject::ReferenceCount() const - { - // DBG_START_METH("ReferencedObject::ReferenceCount()", 0); - // DBG_PRINT((1,"Returning reference_count_ = %d\n", reference_count_)); - return reference_count_; - } - - inline - void ReferencedObject::AddRef(const Referencer* referencer) const - { - // DBG_START_METH("ReferencedObject::AddRef(const Referencer* referencer)", 0); - reference_count_++; - // DBG_PRINT((1, "New reference_count_ = %d\n", reference_count_)); -# ifdef REF_DEBUG - - referencers_.push_back(referencer); -# endif - - } - - inline - void ReferencedObject::ReleaseRef(const Referencer* referencer) const - { - // DBG_START_METH("ReferencedObject::ReleaseRef(const Referencer* referencer)", - // 0); - reference_count_--; - // DBG_PRINT((1, "New reference_count_ = %d\n", reference_count_)); - -# ifdef REF_DEBUG - - bool found = false; - std::list<const Referencer*>::iterator iter; - for (iter = referencers_.begin(); iter != referencers_.end(); iter++) { - if ((*iter) == referencer) { - found = true; - break; - } - } - - // cannot call release on a reference that was never added... - DBG_ASSERT(found); - - if (found) { - referencers_.erase(iter); - } -# endif - - } - - -} // namespace Ipopt - -#endif +// Copyright (C) 2004, 2006 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpReferenced.hpp 2182 2013-03-30 20:02:18Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPREFERENCED_HPP__
+#define __IPREFERENCED_HPP__
+
+#include "IpTypes.hpp"
+#include "IpDebug.hpp"
+
+#include <list>
+
+#if COIN_IPOPT_CHECKLEVEL > 3
+ #define IP_DEBUG_REFERENCED
+#endif
+
+namespace Ipopt
+{
+
+ /** Psydo-class, from which everything has to inherit that wants to
+ * use be registered as a Referencer for a ReferencedObject.
+ */
+ class Referencer
+ {}
+ ;
+
+ /** ReferencedObject class.
+ * This is part of the implementation of an intrusive smart pointer
+ * design. This class stores the reference count of all the smart
+ * pointers that currently reference it. See the documentation for
+ * the SmartPtr class for more details.
+ *
+ * A SmartPtr behaves much like a raw pointer, but manages the lifetime
+ * of an object, deleting the object automatically. This class implements
+ * a reference-counting, intrusive smart pointer design, where all
+ * objects pointed to must inherit off of ReferencedObject, which
+ * stores the reference count. Although this is intrusive (native types
+ * and externally authored classes require wrappers to be referenced
+ * by smart pointers), it is a safer design. A more detailed discussion of
+ * these issues follows after the usage information.
+ *
+ * Usage Example:
+ * Note: to use the SmartPtr, all objects to which you point MUST
+ * inherit off of ReferencedObject.
+ *
+ * \verbatim
+ *
+ * In MyClass.hpp...
+ *
+ * #include "IpReferenced.hpp"
+
+ * namespace Ipopt {
+ *
+ * class MyClass : public ReferencedObject // must derive from ReferencedObject
+ * {
+ * ...
+ * }
+ * } // namespace Ipopt
+ *
+ *
+ * In my_usage.cpp...
+ *
+ * #include "IpSmartPtr.hpp"
+ * #include "MyClass.hpp"
+ *
+ * void func(AnyObject& obj)
+ * {
+ * SmartPtr<MyClass> ptr_to_myclass = new MyClass(...);
+ * // ptr_to_myclass now points to a new MyClass,
+ * // and the reference count is 1
+ *
+ * ...
+ *
+ * obj.SetMyClass(ptr_to_myclass);
+ * // Here, let's assume that AnyObject uses a
+ * // SmartPtr<MyClass> internally here.
+ * // Now, both ptr_to_myclass and the internal
+ * // SmartPtr in obj point to the same MyClass object
+ * // and its reference count is 2.
+ *
+ * ...
+ *
+ * // No need to delete ptr_to_myclass, this
+ * // will be done automatically when the
+ * // reference count drops to zero.
+ *
+ * }
+ *
+ * \endverbatim
+ *
+ * Other Notes:
+ * The SmartPtr implements both dereference operators -> & *.
+ * The SmartPtr does NOT implement a conversion operator to
+ * the raw pointer. Use the GetRawPtr() method when this
+ * is necessary. Make sure that the raw pointer is NOT
+ * deleted.
+ * The SmartPtr implements the comparison operators == & !=
+ * for a variety of types. Use these instead of
+ * \verbatim
+ * if (GetRawPtr(smrt_ptr) == ptr) // Don't use this
+ * \endverbatim
+ * SmartPtr's, as currently implemented, do NOT handle circular references.
+ * For example: consider a higher level object using SmartPtrs to point to
+ * A and B, but A and B also point to each other (i.e. A has a SmartPtr
+ * to B and B has a SmartPtr to A). In this scenario, when the higher
+ * level object is finished with A and B, their reference counts will
+ * never drop to zero (since they reference each other) and they
+ * will not be deleted. This can be detected by memory leak tools like
+ * valgrind. If the circular reference is necessary, the problem can be
+ * overcome by a number of techniques:
+ *
+ * 1) A and B can have a method that "releases" each other, that is
+ * they set their internal SmartPtrs to NULL.
+ * \verbatim
+ * void AClass::ReleaseCircularReferences()
+ * {
+ * smart_ptr_to_B = NULL;
+ * }
+ * \endverbatim
+ * Then, the higher level class can call these methods before
+ * it is done using A & B.
+ *
+ * 2) Raw pointers can be used in A and B to reference each other.
+ * Here, an implicit assumption is made that the lifetime is
+ * controlled by the higher level object and that A and B will
+ * both exist in a controlled manner. Although this seems
+ * dangerous, in many situations, this type of referencing
+ * is very controlled and this is reasonably safe.
+ *
+ * 3) This SmartPtr class could be redesigned with the Weak/Strong
+ * design concept. Here, the SmartPtr is identified as being
+ * Strong (controls lifetime of the object) or Weak (merely
+ * referencing the object). The Strong SmartPtr increments
+ * (and decrements) the reference count in ReferencedObject
+ * but the Weak SmartPtr does not. In the example above,
+ * the higher level object would have Strong SmartPtrs to
+ * A and B, but A and B would have Weak SmartPtrs to each
+ * other. Then, when the higher level object was done with
+ * A and B, they would be deleted. The Weak SmartPtrs in A
+ * and B would not decrement the reference count and would,
+ * of course, not delete the object. This idea is very similar
+ * to item (2), where it is implied that the sequence of events
+ * is controlled such that A and B will not call anything using
+ * their pointers following the higher level delete (i.e. in
+ * their destructors!). This is somehow safer, however, because
+ * code can be written (however expensive) to perform run-time
+ * detection of this situation. For example, the ReferencedObject
+ * could store pointers to all Weak SmartPtrs that are referencing
+ * it and, in its destructor, tell these pointers that it is
+ * dying. They could then set themselves to NULL, or set an
+ * internal flag to detect usage past this point.
+ *
+ * For every most derived object only one ReferencedObject may exist,
+ * that is multiple inheritance requires virtual inheritance, see also
+ * the 2nd point in ticket #162.
+ *
+ * Comments on Non-Intrusive Design:
+ * In a non-intrusive design, the reference count is stored somewhere other
+ * than the object being referenced. This means, unless the reference
+ * counting pointer is the first referencer, it must get a pointer to the
+ * referenced object from another smart pointer (so it has access to the
+ * reference count location). In this non-intrusive design, if we are
+ * pointing to an object with a smart pointer (or a number of smart
+ * pointers), and we then give another smart pointer the address through
+ * a RAW pointer, we will have two independent, AND INCORRECT, reference
+ * counts. To avoid this pitfall, we use an intrusive reference counting
+ * technique where the reference count is stored in the object being
+ * referenced.
+ */
+ class ReferencedObject
+ {
+ public:
+ ReferencedObject()
+ :
+ reference_count_(0)
+ {}
+
+ virtual ~ReferencedObject()
+ {
+ DBG_ASSERT(reference_count_ == 0);
+ }
+
+ inline
+ Index ReferenceCount() const;
+
+ inline
+ void AddRef(const Referencer* referencer) const;
+
+ inline
+ void ReleaseRef(const Referencer* referencer) const;
+
+ private:
+ mutable Index reference_count_;
+
+# ifdef IP_DEBUG_REFERENCED
+ mutable std::list<const Referencer*> referencers_;
+# endif
+
+ };
+
+ /* inline methods */
+ inline
+ Index ReferencedObject::ReferenceCount() const
+ {
+ // DBG_START_METH("ReferencedObject::ReferenceCount()", 0);
+ // DBG_PRINT((1,"Returning reference_count_ = %d\n", reference_count_));
+ return reference_count_;
+ }
+
+ inline
+ void ReferencedObject::AddRef(const Referencer* referencer) const
+ {
+ // DBG_START_METH("ReferencedObject::AddRef(const Referencer* referencer)", 0);
+ reference_count_++;
+ // DBG_PRINT((1, "New reference_count_ = %d\n", reference_count_));
+# ifdef IP_DEBUG_REFERENCED
+ referencers_.push_back(referencer);
+# endif
+
+ }
+
+ inline
+ void ReferencedObject::ReleaseRef(const Referencer* referencer) const
+ {
+ // DBG_START_METH("ReferencedObject::ReleaseRef(const Referencer* referencer)",
+ // 0);
+ reference_count_--;
+ // DBG_PRINT((1, "New reference_count_ = %d\n", reference_count_));
+
+# ifdef IP_DEBUG_REFERENCED
+
+ bool found = false;
+ std::list<const Referencer*>::iterator iter;
+ for (iter = referencers_.begin(); iter != referencers_.end(); iter++) {
+ if ((*iter) == referencer) {
+ found = true;
+ break;
+ }
+ }
+
+ // cannot call release on a reference that was never added...
+ DBG_ASSERT(found);
+
+ if (found) {
+ referencers_.erase(iter);
+ }
+# endif
+
+ }
+
+
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpRegOptions.hpp b/thirdparty/windows/include/coin/IpRegOptions.hpp index 0e3c904..c3dc8ff 100644 --- a/thirdparty/windows/include/coin/IpRegOptions.hpp +++ b/thirdparty/windows/include/coin/IpRegOptions.hpp @@ -1,651 +1,658 @@ -// Copyright (C) 2004, 2007 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpRegOptions.hpp 1587 2009-10-27 16:09:21Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2005-06-18 - -#ifndef __IPREGOPTIONS_HPP__ -#define __IPREGOPTIONS_HPP__ - -#include "IpUtils.hpp" -#include "IpReferenced.hpp" -#include "IpException.hpp" -#include "IpSmartPtr.hpp" - -#include <map> - -namespace Ipopt -{ - - enum RegisteredOptionType - { - OT_Number, - OT_Integer, - OT_String, - OT_Unknown - }; - - /** Base class for registered options. The derived types are more - * specific to a string option or a Number (real) option, etc. - */ - class RegisteredOption : public ReferencedObject - { - public: - /** Constructors / Destructors */ - //@{ - RegisteredOption() - : - type_(OT_Unknown), - has_lower_(false), - has_upper_(false), - counter_(0) - {} - - RegisteredOption(const std::string& name, - const std::string& short_description, - const std::string& long_description, - const std::string& registering_category) - : - name_(name), - short_description_(short_description), - long_description_(long_description), - registering_category_(registering_category), - type_(OT_Unknown), - has_lower_(false), - has_upper_(false), - counter_(next_counter_++) - {} - - RegisteredOption(const RegisteredOption& copy) - : - name_(copy.name_), - short_description_(copy.short_description_), - long_description_(copy.long_description_), - registering_category_(copy.registering_category_), - type_(copy.type_), - has_lower_(copy.has_lower_), - lower_(copy.lower_), - has_upper_(copy.has_upper_), - upper_(copy.upper_), - valid_strings_(copy.valid_strings_), - counter_(copy.counter_) - {} - - virtual ~RegisteredOption() - {} - //@} - - DECLARE_STD_EXCEPTION(ERROR_CONVERTING_STRING_TO_ENUM); - - /** Standard Get / Set Methods */ - //@{ - /** Get the option's name (tag in the input file) */ - virtual const std::string& Name() const - { - return name_; - } - /** Set the option's name (tag in the input file) */ - virtual void SetName(const std::string& name) - { - name_ = name; - } - /** Get the short description */ - virtual const std::string& ShortDescription() const - { - return short_description_; - } - /** Get the long description */ - virtual const std::string& LongDescription() const - { - return long_description_; - } - /** Set the short description */ - virtual void SetShortDescription(const std::string& short_description) - { - short_description_ = short_description; - } - /** Set the long description */ - virtual void SetLongDescription(const std::string& long_description) - { - long_description_ = long_description; - } - /** Get the registering class */ - virtual const std::string& RegisteringCategory() const - { - return registering_category_; - } - /** Set the registering class */ - virtual void SetRegisteringCategory(const std::string& registering_category) - { - registering_category_ = registering_category; - } - /** Get the Option's type */ - virtual const RegisteredOptionType& Type() const - { - return type_; - } - /** Get the Option's type */ - virtual void SetType(const RegisteredOptionType& type) - { - type_ = type; - } - /** Counter */ - virtual Index Counter() const - { - return counter_; - } - //@} - - /** @name Get / Set methods valid for specific types - NOTE: the Type - * must be set before calling these methods. - */ - //@{ - /** check if the option has a lower bound - can be called for - * OT_Number & OT_Integer*/ - virtual const bool& HasLower() const - { - DBG_ASSERT(type_ == OT_Number || type_ == OT_Integer); - return has_lower_; - } - /** check if the lower bound is strict - can be called for - OT_Number */ - virtual const bool& LowerStrict() const - { - DBG_ASSERT(type_ == OT_Number && has_lower_ == true); - return lower_strict_; - } - /** get the Number version of the lower bound - can be called for - * OT_Number */ - virtual Number LowerNumber() const - { - DBG_ASSERT(has_lower_ == true && type_ == OT_Number); - return lower_; - } - /** set the Number version of the lower bound - can be called for - * OT_Number */ - virtual void SetLowerNumber(const Number& lower, const bool& strict) - { - DBG_ASSERT(type_ == OT_Number); - lower_ = lower; - lower_strict_ = strict, has_lower_ = true; - } - /** get the Integer version of the lower bound can be called for - * OT_Integer*/ - virtual Index LowerInteger() const - { - DBG_ASSERT(has_lower_ == true && type_ == OT_Integer); - return (Index)lower_; - } - /** set the Integer version of the lower bound - can be called for - * OT_Integer */ - virtual void SetLowerInteger(const Index& lower) - { - DBG_ASSERT(type_ == OT_Integer); - lower_ = (Number)lower; - has_lower_ = true; - } - /** check if the option has an upper bound - can be called for - * OT_Number & OT_Integer*/ - virtual const bool& HasUpper() const - { - DBG_ASSERT(type_ == OT_Number || type_ == OT_Integer); - return has_upper_; - } - /** check if the upper bound is strict - can be called for - * OT_Number */ - virtual const bool& UpperStrict() const - { - DBG_ASSERT(type_ == OT_Number && has_upper_ == true); - return upper_strict_; - } - /** get the Number version of the upper bound - can be called for - * OT_Number */ - virtual Number UpperNumber() const - { - DBG_ASSERT(has_upper_ == true && type_ == OT_Number); - return upper_; - } - /** set the Number version of the upper bound - can be called for - * OT_Number */ - virtual void SetUpperNumber(const Number& upper, const bool& strict) - { - DBG_ASSERT(type_ == OT_Number); - upper_ = upper; - upper_strict_ = strict; - has_upper_ = true; - } - /** get the Integer version of the upper bound - can be called for - * OT_Integer*/ - virtual Index UpperInteger() const - { - DBG_ASSERT(has_upper_ == true && type_ == OT_Integer); - return (Index)upper_; - } - /** set the Integer version of the upper bound - can be called for - * OT_Integer */ - virtual void SetUpperInteger(const Index& upper) - { - DBG_ASSERT(type_ == OT_Integer); - upper_ = (Number)upper; - has_upper_ = true; - } - /** method to add valid string entries - can be called for - * OT_String */ - virtual void AddValidStringSetting(const std::string value, - const std::string description) - { - DBG_ASSERT(type_ == OT_String); - valid_strings_.push_back(string_entry(value, description)); - } - /** get the default as a Number - can be called for OT_Number */ - virtual Number DefaultNumber() const - { - DBG_ASSERT(type_ == OT_Number); - return default_number_; - } - /** Set the default as a Number - can be called for OT_Number */ - virtual void SetDefaultNumber(const Number& default_value) - { - DBG_ASSERT(type_ == OT_Number); - default_number_ = default_value; - } - /** get the default as an Integer - can be called for OT_Integer*/ - virtual Index DefaultInteger() const - { - DBG_ASSERT(type_ == OT_Integer); - return (Index)default_number_; - } - /** Set the default as an Integer - can be called for - OT_Integer */ - virtual void SetDefaultInteger(const Index& default_value) - { - DBG_ASSERT(type_ == OT_Integer); - default_number_ = (Number)default_value; - } - /** get the default as a string - can be called for OT_String */ - virtual std::string DefaultString() const - { - DBG_ASSERT(type_ == OT_String); - return default_string_; - } - /** get the default as a string, but as the index of the string in - * the list - helps map from a string to an enum- can be called - * for OT_String */ - virtual Index DefaultStringAsEnum() const - { - DBG_ASSERT(type_ == OT_String); - return MapStringSettingToEnum(default_string_); - } - /** Set the default as a string - can be called for OT_String */ - virtual void SetDefaultString(const std::string& default_value) - { - DBG_ASSERT(type_ == OT_String); - default_string_ = default_value; - } - /** Check if the Number value is a valid setting - can be called - * for OT_Number */ - virtual bool IsValidNumberSetting(const Number& value) const - { - DBG_ASSERT(type_ == OT_Number); - if (has_lower_ && ((lower_strict_ == true && value <= lower_) || - (lower_strict_ == false && value < lower_))) { - return false; - } - if (has_upper_ && ((upper_strict_ == true && value >= upper_) || - (upper_strict_ == false && value > upper_))) { - return false; - } - return true; - } - /** Check if the Integer value is a valid setting - can be called - * for OT_Integer */ - virtual bool IsValidIntegerSetting(const Index& value) const - { - DBG_ASSERT(type_ == OT_Integer); - if (has_lower_ && value < lower_) { - return false; - } - if (has_upper_ && value > upper_) { - return false; - } - return true; - } - /** Check if the String value is a valid setting - can be called - * for OT_String */ - virtual bool IsValidStringSetting(const std::string& value) const; - - /** Map a user setting (allowing any case) to the case used when - * the setting was registered. - */ - virtual std::string MapStringSetting(const std::string& value) const; - - /** Map a user setting (allowing any case) to the index of the - * matched setting in the list of string settings. Helps map a - * string setting to an enumeration. - */ - virtual Index MapStringSettingToEnum(const std::string& value) const; - //@} - - /** output a description of the option */ - virtual void OutputDescription(const Journalist& jnlst) const; - /** output a more concise version */ - virtual void OutputShortDescription(const Journalist& jnlst) const; - /** output a latex version */ - virtual void OutputLatexDescription(const Journalist& jnlst) const; - - private: - std::string name_; - std::string short_description_; - std::string long_description_; - std::string registering_category_; - RegisteredOptionType type_; - - bool has_lower_; - bool lower_strict_; - Number lower_; - bool has_upper_; - bool upper_strict_; - Number upper_; - Number default_number_; - - void MakeValidLatexString(std::string source, std::string& dest) const; - std::string MakeValidLatexNumber(Number value) const; - - /** Compare two strings and return true if they are equal (case - insensitive comparison) */ - bool string_equal_insensitive(const std::string& s1, - const std::string& s2) const; - - /** class to hold the valid string settings for a string option */ - class string_entry - { - public: - string_entry(const std::string& value, const std::string& description) - : value_(value), description_(description) - {} - std::string value_; - std::string description_; - }; - - std::vector<string_entry> valid_strings_; - std::string default_string_; - - /** Has the information as how many-th option this one was - * registered. */ - const Index counter_; - - static Index next_counter_; - }; - - /** Class for storing registered options. Used for validation and - * documentation. - */ - class RegisteredOptions : public ReferencedObject - { - public: - /** Constructors / Destructors */ - //@{ - /** Standard Constructor */ - RegisteredOptions() - : - current_registering_category_("Uncategorized") - {} - - /** Standard Destructor */ - virtual ~RegisteredOptions() - {} - //@} - - DECLARE_STD_EXCEPTION(OPTION_ALREADY_REGISTERED); - - /** Methods to interact with registered options */ - //@{ - /** set the registering class. All subsequent options will be - * added with the registered class */ - virtual void SetRegisteringCategory(const std::string& registering_category) - { - current_registering_category_ = registering_category; - } - - /** retrieve the value of the current registering category */ - virtual std::string RegisteringCategory() - { - return current_registering_category_; - } - - /** Add a Number option (with no restrictions) */ - virtual void AddNumberOption(const std::string& name, - const std::string& short_description, - Number default_value, - const std::string& long_description=""); - /** Add a Number option (with a lower bound) */ - virtual void AddLowerBoundedNumberOption(const std::string& name, - const std::string& short_description, - Number lower, bool strict, - Number default_value, - const std::string& long_description=""); - /** Add a Number option (with a upper bound) */ - virtual void AddUpperBoundedNumberOption(const std::string& name, - const std::string& short_description, - Number upper, bool strict, - Number default_value, - const std::string& long_description=""); - /** Add a Number option (with a both bounds) */ - virtual void AddBoundedNumberOption(const std::string& name, - const std::string& short_description, - Number lower, bool lower_strict, - Number upper, bool upper_strict, - Number default_value, - const std::string& long_description=""); - /** Add a Integer option (with no restrictions) */ - virtual void AddIntegerOption(const std::string& name, - const std::string& short_description, - Index default_value, - const std::string& long_description=""); - /** Add a Integer option (with a lower bound) */ - virtual void AddLowerBoundedIntegerOption(const std::string& name, - const std::string& short_description, - Index lower, Index default_value, - const std::string& long_description=""); - /** Add a Integer option (with a upper bound) */ - virtual void AddUpperBoundedIntegerOption(const std::string& name, - const std::string& short_description, - Index upper, Index default_value, - const std::string& long_description=""); - /** Add a Integer option (with a both bounds) */ - virtual void AddBoundedIntegerOption(const std::string& name, - const std::string& short_description, - Index lower, Index upper, - Index default_value, - const std::string& long_description=""); - - /** Add a String option (with no restrictions) */ - virtual void AddStringOption(const std::string& name, - const std::string& short_description, - const std::string& default_value, - const std::vector<std::string>& settings, - const std::vector<std::string>& descriptions, - const std::string& long_description=""); - /** Methods that make adding string options with only a few - * entries easier */ - virtual void AddStringOption1(const std::string& name, - const std::string& short_description, - const std::string& default_value, - const std::string& setting1, - const std::string& description1, - const std::string& long_description=""); - virtual void AddStringOption2(const std::string& name, - const std::string& short_description, - const std::string& default_value, - const std::string& setting1, - const std::string& description1, - const std::string& setting2, - const std::string& description2, - const std::string& long_description=""); - virtual void AddStringOption3(const std::string& name, - const std::string& short_description, - const std::string& default_value, - const std::string& setting1, - const std::string& description1, - const std::string& setting2, - const std::string& description2, - const std::string& setting3, - const std::string& description3, - const std::string& long_description=""); - virtual void AddStringOption4(const std::string& name, - const std::string& short_description, - const std::string& default_value, - const std::string& setting1, - const std::string& description1, - const std::string& setting2, - const std::string& description2, - const std::string& setting3, - const std::string& description3, - const std::string& setting4, - const std::string& description4, - const std::string& long_description=""); - virtual void AddStringOption5(const std::string& name, - const std::string& short_description, - const std::string& default_value, - const std::string& setting1, - const std::string& description1, - const std::string& setting2, - const std::string& description2, - const std::string& setting3, - const std::string& description3, - const std::string& setting4, - const std::string& description4, - const std::string& setting5, - const std::string& description5, - const std::string& long_description=""); - virtual void AddStringOption6(const std::string& name, - const std::string& short_description, - const std::string& default_value, - const std::string& setting1, - const std::string& description1, - const std::string& setting2, - const std::string& description2, - const std::string& setting3, - const std::string& description3, - const std::string& setting4, - const std::string& description4, - const std::string& setting5, - const std::string& description5, - const std::string& setting6, - const std::string& description6, - const std::string& long_description=""); - virtual void AddStringOption7(const std::string& name, - const std::string& short_description, - const std::string& default_value, - const std::string& setting1, - const std::string& description1, - const std::string& setting2, - const std::string& description2, - const std::string& setting3, - const std::string& description3, - const std::string& setting4, - const std::string& description4, - const std::string& setting5, - const std::string& description5, - const std::string& setting6, - const std::string& description6, - const std::string& setting7, - const std::string& description7, - const std::string& long_description=""); - virtual void AddStringOption8(const std::string& name, - const std::string& short_description, - const std::string& default_value, - const std::string& setting1, - const std::string& description1, - const std::string& setting2, - const std::string& description2, - const std::string& setting3, - const std::string& description3, - const std::string& setting4, - const std::string& description4, - const std::string& setting5, - const std::string& description5, - const std::string& setting6, - const std::string& description6, - const std::string& setting7, - const std::string& description7, - const std::string& setting8, - const std::string& description8, - const std::string& long_description=""); - virtual void AddStringOption9(const std::string& name, - const std::string& short_description, - const std::string& default_value, - const std::string& setting1, - const std::string& description1, - const std::string& setting2, - const std::string& description2, - const std::string& setting3, - const std::string& description3, - const std::string& setting4, - const std::string& description4, - const std::string& setting5, - const std::string& description5, - const std::string& setting6, - const std::string& description6, - const std::string& setting7, - const std::string& description7, - const std::string& setting8, - const std::string& description8, - const std::string& setting9, - const std::string& description9, - const std::string& long_description=""); - virtual void AddStringOption10(const std::string& name, - const std::string& short_description, - const std::string& default_value, - const std::string& setting1, - const std::string& description1, - const std::string& setting2, - const std::string& description2, - const std::string& setting3, - const std::string& description3, - const std::string& setting4, - const std::string& description4, - const std::string& setting5, - const std::string& description5, - const std::string& setting6, - const std::string& description6, - const std::string& setting7, - const std::string& description7, - const std::string& setting8, - const std::string& description8, - const std::string& setting9, - const std::string& description9, - const std::string& setting10, - const std::string& description10, - const std::string& long_description=""); - - /** Get a registered option - this will return NULL if the option - * does not exist */ - virtual SmartPtr<const RegisteredOption> GetOption(const std::string& name); - - /** Output documentation for the options - gives a description, - * etc. */ - virtual void OutputOptionDocumentation(const Journalist& jnlst, std::list<std::string>& categories); - - /** Output documentation in Latex format to include in a latex file */ - virtual void OutputLatexOptionDocumentation(const Journalist& jnlst, std::list<std::string>& categories); - //@} - - typedef std::map<std::string, SmartPtr<RegisteredOption> > RegOptionsList; - - /** Giving access to iteratable representation of the registered - * options */ - virtual const RegOptionsList& RegisteredOptionsList () const - { - return registered_options_; - } - - private: - std::string current_registering_category_; - std::map<std::string, SmartPtr<RegisteredOption> > registered_options_; - }; -} // namespace Ipopt - -#endif +// Copyright (C) 2004, 2007 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpRegOptions.hpp 2189 2013-03-31 15:06:11Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2005-06-18
+
+#ifndef __IPREGOPTIONS_HPP__
+#define __IPREGOPTIONS_HPP__
+
+#include "IpUtils.hpp"
+#include "IpReferenced.hpp"
+#include "IpException.hpp"
+#include "IpSmartPtr.hpp"
+
+#include <map>
+
+namespace Ipopt
+{
+
+ enum RegisteredOptionType
+ {
+ OT_Number,
+ OT_Integer,
+ OT_String,
+ OT_Unknown
+ };
+
+ /** Base class for registered options. The derived types are more
+ * specific to a string option or a Number (real) option, etc.
+ */
+ class RegisteredOption : public ReferencedObject
+ {
+ public:
+ /** class to hold the valid string settings for a string option */
+ class string_entry
+ {
+ public:
+ string_entry(const std::string& value, const std::string& description)
+ : value_(value), description_(description)
+ {}
+ std::string value_;
+ std::string description_;
+ };
+
+ /** Constructors / Destructors */
+ //@{
+ RegisteredOption(Index counter)
+ :
+ type_(OT_Unknown),
+ has_lower_(false),
+ has_upper_(false),
+ counter_(counter)
+ {}
+
+ RegisteredOption(const std::string& name,
+ const std::string& short_description,
+ const std::string& long_description,
+ const std::string& registering_category,
+ Index counter)
+ :
+ name_(name),
+ short_description_(short_description),
+ long_description_(long_description),
+ registering_category_(registering_category),
+ type_(OT_Unknown),
+ has_lower_(false),
+ has_upper_(false),
+ counter_(counter)
+ {}
+
+ RegisteredOption(const RegisteredOption& copy)
+ :
+ name_(copy.name_),
+ short_description_(copy.short_description_),
+ long_description_(copy.long_description_),
+ registering_category_(copy.registering_category_),
+ type_(copy.type_),
+ has_lower_(copy.has_lower_),
+ lower_(copy.lower_),
+ has_upper_(copy.has_upper_),
+ upper_(copy.upper_),
+ valid_strings_(copy.valid_strings_),
+ counter_(copy.counter_)
+ {}
+
+ virtual ~RegisteredOption()
+ {}
+ //@}
+
+ DECLARE_STD_EXCEPTION(ERROR_CONVERTING_STRING_TO_ENUM);
+
+ /** Standard Get / Set Methods */
+ //@{
+ /** Get the option's name (tag in the input file) */
+ virtual const std::string& Name() const
+ {
+ return name_;
+ }
+ /** Set the option's name (tag in the input file) */
+ virtual void SetName(const std::string& name)
+ {
+ name_ = name;
+ }
+ /** Get the short description */
+ virtual const std::string& ShortDescription() const
+ {
+ return short_description_;
+ }
+ /** Get the long description */
+ virtual const std::string& LongDescription() const
+ {
+ return long_description_;
+ }
+ /** Set the short description */
+ virtual void SetShortDescription(const std::string& short_description)
+ {
+ short_description_ = short_description;
+ }
+ /** Set the long description */
+ virtual void SetLongDescription(const std::string& long_description)
+ {
+ long_description_ = long_description;
+ }
+ /** Get the registering class */
+ virtual const std::string& RegisteringCategory() const
+ {
+ return registering_category_;
+ }
+ /** Set the registering class */
+ virtual void SetRegisteringCategory(const std::string& registering_category)
+ {
+ registering_category_ = registering_category;
+ }
+ /** Get the Option's type */
+ virtual const RegisteredOptionType& Type() const
+ {
+ return type_;
+ }
+ /** Get the Option's type */
+ virtual void SetType(const RegisteredOptionType& type)
+ {
+ type_ = type;
+ }
+ /** Counter */
+ virtual Index Counter() const
+ {
+ return counter_;
+ }
+ //@}
+
+ /** @name Get / Set methods valid for specific types - NOTE: the Type
+ * must be set before calling these methods.
+ */
+ //@{
+ /** check if the option has a lower bound - can be called for
+ * OT_Number & OT_Integer*/
+ virtual const bool& HasLower() const
+ {
+ DBG_ASSERT(type_ == OT_Number || type_ == OT_Integer);
+ return has_lower_;
+ }
+ /** check if the lower bound is strict - can be called for
+ OT_Number */
+ virtual const bool& LowerStrict() const
+ {
+ DBG_ASSERT(type_ == OT_Number && has_lower_ == true);
+ return lower_strict_;
+ }
+ /** get the Number version of the lower bound - can be called for
+ * OT_Number */
+ virtual Number LowerNumber() const
+ {
+ DBG_ASSERT(has_lower_ == true && type_ == OT_Number);
+ return lower_;
+ }
+ /** set the Number version of the lower bound - can be called for
+ * OT_Number */
+ virtual void SetLowerNumber(const Number& lower, const bool& strict)
+ {
+ DBG_ASSERT(type_ == OT_Number);
+ lower_ = lower;
+ lower_strict_ = strict, has_lower_ = true;
+ }
+ /** get the Integer version of the lower bound can be called for
+ * OT_Integer*/
+ virtual Index LowerInteger() const
+ {
+ DBG_ASSERT(has_lower_ == true && type_ == OT_Integer);
+ return (Index)lower_;
+ }
+ /** set the Integer version of the lower bound - can be called for
+ * OT_Integer */
+ virtual void SetLowerInteger(const Index& lower)
+ {
+ DBG_ASSERT(type_ == OT_Integer);
+ lower_ = (Number)lower;
+ has_lower_ = true;
+ }
+ /** check if the option has an upper bound - can be called for
+ * OT_Number & OT_Integer*/
+ virtual const bool& HasUpper() const
+ {
+ DBG_ASSERT(type_ == OT_Number || type_ == OT_Integer);
+ return has_upper_;
+ }
+ /** check if the upper bound is strict - can be called for
+ * OT_Number */
+ virtual const bool& UpperStrict() const
+ {
+ DBG_ASSERT(type_ == OT_Number && has_upper_ == true);
+ return upper_strict_;
+ }
+ /** get the Number version of the upper bound - can be called for
+ * OT_Number */
+ virtual Number UpperNumber() const
+ {
+ DBG_ASSERT(has_upper_ == true && type_ == OT_Number);
+ return upper_;
+ }
+ /** set the Number version of the upper bound - can be called for
+ * OT_Number */
+ virtual void SetUpperNumber(const Number& upper, const bool& strict)
+ {
+ DBG_ASSERT(type_ == OT_Number);
+ upper_ = upper;
+ upper_strict_ = strict;
+ has_upper_ = true;
+ }
+ /** get the Integer version of the upper bound - can be called for
+ * OT_Integer*/
+ virtual Index UpperInteger() const
+ {
+ DBG_ASSERT(has_upper_ == true && type_ == OT_Integer);
+ return (Index)upper_;
+ }
+ /** set the Integer version of the upper bound - can be called for
+ * OT_Integer */
+ virtual void SetUpperInteger(const Index& upper)
+ {
+ DBG_ASSERT(type_ == OT_Integer);
+ upper_ = (Number)upper;
+ has_upper_ = true;
+ }
+ /** method to add valid string entries - can be called for
+ * OT_String */
+ virtual void AddValidStringSetting(const std::string value,
+ const std::string description)
+ {
+ DBG_ASSERT(type_ == OT_String);
+ valid_strings_.push_back(string_entry(value, description));
+ }
+ /** get the default as a Number - can be called for OT_Number */
+ virtual Number DefaultNumber() const
+ {
+ DBG_ASSERT(type_ == OT_Number);
+ return default_number_;
+ }
+ /** Set the default as a Number - can be called for OT_Number */
+ virtual void SetDefaultNumber(const Number& default_value)
+ {
+ DBG_ASSERT(type_ == OT_Number);
+ default_number_ = default_value;
+ }
+ /** get the default as an Integer - can be called for OT_Integer*/
+ virtual Index DefaultInteger() const
+ {
+ DBG_ASSERT(type_ == OT_Integer);
+ return (Index)default_number_;
+ }
+ /** Set the default as an Integer - can be called for
+ OT_Integer */
+ virtual void SetDefaultInteger(const Index& default_value)
+ {
+ DBG_ASSERT(type_ == OT_Integer);
+ default_number_ = (Number)default_value;
+ }
+ /** get the default as a string - can be called for OT_String */
+ virtual std::string DefaultString() const
+ {
+ DBG_ASSERT(type_ == OT_String);
+ return default_string_;
+ }
+ /** get the default as a string, but as the index of the string in
+ * the list - helps map from a string to an enum- can be called
+ * for OT_String */
+ virtual Index DefaultStringAsEnum() const
+ {
+ DBG_ASSERT(type_ == OT_String);
+ return MapStringSettingToEnum(default_string_);
+ }
+ /** Set the default as a string - can be called for OT_String */
+ virtual void SetDefaultString(const std::string& default_value)
+ {
+ DBG_ASSERT(type_ == OT_String);
+ default_string_ = default_value;
+ }
+ /** get the valid string settings - can be called for OT_String */
+ virtual std::vector<string_entry> GetValidStrings() const
+ {
+ DBG_ASSERT(type_ == OT_String);
+ return valid_strings_;
+ }
+ /** Check if the Number value is a valid setting - can be called
+ * for OT_Number */
+ virtual bool IsValidNumberSetting(const Number& value) const
+ {
+ DBG_ASSERT(type_ == OT_Number);
+ if (has_lower_ && ((lower_strict_ == true && value <= lower_) ||
+ (lower_strict_ == false && value < lower_))) {
+ return false;
+ }
+ if (has_upper_ && ((upper_strict_ == true && value >= upper_) ||
+ (upper_strict_ == false && value > upper_))) {
+ return false;
+ }
+ return true;
+ }
+ /** Check if the Integer value is a valid setting - can be called
+ * for OT_Integer */
+ virtual bool IsValidIntegerSetting(const Index& value) const
+ {
+ DBG_ASSERT(type_ == OT_Integer);
+ if (has_lower_ && value < lower_) {
+ return false;
+ }
+ if (has_upper_ && value > upper_) {
+ return false;
+ }
+ return true;
+ }
+ /** Check if the String value is a valid setting - can be called
+ * for OT_String */
+ virtual bool IsValidStringSetting(const std::string& value) const;
+
+ /** Map a user setting (allowing any case) to the case used when
+ * the setting was registered.
+ */
+ virtual std::string MapStringSetting(const std::string& value) const;
+
+ /** Map a user setting (allowing any case) to the index of the
+ * matched setting in the list of string settings. Helps map a
+ * string setting to an enumeration.
+ */
+ virtual Index MapStringSettingToEnum(const std::string& value) const;
+ //@}
+
+ /** output a description of the option */
+ virtual void OutputDescription(const Journalist& jnlst) const;
+ /** output a more concise version */
+ virtual void OutputShortDescription(const Journalist& jnlst) const;
+ /** output a latex version */
+ virtual void OutputLatexDescription(const Journalist& jnlst) const;
+
+ private:
+ std::string name_;
+ std::string short_description_;
+ std::string long_description_;
+ std::string registering_category_;
+ RegisteredOptionType type_;
+
+ bool has_lower_;
+ bool lower_strict_;
+ Number lower_;
+ bool has_upper_;
+ bool upper_strict_;
+ Number upper_;
+ Number default_number_;
+
+ void MakeValidLatexString(std::string source, std::string& dest) const;
+ std::string MakeValidLatexNumber(Number value) const;
+
+ /** Compare two strings and return true if they are equal (case
+ insensitive comparison) */
+ bool string_equal_insensitive(const std::string& s1,
+ const std::string& s2) const;
+
+ std::vector<string_entry> valid_strings_;
+ std::string default_string_;
+
+ /** Has the information as how many-th option this one was
+ * registered. */
+ const Index counter_;
+ };
+
+ /** Class for storing registered options. Used for validation and
+ * documentation.
+ */
+ class RegisteredOptions : public ReferencedObject
+ {
+ public:
+ /** Constructors / Destructors */
+ //@{
+ /** Standard Constructor */
+ RegisteredOptions()
+ :
+ next_counter_(0),
+ current_registering_category_("Uncategorized")
+ {}
+
+ /** Standard Destructor */
+ virtual ~RegisteredOptions()
+ {}
+ //@}
+
+ DECLARE_STD_EXCEPTION(OPTION_ALREADY_REGISTERED);
+
+ /** Methods to interact with registered options */
+ //@{
+ /** set the registering class. All subsequent options will be
+ * added with the registered class */
+ virtual void SetRegisteringCategory(const std::string& registering_category)
+ {
+ current_registering_category_ = registering_category;
+ }
+
+ /** retrieve the value of the current registering category */
+ virtual std::string RegisteringCategory()
+ {
+ return current_registering_category_;
+ }
+
+ /** Add a Number option (with no restrictions) */
+ virtual void AddNumberOption(const std::string& name,
+ const std::string& short_description,
+ Number default_value,
+ const std::string& long_description="");
+ /** Add a Number option (with a lower bound) */
+ virtual void AddLowerBoundedNumberOption(const std::string& name,
+ const std::string& short_description,
+ Number lower, bool strict,
+ Number default_value,
+ const std::string& long_description="");
+ /** Add a Number option (with a upper bound) */
+ virtual void AddUpperBoundedNumberOption(const std::string& name,
+ const std::string& short_description,
+ Number upper, bool strict,
+ Number default_value,
+ const std::string& long_description="");
+ /** Add a Number option (with a both bounds) */
+ virtual void AddBoundedNumberOption(const std::string& name,
+ const std::string& short_description,
+ Number lower, bool lower_strict,
+ Number upper, bool upper_strict,
+ Number default_value,
+ const std::string& long_description="");
+ /** Add a Integer option (with no restrictions) */
+ virtual void AddIntegerOption(const std::string& name,
+ const std::string& short_description,
+ Index default_value,
+ const std::string& long_description="");
+ /** Add a Integer option (with a lower bound) */
+ virtual void AddLowerBoundedIntegerOption(const std::string& name,
+ const std::string& short_description,
+ Index lower, Index default_value,
+ const std::string& long_description="");
+ /** Add a Integer option (with a upper bound) */
+ virtual void AddUpperBoundedIntegerOption(const std::string& name,
+ const std::string& short_description,
+ Index upper, Index default_value,
+ const std::string& long_description="");
+ /** Add a Integer option (with a both bounds) */
+ virtual void AddBoundedIntegerOption(const std::string& name,
+ const std::string& short_description,
+ Index lower, Index upper,
+ Index default_value,
+ const std::string& long_description="");
+
+ /** Add a String option (with no restrictions) */
+ virtual void AddStringOption(const std::string& name,
+ const std::string& short_description,
+ const std::string& default_value,
+ const std::vector<std::string>& settings,
+ const std::vector<std::string>& descriptions,
+ const std::string& long_description="");
+ /** Methods that make adding string options with only a few
+ * entries easier */
+ virtual void AddStringOption1(const std::string& name,
+ const std::string& short_description,
+ const std::string& default_value,
+ const std::string& setting1,
+ const std::string& description1,
+ const std::string& long_description="");
+ virtual void AddStringOption2(const std::string& name,
+ const std::string& short_description,
+ const std::string& default_value,
+ const std::string& setting1,
+ const std::string& description1,
+ const std::string& setting2,
+ const std::string& description2,
+ const std::string& long_description="");
+ virtual void AddStringOption3(const std::string& name,
+ const std::string& short_description,
+ const std::string& default_value,
+ const std::string& setting1,
+ const std::string& description1,
+ const std::string& setting2,
+ const std::string& description2,
+ const std::string& setting3,
+ const std::string& description3,
+ const std::string& long_description="");
+ virtual void AddStringOption4(const std::string& name,
+ const std::string& short_description,
+ const std::string& default_value,
+ const std::string& setting1,
+ const std::string& description1,
+ const std::string& setting2,
+ const std::string& description2,
+ const std::string& setting3,
+ const std::string& description3,
+ const std::string& setting4,
+ const std::string& description4,
+ const std::string& long_description="");
+ virtual void AddStringOption5(const std::string& name,
+ const std::string& short_description,
+ const std::string& default_value,
+ const std::string& setting1,
+ const std::string& description1,
+ const std::string& setting2,
+ const std::string& description2,
+ const std::string& setting3,
+ const std::string& description3,
+ const std::string& setting4,
+ const std::string& description4,
+ const std::string& setting5,
+ const std::string& description5,
+ const std::string& long_description="");
+ virtual void AddStringOption6(const std::string& name,
+ const std::string& short_description,
+ const std::string& default_value,
+ const std::string& setting1,
+ const std::string& description1,
+ const std::string& setting2,
+ const std::string& description2,
+ const std::string& setting3,
+ const std::string& description3,
+ const std::string& setting4,
+ const std::string& description4,
+ const std::string& setting5,
+ const std::string& description5,
+ const std::string& setting6,
+ const std::string& description6,
+ const std::string& long_description="");
+ virtual void AddStringOption7(const std::string& name,
+ const std::string& short_description,
+ const std::string& default_value,
+ const std::string& setting1,
+ const std::string& description1,
+ const std::string& setting2,
+ const std::string& description2,
+ const std::string& setting3,
+ const std::string& description3,
+ const std::string& setting4,
+ const std::string& description4,
+ const std::string& setting5,
+ const std::string& description5,
+ const std::string& setting6,
+ const std::string& description6,
+ const std::string& setting7,
+ const std::string& description7,
+ const std::string& long_description="");
+ virtual void AddStringOption8(const std::string& name,
+ const std::string& short_description,
+ const std::string& default_value,
+ const std::string& setting1,
+ const std::string& description1,
+ const std::string& setting2,
+ const std::string& description2,
+ const std::string& setting3,
+ const std::string& description3,
+ const std::string& setting4,
+ const std::string& description4,
+ const std::string& setting5,
+ const std::string& description5,
+ const std::string& setting6,
+ const std::string& description6,
+ const std::string& setting7,
+ const std::string& description7,
+ const std::string& setting8,
+ const std::string& description8,
+ const std::string& long_description="");
+ virtual void AddStringOption9(const std::string& name,
+ const std::string& short_description,
+ const std::string& default_value,
+ const std::string& setting1,
+ const std::string& description1,
+ const std::string& setting2,
+ const std::string& description2,
+ const std::string& setting3,
+ const std::string& description3,
+ const std::string& setting4,
+ const std::string& description4,
+ const std::string& setting5,
+ const std::string& description5,
+ const std::string& setting6,
+ const std::string& description6,
+ const std::string& setting7,
+ const std::string& description7,
+ const std::string& setting8,
+ const std::string& description8,
+ const std::string& setting9,
+ const std::string& description9,
+ const std::string& long_description="");
+ virtual void AddStringOption10(const std::string& name,
+ const std::string& short_description,
+ const std::string& default_value,
+ const std::string& setting1,
+ const std::string& description1,
+ const std::string& setting2,
+ const std::string& description2,
+ const std::string& setting3,
+ const std::string& description3,
+ const std::string& setting4,
+ const std::string& description4,
+ const std::string& setting5,
+ const std::string& description5,
+ const std::string& setting6,
+ const std::string& description6,
+ const std::string& setting7,
+ const std::string& description7,
+ const std::string& setting8,
+ const std::string& description8,
+ const std::string& setting9,
+ const std::string& description9,
+ const std::string& setting10,
+ const std::string& description10,
+ const std::string& long_description="");
+
+ /** Get a registered option - this will return NULL if the option
+ * does not exist */
+ virtual SmartPtr<const RegisteredOption> GetOption(const std::string& name);
+
+ /** Output documentation for the options - gives a description,
+ * etc. */
+ virtual void OutputOptionDocumentation(const Journalist& jnlst, std::list<std::string>& categories);
+
+ /** Output documentation in Latex format to include in a latex file */
+ virtual void OutputLatexOptionDocumentation(const Journalist& jnlst, std::list<std::string>& categories);
+ //@}
+
+ typedef std::map<std::string, SmartPtr<RegisteredOption> > RegOptionsList;
+
+ /** Giving access to iteratable representation of the registered
+ * options */
+ virtual const RegOptionsList& RegisteredOptionsList () const
+ {
+ return registered_options_;
+ }
+
+ private:
+ Index next_counter_;
+ std::string current_registering_category_;
+ std::map<std::string, SmartPtr<RegisteredOption> > registered_options_;
+ };
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpReturnCodes.h b/thirdparty/windows/include/coin/IpReturnCodes.h index 54cf0ae..7d98103 100644 --- a/thirdparty/windows/include/coin/IpReturnCodes.h +++ b/thirdparty/windows/include/coin/IpReturnCodes.h @@ -1,18 +1,18 @@ -/*********************************************************************** -// Copyright (C) 2004, 2006 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpReturnCodes.h 735 2006-06-04 06:10:05Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 -************************************************************************/ - -#ifndef __IPRETURNCODES_H__ -#define __IPRETURNCODES_H__ - -/* include from a common include file */ - -#include "IpReturnCodes_inc.h" - -#endif +/***********************************************************************
+// Copyright (C) 2004, 2006 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpReturnCodes.h 1861 2010-12-21 21:34:47Z andreasw $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+************************************************************************/
+
+#ifndef __IPRETURNCODES_H__
+#define __IPRETURNCODES_H__
+
+/* include from a common include file */
+
+#include "IpReturnCodes_inc.h"
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpReturnCodes.hpp b/thirdparty/windows/include/coin/IpReturnCodes.hpp index 8c688b7..7ad2649 100644 --- a/thirdparty/windows/include/coin/IpReturnCodes.hpp +++ b/thirdparty/windows/include/coin/IpReturnCodes.hpp @@ -1,21 +1,21 @@ -/*********************************************************************** -// Copyright (C) 2006 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpReturnCodes.hpp 1324 2008-09-16 14:19:26Z andreasw $ -// -// Authors: Andreas Waechter IBM 2006-03-01 -************************************************************************/ - -#ifndef __IPRETURNCODES_HPP__ -#define __IPRETURNCODES_HPP__ - -/* include from a common include file */ - -namespace Ipopt -{ -#include "IpReturnCodes_inc.h" -} - -#endif +/***********************************************************************
+// Copyright (C) 2006 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpReturnCodes.hpp 1861 2010-12-21 21:34:47Z andreasw $
+//
+// Authors: Andreas Waechter IBM 2006-03-01
+************************************************************************/
+
+#ifndef __IPRETURNCODES_HPP__
+#define __IPRETURNCODES_HPP__
+
+/* include from a common include file */
+
+namespace Ipopt
+{
+#include "IpReturnCodes_inc.h"
+}
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpReturnCodes.inc b/thirdparty/windows/include/coin/IpReturnCodes.inc index 033d47f..f0d6379 100644 --- a/thirdparty/windows/include/coin/IpReturnCodes.inc +++ b/thirdparty/windows/include/coin/IpReturnCodes.inc @@ -1,70 +1,70 @@ -C Copyright (C) 2005, 2009 International Business Machines and others. -C All Rights Reserved. -C This code is published under the Common Public License. -C -C $Id: IpReturnCodes.inc 1430 2009-04-20 20:58:25Z andreasw $ -C -C Author: Andreas Waechter IBM 2005-08-11 -C - INTEGER IP_SOLVE_SUCCEEDED - PARAMETER( IP_SOLVE_SUCCEEDED = 0 ) - - INTEGER IP_ACCEPTABLE_LEVEL - PARAMETER( IP_ACCEPTABLE_LEVEL = 1 ) - - INTEGER IP_INFEASIBLE_PROBLEM - PARAMETER( IP_INFEASIBLE_PROBLEM = 2 ) - - INTEGER IP_SEARCH_DIRECTION_TOO_SMALL - PARAMETER( IP_SEARCH_DIRECTION_TOO_SMALL = 3 ) - - INTEGER IP_DIVERGING_ITERATES - PARAMETER( IP_DIVERGING_ITERATES = 4 ) - - INTEGER IP_USER_REQUESTED_STOP - PARAMETER( IP_USER_REQUESTED_STOP = 5 ) - - INTEGER IP_FEASIBLE_POINT_FOUND - PARAMETER( IP_FEASIBLE_POINT_FOUND = 6 ) - - INTEGER IP_ITERATION_EXCEEDED - PARAMETER( IP_ITERATION_EXCEEDED = -1 ) - - INTEGER IP_RESTORATION_FAILED - PARAMETER( IP_RESTORATION_FAILED = -2 ) - - INTEGER IP_ERROR_IN_STEP_COMPUTATION - PARAMETER( IP_ERROR_IN_STEP_COMPUTATION = -3 ) - - INTEGER IP_CPUTIME_EXCEEDED - PARAMETER( IP_CPUTIME_EXCEEDED = -4 ) - - INTEGER IP_NOT_ENOUGH_DEGREES_OF_FRE - PARAMETER( IP_NOT_ENOUGH_DEGREES_OF_FRE = -10 ) - - INTEGER IP_INVALID_PROBLEM_DEFINITION - PARAMETER( IP_INVALID_PROBLEM_DEFINITION = -11) - - INTEGER IP_INVALID_OPTION - PARAMETER( IP_INVALID_OPTION = -12 ) - - INTEGER IP_INVALID_NUMBER_DETECTED - PARAMETER( IP_INVALID_NUMBER_DETECTED = -13 ) - - INTEGER IP_UNRECOVERABLE_EXCEPTION - PARAMETER( IP_UNRECOVERABLE_EXCEPTION = -100 ) - - INTEGER IP_NON_IPOPT_EXCEPTION - PARAMETER( IP_NON_IPOPT_EXCEPTION = -101 ) - - INTEGER IP_INSUFFICIENT_MEMORY - PARAMETER( IP_INSUFFICIENT_MEMORY = -102 ) - - INTEGER IP_INTERNAL_ERROR - PARAMETER( IP_INTERNAL_ERROR = -199 ) - - INTEGER IP_REGULAR_MODE - PARAMETER( IP_REGULAR_MODE = 0 ) - - INTEGER IP_RESTORATION_PHASE_MODE - PARAMETER( IP_RESTORATION_PHASE_MODE = 1 ) +C Copyright (C) 2005, 2009 International Business Machines and others.
+C All Rights Reserved.
+C This code is published under the Eclipse Public License.
+C
+C $Id: IpReturnCodes.inc 1861 2010-12-21 21:34:47Z andreasw $
+C
+C Author: Andreas Waechter IBM 2005-08-11
+C
+ INTEGER IP_SOLVE_SUCCEEDED
+ PARAMETER( IP_SOLVE_SUCCEEDED = 0 )
+
+ INTEGER IP_ACCEPTABLE_LEVEL
+ PARAMETER( IP_ACCEPTABLE_LEVEL = 1 )
+
+ INTEGER IP_INFEASIBLE_PROBLEM
+ PARAMETER( IP_INFEASIBLE_PROBLEM = 2 )
+
+ INTEGER IP_SEARCH_DIRECTION_TOO_SMALL
+ PARAMETER( IP_SEARCH_DIRECTION_TOO_SMALL = 3 )
+
+ INTEGER IP_DIVERGING_ITERATES
+ PARAMETER( IP_DIVERGING_ITERATES = 4 )
+
+ INTEGER IP_USER_REQUESTED_STOP
+ PARAMETER( IP_USER_REQUESTED_STOP = 5 )
+
+ INTEGER IP_FEASIBLE_POINT_FOUND
+ PARAMETER( IP_FEASIBLE_POINT_FOUND = 6 )
+
+ INTEGER IP_ITERATION_EXCEEDED
+ PARAMETER( IP_ITERATION_EXCEEDED = -1 )
+
+ INTEGER IP_RESTORATION_FAILED
+ PARAMETER( IP_RESTORATION_FAILED = -2 )
+
+ INTEGER IP_ERROR_IN_STEP_COMPUTATION
+ PARAMETER( IP_ERROR_IN_STEP_COMPUTATION = -3 )
+
+ INTEGER IP_CPUTIME_EXCEEDED
+ PARAMETER( IP_CPUTIME_EXCEEDED = -4 )
+
+ INTEGER IP_NOT_ENOUGH_DEGREES_OF_FRE
+ PARAMETER( IP_NOT_ENOUGH_DEGREES_OF_FRE = -10 )
+
+ INTEGER IP_INVALID_PROBLEM_DEFINITION
+ PARAMETER( IP_INVALID_PROBLEM_DEFINITION = -11)
+
+ INTEGER IP_INVALID_OPTION
+ PARAMETER( IP_INVALID_OPTION = -12 )
+
+ INTEGER IP_INVALID_NUMBER_DETECTED
+ PARAMETER( IP_INVALID_NUMBER_DETECTED = -13 )
+
+ INTEGER IP_UNRECOVERABLE_EXCEPTION
+ PARAMETER( IP_UNRECOVERABLE_EXCEPTION = -100 )
+
+ INTEGER IP_NON_IPOPT_EXCEPTION
+ PARAMETER( IP_NON_IPOPT_EXCEPTION = -101 )
+
+ INTEGER IP_INSUFFICIENT_MEMORY
+ PARAMETER( IP_INSUFFICIENT_MEMORY = -102 )
+
+ INTEGER IP_INTERNAL_ERROR
+ PARAMETER( IP_INTERNAL_ERROR = -199 )
+
+ INTEGER IP_REGULAR_MODE
+ PARAMETER( IP_REGULAR_MODE = 0 )
+
+ INTEGER IP_RESTORATION_PHASE_MODE
+ PARAMETER( IP_RESTORATION_PHASE_MODE = 1 )
diff --git a/thirdparty/windows/include/coin/IpReturnCodes_inc.h b/thirdparty/windows/include/coin/IpReturnCodes_inc.h index 2de94bb..8a9b228 100644 --- a/thirdparty/windows/include/coin/IpReturnCodes_inc.h +++ b/thirdparty/windows/include/coin/IpReturnCodes_inc.h @@ -1,46 +1,46 @@ -/*********************************************************************** -// Copyright (C) 2004, 2009 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpReturnCodes_inc.h 1430 2009-04-20 20:58:25Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 -************************************************************************/ - -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ -/* !!!!!!!!!!!!!!!! REMEMBER TO UPDATE IpReturnCodes.inc !!!!!!!!!!!!!!!! */ -/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ - -/** Return codes for the Optimize call for an application */ -enum ApplicationReturnStatus - { - Solve_Succeeded=0, - Solved_To_Acceptable_Level=1, - Infeasible_Problem_Detected=2, - Search_Direction_Becomes_Too_Small=3, - Diverging_Iterates=4, - User_Requested_Stop=5, - Feasible_Point_Found=6, - - Maximum_Iterations_Exceeded=-1, - Restoration_Failed=-2, - Error_In_Step_Computation=-3, - Maximum_CpuTime_Exceeded=-4, - Not_Enough_Degrees_Of_Freedom=-10, - Invalid_Problem_Definition=-11, - Invalid_Option=-12, - Invalid_Number_Detected=-13, - - Unrecoverable_Exception=-100, - NonIpopt_Exception_Thrown=-101, - Insufficient_Memory=-102, - Internal_Error=-199 - }; - -/** enum to indicate the mode in which the algorithm is */ -enum AlgorithmMode - { - RegularMode=0, - RestorationPhaseMode=1 - }; +/***********************************************************************
+// Copyright (C) 2004, 2009 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpReturnCodes_inc.h 2216 2013-04-14 17:06:00Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+************************************************************************/
+
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+/* !!!!!!!!! REMEMBER TO UPDATE IpReturnCodes.inc and Ipopt.java !!!!!!!! */
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
+/** Return codes for the Optimize call for an application */
+enum ApplicationReturnStatus
+ {
+ Solve_Succeeded=0,
+ Solved_To_Acceptable_Level=1,
+ Infeasible_Problem_Detected=2,
+ Search_Direction_Becomes_Too_Small=3,
+ Diverging_Iterates=4,
+ User_Requested_Stop=5,
+ Feasible_Point_Found=6,
+
+ Maximum_Iterations_Exceeded=-1,
+ Restoration_Failed=-2,
+ Error_In_Step_Computation=-3,
+ Maximum_CpuTime_Exceeded=-4,
+ Not_Enough_Degrees_Of_Freedom=-10,
+ Invalid_Problem_Definition=-11,
+ Invalid_Option=-12,
+ Invalid_Number_Detected=-13,
+
+ Unrecoverable_Exception=-100,
+ NonIpopt_Exception_Thrown=-101,
+ Insufficient_Memory=-102,
+ Internal_Error=-199
+ };
+
+/** enum to indicate the mode in which the algorithm is */
+enum AlgorithmMode
+ {
+ RegularMode=0,
+ RestorationPhaseMode=1
+ };
diff --git a/thirdparty/windows/include/coin/IpSmartPtr.hpp b/thirdparty/windows/include/coin/IpSmartPtr.hpp index ef7e705..263fddf 100644 --- a/thirdparty/windows/include/coin/IpSmartPtr.hpp +++ b/thirdparty/windows/include/coin/IpSmartPtr.hpp @@ -1,670 +1,734 @@ -// Copyright (C) 2004, 2007 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpSmartPtr.hpp 1019 2007-06-24 03:52:34Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPSMARTPTR_HPP__ -#define __IPSMARTPTR_HPP__ - -#include "IpReferenced.hpp" - -#include "IpDebug.hpp" -#if COIN_IPOPT_CHECKLEVEL > 2 -# define IP_DEBUG_SMARTPTR -#endif - -namespace Ipopt -{ - - /** Template class for Smart Pointers. - * A SmartPtr behaves much like a raw pointer, but manages the lifetime - * of an object, deleting the object automatically. This class implements - * a reference-counting, intrusive smart pointer design, where all - * objects pointed to must inherit off of ReferencedObject, which - * stores the reference count. Although this is intrusive (native types - * and externally authored classes require wrappers to be referenced - * by smart pointers), it is a safer design. A more detailed discussion of - * these issues follows after the usage information. - * - * Usage Example: - * Note: to use the SmartPtr, all objects to which you point MUST - * inherit off of ReferencedObject. - * - * \verbatim - * - * In MyClass.hpp... - * - * #include "IpReferenced.hpp" - - * namespace Ipopt { - * - * class MyClass : public ReferencedObject // must derive from ReferencedObject - * { - * ... - * } - * } // namespace Ipopt - * - * - * In my_usage.cpp... - * - * #include "IpSmartPtr.hpp" - * #include "MyClass.hpp" - * - * void func(AnyObject& obj) - * { - * SmartPtr<MyClass> ptr_to_myclass = new MyClass(...); - * // ptr_to_myclass now points to a new MyClass, - * // and the reference count is 1 - * - * ... - * - * obj.SetMyClass(ptr_to_myclass); - * // Here, let's assume that AnyObject uses a - * // SmartPtr<MyClass> internally here. - * // Now, both ptr_to_myclass and the internal - * // SmartPtr in obj point to the same MyClass object - * // and its reference count is 2. - * - * ... - * - * // No need to delete ptr_to_myclass, this - * // will be done automatically when the - * // reference count drops to zero. - * - * } - * - * \endverbatim - * - * It is not necessary to use SmartPtr's in all cases where an - * object is used that has been allocated "into" a SmartPtr. It is - * possible to just pass objects by reference or regular pointers, - * even if lower down in the stack a SmartPtr is to be held on to. - * Everything should work fine as long as a pointer created by "new" - * is immediately passed into a SmartPtr, and if SmartPtr's are used - * to hold on to objects. - * - * Other Notes: - * The SmartPtr implements both dereference operators -> & *. - * The SmartPtr does NOT implement a conversion operator to - * the raw pointer. Use the GetRawPtr() method when this - * is necessary. Make sure that the raw pointer is NOT - * deleted. - * The SmartPtr implements the comparison operators == & != - * for a variety of types. Use these instead of - * \verbatim - * if (GetRawPtr(smrt_ptr) == ptr) // Don't use this - * \endverbatim - * SmartPtr's, as currently implemented, do NOT handle circular references. - * For example: consider a higher level object using SmartPtrs to point to - * A and B, but A and B also point to each other (i.e. A has a SmartPtr - * to B and B has a SmartPtr to A). In this scenario, when the higher - * level object is finished with A and B, their reference counts will - * never drop to zero (since they reference each other) and they - * will not be deleted. This can be detected by memory leak tools like - * valgrind. If the circular reference is necessary, the problem can be - * overcome by a number of techniques: - * - * 1) A and B can have a method that "releases" each other, that is - * they set their internal SmartPtrs to NULL. - * \verbatim - * void AClass::ReleaseCircularReferences() - * { - * smart_ptr_to_B = NULL; - * } - * \endverbatim - * Then, the higher level class can call these methods before - * it is done using A & B. - * - * 2) Raw pointers can be used in A and B to reference each other. - * Here, an implicit assumption is made that the lifetime is - * controlled by the higher level object and that A and B will - * both exist in a controlled manner. Although this seems - * dangerous, in many situations, this type of referencing - * is very controlled and this is reasonably safe. - * - * 3) This SmartPtr class could be redesigned with the Weak/Strong - * design concept. Here, the SmartPtr is identified as being - * Strong (controls lifetime of the object) or Weak (merely - * referencing the object). The Strong SmartPtr increments - * (and decrements) the reference count in ReferencedObject - * but the Weak SmartPtr does not. In the example above, - * the higher level object would have Strong SmartPtrs to - * A and B, but A and B would have Weak SmartPtrs to each - * other. Then, when the higher level object was done with - * A and B, they would be deleted. The Weak SmartPtrs in A - * and B would not decrement the reference count and would, - * of course, not delete the object. This idea is very similar - * to item (2), where it is implied that the sequence of events - * is controlled such that A and B will not call anything using - * their pointers following the higher level delete (i.e. in - * their destructors!). This is somehow safer, however, because - * code can be written (however expensive) to perform run-time - * detection of this situation. For example, the ReferencedObject - * could store pointers to all Weak SmartPtrs that are referencing - * it and, in its destructor, tell these pointers that it is - * dying. They could then set themselves to NULL, or set an - * internal flag to detect usage past this point. - * - * Comments on Non-Intrusive Design: - * In a non-intrusive design, the reference count is stored somewhere other - * than the object being referenced. This means, unless the reference - * counting pointer is the first referencer, it must get a pointer to the - * referenced object from another smart pointer (so it has access to the - * reference count location). In this non-intrusive design, if we are - * pointing to an object with a smart pointer (or a number of smart - * pointers), and we then give another smart pointer the address through - * a RAW pointer, we will have two independent, AND INCORRECT, reference - * counts. To avoid this pitfall, we use an intrusive reference counting - * technique where the reference count is stored in the object being - * referenced. - */ - template<class T> - class SmartPtr : public Referencer - { - public: -#define dbg_smartptr_verbosity 0 - - /**@name Constructors/Destructors */ - //@{ - /** Default constructor, initialized to NULL */ - SmartPtr(); - - /** Copy constructor, initialized from copy */ - SmartPtr(const SmartPtr<T>& copy); - - /** Constructor, initialized from T* ptr */ - SmartPtr(T* ptr); - - /** Destructor, automatically decrements the - * reference count, deletes the object if - * necessary.*/ - ~SmartPtr(); - //@} - - /**@name Overloaded operators. */ - //@{ - /** Overloaded arrow operator, allows the user to call - * methods using the contained pointer. */ - T* operator->() const; - - /** Overloaded dereference operator, allows the user - * to dereference the contained pointer. */ - T& operator*() const; - - /** Overloaded equals operator, allows the user to - * set the value of the SmartPtr from a raw pointer */ - SmartPtr<T>& operator=(T* rhs); - - /** Overloaded equals operator, allows the user to - * set the value of the SmartPtr from another - * SmartPtr */ - SmartPtr<T>& operator=(const SmartPtr<T>& rhs); - - /** Overloaded equality comparison operator, allows the - * user to compare the value of two SmartPtrs */ - template <class U1, class U2> - friend - bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs); - - /** Overloaded equality comparison operator, allows the - * user to compare the value of a SmartPtr with a raw pointer. */ - template <class U1, class U2> - friend - bool operator==(const SmartPtr<U1>& lhs, U2* raw_rhs); - - /** Overloaded equality comparison operator, allows the - * user to compare the value of a raw pointer with a SmartPtr. */ - template <class U1, class U2> - friend - bool operator==(U1* lhs, const SmartPtr<U2>& raw_rhs); - - /** Overloaded in-equality comparison operator, allows the - * user to compare the value of two SmartPtrs */ - template <class U1, class U2> - friend - bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs); - - /** Overloaded in-equality comparison operator, allows the - * user to compare the value of a SmartPtr with a raw pointer. */ - template <class U1, class U2> - friend - bool operator!=(const SmartPtr<U1>& lhs, U2* raw_rhs); - - /** Overloaded in-equality comparison operator, allows the - * user to compare the value of a SmartPtr with a raw pointer. */ - template <class U1, class U2> - friend - bool operator!=(U1* lhs, const SmartPtr<U2>& raw_rhs); - //@} - - /**@name friend method declarations. */ - //@{ - /** Returns the raw pointer contained. - * Use to get the value of - * the raw ptr (i.e. to pass to other - * methods/functions, etc.) - * Note: This method does NOT copy, - * therefore, modifications using this - * value modify the underlying object - * contained by the SmartPtr, - * NEVER delete this returned value. - */ - template <class U> - friend - U* GetRawPtr(const SmartPtr<U>& smart_ptr); - - /** Returns a const pointer */ - template <class U> - friend - SmartPtr<const U> ConstPtr(const SmartPtr<U>& smart_ptr); - - /** Returns true if the SmartPtr is NOT NULL. - * Use this to check if the SmartPtr is not null - * This is preferred to if(GetRawPtr(sp) != NULL) - */ - template <class U> - friend - bool IsValid(const SmartPtr<U>& smart_ptr); - - /** Returns true if the SmartPtr is NULL. - * Use this to check if the SmartPtr IsNull. - * This is preferred to if(GetRawPtr(sp) == NULL) - */ - template <class U> - friend - bool IsNull(const SmartPtr<U>& smart_ptr); - //@} - - private: - /**@name Private Data/Methods */ - //@{ - /** Actual raw pointer to the object. */ - T* ptr_; - - /** Set the value of the internal raw pointer - * from another raw pointer, releasing the - * previously referenced object if necessary. */ - SmartPtr<T>& SetFromRawPtr_(T* rhs); - - /** Set the value of the internal raw pointer - * from a SmartPtr, releasing the previously referenced - * object if necessary. */ - SmartPtr<T>& SetFromSmartPtr_(const SmartPtr<T>& rhs); - - /** Release the currently referenced object. */ - void ReleasePointer_(); - //@} - }; - - /**@name SmartPtr friend function declarations.*/ - //@{ - template <class U> - U* GetRawPtr(const SmartPtr<U>& smart_ptr); - - template <class U> - SmartPtr<const U> ConstPtr(const SmartPtr<U>& smart_ptr); - - template <class U> - bool IsNull(const SmartPtr<U>& smart_ptr); - - template <class U> - bool IsValid(const SmartPtr<U>& smart_ptr); - - template <class U1, class U2> - bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs); - - template <class U1, class U2> - bool operator==(const SmartPtr<U1>& lhs, U2* raw_rhs); - - template <class U1, class U2> - bool operator==(U1* lhs, const SmartPtr<U2>& raw_rhs); - - template <class U1, class U2> - bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs); - - template <class U1, class U2> - bool operator!=(const SmartPtr<U1>& lhs, U2* raw_rhs); - - template <class U1, class U2> - bool operator!=(U1* lhs, const SmartPtr<U2>& raw_rhs); - - //@} - - - template <class T> - SmartPtr<T>::SmartPtr() - : - ptr_(NULL) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_METH("SmartPtr<T>::SmartPtr()", dbg_smartptr_verbosity); -#endif - -#ifdef CHECK_SMARTPTR - - const ReferencedObject* trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ - = ptr_; - trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = NULL; -#endif - - } - - - template <class T> - SmartPtr<T>::SmartPtr(const SmartPtr<T>& copy) - : - ptr_(NULL) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_METH("SmartPtr<T>::SmartPtr(const SmartPtr<T>& copy)", dbg_smartptr_verbosity); -#endif - -#ifdef CHECK_SMARTPTR - - const ReferencedObject* trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ - = ptr_; - trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = NULL; -#endif - - (void) SetFromSmartPtr_(copy); - } - - - template <class T> - SmartPtr<T>::SmartPtr(T* ptr) - : - ptr_(NULL) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_METH("SmartPtr<T>::SmartPtr(T* ptr)", dbg_smartptr_verbosity); -#endif - -#ifdef CHECK_SMARTPTR - - const ReferencedObject* trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ - = ptr_; - trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = NULL; -#endif - - (void) SetFromRawPtr_(ptr); - } - - template <class T> - SmartPtr<T>::~SmartPtr() - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_METH("SmartPtr<T>::~SmartPtr(T* ptr)", dbg_smartptr_verbosity); -#endif - - ReleasePointer_(); - } - - - template <class T> - T* SmartPtr<T>::operator->() const - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_METH("T* SmartPtr<T>::operator->()", dbg_smartptr_verbosity); -#endif - - // cannot deref a null pointer -#if COIN_IPOPT_CHECKLEVEL > 0 - - assert(ptr_); -#endif - - return ptr_; - } - - - template <class T> - T& SmartPtr<T>::operator*() const - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_METH("T& SmartPtr<T>::operator*()", dbg_smartptr_verbosity); -#endif - - // cannot dereference a null pointer -#if COIN_IPOPT_CHECKLEVEL > 0 - - assert(ptr_); -#endif - - return *ptr_; - } - - - template <class T> - SmartPtr<T>& SmartPtr<T>::operator=(T* rhs) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_METH("SmartPtr<T>& SmartPtr<T>::operator=(T* rhs)", dbg_smartptr_verbosity); -#endif - - return SetFromRawPtr_(rhs); - } - - - template <class T> - SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<T>& rhs) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_METH( - "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<T>& rhs)", - dbg_smartptr_verbosity); -#endif - - return SetFromSmartPtr_(rhs); - } - - - template <class T> - SmartPtr<T>& SmartPtr<T>::SetFromRawPtr_(T* rhs) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_METH( - "SmartPtr<T>& SmartPtr<T>::SetFromRawPtr_(T* rhs)", dbg_smartptr_verbosity); -#endif - - // Release any old pointer - ReleasePointer_(); - - if (rhs != NULL) { - rhs->AddRef(this); - ptr_ = rhs; - } - - return *this; - } - - template <class T> - SmartPtr<T>& SmartPtr<T>::SetFromSmartPtr_(const SmartPtr<T>& rhs) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_METH( - "SmartPtr<T>& SmartPtr<T>::SetFromSmartPtr_(const SmartPtr<T>& rhs)", - dbg_smartptr_verbosity); -#endif - - T* ptr = GetRawPtr(rhs); - /* AW: I changed this so that NULL is correctly copied from the - right hand side */ - // if (ptr != NULL) { - // SetFromRawPtr_(ptr); - // } - SetFromRawPtr_(ptr); - - return (*this); - } - - - template <class T> - void SmartPtr<T>::ReleasePointer_() - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_METH( - "void SmartPtr<T>::ReleasePointer()", - dbg_smartptr_verbosity); -#endif - - if (ptr_) { - ptr_->ReleaseRef(this); - if (ptr_->ReferenceCount() == 0) { - delete ptr_; - } - ptr_ = NULL; - } - } - - - template <class U> - U* GetRawPtr(const SmartPtr<U>& smart_ptr) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_FUN( - "T* GetRawPtr(const SmartPtr<T>& smart_ptr)", - 0); -#endif - - return smart_ptr.ptr_; - } - - template <class U> - SmartPtr<const U> ConstPtr(const SmartPtr<U>& smart_ptr) - { - // compiler should implicitly cast - return GetRawPtr(smart_ptr); - } - - template <class U> - bool IsValid(const SmartPtr<U>& smart_ptr) - { - return !IsNull(smart_ptr); - } - - template <class U> - bool IsNull(const SmartPtr<U>& smart_ptr) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_FUN( - "bool IsNull(const SmartPtr<T>& smart_ptr)", - 0); -#endif - - return (smart_ptr.ptr_ == NULL); - } - - - template <class U1, class U2> - bool ComparePointers(const U1* lhs, const U2* rhs) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_FUN( - "bool ComparePtrs(const U1* lhs, const U2* rhs)", - dbg_smartptr_verbosity); -#endif - - if (lhs == rhs) { - return true; - } - - // Even if lhs and rhs point to the same object - // with different interfaces U1 and U2, we cannot guarantee that - // the value of the pointers will be equivalent. We can - // guarantee this if we convert to void* - const void* v_lhs = static_cast<const void*>(lhs); - const void* v_rhs = static_cast<const void*>(rhs); - if (v_lhs == v_rhs) { - return true; - } - - // They must not be the same - return false; - } - - template <class U1, class U2> - bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_FUN( - "bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)", - dbg_smartptr_verbosity); -#endif - - U1* raw_lhs = GetRawPtr(lhs); - U2* raw_rhs = GetRawPtr(rhs); - return ComparePointers(raw_lhs, raw_rhs); - } - - template <class U1, class U2> - bool operator==(const SmartPtr<U1>& lhs, U2* raw_rhs) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_FUN( - "bool operator==(SmartPtr<U1>& lhs, U2* rhs)", - dbg_smartptr_verbosity); -#endif - - U1* raw_lhs = GetRawPtr(lhs); - return ComparePointers(raw_lhs, raw_rhs); - } - - template <class U1, class U2> - bool operator==(U1* raw_lhs, const SmartPtr<U2>& rhs) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_FUN( - "bool operator==(U1* raw_lhs, SmartPtr<U2>& rhs)", - dbg_smartptr_verbosity); -#endif - - const U2* raw_rhs = GetRawPtr(rhs); - return ComparePointers(raw_lhs, raw_rhs); - } - - template <class U1, class U2> - bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_FUN( - "bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)", - dbg_smartptr_verbosity); -#endif - - bool retValue = operator==(lhs, rhs); - return !retValue; - } - - template <class U1, class U2> - bool operator!=(const SmartPtr<U1>& lhs, U2* raw_rhs) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_FUN( - "bool operator!=(SmartPtr<U1>& lhs, U2* rhs)", - dbg_smartptr_verbosity); -#endif - - bool retValue = operator==(lhs, raw_rhs); - return !retValue; - } - - template <class U1, class U2> - bool operator!=(U1* raw_lhs, const SmartPtr<U2>& rhs) - { -#ifdef IP_DEBUG_SMARTPTR - DBG_START_FUN( - "bool operator!=(U1* raw_lhs, SmartPtr<U2>& rhs)", - dbg_smartptr_verbosity); -#endif - - bool retValue = operator==(raw_lhs, rhs); - return !retValue; - } - -} // namespace Ipopt - -#endif - +// Copyright (C) 2004, 2011 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpSmartPtr.hpp 2182 2013-03-30 20:02:18Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPSMARTPTR_HPP__
+#define __IPSMARTPTR_HPP__
+
+#include "IpReferenced.hpp"
+
+#include "IpDebug.hpp"
+#if COIN_IPOPT_CHECKLEVEL > 2
+# define IP_DEBUG_SMARTPTR
+#endif
+#ifndef IPOPT_UNUSED
+# if defined(__GNUC__)
+# define IPOPT_UNUSED __attribute__((unused))
+# else
+# define IPOPT_UNUSED
+# endif
+#endif
+
+namespace Ipopt
+{
+
+ /** Template class for Smart Pointers.
+ * A SmartPtr behaves much like a raw pointer, but manages the lifetime
+ * of an object, deleting the object automatically. This class implements
+ * a reference-counting, intrusive smart pointer design, where all
+ * objects pointed to must inherit off of ReferencedObject, which
+ * stores the reference count. Although this is intrusive (native types
+ * and externally authored classes require wrappers to be referenced
+ * by smart pointers), it is a safer design. A more detailed discussion of
+ * these issues follows after the usage information.
+ *
+ * Usage Example:
+ * Note: to use the SmartPtr, all objects to which you point MUST
+ * inherit off of ReferencedObject.
+ *
+ * \verbatim
+ *
+ * In MyClass.hpp...
+ *
+ * #include "IpReferenced.hpp"
+
+ * namespace Ipopt {
+ *
+ * class MyClass : public ReferencedObject // must derive from ReferencedObject
+ * {
+ * ...
+ * }
+ * } // namespace Ipopt
+ *
+ *
+ * In my_usage.cpp...
+ *
+ * #include "IpSmartPtr.hpp"
+ * #include "MyClass.hpp"
+ *
+ * void func(AnyObject& obj)
+ * {
+ * SmartPtr<MyClass> ptr_to_myclass = new MyClass(...);
+ * // ptr_to_myclass now points to a new MyClass,
+ * // and the reference count is 1
+ *
+ * ...
+ *
+ * obj.SetMyClass(ptr_to_myclass);
+ * // Here, let's assume that AnyObject uses a
+ * // SmartPtr<MyClass> internally here.
+ * // Now, both ptr_to_myclass and the internal
+ * // SmartPtr in obj point to the same MyClass object
+ * // and its reference count is 2.
+ *
+ * ...
+ *
+ * // No need to delete ptr_to_myclass, this
+ * // will be done automatically when the
+ * // reference count drops to zero.
+ *
+ * }
+ *
+ * \endverbatim
+ *
+ * It is not necessary to use SmartPtr's in all cases where an
+ * object is used that has been allocated "into" a SmartPtr. It is
+ * possible to just pass objects by reference or regular pointers,
+ * even if lower down in the stack a SmartPtr is to be held on to.
+ * Everything should work fine as long as a pointer created by "new"
+ * is immediately passed into a SmartPtr, and if SmartPtr's are used
+ * to hold on to objects.
+ *
+ * Other Notes:
+ * The SmartPtr implements both dereference operators -> & *.
+ * The SmartPtr does NOT implement a conversion operator to
+ * the raw pointer. Use the GetRawPtr() method when this
+ * is necessary. Make sure that the raw pointer is NOT
+ * deleted.
+ * The SmartPtr implements the comparison operators == & !=
+ * for a variety of types. Use these instead of
+ * \verbatim
+ * if (GetRawPtr(smrt_ptr) == ptr) // Don't use this
+ * \endverbatim
+ * SmartPtr's, as currently implemented, do NOT handle circular references.
+ * For example: consider a higher level object using SmartPtrs to point to
+ * A and B, but A and B also point to each other (i.e. A has a SmartPtr
+ * to B and B has a SmartPtr to A). In this scenario, when the higher
+ * level object is finished with A and B, their reference counts will
+ * never drop to zero (since they reference each other) and they
+ * will not be deleted. This can be detected by memory leak tools like
+ * valgrind. If the circular reference is necessary, the problem can be
+ * overcome by a number of techniques:
+ *
+ * 1) A and B can have a method that "releases" each other, that is
+ * they set their internal SmartPtrs to NULL.
+ * \verbatim
+ * void AClass::ReleaseCircularReferences()
+ * {
+ * smart_ptr_to_B = NULL;
+ * }
+ * \endverbatim
+ * Then, the higher level class can call these methods before
+ * it is done using A & B.
+ *
+ * 2) Raw pointers can be used in A and B to reference each other.
+ * Here, an implicit assumption is made that the lifetime is
+ * controlled by the higher level object and that A and B will
+ * both exist in a controlled manner. Although this seems
+ * dangerous, in many situations, this type of referencing
+ * is very controlled and this is reasonably safe.
+ *
+ * 3) This SmartPtr class could be redesigned with the Weak/Strong
+ * design concept. Here, the SmartPtr is identified as being
+ * Strong (controls lifetime of the object) or Weak (merely
+ * referencing the object). The Strong SmartPtr increments
+ * (and decrements) the reference count in ReferencedObject
+ * but the Weak SmartPtr does not. In the example above,
+ * the higher level object would have Strong SmartPtrs to
+ * A and B, but A and B would have Weak SmartPtrs to each
+ * other. Then, when the higher level object was done with
+ * A and B, they would be deleted. The Weak SmartPtrs in A
+ * and B would not decrement the reference count and would,
+ * of course, not delete the object. This idea is very similar
+ * to item (2), where it is implied that the sequence of events
+ * is controlled such that A and B will not call anything using
+ * their pointers following the higher level delete (i.e. in
+ * their destructors!). This is somehow safer, however, because
+ * code can be written (however expensive) to perform run-time
+ * detection of this situation. For example, the ReferencedObject
+ * could store pointers to all Weak SmartPtrs that are referencing
+ * it and, in its destructor, tell these pointers that it is
+ * dying. They could then set themselves to NULL, or set an
+ * internal flag to detect usage past this point.
+ *
+ * Comments on Non-Intrusive Design:
+ * In a non-intrusive design, the reference count is stored somewhere other
+ * than the object being referenced. This means, unless the reference
+ * counting pointer is the first referencer, it must get a pointer to the
+ * referenced object from another smart pointer (so it has access to the
+ * reference count location). In this non-intrusive design, if we are
+ * pointing to an object with a smart pointer (or a number of smart
+ * pointers), and we then give another smart pointer the address through
+ * a RAW pointer, we will have two independent, AND INCORRECT, reference
+ * counts. To avoid this pitfall, we use an intrusive reference counting
+ * technique where the reference count is stored in the object being
+ * referenced.
+ */
+ template<class T>
+ class SmartPtr : public Referencer
+ {
+ public:
+#define ipopt_dbg_smartptr_verbosity 0
+
+ /**@name Constructors/Destructors */
+ //@{
+ /** Default constructor, initialized to NULL */
+ SmartPtr();
+
+ /** Copy constructor, initialized from copy of type T */
+ SmartPtr(const SmartPtr<T>& copy);
+
+ /** Copy constructor, initialized from copy of type U */
+ template <class U>
+ SmartPtr(const SmartPtr<U>& copy);
+
+ /** Constructor, initialized from T* ptr */
+ SmartPtr(T* ptr);
+
+ /** Destructor, automatically decrements the
+ * reference count, deletes the object if
+ * necessary.*/
+ ~SmartPtr();
+ //@}
+
+ /**@name Overloaded operators. */
+ //@{
+ /** Overloaded arrow operator, allows the user to call
+ * methods using the contained pointer. */
+ T* operator->() const;
+
+ /** Overloaded dereference operator, allows the user
+ * to dereference the contained pointer. */
+ T& operator*() const;
+
+ /** Overloaded equals operator, allows the user to
+ * set the value of the SmartPtr from a raw pointer */
+ SmartPtr<T>& operator=(T* rhs);
+
+ /** Overloaded equals operator, allows the user to
+ * set the value of the SmartPtr from another
+ * SmartPtr */
+ SmartPtr<T>& operator=(const SmartPtr<T>& rhs);
+
+ /** Overloaded equals operator, allows the user to
+ * set the value of the SmartPtr from another
+ * SmartPtr of a different type */
+ template <class U>
+ SmartPtr<T>& operator=(const SmartPtr<U>& rhs);
+
+ /** Overloaded equality comparison operator, allows the
+ * user to compare the value of two SmartPtrs */
+ template <class U1, class U2>
+ friend
+ bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs);
+
+ /** Overloaded equality comparison operator, allows the
+ * user to compare the value of a SmartPtr with a raw pointer. */
+ template <class U1, class U2>
+ friend
+ bool operator==(const SmartPtr<U1>& lhs, U2* raw_rhs);
+
+ /** Overloaded equality comparison operator, allows the
+ * user to compare the value of a raw pointer with a SmartPtr. */
+ template <class U1, class U2>
+ friend
+ bool operator==(U1* lhs, const SmartPtr<U2>& raw_rhs);
+
+ /** Overloaded in-equality comparison operator, allows the
+ * user to compare the value of two SmartPtrs */
+ template <class U1, class U2>
+ friend
+ bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs);
+
+ /** Overloaded in-equality comparison operator, allows the
+ * user to compare the value of a SmartPtr with a raw pointer. */
+ template <class U1, class U2>
+ friend
+ bool operator!=(const SmartPtr<U1>& lhs, U2* raw_rhs);
+
+ /** Overloaded in-equality comparison operator, allows the
+ * user to compare the value of a SmartPtr with a raw pointer. */
+ template <class U1, class U2>
+ friend
+ bool operator!=(U1* lhs, const SmartPtr<U2>& raw_rhs);
+
+ /** Overloaded less-than comparison operator, allows the
+ * user to compare the value of two SmartPtrs */
+ template <class U>
+ friend
+ bool operator<(const SmartPtr<U>& lhs, const SmartPtr<U>& rhs);
+ //@}
+
+ /**@name friend method declarations. */
+ //@{
+ /** Returns the raw pointer contained.
+ * Use to get the value of
+ * the raw ptr (i.e. to pass to other
+ * methods/functions, etc.)
+ * Note: This method does NOT copy,
+ * therefore, modifications using this
+ * value modify the underlying object
+ * contained by the SmartPtr,
+ * NEVER delete this returned value.
+ */
+ template <class U>
+ friend
+ U* GetRawPtr(const SmartPtr<U>& smart_ptr);
+
+ /** Returns a const pointer */
+ template <class U>
+ friend
+ SmartPtr<const U> ConstPtr(const SmartPtr<U>& smart_ptr);
+
+ /** Returns true if the SmartPtr is NOT NULL.
+ * Use this to check if the SmartPtr is not null
+ * This is preferred to if(GetRawPtr(sp) != NULL)
+ */
+ template <class U>
+ friend
+ bool IsValid(const SmartPtr<U>& smart_ptr);
+
+ /** Returns true if the SmartPtr is NULL.
+ * Use this to check if the SmartPtr IsNull.
+ * This is preferred to if(GetRawPtr(sp) == NULL)
+ */
+ template <class U>
+ friend
+ bool IsNull(const SmartPtr<U>& smart_ptr);
+ //@}
+
+ private:
+ /**@name Private Data/Methods */
+ //@{
+ /** Actual raw pointer to the object. */
+ T* ptr_;
+
+ /** Set the value of the internal raw pointer
+ * from another raw pointer, releasing the
+ * previously referenced object if necessary. */
+ SmartPtr<T>& SetFromRawPtr_(T* rhs);
+
+ /** Set the value of the internal raw pointer
+ * from a SmartPtr, releasing the previously referenced
+ * object if necessary. */
+ SmartPtr<T>& SetFromSmartPtr_(const SmartPtr<T>& rhs);
+
+ /** Release the currently referenced object. */
+ void ReleasePointer_();
+ //@}
+ };
+
+ /**@name SmartPtr friend function declarations.*/
+ //@{
+ template <class U>
+ U* GetRawPtr(const SmartPtr<U>& smart_ptr);
+
+ template <class U>
+ SmartPtr<const U> ConstPtr(const SmartPtr<U>& smart_ptr);
+
+ template <class U>
+ bool IsNull(const SmartPtr<U>& smart_ptr);
+
+ template <class U>
+ bool IsValid(const SmartPtr<U>& smart_ptr);
+
+ template <class U1, class U2>
+ bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs);
+
+ template <class U1, class U2>
+ bool operator==(const SmartPtr<U1>& lhs, U2* raw_rhs);
+
+ template <class U1, class U2>
+ bool operator==(U1* lhs, const SmartPtr<U2>& raw_rhs);
+
+ template <class U1, class U2>
+ bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs);
+
+ template <class U1, class U2>
+ bool operator!=(const SmartPtr<U1>& lhs, U2* raw_rhs);
+
+ template <class U1, class U2>
+ bool operator!=(U1* lhs, const SmartPtr<U2>& raw_rhs);
+
+ //@}
+
+
+ template <class T>
+ SmartPtr<T>::SmartPtr()
+ :
+ ptr_(0)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH("SmartPtr<T>::SmartPtr()", ipopt_dbg_smartptr_verbosity);
+#endif
+
+#ifndef NDEBUG
+ const ReferencedObject* IPOPT_UNUSED trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = ptr_;
+#endif
+
+ }
+
+
+ template <class T>
+ SmartPtr<T>::SmartPtr(const SmartPtr<T>& copy)
+ :
+ ptr_(0)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH("SmartPtr<T>::SmartPtr(const SmartPtr<T>& copy)", ipopt_dbg_smartptr_verbosity);
+#endif
+
+#ifndef NDEBUG
+ const ReferencedObject* IPOPT_UNUSED trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = ptr_;
+#endif
+
+ (void) SetFromSmartPtr_(copy);
+ }
+
+
+ template <class T>
+ template <class U>
+ SmartPtr<T>::SmartPtr(const SmartPtr<U>& copy)
+ :
+ ptr_(0)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH("SmartPtr<T>::SmartPtr(const SmartPtr<U>& copy)", ipopt_dbg_smartptr_verbosity);
+#endif
+
+#ifndef NDEBUG
+ const ReferencedObject* IPOPT_UNUSED trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = ptr_;
+#endif
+
+ (void) SetFromSmartPtr_(GetRawPtr(copy));
+ }
+
+
+ template <class T>
+ SmartPtr<T>::SmartPtr(T* ptr)
+ :
+ ptr_(0)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH("SmartPtr<T>::SmartPtr(T* ptr)", ipopt_dbg_smartptr_verbosity);
+#endif
+
+#ifndef NDEBUG
+ const ReferencedObject* IPOPT_UNUSED trying_to_use_SmartPtr_with_an_object_that_does_not_inherit_from_ReferencedObject_ = ptr_;
+#endif
+
+ (void) SetFromRawPtr_(ptr);
+ }
+
+ template <class T>
+ SmartPtr<T>::~SmartPtr()
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH("SmartPtr<T>::~SmartPtr(T* ptr)", ipopt_dbg_smartptr_verbosity);
+#endif
+
+ ReleasePointer_();
+ }
+
+
+ template <class T>
+ T* SmartPtr<T>::operator->() const
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH("T* SmartPtr<T>::operator->()", ipopt_dbg_smartptr_verbosity);
+#endif
+
+ // cannot deref a null pointer
+#if COIN_IPOPT_CHECKLEVEL > 0
+ assert(ptr_);
+#endif
+
+ return ptr_;
+ }
+
+
+ template <class T>
+ T& SmartPtr<T>::operator*() const
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH("T& SmartPtr<T>::operator*()", ipopt_dbg_smartptr_verbosity);
+#endif
+
+ // cannot dereference a null pointer
+#if COIN_IPOPT_CHECKLEVEL > 0
+ assert(ptr_);
+#endif
+
+ return *ptr_;
+ }
+
+
+ template <class T>
+ SmartPtr<T>& SmartPtr<T>::operator=(T* rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH("SmartPtr<T>& SmartPtr<T>::operator=(T* rhs)", ipopt_dbg_smartptr_verbosity);
+#endif
+
+ return SetFromRawPtr_(rhs);
+ }
+
+
+ template <class T>
+ SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<T>& rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH(
+ "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<T>& rhs)",
+ ipopt_dbg_smartptr_verbosity);
+#endif
+
+ return SetFromSmartPtr_(rhs);
+ }
+
+
+ template <class T>
+ template <class U>
+ SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<U>& rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH(
+ "SmartPtr<T>& SmartPtr<T>::operator=(const SmartPtr<U>& rhs)",
+ ipopt_dbg_smartptr_verbosity);
+#endif
+
+ return SetFromSmartPtr_(GetRawPtr(rhs));
+ }
+
+
+ template <class T>
+ SmartPtr<T>& SmartPtr<T>::SetFromRawPtr_(T* rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH(
+ "SmartPtr<T>& SmartPtr<T>::SetFromRawPtr_(T* rhs)", ipopt_dbg_smartptr_verbosity);
+#endif
+
+ if (rhs != 0)
+ rhs->AddRef(this);
+
+ // Release any old pointer
+ ReleasePointer_();
+
+ ptr_ = rhs;
+
+ return *this;
+ }
+
+ template <class T>
+ SmartPtr<T>& SmartPtr<T>::SetFromSmartPtr_(const SmartPtr<T>& rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH(
+ "SmartPtr<T>& SmartPtr<T>::SetFromSmartPtr_(const SmartPtr<T>& rhs)",
+ ipopt_dbg_smartptr_verbosity);
+#endif
+
+ SetFromRawPtr_(GetRawPtr(rhs));
+
+ return (*this);
+ }
+
+
+ template <class T>
+ void SmartPtr<T>::ReleasePointer_()
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_METH(
+ "void SmartPtr<T>::ReleasePointer()",
+ ipopt_dbg_smartptr_verbosity);
+#endif
+
+ if (ptr_) {
+ ptr_->ReleaseRef(this);
+ if (ptr_->ReferenceCount() == 0)
+ delete ptr_;
+ }
+ }
+
+
+ template <class U>
+ U* GetRawPtr(const SmartPtr<U>& smart_ptr)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_FUN(
+ "T* GetRawPtr(const SmartPtr<T>& smart_ptr)",
+ 0);
+#endif
+
+ return smart_ptr.ptr_;
+ }
+
+ template <class U>
+ SmartPtr<const U> ConstPtr(const SmartPtr<U>& smart_ptr)
+ {
+ // compiler should implicitly cast
+ return GetRawPtr(smart_ptr);
+ }
+
+ template <class U>
+ bool IsValid(const SmartPtr<U>& smart_ptr)
+ {
+ return !IsNull(smart_ptr);
+ }
+
+ template <class U>
+ bool IsNull(const SmartPtr<U>& smart_ptr)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_FUN(
+ "bool IsNull(const SmartPtr<T>& smart_ptr)",
+ 0);
+#endif
+
+ return (smart_ptr.ptr_ == 0);
+ }
+
+
+ template <class U1, class U2>
+ bool ComparePointers(const U1* lhs, const U2* rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_FUN(
+ "bool ComparePtrs(const U1* lhs, const U2* rhs)",
+ ipopt_dbg_smartptr_verbosity);
+#endif
+
+ // Even if lhs and rhs point to the same object
+ // with different interfaces U1 and U2, we cannot guarantee that
+ // the value of the pointers will be equivalent. We can
+ // guarantee this if we convert to ReferencedObject* (see also #162)
+ const ReferencedObject* v_lhs = lhs;
+ const ReferencedObject* v_rhs = rhs;
+
+ return v_lhs == v_rhs;
+ }
+
+ template <class U1, class U2>
+ bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_FUN(
+ "bool operator==(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
+ ipopt_dbg_smartptr_verbosity);
+#endif
+
+ U1* raw_lhs = GetRawPtr(lhs);
+ U2* raw_rhs = GetRawPtr(rhs);
+ return ComparePointers(raw_lhs, raw_rhs);
+ }
+
+ template <class U1, class U2>
+ bool operator==(const SmartPtr<U1>& lhs, U2* raw_rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_FUN(
+ "bool operator==(SmartPtr<U1>& lhs, U2* rhs)",
+ ipopt_dbg_smartptr_verbosity);
+#endif
+
+ U1* raw_lhs = GetRawPtr(lhs);
+ return ComparePointers(raw_lhs, raw_rhs);
+ }
+
+ template <class U1, class U2>
+ bool operator==(U1* raw_lhs, const SmartPtr<U2>& rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_FUN(
+ "bool operator==(U1* raw_lhs, SmartPtr<U2>& rhs)",
+ ipopt_dbg_smartptr_verbosity);
+#endif
+
+ const U2* raw_rhs = GetRawPtr(rhs);
+ return ComparePointers(raw_lhs, raw_rhs);
+ }
+
+ template <class U1, class U2>
+ bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_FUN(
+ "bool operator!=(const SmartPtr<U1>& lhs, const SmartPtr<U2>& rhs)",
+ ipopt_dbg_smartptr_verbosity);
+#endif
+
+ bool retValue = operator==(lhs, rhs);
+ return !retValue;
+ }
+
+ template <class U1, class U2>
+ bool operator!=(const SmartPtr<U1>& lhs, U2* raw_rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_FUN(
+ "bool operator!=(SmartPtr<U1>& lhs, U2* rhs)",
+ ipopt_dbg_smartptr_verbosity);
+#endif
+
+ bool retValue = operator==(lhs, raw_rhs);
+ return !retValue;
+ }
+
+ template <class U1, class U2>
+ bool operator!=(U1* raw_lhs, const SmartPtr<U2>& rhs)
+ {
+#ifdef IP_DEBUG_SMARTPTR
+ DBG_START_FUN(
+ "bool operator!=(U1* raw_lhs, SmartPtr<U2>& rhs)",
+ ipopt_dbg_smartptr_verbosity);
+#endif
+
+ bool retValue = operator==(raw_lhs, rhs);
+ return !retValue;
+ }
+
+ template <class T>
+ void swap(SmartPtr<T>& a, SmartPtr<T>& b)
+ {
+#ifdef IP_DEBUG_REFERENCED
+ SmartPtr<T> tmp(a);
+ a = b;
+ b = tmp;
+#else
+ std::swap(a.prt_, b.ptr_);
+#endif
+ }
+
+ template <class T>
+ bool operator<(const SmartPtr<T>& lhs, const SmartPtr<T>& rhs)
+ {
+ return lhs.ptr_ < rhs.ptr_;
+ }
+
+ template <class T>
+ bool operator> (const SmartPtr<T>& lhs, const SmartPtr<T>& rhs)
+ {
+ return rhs < lhs;
+ }
+
+ template <class T> bool
+ operator<=(const SmartPtr<T>& lhs, const SmartPtr<T>& rhs)
+ {
+ return !( rhs < lhs );
+ }
+
+ template <class T> bool
+ operator>=(const SmartPtr<T>& lhs, const SmartPtr<T>& rhs)
+ {
+ return !( lhs < rhs );
+ }
+} // namespace Ipopt
+
+#undef ipopt_dbg_smartptr_verbosity
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpSolveStatistics.hpp b/thirdparty/windows/include/coin/IpSolveStatistics.hpp index e248939..f4fa774 100644 --- a/thirdparty/windows/include/coin/IpSolveStatistics.hpp +++ b/thirdparty/windows/include/coin/IpSolveStatistics.hpp @@ -1,136 +1,150 @@ -// Copyright (C) 2005, 2006 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpSolveStatistics.hpp 1587 2009-10-27 16:09:21Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2005-08-15 - -#ifndef __IPSOLVESTATISTICS_HPP__ -#define __IPSOLVESTATISTICS_HPP__ - -#include "IpReferenced.hpp" -#include "IpSmartPtr.hpp" - -namespace Ipopt -{ - // forward declaration (to avoid inclusion of too many header files) - class IpoptNLP; - class IpoptData; - class IpoptCalculatedQuantities; - - /** This class collects statistics about an optimziation run, such - * as iteration count, final infeasibilities etc. It is meant to - * provide such information to a user of Ipopt during the - * finalize_solution call. - */ - class SolveStatistics : public ReferencedObject - { - public: - /**@name Constructors/Destructors */ - //@{ - /** Default constructor. It takes in those collecting Ipopt - * objects that can provide the statistics information. Those - * statistics are retrieved at the time of the constructor - * call. */ - SolveStatistics(const SmartPtr<IpoptNLP>& ip_nlp, - const SmartPtr<IpoptData>& ip_data, - const SmartPtr<IpoptCalculatedQuantities>& ip_cq); - - /** Default destructor */ - virtual ~SolveStatistics() - {} - //@} - - /** @name Accessor methods for retrieving different kind of solver - * statistics information */ - //@{ - /** Iteration counts. */ - virtual Index IterationCount() const; - /** Total CPU time, including function evaluations. */ - virtual Number TotalCPUTime() const; - /** Number of NLP function evaluations. */ - virtual void NumberOfEvaluations(Index& num_obj_evals, - Index& num_constr_evals, - Index& num_obj_grad_evals, - Index& num_constr_jac_evals, - Index& num_hess_evals) const; - /** Unscaled solution infeasibilities */ - virtual void Infeasibilities(Number& dual_inf, - Number& constr_viol, - Number& complementarity, - Number& kkt_error) const; - /** Scaled solution infeasibilities */ - virtual void ScaledInfeasibilities(Number& scaled_dual_inf, - Number& scaled_constr_viol, - Number& scaled_complementarity, - Number& scaled_kkt_error) const; - /** Final value of objective function */ - virtual Number FinalObjective() const; - /** Final scaled value of objective function */ - virtual Number FinalScaledObjective() 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 */ - SolveStatistics(); - - /** Copy Constructor */ - SolveStatistics(const SolveStatistics&); - - /** Overloaded Equals Operator */ - void operator=(const SolveStatistics&); - //@} - - /** @name Fields for storing the statistics data */ - //@{ - /** Number of iterations. */ - Index num_iters_; - /* Total CPU time */ - Number total_cpu_time_; - /** Number of objective function evaluations. */ - Index num_obj_evals_; - /** Number of constraints evaluations (max of equality and - * inequality) */ - Index num_constr_evals_; - /** Number of objective gradient evaluations. */ - Index num_obj_grad_evals_; - /** Number of constraint Jacobian evaluations. */ - Index num_constr_jac_evals_; - /** Number of Lagrangian Hessian evaluations. */ - Index num_hess_evals_; - - /** Final scaled value of objective function */ - Number scaled_obj_val_; - /** Final unscaled value of objective function */ - Number obj_val_; - /** Final scaled dual infeasibility (max-norm) */ - Number scaled_dual_inf_; - /** Final unscaled dual infeasibility (max-norm) */ - Number dual_inf_; - /** Final scaled constraint violation (max-norm) */ - Number scaled_constr_viol_; - /** Final unscaled constraint violation (max-norm) */ - Number constr_viol_; - /** Final scaled complementarity error (max-norm) */ - Number scaled_compl_; - /** Final unscaled complementarity error (max-norm) */ - Number compl_; - /** Final overall scaled KKT error (max-norm) */ - Number scaled_kkt_error_; - /** Final overall unscaled KKT error (max-norm) */ - Number kkt_error_; - //@} - }; - -} // namespace Ipopt - -#endif +// Copyright (C) 2005, 2009 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpSolveStatistics.hpp 1861 2010-12-21 21:34:47Z andreasw $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2005-08-15
+
+#ifndef __IPSOLVESTATISTICS_HPP__
+#define __IPSOLVESTATISTICS_HPP__
+
+#include "IpReferenced.hpp"
+#include "IpSmartPtr.hpp"
+
+namespace Ipopt
+{
+ // forward declaration (to avoid inclusion of too many header files)
+ class IpoptNLP;
+ class IpoptData;
+ class IpoptCalculatedQuantities;
+
+ /** This class collects statistics about an optimziation run, such
+ * as iteration count, final infeasibilities etc. It is meant to
+ * provide such information to a user of Ipopt during the
+ * finalize_solution call.
+ */
+ class SolveStatistics : public ReferencedObject
+ {
+ public:
+ /**@name Constructors/Destructors */
+ //@{
+ /** Default constructor. It takes in those collecting Ipopt
+ * objects that can provide the statistics information. Those
+ * statistics are retrieved at the time of the constructor
+ * call. */
+ SolveStatistics(const SmartPtr<IpoptNLP>& ip_nlp,
+ const SmartPtr<IpoptData>& ip_data,
+ const SmartPtr<IpoptCalculatedQuantities>& ip_cq);
+
+ /** Default destructor */
+ virtual ~SolveStatistics()
+ {}
+ //@}
+
+ /** @name Accessor methods for retrieving different kind of solver
+ * statistics information */
+ //@{
+ /** Iteration counts. */
+ virtual Index IterationCount() const;
+ /** Total CPU time, including function evaluations. */
+ virtual Number TotalCpuTime() const;
+ /** Total CPU time, including function evaluations. Included for
+ * backward compatibility. */
+ Number TotalCPUTime() const
+ {
+ return TotalCpuTime();
+ }
+ /** Total System time, including function evaluations. */
+ virtual Number TotalSysTime() const;
+ /** Total wall clock time, including function evaluations. */
+ virtual Number TotalWallclockTime() const;
+ /** Number of NLP function evaluations. */
+ virtual void NumberOfEvaluations(Index& num_obj_evals,
+ Index& num_constr_evals,
+ Index& num_obj_grad_evals,
+ Index& num_constr_jac_evals,
+ Index& num_hess_evals) const;
+ /** Unscaled solution infeasibilities */
+ virtual void Infeasibilities(Number& dual_inf,
+ Number& constr_viol,
+ Number& complementarity,
+ Number& kkt_error) const;
+ /** Scaled solution infeasibilities */
+ virtual void ScaledInfeasibilities(Number& scaled_dual_inf,
+ Number& scaled_constr_viol,
+ Number& scaled_complementarity,
+ Number& scaled_kkt_error) const;
+ /** Final value of objective function */
+ virtual Number FinalObjective() const;
+ /** Final scaled value of objective function */
+ virtual Number FinalScaledObjective() 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 */
+ SolveStatistics();
+
+ /** Copy Constructor */
+ SolveStatistics(const SolveStatistics&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const SolveStatistics&);
+ //@}
+
+ /** @name Fields for storing the statistics data */
+ //@{
+ /** Number of iterations. */
+ Index num_iters_;
+ /* Total CPU time */
+ Number total_cpu_time_;
+ /* Total system time */
+ Number total_sys_time_;
+ /* Total wall clock time */
+ Number total_wallclock_time_;
+ /** Number of objective function evaluations. */
+ Index num_obj_evals_;
+ /** Number of constraints evaluations (max of equality and
+ * inequality) */
+ Index num_constr_evals_;
+ /** Number of objective gradient evaluations. */
+ Index num_obj_grad_evals_;
+ /** Number of constraint Jacobian evaluations. */
+ Index num_constr_jac_evals_;
+ /** Number of Lagrangian Hessian evaluations. */
+ Index num_hess_evals_;
+
+ /** Final scaled value of objective function */
+ Number scaled_obj_val_;
+ /** Final unscaled value of objective function */
+ Number obj_val_;
+ /** Final scaled dual infeasibility (max-norm) */
+ Number scaled_dual_inf_;
+ /** Final unscaled dual infeasibility (max-norm) */
+ Number dual_inf_;
+ /** Final scaled constraint violation (max-norm) */
+ Number scaled_constr_viol_;
+ /** Final unscaled constraint violation (max-norm) */
+ Number constr_viol_;
+ /** Final scaled complementarity error (max-norm) */
+ Number scaled_compl_;
+ /** Final unscaled complementarity error (max-norm) */
+ Number compl_;
+ /** Final overall scaled KKT error (max-norm) */
+ Number scaled_kkt_error_;
+ /** Final overall unscaled KKT error (max-norm) */
+ Number kkt_error_;
+ //@}
+ };
+
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpStdCInterface.h b/thirdparty/windows/include/coin/IpStdCInterface.h index 151a8f5..ef96ca4 100644 --- a/thirdparty/windows/include/coin/IpStdCInterface.h +++ b/thirdparty/windows/include/coin/IpStdCInterface.h @@ -1,235 +1,271 @@ -/************************************************************************* - Copyright (C) 2004, 2006 International Business Machines and others. - All Rights Reserved. - This code is published under the Common Public License. - - $Id: IpStdCInterface.h 1586 2009-10-27 15:55:03Z andreasw $ - - Authors: Carl Laird, Andreas Waechter IBM 2004-09-02 - *************************************************************************/ - -#ifndef __IPSTDCINTERFACE_H__ -#define __IPSTDCINTERFACE_H__ - -#ifndef IPOPT_EXPORT -#ifdef _MSC_VER -#ifdef IPOPT_DLL -#define IPOPT_EXPORT(type) __declspec(dllexport) type __cdecl -#else -#define IPOPT_EXPORT(type) type __cdecl -#endif -#else -#define IPOPT_EXPORT(type) type -#endif -#endif - -#ifdef __cplusplus -extern "C" -{ -#endif - - /** Type for all number. We need to make sure that this is - identical with what is defined in Common/IpTypes.hpp */ - typedef double Number; - - /** Type for all incides. We need to make sure that this is - identical with what is defined in Common/IpTypes.hpp */ - typedef int Index; - - /** Type for all integers. We need to make sure that this is - identical with what is defined in Common/IpTypes.hpp */ - typedef int Int; - - /* This includes the SolverReturn enum type */ -#include "IpReturnCodes.h" - - /** Structure collecting all information about the problem - * definition and solve statistics etc. This is defined in the - * source file. */ - struct IpoptProblemInfo; - - /** Pointer to a Ipopt Problem. */ - typedef struct IpoptProblemInfo* IpoptProblem; - - /** define a boolean type for C */ - typedef int Bool; -#ifndef TRUE -# define TRUE (1) -#endif -#ifndef FALSE -# define FALSE (0) -#endif - - /** A pointer for anything that is to be passed between the called - * and individual callback function */ - typedef void * UserDataPtr; - - /** Type defining the callback function for evaluating the value of - * the objective function. Return value should be set to false if - * there was a problem doing the evaluation. */ - typedef Bool (*Eval_F_CB)(Index n, Number* x, Bool new_x, - Number* obj_value, UserDataPtr user_data); - - /** Type defining the callback function for evaluating the gradient of - * the objective function. Return value should be set to false if - * there was a problem doing the evaluation. */ - typedef Bool (*Eval_Grad_F_CB)(Index n, Number* x, Bool new_x, - Number* grad_f, UserDataPtr user_data); - - /** Type defining the callback function for evaluating the value of - * the constraint functions. Return value should be set to false if - * there was a problem doing the evaluation. */ - typedef Bool (*Eval_G_CB)(Index n, Number* x, Bool new_x, - Index m, Number* g, UserDataPtr user_data); - - /** Type defining the callback function for evaluating the Jacobian of - * the constrant functions. Return value should be set to false if - * there was a problem doing the evaluation. */ - typedef Bool (*Eval_Jac_G_CB)(Index n, Number *x, Bool new_x, - Index m, Index nele_jac, - Index *iRow, Index *jCol, Number *values, - UserDataPtr user_data); - - /** Type defining the callback function for evaluating the Hessian of - * the Lagrangian function. Return value should be set to false if - * there was a problem doing the evaluation. */ - typedef Bool (*Eval_H_CB)(Index n, Number *x, Bool new_x, Number obj_factor, - Index m, Number *lambda, Bool new_lambda, - Index nele_hess, Index *iRow, Index *jCol, - Number *values, UserDataPtr user_data); - - /** Function for creating a new Ipopt Problem object. This function - * returns an object that can be passed to the IpoptSolve call. It - * contains the basic definition of the optimization problem, such - * as number of variables and constraints, bounds on variables and - * constraints, information about the derivatives, and the callback - * function for the computation of the optimization problem - * functions and derivatives. During this call, the options file - * PARAMS.DAT is read as well. - * - * If NULL is returned, there was a problem with one of the inputs - * or reading the options file. */ - IPOPT_EXPORT(IpoptProblem) CreateIpoptProblem( - Index n /** Number of optimization variables */ - , Number* x_L /** Lower bounds on variables. This array of - size n is copied internally, so that the - caller can change the incoming data after - return without that IpoptProblem is - modified. Any value less or equal than - the number specified by option - 'nlp_lower_bound_inf' is interpreted to - be minus infinity. */ - , Number* x_U /** Upper bounds on variables. This array of - size n is copied internally, so that the - caller can change the incoming data after - return without that IpoptProblem is - modified. Any value greater or equal - than the number specified by option - 'nlp_upper_bound_inf' is interpreted to - be plus infinity. */ - , Index m /** Number of constraints. */ - , Number* g_L /** Lower bounds on constraints. This array of - size m is copied internally, so that the - caller can change the incoming data after - return without that IpoptProblem is - modified. Any value less or equal than - the number specified by option - 'nlp_lower_bound_inf' is interpreted to - be minus infinity. */ - , Number* g_U /** Upper bounds on constraints. This array of - size m is copied internally, so that the - caller can change the incoming data after - return without that IpoptProblem is - modified. Any value greater or equal - than the number specified by option - 'nlp_upper_bound_inf' is interpreted to - be plus infinity. */ - , Index nele_jac /** Number of non-zero elements in constraint - Jacobian. */ - , Index nele_hess /** Number of non-zero elements in Hessian of - Lagrangian. */ - , Index index_style /** indexing style for iRow & jCol, - 0 for C style, 1 for Fortran style */ - , Eval_F_CB eval_f /** Callback function for evaluating - objective function */ - , Eval_G_CB eval_g /** Callback function for evaluating - constraint functions */ - , Eval_Grad_F_CB eval_grad_f - /** Callback function for evaluating gradient - of objective function */ - , Eval_Jac_G_CB eval_jac_g - /** Callback function for evaluating Jacobian - of constraint functions */ - , Eval_H_CB eval_h /** Callback function for evaluating Hessian - of Lagrangian function */ - ); - - /** Method for freeing a previously created IpoptProblem. After - freeing an IpoptProblem, it cannot be used anymore. */ - IPOPT_EXPORT(void) FreeIpoptProblem(IpoptProblem ipopt_problem); - - - /** Function for adding a string option. Returns FALSE the option - * could not be set (e.g., if keyword is unknown) */ - IPOPT_EXPORT(Bool) AddIpoptStrOption(IpoptProblem ipopt_problem, char* keyword, char* val); - - /** Function for adding a Number option. Returns FALSE the option - * could not be set (e.g., if keyword is unknown) */ - IPOPT_EXPORT(Bool) AddIpoptNumOption(IpoptProblem ipopt_problem, char* keyword, Number val); - - /** Function for adding an Int option. Returns FALSE the option - * could not be set (e.g., if keyword is unknown) */ - IPOPT_EXPORT(Bool) AddIpoptIntOption(IpoptProblem ipopt_problem, char* keyword, Int val); - - /** Function for opening an output file for a given name with given - * printlevel. Returns false, if there was a problem opening the - * file. */ - IPOPT_EXPORT(Bool) OpenIpoptOutputFile(IpoptProblem ipopt_problem, char* file_name, - Int print_level); - - /** Optional function for setting scaling parameter for the NLP. - * This corresponds to the get_scaling_parameters method in TNLP. - * If the pointers x_scaling or g_scaling are NULL, then no scaling - * for x resp. g is done. */ - IPOPT_EXPORT(Bool) SetIpoptProblemScaling(IpoptProblem ipopt_problem, - Number obj_scaling, - Number* x_scaling, - Number* g_scaling); - - /** Function calling the Ipopt optimization algorithm for a problem - previously defined with CreateIpoptProblem. The return - specified outcome of the optimization procedure (e.g., success, - failure etc). - */ - IPOPT_EXPORT(enum ApplicationReturnStatus) IpoptSolve( - IpoptProblem ipopt_problem - /** Problem that is to be optimized. Ipopt - will use the options previously specified with - AddIpoptOption (etc) for this problem. */ - , Number* x /** Input: Starting point - Output: Optimal solution */ - , Number* g /** Values of constraint at final point - (output only - ignored if set to NULL) */ - , Number* obj_val /** Final value of objective function - (output only - ignored if set to NULL) */ - , Number* mult_g /** Final multipliers for constraints - (output only - ignored if set to NULL) */ - , Number* mult_x_L /** Final multipliers for lower variable bounds - (output only - ignored if set to NULL) */ - , Number* mult_x_U /** Final multipliers for upper variable bounds - (output only - ignored if set to NULL) */ - , UserDataPtr user_data - /** Pointer to user data. This will be - passed unmodified to the callback - functions. */ - ); - - /** - void IpoptStatisticsCounts; - - void IpoptStatisticsInfeasibilities; */ -#ifdef __cplusplus -} /* extern "C" { */ -#endif - -#endif +/*************************************************************************
+ Copyright (C) 2004, 2010 International Business Machines and others.
+ All Rights Reserved.
+ This code is published under the Eclipse Public License.
+
+ $Id: IpStdCInterface.h 2082 2012-02-16 03:00:34Z andreasw $
+
+ Authors: Carl Laird, Andreas Waechter IBM 2004-09-02
+ *************************************************************************/
+
+#ifndef __IPSTDCINTERFACE_H__
+#define __IPSTDCINTERFACE_H__
+
+#ifndef IPOPT_EXPORT
+#ifdef _MSC_VER
+#ifdef IPOPT_DLL
+#define IPOPT_EXPORT(type) __declspec(dllexport) type __cdecl
+#else
+#define IPOPT_EXPORT(type) type __cdecl
+#endif
+#else
+#define IPOPT_EXPORT(type) type
+#endif
+#endif
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /** Type for all number. We need to make sure that this is
+ identical with what is defined in Common/IpTypes.hpp */
+ typedef double Number;
+
+ /** Type for all incides. We need to make sure that this is
+ identical with what is defined in Common/IpTypes.hpp */
+ typedef int Index;
+
+ /** Type for all integers. We need to make sure that this is
+ identical with what is defined in Common/IpTypes.hpp */
+ typedef int Int;
+
+ /* This includes the SolverReturn enum type */
+#include "IpReturnCodes.h"
+
+ /** Structure collecting all information about the problem
+ * definition and solve statistics etc. This is defined in the
+ * source file. */
+ struct IpoptProblemInfo;
+
+ /** Pointer to a Ipopt Problem. */
+ typedef struct IpoptProblemInfo* IpoptProblem;
+
+ /** define a boolean type for C */
+ typedef int Bool;
+#ifndef TRUE
+# define TRUE (1)
+#endif
+#ifndef FALSE
+# define FALSE (0)
+#endif
+
+ /** A pointer for anything that is to be passed between the called
+ * and individual callback function */
+ typedef void * UserDataPtr;
+
+ /** Type defining the callback function for evaluating the value of
+ * the objective function. Return value should be set to false if
+ * there was a problem doing the evaluation. */
+ typedef Bool (*Eval_F_CB)(Index n, Number* x, Bool new_x,
+ Number* obj_value, UserDataPtr user_data);
+
+ /** Type defining the callback function for evaluating the gradient of
+ * the objective function. Return value should be set to false if
+ * there was a problem doing the evaluation. */
+ typedef Bool (*Eval_Grad_F_CB)(Index n, Number* x, Bool new_x,
+ Number* grad_f, UserDataPtr user_data);
+
+ /** Type defining the callback function for evaluating the value of
+ * the constraint functions. Return value should be set to false if
+ * there was a problem doing the evaluation. */
+ typedef Bool (*Eval_G_CB)(Index n, Number* x, Bool new_x,
+ Index m, Number* g, UserDataPtr user_data);
+
+ /** Type defining the callback function for evaluating the Jacobian of
+ * the constrant functions. Return value should be set to false if
+ * there was a problem doing the evaluation. */
+ typedef Bool (*Eval_Jac_G_CB)(Index n, Number *x, Bool new_x,
+ Index m, Index nele_jac,
+ Index *iRow, Index *jCol, Number *values,
+ UserDataPtr user_data);
+
+ /** Type defining the callback function for evaluating the Hessian of
+ * the Lagrangian function. Return value should be set to false if
+ * there was a problem doing the evaluation. */
+ typedef Bool (*Eval_H_CB)(Index n, Number *x, Bool new_x, Number obj_factor,
+ Index m, Number *lambda, Bool new_lambda,
+ Index nele_hess, Index *iRow, Index *jCol,
+ Number *values, UserDataPtr user_data);
+
+ /** Type defining the callback function for giving intermediate
+ * execution control to the user. If set, it is called once per
+ * iteration, providing the user with some information on the state
+ * of the optimization. This can be used to print some
+ * user-defined output. It also gives the user a way to terminate
+ * the optimization prematurely. If this method returns false,
+ * Ipopt will terminate the optimization. */
+ typedef Bool (*Intermediate_CB)(Index alg_mod, /* 0 is regular, 1 is resto */
+ Index iter_count, Number obj_value,
+ Number inf_pr, Number inf_du,
+ Number mu, Number d_norm,
+ Number regularization_size,
+ Number alpha_du, Number alpha_pr,
+ Index ls_trials, UserDataPtr user_data);
+
+ /** Function for creating a new Ipopt Problem object. This function
+ * returns an object that can be passed to the IpoptSolve call. It
+ * contains the basic definition of the optimization problem, such
+ * as number of variables and constraints, bounds on variables and
+ * constraints, information about the derivatives, and the callback
+ * function for the computation of the optimization problem
+ * functions and derivatives. During this call, the options file
+ * PARAMS.DAT is read as well.
+ *
+ * If NULL is returned, there was a problem with one of the inputs
+ * or reading the options file. */
+ IPOPT_EXPORT(IpoptProblem) CreateIpoptProblem(
+ Index n /** Number of optimization variables */
+ , Number* x_L /** Lower bounds on variables. This array of
+ size n is copied internally, so that the
+ caller can change the incoming data after
+ return without that IpoptProblem is
+ modified. Any value less or equal than
+ the number specified by option
+ 'nlp_lower_bound_inf' is interpreted to
+ be minus infinity. */
+ , Number* x_U /** Upper bounds on variables. This array of
+ size n is copied internally, so that the
+ caller can change the incoming data after
+ return without that IpoptProblem is
+ modified. Any value greater or equal
+ than the number specified by option
+ 'nlp_upper_bound_inf' is interpreted to
+ be plus infinity. */
+ , Index m /** Number of constraints. */
+ , Number* g_L /** Lower bounds on constraints. This array of
+ size m is copied internally, so that the
+ caller can change the incoming data after
+ return without that IpoptProblem is
+ modified. Any value less or equal than
+ the number specified by option
+ 'nlp_lower_bound_inf' is interpreted to
+ be minus infinity. */
+ , Number* g_U /** Upper bounds on constraints. This array of
+ size m is copied internally, so that the
+ caller can change the incoming data after
+ return without that IpoptProblem is
+ modified. Any value greater or equal
+ than the number specified by option
+ 'nlp_upper_bound_inf' is interpreted to
+ be plus infinity. */
+ , Index nele_jac /** Number of non-zero elements in constraint
+ Jacobian. */
+ , Index nele_hess /** Number of non-zero elements in Hessian of
+ Lagrangian. */
+ , Index index_style /** indexing style for iRow & jCol,
+ 0 for C style, 1 for Fortran style */
+ , Eval_F_CB eval_f /** Callback function for evaluating
+ objective function */
+ , Eval_G_CB eval_g /** Callback function for evaluating
+ constraint functions */
+ , Eval_Grad_F_CB eval_grad_f
+ /** Callback function for evaluating gradient
+ of objective function */
+ , Eval_Jac_G_CB eval_jac_g
+ /** Callback function for evaluating Jacobian
+ of constraint functions */
+ , Eval_H_CB eval_h /** Callback function for evaluating Hessian
+ of Lagrangian function */
+ );
+
+ /** Method for freeing a previously created IpoptProblem. After
+ freeing an IpoptProblem, it cannot be used anymore. */
+ IPOPT_EXPORT(void) FreeIpoptProblem(IpoptProblem ipopt_problem);
+
+
+ /** Function for adding a string option. Returns FALSE the option
+ * could not be set (e.g., if keyword is unknown) */
+ IPOPT_EXPORT(Bool) AddIpoptStrOption(IpoptProblem ipopt_problem, char* keyword, char* val);
+
+ /** Function for adding a Number option. Returns FALSE the option
+ * could not be set (e.g., if keyword is unknown) */
+ IPOPT_EXPORT(Bool) AddIpoptNumOption(IpoptProblem ipopt_problem, char* keyword, Number val);
+
+ /** Function for adding an Int option. Returns FALSE the option
+ * could not be set (e.g., if keyword is unknown) */
+ IPOPT_EXPORT(Bool) AddIpoptIntOption(IpoptProblem ipopt_problem, char* keyword, Int val);
+
+ /** Function for opening an output file for a given name with given
+ * printlevel. Returns false, if there was a problem opening the
+ * file. */
+ IPOPT_EXPORT(Bool) OpenIpoptOutputFile(IpoptProblem ipopt_problem, char* file_name,
+ Int print_level);
+
+ /** Optional function for setting scaling parameter for the NLP.
+ * This corresponds to the get_scaling_parameters method in TNLP.
+ * If the pointers x_scaling or g_scaling are NULL, then no scaling
+ * for x resp. g is done. */
+ IPOPT_EXPORT(Bool) SetIpoptProblemScaling(IpoptProblem ipopt_problem,
+ Number obj_scaling,
+ Number* x_scaling,
+ Number* g_scaling);
+
+ /** Setting a callback function for the "intermediate callback"
+ * method in the TNLP. This gives control back to the user once
+ * per iteration. If set, it provides the user with some
+ * information on the state of the optimization. This can be used
+ * to print some user-defined output. It also gives the user a way
+ * to terminate the optimization prematurely. If the callback
+ * method returns false, Ipopt will terminate the optimization.
+ * Calling this set method to set the CB pointer to NULL disables
+ * the intermediate callback functionality. */
+ IPOPT_EXPORT(Bool) SetIntermediateCallback(IpoptProblem ipopt_problem,
+ Intermediate_CB intermediate_cb);
+
+ /** Function calling the Ipopt optimization algorithm for a problem
+ previously defined with CreateIpoptProblem. The return
+ specified outcome of the optimization procedure (e.g., success,
+ failure etc).
+ */
+ IPOPT_EXPORT(enum ApplicationReturnStatus) IpoptSolve(
+ IpoptProblem ipopt_problem
+ /** Problem that is to be optimized. Ipopt
+ will use the options previously specified with
+ AddIpoptOption (etc) for this problem. */
+ , Number* x /** Input: Starting point
+ Output: Optimal solution */
+ , Number* g /** Values of constraint at final point
+ (output only - ignored if set to NULL) */
+ , Number* obj_val /** Final value of objective function
+ (output only - ignored if set to NULL) */
+ , Number* mult_g /** Input: Initial values for the constraint
+ multipliers (only if warm start option
+ is chosen)
+ Output: Final multipliers for constraints
+ (ignored if set to NULL) */
+ , Number* mult_x_L /** Input: Initial values for the multipliers for
+ lower variable bounds (only if warm start
+ option is chosen)
+ Output: Final multipliers for lower variable
+ bounds (ignored if set to NULL) */
+ , Number* mult_x_U /** Input: Initial values for the multipliers for
+ upper variable bounds (only if warm start
+ option is chosen)
+ Output: Final multipliers for upper variable
+ bounds (ignored if set to NULL) */
+ , UserDataPtr user_data
+ /** Pointer to user data. This will be
+ passed unmodified to the callback
+ functions. */
+ );
+
+ /**
+ void IpoptStatisticsCounts;
+
+ void IpoptStatisticsInfeasibilities; */
+#ifdef __cplusplus
+} /* extern "C" { */
+#endif
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpSymMatrix.hpp b/thirdparty/windows/include/coin/IpSymMatrix.hpp index 736541e..ea74a02 100644 --- a/thirdparty/windows/include/coin/IpSymMatrix.hpp +++ b/thirdparty/windows/include/coin/IpSymMatrix.hpp @@ -1,159 +1,162 @@ -// Copyright (C) 2004, 2008 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpSymMatrix.hpp 1280 2008-08-10 21:19:31Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPSYMMATRIX_HPP__ -#define __IPSYMMATRIX_HPP__ - -#include "IpUtils.hpp" -#include "IpMatrix.hpp" - -namespace Ipopt -{ - - /* forward declarations */ - class SymMatrixSpace; - - /** This is the base class for all derived symmetric matrix types. - */ - class SymMatrix : public Matrix - { - public: - /** @name Constructor/Destructor */ - //@{ - /** Constructor, taking the owner_space. - */ - SymMatrix(const SymMatrixSpace* owner_space); - - /** Destructor */ - virtual ~SymMatrix() - {} - //@} - - /** @name Information about the size of the matrix */ - //@{ - /** Dimension of the matrix (number of rows and columns) */ - Index Dim() const; - //@} - - SmartPtr<const SymMatrixSpace> OwnerSymMatrixSpace() const; - - protected: - /** @name Overloaded methods from Matrix. */ - //@{ - /** Since the matrix is - * symmetric, it is only necessary to implement the - * MultVectorImpl method in a class that inherits from this base - * class. If the TransMultVectorImpl is called, this base class - * automatically calls MultVectorImpl instead. */ - virtual void TransMultVectorImpl(Number alpha, const Vector& x, Number beta, - Vector& y) const - { - // Since this matrix is symetric, this is the same operation as - // MultVector - MultVector(alpha, x, beta, y); - } - /** Since the matrix is symmetric, the row and column max norms - * are identical */ - virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const - { - ComputeRowAMaxImpl(cols_norms, init); - } - //@} - - private: - /** Copy of the owner space ptr as a SymMatrixSpace instead - * of a MatrixSpace - */ - const SymMatrixSpace* owner_space_; - }; - - - /** SymMatrixSpace base class, corresponding to the SymMatrix base - * class. */ - class SymMatrixSpace : public MatrixSpace - { - public: - /** @name Constructors/Destructors */ - //@{ - /** Constructor, given the dimension (identical to the number of - * rows and columns). - */ - SymMatrixSpace(Index dim) - : - MatrixSpace(dim,dim) - {} - - /** Destructor */ - virtual ~SymMatrixSpace() - {} - //@} - - /** Pure virtual method for creating a new matrix of this specific - * type. */ - virtual SymMatrix* MakeNewSymMatrix() const=0; - - /** Overloaded MakeNew method for the MatrixSpace base class. - */ - virtual Matrix* MakeNew() const - { - return MakeNewSymMatrix(); - } - - /** Accessor method for the dimension of the matrices in this - * matrix space. - */ - Index Dim() const - { - DBG_ASSERT(NRows() == NCols()); - return NRows(); - } - - 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 */ - SymMatrixSpace(); - - /* Copy constructor */ - SymMatrixSpace(const SymMatrixSpace&); - - /** Overloaded Equals Operator */ - SymMatrixSpace& operator=(const SymMatrixSpace&); - //@} - - }; - - /* inline methods */ - inline - SymMatrix::SymMatrix(const SymMatrixSpace* owner_space) - : - Matrix(owner_space), - owner_space_(owner_space) - {} - - inline - Index SymMatrix::Dim() const - { - return owner_space_->Dim(); - } - - inline - SmartPtr<const SymMatrixSpace> SymMatrix::OwnerSymMatrixSpace() const - { - return owner_space_; - } - -} // namespace Ipopt - -#endif +// Copyright (C) 2004, 2008 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpSymMatrix.hpp 2161 2013-01-01 20:39:05Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPSYMMATRIX_HPP__
+#define __IPSYMMATRIX_HPP__
+
+#include "IpUtils.hpp"
+#include "IpMatrix.hpp"
+
+namespace Ipopt
+{
+
+ /* forward declarations */
+ class SymMatrixSpace;
+
+ /** This is the base class for all derived symmetric matrix types.
+ */
+ class SymMatrix : public Matrix
+ {
+ public:
+ /** @name Constructor/Destructor */
+ //@{
+ /** Constructor, taking the owner_space.
+ */
+ inline
+ SymMatrix(const SymMatrixSpace* owner_space);
+
+ /** Destructor */
+ virtual ~SymMatrix()
+ {}
+ //@}
+
+ /** @name Information about the size of the matrix */
+ //@{
+ /** Dimension of the matrix (number of rows and columns) */
+ inline
+ Index Dim() const;
+ //@}
+
+ inline
+ SmartPtr<const SymMatrixSpace> OwnerSymMatrixSpace() const;
+
+ protected:
+ /** @name Overloaded methods from Matrix. */
+ //@{
+ /** Since the matrix is
+ * symmetric, it is only necessary to implement the
+ * MultVectorImpl method in a class that inherits from this base
+ * class. If the TransMultVectorImpl is called, this base class
+ * automatically calls MultVectorImpl instead. */
+ virtual void TransMultVectorImpl(Number alpha, const Vector& x, Number beta,
+ Vector& y) const
+ {
+ // Since this matrix is symetric, this is the same operation as
+ // MultVector
+ MultVector(alpha, x, beta, y);
+ }
+ /** Since the matrix is symmetric, the row and column max norms
+ * are identical */
+ virtual void ComputeColAMaxImpl(Vector& cols_norms, bool init) const
+ {
+ ComputeRowAMaxImpl(cols_norms, init);
+ }
+ //@}
+
+ private:
+ /** Copy of the owner space ptr as a SymMatrixSpace instead
+ * of a MatrixSpace
+ */
+ const SymMatrixSpace* owner_space_;
+ };
+
+
+ /** SymMatrixSpace base class, corresponding to the SymMatrix base
+ * class. */
+ class SymMatrixSpace : public MatrixSpace
+ {
+ public:
+ /** @name Constructors/Destructors */
+ //@{
+ /** Constructor, given the dimension (identical to the number of
+ * rows and columns).
+ */
+ SymMatrixSpace(Index dim)
+ :
+ MatrixSpace(dim,dim)
+ {}
+
+ /** Destructor */
+ virtual ~SymMatrixSpace()
+ {}
+ //@}
+
+ /** Pure virtual method for creating a new matrix of this specific
+ * type. */
+ virtual SymMatrix* MakeNewSymMatrix() const=0;
+
+ /** Overloaded MakeNew method for the MatrixSpace base class.
+ */
+ virtual Matrix* MakeNew() const
+ {
+ return MakeNewSymMatrix();
+ }
+
+ /** Accessor method for the dimension of the matrices in this
+ * matrix space.
+ */
+ Index Dim() const
+ {
+ DBG_ASSERT(NRows() == NCols());
+ return NRows();
+ }
+
+ 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 */
+ SymMatrixSpace();
+
+ /* Copy constructor */
+ SymMatrixSpace(const SymMatrixSpace&);
+
+ /** Overloaded Equals Operator */
+ SymMatrixSpace& operator=(const SymMatrixSpace&);
+ //@}
+
+ };
+
+ /* inline methods */
+ inline
+ SymMatrix::SymMatrix(const SymMatrixSpace* owner_space)
+ :
+ Matrix(owner_space),
+ owner_space_(owner_space)
+ {}
+
+ inline
+ Index SymMatrix::Dim() const
+ {
+ return owner_space_->Dim();
+ }
+
+ inline
+ SmartPtr<const SymMatrixSpace> SymMatrix::OwnerSymMatrixSpace() const
+ {
+ return owner_space_;
+ }
+
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpTNLP.hpp b/thirdparty/windows/include/coin/IpTNLP.hpp index c97ba88..b00325c 100644 --- a/thirdparty/windows/include/coin/IpTNLP.hpp +++ b/thirdparty/windows/include/coin/IpTNLP.hpp @@ -1,279 +1,301 @@ -// Copyright (C) 2004, 2009 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpTNLP.hpp 1462 2009-06-02 04:17:13Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPTNLP_HPP__ -#define __IPTNLP_HPP__ - -#include "IpUtils.hpp" -#include "IpReferenced.hpp" -#include "IpException.hpp" -#include "IpAlgTypes.hpp" -#include "IpReturnCodes.hpp" - -#include <map> - -namespace Ipopt -{ - // forward declarations - class IpoptData; - class IpoptCalculatedQuantities; - class IteratesVector; - - /** Base class for all NLP's that use standard triplet matrix form - * and dense vectors. This is the standard base class for all - * NLP's that use the standard triplet matrix form (as for Harwell - * routines) and dense vectors. The class TNLPAdapter then converts - * this interface to an interface that can be used directly by - * ipopt. - * - * This interface presents the problem form: - * - * min f(x) - * - * s.t. gL <= g(x) <= gU - * - * xL <= x <= xU - * - * In order to specify an equality constraint, set gL_i = gU_i = - * rhs. The value that indicates "infinity" for the bounds - * (i.e. the variable or constraint has no lower bound (-infinity) - * or upper bound (+infinity)) is set through the option - * nlp_lower_bound_inf and nlp_upper_bound_inf. To indicate that a - * variable has no upper or lower bound, set the bound to - * -ipopt_inf or +ipopt_inf respectively - */ - class TNLP : public ReferencedObject - { - public: - /** Type of the constraints*/ - enum LinearityType - { - LINEAR/** Constraint/Variable is linear.*/, - NON_LINEAR/**Constraint/Varaible is non-linear.*/ - }; - - /**@name Constructors/Destructors */ - //@{ - TNLP() - {} - - /** Default destructor */ - virtual ~TNLP() - {} - //@} - - DECLARE_STD_EXCEPTION(INVALID_TNLP); - - /**@name methods to gather information about the NLP */ - //@{ - /** overload this method to return the number of variables - * and constraints, and the number of non-zeros in the jacobian and - * the hessian. The index_style parameter lets you specify C or Fortran - * style indexing for the sparse matrix iRow and jCol parameters. - * C_STYLE is 0-based, and FORTRAN_STYLE is 1-based. - */ - enum IndexStyleEnum { C_STYLE=0, FORTRAN_STYLE=1 }; - virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, - Index& nnz_h_lag, IndexStyleEnum& index_style)=0; - - typedef std::map<std::string, std::vector<std::string> > StringMetaDataMapType; - typedef std::map<std::string, std::vector<Index> > IntegerMetaDataMapType; - typedef std::map<std::string, std::vector<Number> > NumericMetaDataMapType; - - /** overload this method to return any meta data for - * the variables and the constraints */ - virtual bool get_var_con_metadata(Index n, - StringMetaDataMapType& var_string_md, - IntegerMetaDataMapType& var_integer_md, - NumericMetaDataMapType& var_numeric_md, - Index m, - StringMetaDataMapType& con_string_md, - IntegerMetaDataMapType& con_integer_md, - NumericMetaDataMapType& con_numeric_md) - - { - return false; - } - - /** overload this method to return the information about the bound - * on the variables and constraints. The value that indicates - * that a bound does not exist is specified in the parameters - * nlp_lower_bound_inf and nlp_upper_bound_inf. By default, - * nlp_lower_bound_inf is -1e19 and nlp_upper_bound_inf is - * 1e19. (see TNLPAdapter) */ - virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u, - Index m, Number* g_l, Number* g_u)=0; - - /** overload this method to return scaling parameters. This is - * only called if the options are set to retrieve user scaling. - * There, use_x_scaling (or use_g_scaling) should get set to true - * only if the variables (or constraints) are to be scaled. This - * method should return true only if the scaling parameters could - * be provided. - */ - virtual bool get_scaling_parameters(Number& obj_scaling, - bool& use_x_scaling, Index n, - Number* x_scaling, - bool& use_g_scaling, Index m, - Number* g_scaling) - { - return false; - } - - /** overload this method to return the variables linearity - * (TNLP::Linear or TNLP::NonLinear). The var_types - * array should be allocated with length at least n. (default implementation - * just return false and does not fill the array).*/ - virtual bool get_variables_linearity(Index n, LinearityType* var_types) - { - return false; - } - - /** overload this method to return the constraint linearity. - * array should be alocated with length at least n. (default implementation - * just return false and does not fill the array).*/ - virtual bool get_constraints_linearity(Index m, LinearityType* const_types) - { - return false; - } - - /** overload this method to return the starting point. The bool - * variables indicate whether the algorithm wants you to - * initialize x, z_L/z_u, and lambda, respectively. If, for some - * reason, the algorithm wants you to initialize these and you - * cannot, return false, which will cause Ipopt to stop. You - * will have to run Ipopt with different options then. - */ - virtual bool get_starting_point(Index n, bool init_x, Number* x, - bool init_z, Number* z_L, Number* z_U, - Index m, bool init_lambda, - Number* lambda)=0; - - /** overload this method to provide an Ipopt iterate (already in - * the form Ipopt requires it internally) for a warm start. - * Since this is only for expert users, a default dummy - * implementation is provided and returns false. */ - virtual bool get_warm_start_iterate(IteratesVector& warm_start_iterate) - { - return false; - } - - /** overload this method to return the value of the objective function */ - virtual bool eval_f(Index n, const Number* x, bool new_x, - Number& obj_value)=0; - - /** overload this method to return the vector of the gradient of - * the objective w.r.t. x */ - virtual bool eval_grad_f(Index n, const Number* x, bool new_x, - Number* grad_f)=0; - - /** overload this method to return the vector of constraint values */ - virtual bool eval_g(Index n, const Number* x, bool new_x, - Index m, Number* g)=0; - /** overload this method to return the jacobian of the - * constraints. The vectors iRow and jCol only need to be set - * once. The first call is used to set the structure only (iRow - * and jCol will be non-NULL, and values will be NULL) For - * subsequent calls, iRow and jCol will be NULL. */ - virtual bool eval_jac_g(Index n, const Number* x, bool new_x, - Index m, Index nele_jac, Index* iRow, - Index *jCol, Number* values)=0; - - /** overload this method to return the hessian of the - * lagrangian. The vectors iRow and jCol only need to be set once - * (during the first call). The first call is used to set the - * structure only (iRow and jCol will be non-NULL, and values - * will be NULL) For subsequent calls, iRow and jCol will be - * NULL. This matrix is symmetric - specify the lower diagonal - * only. A default implementation is provided, in case the user - * wants to se quasi-Newton approximations to estimate the second - * derivatives and doesn't not neet to implement this method. */ - virtual bool eval_h(Index n, const Number* x, bool new_x, - Number obj_factor, Index m, const Number* lambda, - bool new_lambda, Index nele_hess, - Index* iRow, Index* jCol, Number* values) - { - return false; - } - //@} - - /** @name Solution Methods */ - //@{ - /** This method is called when the algorithm is complete so the TNLP can store/write the solution */ - virtual void finalize_solution(SolverReturn status, - Index n, const Number* x, const Number* z_L, const Number* z_U, - Index m, const Number* g, const Number* lambda, - Number obj_value, - const IpoptData* ip_data, - IpoptCalculatedQuantities* ip_cq)=0; - - /** Intermediate Callback method for the user. Providing dummy - * default implementation. For details see IntermediateCallBack - * in IpNLP.hpp. */ - virtual bool intermediate_callback(AlgorithmMode mode, - Index iter, Number obj_value, - Number inf_pr, Number inf_du, - Number mu, Number d_norm, - Number regularization_size, - Number alpha_du, Number alpha_pr, - Index ls_trials, - const IpoptData* ip_data, - IpoptCalculatedQuantities* ip_cq) - { - return true; - } - //@} - - /** @name Methods for quasi-Newton approximation. If the second - * derivatives are approximated by Ipopt, it is better to do this - * only in the space of nonlinear variables. The following - * methods are call by Ipopt if the quasi-Newton approximation is - * selected. If -1 is returned as number of nonlinear variables, - * Ipopt assumes that all variables are nonlinear. Otherwise, it - * calls get_list_of_nonlinear_variables with an array into which - * the indices of the nonlinear variables should be written - the - * array has the lengths num_nonlin_vars, which is identical with - * the return value of get_number_of_nonlinear_variables(). It - * is assumed that the indices are counted starting with 1 in the - * FORTRAN_STYLE, and 0 for the C_STYLE. */ - //@{ - virtual Index get_number_of_nonlinear_variables() - { - return -1; - } - - virtual bool get_list_of_nonlinear_variables(Index num_nonlin_vars, - Index* pos_nonlin_vars) - { - return false; - } - //@} - - 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 */ - //TNLP(); - - /** Copy Constructor */ - TNLP(const TNLP&); - - /** Overloaded Equals Operator */ - void operator=(const TNLP&); - //@} - }; - -} // namespace Ipopt - -#endif +// Copyright (C) 2004, 2009 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpTNLP.hpp 2212 2013-04-14 14:51:52Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPTNLP_HPP__
+#define __IPTNLP_HPP__
+
+#include "IpUtils.hpp"
+#include "IpReferenced.hpp"
+#include "IpException.hpp"
+#include "IpAlgTypes.hpp"
+#include "IpReturnCodes.hpp"
+
+#include <map>
+
+namespace Ipopt
+{
+ // forward declarations
+ class IpoptData;
+ class IpoptCalculatedQuantities;
+ class IteratesVector;
+
+ /** Base class for all NLP's that use standard triplet matrix form
+ * and dense vectors. This is the standard base class for all
+ * NLP's that use the standard triplet matrix form (as for Harwell
+ * routines) and dense vectors. The class TNLPAdapter then converts
+ * this interface to an interface that can be used directly by
+ * ipopt.
+ *
+ * This interface presents the problem form:
+ *
+ * min f(x)
+ *
+ * s.t. gL <= g(x) <= gU
+ *
+ * xL <= x <= xU
+ *
+ * In order to specify an equality constraint, set gL_i = gU_i =
+ * rhs. The value that indicates "infinity" for the bounds
+ * (i.e. the variable or constraint has no lower bound (-infinity)
+ * or upper bound (+infinity)) is set through the option
+ * nlp_lower_bound_inf and nlp_upper_bound_inf. To indicate that a
+ * variable has no upper or lower bound, set the bound to
+ * -ipopt_inf or +ipopt_inf respectively
+ */
+ class TNLP : public ReferencedObject
+ {
+ public:
+ /** Type of the constraints*/
+ enum LinearityType
+ {
+ LINEAR/** Constraint/Variable is linear.*/,
+ NON_LINEAR/**Constraint/Varaible is non-linear.*/
+ };
+
+ /**@name Constructors/Destructors */
+ //@{
+ TNLP()
+ {}
+
+ /** Default destructor */
+ virtual ~TNLP()
+ {}
+ //@}
+
+ DECLARE_STD_EXCEPTION(INVALID_TNLP);
+
+ /**@name methods to gather information about the NLP */
+ //@{
+ /** overload this method to return the number of variables
+ * and constraints, and the number of non-zeros in the jacobian and
+ * the hessian. The index_style parameter lets you specify C or Fortran
+ * style indexing for the sparse matrix iRow and jCol parameters.
+ * C_STYLE is 0-based, and FORTRAN_STYLE is 1-based.
+ */
+ enum IndexStyleEnum { C_STYLE=0, FORTRAN_STYLE=1 };
+ virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
+ Index& nnz_h_lag, IndexStyleEnum& index_style)=0;
+
+ typedef std::map<std::string, std::vector<std::string> > StringMetaDataMapType;
+ typedef std::map<std::string, std::vector<Index> > IntegerMetaDataMapType;
+ typedef std::map<std::string, std::vector<Number> > NumericMetaDataMapType;
+
+ /** overload this method to return any meta data for
+ * the variables and the constraints */
+ virtual bool get_var_con_metadata(Index n,
+ StringMetaDataMapType& var_string_md,
+ IntegerMetaDataMapType& var_integer_md,
+ NumericMetaDataMapType& var_numeric_md,
+ Index m,
+ StringMetaDataMapType& con_string_md,
+ IntegerMetaDataMapType& con_integer_md,
+ NumericMetaDataMapType& con_numeric_md)
+
+ {
+ return false;
+ }
+
+ /** overload this method to return the information about the bound
+ * on the variables and constraints. The value that indicates
+ * that a bound does not exist is specified in the parameters
+ * nlp_lower_bound_inf and nlp_upper_bound_inf. By default,
+ * nlp_lower_bound_inf is -1e19 and nlp_upper_bound_inf is
+ * 1e19. (see TNLPAdapter) */
+ virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
+ Index m, Number* g_l, Number* g_u)=0;
+
+ /** overload this method to return scaling parameters. This is
+ * only called if the options are set to retrieve user scaling.
+ * There, use_x_scaling (or use_g_scaling) should get set to true
+ * only if the variables (or constraints) are to be scaled. This
+ * method should return true only if the scaling parameters could
+ * be provided.
+ */
+ virtual bool get_scaling_parameters(Number& obj_scaling,
+ bool& use_x_scaling, Index n,
+ Number* x_scaling,
+ bool& use_g_scaling, Index m,
+ Number* g_scaling)
+ {
+ return false;
+ }
+
+ /** overload this method to return the variables linearity
+ * (TNLP::LINEAR or TNLP::NON_LINEAR). The var_types
+ * array has been allocated with length at least n. (default implementation
+ * just return false and does not fill the array).*/
+ virtual bool get_variables_linearity(Index n, LinearityType* var_types)
+ {
+ return false;
+ }
+
+ /** overload this method to return the constraint linearity.
+ * array has been allocated with length at least n. (default implementation
+ * just return false and does not fill the array).*/
+ virtual bool get_constraints_linearity(Index m, LinearityType* const_types)
+ {
+ return false;
+ }
+
+ /** overload this method to return the starting point. The bool
+ * variables indicate whether the algorithm wants you to
+ * initialize x, z_L/z_u, and lambda, respectively. If, for some
+ * reason, the algorithm wants you to initialize these and you
+ * cannot, return false, which will cause Ipopt to stop. You
+ * will have to run Ipopt with different options then.
+ */
+ virtual bool get_starting_point(Index n, bool init_x, Number* x,
+ bool init_z, Number* z_L, Number* z_U,
+ Index m, bool init_lambda,
+ Number* lambda)=0;
+
+ /** overload this method to provide an Ipopt iterate (already in
+ * the form Ipopt requires it internally) for a warm start.
+ * Since this is only for expert users, a default dummy
+ * implementation is provided and returns false. */
+ virtual bool get_warm_start_iterate(IteratesVector& warm_start_iterate)
+ {
+ return false;
+ }
+
+ /** overload this method to return the value of the objective function */
+ virtual bool eval_f(Index n, const Number* x, bool new_x,
+ Number& obj_value)=0;
+
+ /** overload this method to return the vector of the gradient of
+ * the objective w.r.t. x */
+ virtual bool eval_grad_f(Index n, const Number* x, bool new_x,
+ Number* grad_f)=0;
+
+ /** overload this method to return the vector of constraint values */
+ virtual bool eval_g(Index n, const Number* x, bool new_x,
+ Index m, Number* g)=0;
+ /** overload this method to return the jacobian of the
+ * constraints. The vectors iRow and jCol only need to be set
+ * once. The first call is used to set the structure only (iRow
+ * and jCol will be non-NULL, and values will be NULL) For
+ * subsequent calls, iRow and jCol will be NULL. */
+ virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
+ Index m, Index nele_jac, Index* iRow,
+ Index *jCol, Number* values)=0;
+
+ /** overload this method to return the hessian of the
+ * lagrangian. The vectors iRow and jCol only need to be set once
+ * (during the first call). The first call is used to set the
+ * structure only (iRow and jCol will be non-NULL, and values
+ * will be NULL) For subsequent calls, iRow and jCol will be
+ * NULL. This matrix is symmetric - specify the lower diagonal
+ * only. A default implementation is provided, in case the user
+ * wants to se quasi-Newton approximations to estimate the second
+ * derivatives and doesn't not neet to implement this method. */
+ virtual bool eval_h(Index n, const Number* x, bool new_x,
+ Number obj_factor, Index m, const Number* lambda,
+ bool new_lambda, Index nele_hess,
+ Index* iRow, Index* jCol, Number* values)
+ {
+ return false;
+ }
+ //@}
+
+ /** @name Solution Methods */
+ //@{
+ /** This method is called when the algorithm is complete so the TNLP can store/write the solution */
+ virtual void finalize_solution(SolverReturn status,
+ Index n, const Number* x, const Number* z_L, const Number* z_U,
+ Index m, const Number* g, const Number* lambda,
+ Number obj_value,
+ const IpoptData* ip_data,
+ IpoptCalculatedQuantities* ip_cq)=0;
+ /** This method is called just before finalize_solution. With
+ * this method, the algorithm returns any metadata collected
+ * during its run, including the metadata provided by the user
+ * with the above get_var_con_metadata. Each metadata can be of
+ * type string, integer, and numeric. It can be associated to
+ * either the variables or the constraints. The metadata that
+ * was associated with the primal variable vector is stored in
+ * var_..._md. The metadata associated with the constraint
+ * multipliers is stored in con_..._md. The metadata associated
+ * with the bound multipliers is stored in var_..._md, with the
+ * suffixes "_z_L", and "_z_U", denoting lower and upper
+ * bounds. */
+ virtual void finalize_metadata(Index n,
+ const StringMetaDataMapType& var_string_md,
+ const IntegerMetaDataMapType& var_integer_md,
+ const NumericMetaDataMapType& var_numeric_md,
+ Index m,
+ const StringMetaDataMapType& con_string_md,
+ const IntegerMetaDataMapType& con_integer_md,
+ const NumericMetaDataMapType& con_numeric_md)
+ {}
+
+
+ /** Intermediate Callback method for the user. Providing dummy
+ * default implementation. For details see IntermediateCallBack
+ * in IpNLP.hpp. */
+ virtual bool intermediate_callback(AlgorithmMode mode,
+ Index iter, Number obj_value,
+ Number inf_pr, Number inf_du,
+ Number mu, Number d_norm,
+ Number regularization_size,
+ Number alpha_du, Number alpha_pr,
+ Index ls_trials,
+ const IpoptData* ip_data,
+ IpoptCalculatedQuantities* ip_cq)
+ {
+ return true;
+ }
+ //@}
+
+ /** @name Methods for quasi-Newton approximation. If the second
+ * derivatives are approximated by Ipopt, it is better to do this
+ * only in the space of nonlinear variables. The following
+ * methods are call by Ipopt if the quasi-Newton approximation is
+ * selected. If -1 is returned as number of nonlinear variables,
+ * Ipopt assumes that all variables are nonlinear. Otherwise, it
+ * calls get_list_of_nonlinear_variables with an array into which
+ * the indices of the nonlinear variables should be written - the
+ * array has the lengths num_nonlin_vars, which is identical with
+ * the return value of get_number_of_nonlinear_variables(). It
+ * is assumed that the indices are counted starting with 1 in the
+ * FORTRAN_STYLE, and 0 for the C_STYLE. */
+ //@{
+ virtual Index get_number_of_nonlinear_variables()
+ {
+ return -1;
+ }
+
+ virtual bool get_list_of_nonlinear_variables(Index num_nonlin_vars,
+ Index* pos_nonlin_vars)
+ {
+ return false;
+ }
+ //@}
+
+ 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 */
+ //TNLP();
+
+ /** Copy Constructor */
+ TNLP(const TNLP&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const TNLP&);
+ //@}
+ };
+
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpTNLPReducer.hpp b/thirdparty/windows/include/coin/IpTNLPReducer.hpp index 2e880f4..44a18eb 100644 --- a/thirdparty/windows/include/coin/IpTNLPReducer.hpp +++ b/thirdparty/windows/include/coin/IpTNLPReducer.hpp @@ -1,180 +1,180 @@ -// Copyright (C) 2008 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpTNLPReducer.hpp 1324 2008-09-16 14:19:26Z andreasw $ -// -// Authors: Andreas Waechter IBM 2008-08-10 - -#ifndef __IPTNLPREDUCER_HPP__ -#define __IPTNLPREDUCER_HPP__ - -#include "IpTNLP.hpp" - -namespace Ipopt -{ - /** This is a wrapper around a given TNLP class that takes out a - * list of constraints that are given to the constructor. It is - * provided for convenience, if one wants to experiment with - * problems that consist of only a subset of the constraints. But - * keep in mind that this is not efficient, since behind the scenes - * we are still evaluation all functions and derivatives, and are - * making copies of the original data. */ - class TNLPReducer : public TNLP - { - public: - /**@name Constructors/Destructors */ - //@{ - /** Constructor is given the indices of the constraints that - * should be taken out of the problem statement, as well as the - * original TNLP. */ - TNLPReducer(TNLP& tnlp, Index n_g_skip, const Index* index_g_skip, - Index n_xL_skip, const Index* index_xL_skip, - Index n_xU_skip, const Index* index_xU_skip, - Index n_x_fix, const Index* index_f_fix); - - /** Default destructor */ - virtual ~TNLPReducer(); - //@} - - /** @name Overloaded methods from TNLP */ - virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g, - Index& nnz_h_lag, IndexStyleEnum& index_style); - - virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u, - Index m, Number* g_l, Number* g_u); - - virtual bool get_scaling_parameters(Number& obj_scaling, - bool& use_x_scaling, Index n, - Number* x_scaling, - bool& use_g_scaling, Index m, - Number* g_scaling); - - virtual bool get_variables_linearity(Index n, LinearityType* var_types); - - virtual bool get_constraints_linearity(Index m, LinearityType* const_types); - - virtual bool get_starting_point(Index n, bool init_x, Number* x, - bool init_z, Number* z_L, Number* z_U, - Index m, bool init_lambda, - Number* lambda); - - virtual bool get_warm_start_iterate(IteratesVector& warm_start_iterate); - - virtual bool eval_f(Index n, const Number* x, bool new_x, - Number& obj_value); - - virtual bool eval_grad_f(Index n, const Number* x, bool new_x, - Number* grad_f); - - virtual bool eval_g(Index n, const Number* x, bool new_x, - Index m, Number* g); - - virtual bool eval_jac_g(Index n, const Number* x, bool new_x, - Index m, Index nele_jac, Index* iRow, - Index *jCol, Number* values); - - virtual bool eval_h(Index n, const Number* x, bool new_x, - Number obj_factor, Index m, const Number* lambda, - bool new_lambda, Index nele_hess, - Index* iRow, Index* jCol, Number* values); - - virtual void finalize_solution(SolverReturn status, - Index n, const Number* x, const Number* z_L, const Number* z_U, - Index m, const Number* g, const Number* lambda, - Number obj_value, - const IpoptData* ip_data, - IpoptCalculatedQuantities* ip_cq); - - virtual bool intermediate_callback(AlgorithmMode mode, - Index iter, Number obj_value, - Number inf_pr, Number inf_du, - Number mu, Number d_norm, - Number regularization_size, - Number alpha_du, Number alpha_pr, - Index ls_trials, - const IpoptData* ip_data, - IpoptCalculatedQuantities* ip_cq); - - virtual Index get_number_of_nonlinear_variables(); - - virtual bool get_list_of_nonlinear_variables(Index num_nonlin_vars, - Index* pos_nonlin_vars); - //@} - - 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 */ - TNLPReducer(); - - /** Copy Constructor */ - TNLPReducer(const TNLPReducer&); - - /** Overloaded Equals Operator */ - void operator=(const TNLPReducer&); - //@} - - /** @name original TNLP */ - //@{ - SmartPtr<TNLP> tnlp_; - Index m_orig_; - Index nnz_jac_g_orig_; - //@} - - /** Number of constraints to be skipped */ - Index n_g_skip_; - - /** Array of indices of the constraints that are to be skipped. - * This is provided at the beginning in the constructor. */ - Index* index_g_skip_; - - /** Index style for original problem. Internally, we use C-Style - * now. */ - IndexStyleEnum index_style_orig_; - - /** Map from original constraints to new constraints. A -1 means - * that a constraint is skipped. */ - Index* g_keep_map_; - - /** Number of constraints in reduced NLP */ - Index m_reduced_; - - /** Number of Jacobian nonzeros in the reduced NLP */ - Index nnz_jac_g_reduced_; - - /** Number of Jacobian nonzeros that are skipped */ - Index nnz_jac_g_skipped_; - - /** Array of Jacobian elements that are to be skipped. This is in - * increasing order. */ - Index* jac_g_skipped_; - - /** Number of lower variable bounds to be skipped. */ - Index n_xL_skip_; - - /** Array of indices of the lower variable bounds to be skipped. */ - Index* index_xL_skip_; - - /** Number of upper variable bounds to be skipped. */ - Index n_xU_skip_; - - /** Array of indices of the upper variable bounds to be skipped. */ - Index* index_xU_skip_; - - /** Number of variables that are to be fixed to initial value. */ - Index n_x_fix_; - - /** Array of indices of the variables that are to be fixed. */ - Index* index_x_fix_; - }; - -} // namespace Ipopt - -#endif +// Copyright (C) 2008 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpTNLPReducer.hpp 1861 2010-12-21 21:34:47Z andreasw $
+//
+// Authors: Andreas Waechter IBM 2008-08-10
+
+#ifndef __IPTNLPREDUCER_HPP__
+#define __IPTNLPREDUCER_HPP__
+
+#include "IpTNLP.hpp"
+
+namespace Ipopt
+{
+ /** This is a wrapper around a given TNLP class that takes out a
+ * list of constraints that are given to the constructor. It is
+ * provided for convenience, if one wants to experiment with
+ * problems that consist of only a subset of the constraints. But
+ * keep in mind that this is not efficient, since behind the scenes
+ * we are still evaluation all functions and derivatives, and are
+ * making copies of the original data. */
+ class TNLPReducer : public TNLP
+ {
+ public:
+ /**@name Constructors/Destructors */
+ //@{
+ /** Constructor is given the indices of the constraints that
+ * should be taken out of the problem statement, as well as the
+ * original TNLP. */
+ TNLPReducer(TNLP& tnlp, Index n_g_skip, const Index* index_g_skip,
+ Index n_xL_skip, const Index* index_xL_skip,
+ Index n_xU_skip, const Index* index_xU_skip,
+ Index n_x_fix, const Index* index_f_fix);
+
+ /** Default destructor */
+ virtual ~TNLPReducer();
+ //@}
+
+ /** @name Overloaded methods from TNLP */
+ virtual bool get_nlp_info(Index& n, Index& m, Index& nnz_jac_g,
+ Index& nnz_h_lag, IndexStyleEnum& index_style);
+
+ virtual bool get_bounds_info(Index n, Number* x_l, Number* x_u,
+ Index m, Number* g_l, Number* g_u);
+
+ virtual bool get_scaling_parameters(Number& obj_scaling,
+ bool& use_x_scaling, Index n,
+ Number* x_scaling,
+ bool& use_g_scaling, Index m,
+ Number* g_scaling);
+
+ virtual bool get_variables_linearity(Index n, LinearityType* var_types);
+
+ virtual bool get_constraints_linearity(Index m, LinearityType* const_types);
+
+ virtual bool get_starting_point(Index n, bool init_x, Number* x,
+ bool init_z, Number* z_L, Number* z_U,
+ Index m, bool init_lambda,
+ Number* lambda);
+
+ virtual bool get_warm_start_iterate(IteratesVector& warm_start_iterate);
+
+ virtual bool eval_f(Index n, const Number* x, bool new_x,
+ Number& obj_value);
+
+ virtual bool eval_grad_f(Index n, const Number* x, bool new_x,
+ Number* grad_f);
+
+ virtual bool eval_g(Index n, const Number* x, bool new_x,
+ Index m, Number* g);
+
+ virtual bool eval_jac_g(Index n, const Number* x, bool new_x,
+ Index m, Index nele_jac, Index* iRow,
+ Index *jCol, Number* values);
+
+ virtual bool eval_h(Index n, const Number* x, bool new_x,
+ Number obj_factor, Index m, const Number* lambda,
+ bool new_lambda, Index nele_hess,
+ Index* iRow, Index* jCol, Number* values);
+
+ virtual void finalize_solution(SolverReturn status,
+ Index n, const Number* x, const Number* z_L, const Number* z_U,
+ Index m, const Number* g, const Number* lambda,
+ Number obj_value,
+ const IpoptData* ip_data,
+ IpoptCalculatedQuantities* ip_cq);
+
+ virtual bool intermediate_callback(AlgorithmMode mode,
+ Index iter, Number obj_value,
+ Number inf_pr, Number inf_du,
+ Number mu, Number d_norm,
+ Number regularization_size,
+ Number alpha_du, Number alpha_pr,
+ Index ls_trials,
+ const IpoptData* ip_data,
+ IpoptCalculatedQuantities* ip_cq);
+
+ virtual Index get_number_of_nonlinear_variables();
+
+ virtual bool get_list_of_nonlinear_variables(Index num_nonlin_vars,
+ Index* pos_nonlin_vars);
+ //@}
+
+ 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 */
+ TNLPReducer();
+
+ /** Copy Constructor */
+ TNLPReducer(const TNLPReducer&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const TNLPReducer&);
+ //@}
+
+ /** @name original TNLP */
+ //@{
+ SmartPtr<TNLP> tnlp_;
+ Index m_orig_;
+ Index nnz_jac_g_orig_;
+ //@}
+
+ /** Number of constraints to be skipped */
+ Index n_g_skip_;
+
+ /** Array of indices of the constraints that are to be skipped.
+ * This is provided at the beginning in the constructor. */
+ Index* index_g_skip_;
+
+ /** Index style for original problem. Internally, we use C-Style
+ * now. */
+ IndexStyleEnum index_style_orig_;
+
+ /** Map from original constraints to new constraints. A -1 means
+ * that a constraint is skipped. */
+ Index* g_keep_map_;
+
+ /** Number of constraints in reduced NLP */
+ Index m_reduced_;
+
+ /** Number of Jacobian nonzeros in the reduced NLP */
+ Index nnz_jac_g_reduced_;
+
+ /** Number of Jacobian nonzeros that are skipped */
+ Index nnz_jac_g_skipped_;
+
+ /** Array of Jacobian elements that are to be skipped. This is in
+ * increasing order. */
+ Index* jac_g_skipped_;
+
+ /** Number of lower variable bounds to be skipped. */
+ Index n_xL_skip_;
+
+ /** Array of indices of the lower variable bounds to be skipped. */
+ Index* index_xL_skip_;
+
+ /** Number of upper variable bounds to be skipped. */
+ Index n_xU_skip_;
+
+ /** Array of indices of the upper variable bounds to be skipped. */
+ Index* index_xU_skip_;
+
+ /** Number of variables that are to be fixed to initial value. */
+ Index n_x_fix_;
+
+ /** Array of indices of the variables that are to be fixed. */
+ Index* index_x_fix_;
+ };
+
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpTaggedObject.hpp b/thirdparty/windows/include/coin/IpTaggedObject.hpp index b49ef04..51c6c7d 100644 --- a/thirdparty/windows/include/coin/IpTaggedObject.hpp +++ b/thirdparty/windows/include/coin/IpTaggedObject.hpp @@ -1,149 +1,159 @@ -// Copyright (C) 2004, 2006 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpTaggedObject.hpp 1019 2007-06-24 03:52:34Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPTAGGEDOBJECT_HPP__ -#define __IPTAGGEDOBJECT_HPP__ - -#include "IpUtils.hpp" -#include "IpDebug.hpp" -#include "IpReferenced.hpp" -#include "IpObserver.hpp" -#include <limits> - -namespace Ipopt -{ - - /** TaggedObject class. - * Often, certain calculations or operations are expensive, - * and it can be very inefficient to perform these calculations - * again if the input to the calculation has not changed - * since the result was last stored. - * This base class provides an efficient mechanism to update - * a tag, indicating that the object has changed. - * Users of a TaggedObject class, need their own Tag data - * member to keep track of the state of the TaggedObject, the - * last time they performed a calculation. A basic use case for - * users of a class inheriting off of TaggedObject follows like - * this: - * - * Initialize your own Tag to zero in constructor. - * - * - * - * Before an expensive calculation, - * check if the TaggedObject has changed, passing in - * your own Tag, indicating the last time you used - * the object for the calculation. If it has changed, - * perform the calculation again, and store the result. - * If it has not changed, simply return the stored result. - * - * Here is a simple example: - \verbatim - if (vector.HasChanged(my_vector_tag_)) { - my_vector_tag_ = vector.GetTag(); - result = PerformExpensiveCalculation(vector); - return result; - } - else { - return result; - } - \endverbatim - * - * Objects derived from TaggedObject: - * Objects derived from TaggedObject must indicate that they have changed to - * the base class using the protected member function ObjectChanged(). For - * example, a Vector class, inside its own set method, MUST call - * ObjectChanged() to update the internally stored tag for comparison. - */ - class TaggedObject : public ReferencedObject, public Subject - { - public: - /** Type for the Tag values */ - typedef unsigned int Tag; - - /** Constructor. */ - TaggedObject() - : - Subject() - { - ObjectChanged(); - } - - /** Destructor. */ - virtual ~TaggedObject() - {} - - /** Users of TaggedObjects call this to - * update their own internal tags every time - * they perform the expensive operation. - */ - Tag GetTag() const - { - return tag_; - } - - /** Users of TaggedObjects call this to - * check if the object HasChanged since - * they last updated their own internal - * tag. - */ - bool HasChanged(const Tag comparison_tag) const - { - return (comparison_tag == tag_) ? false : true; - } - protected: - /** Objects derived from TaggedObject MUST call this - * method every time their internal state changes to - * update the internal tag for comparison - */ - void ObjectChanged() - { - DBG_START_METH("TaggedObject::ObjectChanged()", 0); - tag_ = unique_tag_; - unique_tag_++; - DBG_ASSERT(unique_tag_ < std::numeric_limits<Tag>::max()); - // The Notify method from the Subject base class notifies all - // registed Observers that this subject has changed. - Notify(Observer::NT_Changed); - } - 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 */ - TaggedObject(const TaggedObject&); - - /** Overloaded Equals Operator */ - void operator=(const TaggedObject&); - //@} - - /** static data member that is incremented every - * time ANY TaggedObject changes. This allows us - * to obtain a unique Tag when the object changes - */ - static Tag unique_tag_; - - /** The tag indicating the current state of the object. - * We use this to compare against the comparison_tag - * in the HasChanged method. This member is updated - * from the unique_tag_ every time the object changes. - */ - Tag tag_; - - /** The index indicating the cache priority for this - * TaggedObject. If a result that depended on this - * TaggedObject is cached, it will be cached with this - * priority - */ - Index cache_priority_; - }; -} // namespace Ipopt -#endif +// Copyright (C) 2004, 2006 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpTaggedObject.hpp 2276 2013-05-05 12:33:44Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPTAGGEDOBJECT_HPP__
+#define __IPTAGGEDOBJECT_HPP__
+
+#include "IpUtils.hpp"
+#include "IpDebug.hpp"
+#include "IpReferenced.hpp"
+#include "IpObserver.hpp"
+#include <limits>
+#include <utility> // for std::pair
+
+namespace Ipopt
+{
+
+ /** TaggedObject class.
+ * Often, certain calculations or operations are expensive,
+ * and it can be very inefficient to perform these calculations
+ * again if the input to the calculation has not changed
+ * since the result was last stored.
+ * This base class provides an efficient mechanism to update
+ * a tag, indicating that the object has changed.
+ * Users of a TaggedObject class, need their own Tag data
+ * member to keep track of the state of the TaggedObject, the
+ * last time they performed a calculation. A basic use case for
+ * users of a class inheriting from TaggedObject follows like
+ * this:
+ *
+ * 1. Initialize your own Tag by its default constructor.
+ *
+ * 2. Before an expensive calculation,
+ * check if the TaggedObject has changed, passing in
+ * your own Tag, indicating the last time you used
+ * the object for the calculation. If it has changed,
+ * perform the calculation again, and store the result.
+ * If it has not changed, simply return the stored result.
+ *
+ * Here is a simple example:
+ \verbatim
+ if (vector.HasChanged(my_vector_tag_)) {
+ my_vector_tag_ = vector.GetTag();
+ result = PerformExpensiveCalculation(vector);
+ return result;
+ }
+ else {
+ return result;
+ }
+ \endverbatim
+ *
+ * Objects derived from TaggedObject must indicate that they have changed to
+ * the base class using the protected member function ObjectChanged(). For
+ * example, a Vector class, inside its own set method, MUST call
+ * ObjectChanged() to update the internally stored tag for comparison.
+ */
+ class TaggedObject : public ReferencedObject, public Subject
+ {
+ public:
+ /** Type for the Tag values
+ *
+ * To make the tag unique among all objects, we
+ * include the memory address of the object into the
+ * tag value.
+ */
+ typedef std::pair<const TaggedObject*, unsigned int> Tag;
+
+ /** Constructor. */
+ TaggedObject()
+ :
+ Subject(),
+ /* We can initialize the tag counter to 0, because this objects Tag
+ * will differ from a Tag() object in its first member. */
+ tagcount_(0)
+ {
+ ObjectChanged();
+ }
+
+ /** Destructor. */
+ virtual ~TaggedObject()
+ {}
+
+ /** Users of TaggedObjects call this to
+ * update their own internal tags every time
+ * they perform the expensive operation.
+ */
+ Tag GetTag() const
+ {
+ return Tag(this, tagcount_);
+ }
+
+ /** Users of TaggedObjects call this to
+ * check if the object HasChanged since
+ * they last updated their own internal
+ * tag.
+ */
+ bool HasChanged(const Tag comparison_tag) const
+ {
+ return (comparison_tag.first != this) || (comparison_tag.second != tagcount_);
+ }
+ protected:
+ /** Objects derived from TaggedObject MUST call this
+ * method every time their internal state changes to
+ * update the internal tag for comparison
+ */
+ void ObjectChanged()
+ {
+ DBG_START_METH("TaggedObject::ObjectChanged()", 0);
+ tagcount_++;
+ DBG_ASSERT(tagcount_ < std::numeric_limits<Tag::second_type>::max());
+ // The Notify method from the Subject base class notifies all
+ // registered Observers that this subject has changed.
+ Notify(Observer::NT_Changed);
+ }
+ 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 */
+ TaggedObject(const TaggedObject&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const TaggedObject&);
+ //@}
+
+ /** The tag indicating the current state of the object.
+ * We use this to compare against the comparison_tag
+ * in the HasChanged method. This member is increased
+ * every time the object changes.
+ */
+ Tag::second_type tagcount_;
+
+ /** The index indicating the cache priority for this
+ * TaggedObject. If a result that depended on this
+ * TaggedObject is cached, it will be cached with this
+ * priority
+ */
+ Index cache_priority_;
+ };
+
+ /** The addition of two tags - do not use.
+ *
+ * @note Do not use this operator, unless you really know what you are doing.
+ */
+ inline
+ TaggedObject::Tag operator+(const TaggedObject::Tag& tag1, const TaggedObject::Tag& tag2)
+ {
+ return TaggedObject::Tag(tag1.first, tag1.second + tag2.second);
+ }
+
+} // namespace Ipopt
+#endif
diff --git a/thirdparty/windows/include/coin/IpTimedTask.hpp b/thirdparty/windows/include/coin/IpTimedTask.hpp index 3533708..d79469b 100644 --- a/thirdparty/windows/include/coin/IpTimedTask.hpp +++ b/thirdparty/windows/include/coin/IpTimedTask.hpp @@ -1,114 +1,146 @@ -// Copyright (C) 2006 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpTimedTask.hpp 1430 2009-04-20 20:58:25Z andreasw $ -// -// Authors: Andreas Waechter IBM 2005-09-19 - -#ifndef __IPTIMEDTASK_HPP__ -#define __IPTIMEDTASK_HPP__ - -#include "IpUtils.hpp" - -namespace Ipopt -{ - /** This class is used to collect timing information for a - * particular task. */ - class TimedTask - { - public: - /**@name Constructors/Destructors */ - //@{ - /** Default constructor. */ - TimedTask() - : - total_time_(0.), - start_called_(false), - end_called_(true) - {} - - /** Default destructor */ - ~TimedTask() - {} - //@} - - /** Method for resetting time to zero. */ - void Reset() - { - total_time_ = 0.; - start_called_ = false; - end_called_ = true; - } - - /** Method that is called before execution of the task. */ - void Start() - { - DBG_ASSERT(end_called_); - DBG_ASSERT(!start_called_); - end_called_ = false; - start_called_ = true; - start_time_ = CpuTime(); - } - - /** Method that is called after execution of the task. */ - void End() - { - DBG_ASSERT(!end_called_); - DBG_ASSERT(start_called_); - end_called_ = true; - start_called_ = false; - total_time_ += CpuTime() - start_time_; - } - - /** Method that is called after execution of the task for which - * timing might have been started. This only updates the timing - * if the timing has indeed been conducted. This is useful to - * stop timing after catching exceptions. */ - void EndIfStarted() - { - if (start_called_) { - end_called_ = true; - start_called_ = false; - total_time_ += CpuTime() - start_time_; - } - DBG_ASSERT(end_called_); - } - - /** Method returning total time spend for task so far. */ - Number TotalTime() const - { - DBG_ASSERT(end_called_); - return total_time_; - } - - 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 */ - TimedTask(const TimedTask&); - - /** Overloaded Equals Operator */ - void operator=(const TimedTask&); - //@} - - /** Time at beginning of task. */ - Number start_time_; - /** Total time for task measured so far. */ - Number total_time_; - - /** @name fields for debugging */ - //@{ - bool start_called_; - bool end_called_; - //@} - - }; -} // namespace Ipopt - -#endif +// Copyright (C) 2006, 2009 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpTimedTask.hpp 1861 2010-12-21 21:34:47Z andreasw $
+//
+// Authors: Andreas Waechter IBM 2005-09-19
+
+#ifndef __IPTIMEDTASK_HPP__
+#define __IPTIMEDTASK_HPP__
+
+#include "IpUtils.hpp"
+
+namespace Ipopt
+{
+ /** This class is used to collect timing information for a
+ * particular task. */
+ class TimedTask
+ {
+ public:
+ /**@name Constructors/Destructors */
+ //@{
+ /** Default constructor. */
+ TimedTask()
+ :
+ total_cputime_(0.),
+ total_systime_(0.),
+ total_walltime_(0.),
+ start_called_(false),
+ end_called_(true)
+ {}
+
+ /** Default destructor */
+ ~TimedTask()
+ {}
+ //@}
+
+ /** Method for resetting time to zero. */
+ void Reset()
+ {
+ total_cputime_ = 0.;
+ total_systime_ = 0.;
+ total_walltime_ = 0.;
+ start_called_ = false;
+ end_called_ = true;
+ }
+
+ /** Method that is called before execution of the task. */
+ void Start()
+ {
+ DBG_ASSERT(end_called_);
+ DBG_ASSERT(!start_called_);
+ end_called_ = false;
+ start_called_ = true;
+ start_cputime_ = CpuTime();
+ start_systime_ = SysTime();
+ start_walltime_ = WallclockTime();
+ }
+
+ /** Method that is called after execution of the task. */
+ void End()
+ {
+ DBG_ASSERT(!end_called_);
+ DBG_ASSERT(start_called_);
+ end_called_ = true;
+ start_called_ = false;
+ total_cputime_ += CpuTime() - start_cputime_;
+ total_systime_ += SysTime() - start_systime_;
+ total_walltime_ += WallclockTime() - start_walltime_;
+ }
+
+ /** Method that is called after execution of the task for which
+ * timing might have been started. This only updates the timing
+ * if the timing has indeed been conducted. This is useful to
+ * stop timing after catching exceptions. */
+ void EndIfStarted()
+ {
+ if (start_called_) {
+ end_called_ = true;
+ start_called_ = false;
+ total_cputime_ += CpuTime() - start_cputime_;
+ total_systime_ += SysTime() - start_systime_;
+ total_walltime_ += WallclockTime() - start_walltime_;
+ }
+ DBG_ASSERT(end_called_);
+ }
+
+ /** Method returning total CPU time spend for task so far. */
+ Number TotalCpuTime() const
+ {
+ DBG_ASSERT(end_called_);
+ return total_cputime_;
+ }
+
+ /** Method returning total system time spend for task so far. */
+ Number TotalSysTime() const
+ {
+ DBG_ASSERT(end_called_);
+ return total_systime_;
+ }
+
+ /** Method returning total wall clock time spend for task so far. */
+ Number TotalWallclockTime() const
+ {
+ DBG_ASSERT(end_called_);
+ return total_walltime_;
+ }
+
+ 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 */
+ TimedTask(const TimedTask&);
+
+ /** Overloaded Equals Operator */
+ void operator=(const TimedTask&);
+ //@}
+
+ /** CPU time at beginning of task. */
+ Number start_cputime_;
+ /** Total CPU time for task measured so far. */
+ Number total_cputime_;
+ /** System time at beginning of task. */
+ Number start_systime_;
+ /** Total system time for task measured so far. */
+ Number total_systime_;
+ /** Wall clock time at beginning of task. */
+ Number start_walltime_;
+ /** Total wall clock time for task measured so far. */
+ Number total_walltime_;
+
+ /** @name fields for debugging */
+ //@{
+ bool start_called_;
+ bool end_called_;
+ //@}
+
+ };
+} // namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpUtils.hpp b/thirdparty/windows/include/coin/IpUtils.hpp index 55c8fd4..092ace6 100644 --- a/thirdparty/windows/include/coin/IpUtils.hpp +++ b/thirdparty/windows/include/coin/IpUtils.hpp @@ -1,125 +1,128 @@ -// Copyright (C) 2004, 2009 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpUtils.hpp 1521 2009-07-15 22:26:15Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPUTILS_HPP__ -#define __IPUTILS_HPP__ - -// Standard Ip Include Files -#include "IpTypes.hpp" -#include "IpDebug.hpp" - -namespace Ipopt -{ - - inline Index Max(Index a, Index b) - { - return ((a) > (b) ? (a) : (b)); - } - - inline Index Max(Index a, Index b, Index c) - { - Index max = Max(a,b); - max = Max(max, c); - return max; - } - - inline Index Max(Index a, Index b, Index c, Index d) - { - Index max = Max(a, b, c); - max = Max(max, d); - return max; - } - - inline Index Min(Index a, Index b) - { - return ((a) < (b) ? (a) : (b)); - } - - inline Index Min(Index a, Index b, Index c) - { - Index min = Min(a,b); - min = Min(min, c); - return min; - } - - inline Index Min(Index a, Index b, Index c, Index d) - { - Index min = Min(a, b, c); - min = Min(min, d); - return min; - } - - /////////////////////////////////////////// - - inline Number Max(Number a, Number b) - { - return ((a) > (b) ? (a) : (b)); - } - - inline Number Max(Number a, Number b, Number c) - { - Number max = Max(a,b); - max = Max(max, c); - return max; - } - - inline Number Max(Number a, Number b, Number c, Number d) - { - Number max = Max(a, b, c); - max = Max(max, d); - return max; - } - - inline Number Min(Number a, Number b) - { - return ((a) < (b) ? (a) : (b)); - } - - inline Number Min(Number a, Number b, Number c) - { - Number min = Min(a,b); - min = Min(min, c); - return min; - } - - inline Number Min(Number a, Number b, Number c, Number d) - { - Number min = Min(a, b, c); - min = Min(min, d); - return min; - } - - /** Function returning true iff the argument is a valid double number - * (not NaN or Inf). */ - bool IsFiniteNumber(Number val); - - /** Function returning a random number between 0 and 1 */ - Number IpRandom01(); - - /** Function resetting the random number generator */ - void IpResetRandom01(); - - /** method determining CPU executed since start of program */ - Number CpuTime(); - - /** Function for getting a string with the current wallclock time */ - double WallclockTime(); - - /** Method for comparing two numbers within machine precision. The - * return value is true if lhs is less or equal the rhs, relaxing - * this inequality by something a little larger than machine - * precision relative to the absolute value of BasVal. */ - bool Compare_le(Number lhs, Number rhs, Number BasVal); - - /** Method for printing a formatted output to a string with given size. - */ - int Snprintf(char* str, long size, const char* format, ...); - -} //namespace Ipopt - -#endif +// Copyright (C) 2004, 2009 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpUtils.hpp 2167 2013-03-08 11:15:38Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPUTILS_HPP__
+#define __IPUTILS_HPP__
+
+// Standard Ip Include Files
+#include "IpTypes.hpp"
+#include "IpDebug.hpp"
+
+namespace Ipopt
+{
+
+ inline Index Max(Index a, Index b)
+ {
+ return ((a) > (b) ? (a) : (b));
+ }
+
+ inline Index Max(Index a, Index b, Index c)
+ {
+ Index max = Max(a,b);
+ max = Max(max, c);
+ return max;
+ }
+
+ inline Index Max(Index a, Index b, Index c, Index d)
+ {
+ Index max = Max(a, b, c);
+ max = Max(max, d);
+ return max;
+ }
+
+ inline Index Min(Index a, Index b)
+ {
+ return ((a) < (b) ? (a) : (b));
+ }
+
+ inline Index Min(Index a, Index b, Index c)
+ {
+ Index min = Min(a,b);
+ min = Min(min, c);
+ return min;
+ }
+
+ inline Index Min(Index a, Index b, Index c, Index d)
+ {
+ Index min = Min(a, b, c);
+ min = Min(min, d);
+ return min;
+ }
+
+ ///////////////////////////////////////////
+
+ inline Number Max(Number a, Number b)
+ {
+ return ((a) > (b) ? (a) : (b));
+ }
+
+ inline Number Max(Number a, Number b, Number c)
+ {
+ Number max = Max(a,b);
+ max = Max(max, c);
+ return max;
+ }
+
+ inline Number Max(Number a, Number b, Number c, Number d)
+ {
+ Number max = Max(a, b, c);
+ max = Max(max, d);
+ return max;
+ }
+
+ inline Number Min(Number a, Number b)
+ {
+ return ((a) < (b) ? (a) : (b));
+ }
+
+ inline Number Min(Number a, Number b, Number c)
+ {
+ Number min = Min(a,b);
+ min = Min(min, c);
+ return min;
+ }
+
+ inline Number Min(Number a, Number b, Number c, Number d)
+ {
+ Number min = Min(a, b, c);
+ min = Min(min, d);
+ return min;
+ }
+
+ /** Function returning true iff the argument is a valid double number
+ * (not NaN or Inf). */
+ bool IsFiniteNumber(Number val);
+
+ /** Function returning a random number between 0 and 1 */
+ Number IpRandom01();
+
+ /** Function resetting the random number generator */
+ void IpResetRandom01();
+
+ /** method determining CPU time */
+ Number CpuTime();
+
+ /** method determining system time */
+ Number SysTime();
+
+ /** method determining wallclock time since first call */
+ Number WallclockTime();
+
+ /** Method for comparing two numbers within machine precision. The
+ * return value is true if lhs is less or equal the rhs, relaxing
+ * this inequality by something a little larger than machine
+ * precision relative to the absolute value of BasVal. */
+ bool Compare_le(Number lhs, Number rhs, Number BasVal);
+
+ /** Method for printing a formatted output to a string with given size.
+ */
+ int Snprintf(char* str, long size, const char* format, ...);
+
+} //namespace Ipopt
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpVector.hpp b/thirdparty/windows/include/coin/IpVector.hpp index 3b35846..147a8bb 100644 --- a/thirdparty/windows/include/coin/IpVector.hpp +++ b/thirdparty/windows/include/coin/IpVector.hpp @@ -1,744 +1,767 @@ -// Copyright (C) 2004, 2008 International Business Machines and others. -// All Rights Reserved. -// This code is published under the Common Public License. -// -// $Id: IpVector.hpp 1316 2008-09-10 18:42:05Z andreasw $ -// -// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13 - -#ifndef __IPVECTOR_HPP__ -#define __IPVECTOR_HPP__ - -#include "IpTypes.hpp" -#include "IpTaggedObject.hpp" -#include "IpCachedResults.hpp" -#include "IpSmartPtr.hpp" -#include "IpJournalist.hpp" -#include "IpException.hpp" - -#include <vector> - -namespace Ipopt -{ - /** Exception that can be used to flag unimplemented linear algebra - * methods */ - DECLARE_STD_EXCEPTION(UNIMPLEMENTED_LINALG_METHOD_CALLED); - - /* forward declarations */ - class VectorSpace; - - /** Vector Base Class. - * This is the base class for all derived vector types. Those vectors - * are meant to store entities like iterates, Lagrangian multipliers, - * constraint values etc. The implementation of a vector type depends - * on the computational environment (e.g. just a double array on a shared - * memory machine, or distributed double arrays for a distributed - * memory machine.) - * - * Deriving from Vector: This class inherits from tagged object to - * implement an advanced caching scheme. Because of this, the - * TaggedObject method ObjectChanged() must be called each time the - * Vector changes. If you overload the XXXX_Impl protected methods, - * this taken care of (along with caching if possible) for you. If - * you have additional methods in your derived class that change the - * underlying data (vector values), you MUST remember to call - * ObjectChanged() AFTER making the change! - */ - class Vector : public TaggedObject - { - public: - /** @name Constructor/Destructor */ - //@{ - /** Constructor. It has to be given a pointer to the - * corresponding VectorSpace. - */ - Vector(const VectorSpace* owner_space); - - /** Destructor */ - virtual ~Vector(); - //@} - - /** Create new Vector of the same type with uninitialized data */ - Vector* MakeNew() const; - - /** Create new Vector of the same type and copy the data over */ - Vector* MakeNewCopy() const; - - /**@name Standard BLAS-1 Operations - * (derived classes do NOT overload these - * methods, instead, overload the - * protected versions of these methods). */ - //@{ - /** Copy the data of the vector x into this vector (DCOPY). */ - void Copy(const Vector& x); - - /** Scales the vector by scalar alpha (DSCAL) */ - void Scal(Number alpha); - - /** Add the multiple alpha of vector x to this vector (DAXPY) */ - void Axpy(Number alpha, const Vector &x); - - /** Computes inner product of vector x with this (DDOT) */ - Number Dot(const Vector &x) const; - - /** Computes the 2-norm of this vector (DNRM2) */ - Number Nrm2() const; - - /** Computes the 1-norm of this vector (DASUM) */ - Number Asum() const; - - /** Computes the max-norm of this vector (based on IDAMAX) */ - Number Amax() const; - //@} - - /** @name Additional (Non-BLAS) Vector Methods - * (derived classes do NOT overload these - * methods, instead, overload the - * protected versions of these methods). */ - //@{ - /** Set each element in the vector to the scalar alpha. */ - void Set(Number alpha); - - /** Element-wise division \f$y_i \gets y_i/x_i\f$*/ - void ElementWiseDivide(const Vector& x); - - /** Element-wise multiplication \f$y_i \gets y_i*x_i\f$ */ - void ElementWiseMultiply(const Vector& x); - - /** Element-wise max against entries in x */ - void ElementWiseMax(const Vector& x); - - /** Element-wise min against entries in x */ - void ElementWiseMin(const Vector& x); - - /** Reciprocates the entries in the vector */ - void ElementWiseReciprocal(); - - /** Absolute values of the entries in the vector */ - void ElementWiseAbs(); - - /** Element-wise square root of the entries in the vector */ - void ElementWiseSqrt(); - - /** Replaces the vector values with their sgn values - ( -1 if x_i < 0, 0 if x_i == 0, and 1 if x_i > 0) - */ - void ElementWiseSgn(); - - /** Add scalar to every vector component */ - void AddScalar(Number scalar); - - /** Returns the maximum value in the vector */ - Number Max() const; - - /** Returns the minimum value in the vector */ - Number Min() const; - - /** Returns the sum of the vector entries */ - Number Sum() const; - - /** Returns the sum of the logs of each vector entry */ - Number SumLogs() const; - //@} - - /** @name Methods for specialized operations. A prototype - * implementation is provided, but for efficient implementation - * those should be specially implemented. - */ - //@{ - /** Add one vector, y = a * v1 + c * y. This is automatically - * reduced to call AddTwoVectors. */ - void AddOneVector(Number a, const Vector& v1, Number c); - - /** Add two vectors, y = a * v1 + b * v2 + c * y. Here, this - * vector is y */ - void AddTwoVectors(Number a, const Vector& v1, - Number b, const Vector& v2, Number c); - /** Fraction to the boundary parameter. Computes \f$\alpha = - * \max\{\bar\alpha\in(0,1] : x + \bar\alpha \Delta \geq (1-\tau)x\}\f$ - */ - Number FracToBound(const Vector& delta, Number tau) const; - /** Add the quotient of two vectors, y = a * z/s + c * y. */ - void AddVectorQuotient(Number a, const Vector& z, const Vector& s, - Number c); - //@} - - /** Method for determining if all stored numbers are valid (i.e., - * no Inf or Nan). */ - bool HasValidNumbers() const; - - /** @name Accessor methods */ - //@{ - /** Dimension of the Vector */ - Index Dim() const; - - /** Return the owner VectorSpace*/ - SmartPtr<const VectorSpace> OwnerSpace() const; - //@} - - /** @name Output methods - * (derived classes do NOT overload these - * methods, instead, overload the - * protected versions of these methods). */ - //@{ - /** Print the entire vector */ - void Print(SmartPtr<const Journalist> jnlst, - EJournalLevel level, - EJournalCategory category, - const std::string& name, - Index indent=0, - const std::string& prefix="") const; - void Print(const Journalist& jnlst, - EJournalLevel level, - EJournalCategory category, - const std::string& name, - Index indent=0, - const std::string& prefix="") const; - //@} - - protected: - /** @name implementation methods (derived classes MUST - * overload these pure virtual protected methods.) - */ - //@{ - /** Copy the data of the vector x into this vector (DCOPY). */ - virtual void CopyImpl(const Vector& x)=0; - - /** Scales the vector by scalar alpha (DSCAL) */ - virtual void ScalImpl(Number alpha)=0; - - /** Add the multiple alpha of vector x to this vector (DAXPY) */ - virtual void AxpyImpl(Number alpha, const Vector &x)=0; - - /** Computes inner product of vector x with this (DDOT) */ - virtual Number DotImpl(const Vector &x) const =0; - - /** Computes the 2-norm of this vector (DNRM2) */ - virtual Number Nrm2Impl() const =0; - - /** Computes the 1-norm of this vector (DASUM) */ - virtual Number AsumImpl() const =0; - - /** Computes the max-norm of this vector (based on IDAMAX) */ - virtual Number AmaxImpl() const =0; - - /** Set each element in the vector to the scalar alpha. */ - virtual void SetImpl(Number alpha)=0; - - /** Element-wise division \f$y_i \gets y_i/x_i\f$*/ - virtual void ElementWiseDivideImpl(const Vector& x)=0; - - /** Element-wise multiplication \f$y_i \gets y_i*x_i\f$ */ - virtual void ElementWiseMultiplyImpl(const Vector& x)=0; - - /** Element-wise max against entries in x */ - virtual void ElementWiseMaxImpl(const Vector& x)=0; - - /** Element-wise min against entries in x */ - virtual void ElementWiseMinImpl(const Vector& x)=0; - - /** Reciprocates the elements of the vector */ - virtual void ElementWiseReciprocalImpl()=0; - - /** Take elementwise absolute values of the elements of the vector */ - virtual void ElementWiseAbsImpl()=0; - - /** Take elementwise square-root of the elements of the vector */ - virtual void ElementWiseSqrtImpl()=0; - - /** Replaces entries with sgn of the entry */ - virtual void ElementWiseSgnImpl()=0; - - /** Add scalar to every component of vector */ - virtual void AddScalarImpl(Number scalar)=0; - - /** Max value in the vector */ - virtual Number MaxImpl() const=0; - - /** Min number in the vector */ - virtual Number MinImpl() const=0; - - /** Sum of entries in the vector */ - virtual Number SumImpl() const=0; - - /** Sum of logs of entries in the vector */ - virtual Number SumLogsImpl() const=0; - - /** Add two vectors (a * v1 + b * v2). Result is stored in this - vector. */ - virtual void AddTwoVectorsImpl(Number a, const Vector& v1, - Number b, const Vector& v2, Number c); - - /** Fraction to boundary parameter. */ - virtual Number FracToBoundImpl(const Vector& delta, Number tau) const; - - /** Add the quotient of two vectors */ - virtual void AddVectorQuotientImpl(Number a, const Vector& z, - const Vector& s, Number c); - - /** Method for determining if all stored numbers are valid (i.e., - * no Inf or Nan). A default implementation using Asum is - * provided. */ - virtual bool HasValidNumbersImpl() const; - - /** Print the entire vector */ - virtual void PrintImpl(const Journalist& jnlst, - EJournalLevel level, - EJournalCategory category, - const std::string& name, - Index indent, - const std::string& prefix) const =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 */ - Vector(); - - /** Copy constructor */ - Vector(const Vector&); - - /** Overloaded Equals Operator */ - Vector& operator=(const Vector&); - //@} - - /** Vector Space */ - const SmartPtr<const VectorSpace> owner_space_; - - /**@name CachedResults data members */ - //@{ - /** Cache for dot products */ - mutable CachedResults<Number> dot_cache_; - - mutable TaggedObject::Tag nrm2_cache_tag_; - mutable Number cached_nrm2_; - - mutable TaggedObject::Tag asum_cache_tag_; - mutable Number cached_asum_; - - mutable TaggedObject::Tag amax_cache_tag_; - mutable Number cached_amax_; - - mutable TaggedObject::Tag max_cache_tag_; - mutable Number cached_max_; - - mutable TaggedObject::Tag min_cache_tag_; - mutable Number cached_min_; - - mutable TaggedObject::Tag sum_cache_tag_; - mutable Number cached_sum_; - - mutable TaggedObject::Tag sumlogs_cache_tag_; - mutable Number cached_sumlogs_; - - mutable TaggedObject::Tag valid_cache_tag_; - mutable bool cached_valid_; - - // AW: I removed this cache since it gets in the way for the - // quality function search - // /** Cache for FracToBound */ - // mutable CachedResults<Number> frac_to_bound_cache_; - //@} - - }; - - /** VectorSpace base class, corresponding to the Vector base class. - * For each Vector implementation, a corresponding VectorSpace has - * to be implemented. A VectorSpace is able to create new Vectors - * of a specific type. The VectorSpace should also store - * information that is common to all Vectors of that type. For - * example, the dimension of a Vector is stored in the VectorSpace - * base class. - */ - class VectorSpace : public ReferencedObject - { - public: - /** @name Constructors/Destructors */ - //@{ - /** Constructor, given the dimension of all vectors generated by - * this VectorSpace. - */ - VectorSpace(Index dim); - - /** Destructor */ - virtual ~VectorSpace() - {} - //@} - - /** Pure virtual method for creating a new Vector of the - * corresponding type. - */ - virtual Vector* MakeNew() const=0; - - /** Accessor function for the dimension of the vectors of this type.*/ - Index Dim() const - { - return dim_; - } - - 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 */ - VectorSpace(); - - /** Copy constructor */ - VectorSpace(const VectorSpace&); - - /** Overloaded Equals Operator */ - VectorSpace& operator=(const VectorSpace&); - //@} - - /** Dimension of the vectors in this vector space. */ - const Index dim_; - }; - - /* inline methods */ - inline - Vector::~Vector() - {} - - inline - Vector::Vector(const VectorSpace* owner_space) - : - TaggedObject(), - owner_space_(owner_space), - dot_cache_(10), - nrm2_cache_tag_(0), - asum_cache_tag_(0), - amax_cache_tag_(0), - max_cache_tag_(0), - min_cache_tag_(0), - sum_cache_tag_(0), - sumlogs_cache_tag_(0), - cached_valid_(0) - { - DBG_ASSERT(IsValid(owner_space_)); - } - - inline - Vector* Vector::MakeNew() const - { - return owner_space_->MakeNew(); - } - - inline - Vector* Vector::MakeNewCopy() const - { - // ToDo: We can probably copy also the cached values for Norms etc here - Vector* copy = MakeNew(); - copy->Copy(*this); - return copy; - } - - inline - void Vector::Copy(const Vector& x) - { - CopyImpl(x); - ObjectChanged(); - // Also copy any cached scalar values from the original vector - // ToDo: Check if that is too much overhead - TaggedObject::Tag x_tag = x.GetTag(); - if (x_tag == x.nrm2_cache_tag_) { - nrm2_cache_tag_ = GetTag(); - cached_nrm2_ = x.cached_nrm2_; - } - if (x_tag == x.asum_cache_tag_) { - asum_cache_tag_ = GetTag(); - cached_asum_ = x.cached_asum_; - } - if (x_tag == x.amax_cache_tag_) { - amax_cache_tag_ = GetTag(); - cached_amax_ = x.cached_amax_; - } - if (x_tag == x.max_cache_tag_) { - max_cache_tag_ = GetTag(); - cached_max_ = x.cached_max_; - } - if (x_tag == x.min_cache_tag_) { - min_cache_tag_ = GetTag(); - cached_min_ = x.cached_min_; - } - if (x_tag == x.sum_cache_tag_) { - sum_cache_tag_ = GetTag(); - cached_sum_ = x.cached_sum_; - } - if (x_tag == x.sumlogs_cache_tag_) { - sumlogs_cache_tag_ = GetTag(); - cached_sumlogs_ = x.cached_sumlogs_; - } - } - - inline - void Vector::Axpy(Number alpha, const Vector &x) - { - AxpyImpl(alpha, x); - ObjectChanged(); - } - - inline - Number Vector::Dot(const Vector &x) const - { - // The current implementation of the caching doesn't allow to have - // a dependency of something with itself. Therefore, we use the - // Nrm2 method if the dot product is to be taken with the vector - // itself. Might be more efficient anyway. - if (this==&x) { - Number nrm2 = Nrm2(); - return nrm2*nrm2; - } - Number retValue; - if (!dot_cache_.GetCachedResult2Dep(retValue, this, &x)) { - retValue = DotImpl(x); - dot_cache_.AddCachedResult2Dep(retValue, this, &x); - } - return retValue; - } - - inline - Number Vector::Nrm2() const - { - if (nrm2_cache_tag_ != GetTag()) { - cached_nrm2_ = Nrm2Impl(); - nrm2_cache_tag_ = GetTag(); - } - return cached_nrm2_; - } - - inline - Number Vector::Asum() const - { - if (asum_cache_tag_ != GetTag()) { - cached_asum_ = AsumImpl(); - asum_cache_tag_ = GetTag(); - } - return cached_asum_; - } - - inline - Number Vector::Amax() const - { - if (amax_cache_tag_ != GetTag()) { - cached_amax_ = AmaxImpl(); - amax_cache_tag_ = GetTag(); - } - return cached_amax_; - } - - inline - Number Vector::Sum() const - { - if (sum_cache_tag_ != GetTag()) { - cached_sum_ = SumImpl(); - sum_cache_tag_ = GetTag(); - } - return cached_sum_; - } - - inline - Number Vector::SumLogs() const - { - if (sumlogs_cache_tag_ != GetTag()) { - cached_sumlogs_ = SumLogsImpl(); - sumlogs_cache_tag_ = GetTag(); - } - return cached_sumlogs_; - } - - inline - void Vector::ElementWiseSgn() - { - ElementWiseSgnImpl(); - ObjectChanged(); - } - - inline - void Vector::Set(Number alpha) - { - // Could initialize caches here - SetImpl(alpha); - ObjectChanged(); - } - - inline - void Vector::ElementWiseDivide(const Vector& x) - { - ElementWiseDivideImpl(x); - ObjectChanged(); - } - - inline - void Vector::ElementWiseMultiply(const Vector& x) - { - ElementWiseMultiplyImpl(x); - ObjectChanged(); - } - - inline - void Vector::ElementWiseReciprocal() - { - ElementWiseReciprocalImpl(); - ObjectChanged(); - } - - inline - void Vector::ElementWiseMax(const Vector& x) - { - // Could initialize some caches here - ElementWiseMaxImpl(x); - ObjectChanged(); - } - - inline - void Vector::ElementWiseMin(const Vector& x) - { - // Could initialize some caches here - ElementWiseMinImpl(x); - ObjectChanged(); - } - - inline - void Vector::ElementWiseAbs() - { - // Could initialize some caches here - ElementWiseAbsImpl(); - ObjectChanged(); - } - - inline - void Vector::ElementWiseSqrt() - { - ElementWiseSqrtImpl(); - ObjectChanged(); - } - - inline - void Vector::AddScalar(Number scalar) - { - // Could initialize some caches here - AddScalarImpl(scalar); - ObjectChanged(); - } - - inline - Number Vector::Max() const - { - if (max_cache_tag_ != GetTag()) { - cached_max_ = MaxImpl(); - max_cache_tag_ = GetTag(); - } - return cached_max_; - } - - inline - Number Vector::Min() const - { - if (min_cache_tag_ != GetTag()) { - cached_min_ = MinImpl(); - min_cache_tag_ = GetTag(); - } - return cached_min_; - } - - inline - void Vector::AddOneVector(Number a, const Vector& v1, Number c) - { - AddTwoVectors(a, v1, 0., v1, c); - } - - inline - void Vector::AddTwoVectors(Number a, const Vector& v1, - Number b, const Vector& v2, Number c) - { - AddTwoVectorsImpl(a, v1, b, v2, c); - ObjectChanged(); - } - - inline - Number Vector::FracToBound(const Vector& delta, Number tau) const - { - /* AW: I avoid the caching here, since it leads to overhead in the - quality function search. Caches for this are in - CalculatedQuantities. - Number retValue; - std::vector<const TaggedObject*> tdeps(1); - tdeps[0] = δ - std::vector<Number> sdeps(1); - sdeps[0] = tau; - if (!frac_to_bound_cache_.GetCachedResult(retValue, tdeps, sdeps)) { - retValue = FracToBoundImpl(delta, tau); - frac_to_bound_cache_.AddCachedResult(retValue, tdeps, sdeps); - } - return retValue; - */ - return FracToBoundImpl(delta, tau); - } - - inline - void Vector::AddVectorQuotient(Number a, const Vector& z, - const Vector& s, Number c) - { - AddVectorQuotientImpl(a, z, s, c); - ObjectChanged(); - } - - inline - bool Vector::HasValidNumbers() const - { - if (valid_cache_tag_ != GetTag()) { - cached_valid_ = HasValidNumbersImpl(); - valid_cache_tag_ = GetTag(); - } - return cached_valid_; - } - - inline - Index Vector::Dim() const - { - return owner_space_->Dim(); - } - - inline - SmartPtr<const VectorSpace> Vector::OwnerSpace() const - { - return owner_space_; - } - - inline - VectorSpace::VectorSpace(Index dim) - : - dim_(dim) - {} - -} // namespace Ipopt - -// Macro definitions for debugging vectors -#if COIN_IPOPT_VERBOSITY == 0 -# define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec) -#else -# define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec) \ - if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \ - if (dbg_jrnl.Jnlst()!=NULL) { \ - (__vec).Print(dbg_jrnl.Jnlst(), \ - J_ERROR, J_DBG, \ - __vec_name, \ - dbg_jrnl.IndentationLevel()*2, \ - "# "); \ - } \ - } -#endif //if COIN_IPOPT_VERBOSITY == 0 - -#endif +// Copyright (C) 2004, 2008 International Business Machines and others.
+// All Rights Reserved.
+// This code is published under the Eclipse Public License.
+//
+// $Id: IpVector.hpp 2276 2013-05-05 12:33:44Z stefan $
+//
+// Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
+
+#ifndef __IPVECTOR_HPP__
+#define __IPVECTOR_HPP__
+
+#include "IpTypes.hpp"
+#include "IpTaggedObject.hpp"
+#include "IpCachedResults.hpp"
+#include "IpSmartPtr.hpp"
+#include "IpJournalist.hpp"
+#include "IpException.hpp"
+
+#include <vector>
+
+namespace Ipopt
+{
+ /** Exception that can be used to flag unimplemented linear algebra
+ * methods */
+ DECLARE_STD_EXCEPTION(UNIMPLEMENTED_LINALG_METHOD_CALLED);
+
+ /* forward declarations */
+ class VectorSpace;
+
+ /** Vector Base Class.
+ * This is the base class for all derived vector types. Those vectors
+ * are meant to store entities like iterates, Lagrangian multipliers,
+ * constraint values etc. The implementation of a vector type depends
+ * on the computational environment (e.g. just a double array on a shared
+ * memory machine, or distributed double arrays for a distributed
+ * memory machine.)
+ *
+ * Deriving from Vector: This class inherits from tagged object to
+ * implement an advanced caching scheme. Because of this, the
+ * TaggedObject method ObjectChanged() must be called each time the
+ * Vector changes. If you overload the XXXX_Impl protected methods,
+ * this taken care of (along with caching if possible) for you. If
+ * you have additional methods in your derived class that change the
+ * underlying data (vector values), you MUST remember to call
+ * ObjectChanged() AFTER making the change!
+ */
+ class Vector : public TaggedObject
+ {
+ public:
+ /** @name Constructor/Destructor */
+ //@{
+ /** Constructor. It has to be given a pointer to the
+ * corresponding VectorSpace.
+ */
+ inline
+ Vector(const VectorSpace* owner_space);
+
+ /** Destructor */
+ inline
+ virtual ~Vector();
+ //@}
+
+ /** Create new Vector of the same type with uninitialized data */
+ inline
+ Vector* MakeNew() const;
+
+ /** Create new Vector of the same type and copy the data over */
+ inline
+ Vector* MakeNewCopy() const;
+
+ /**@name Standard BLAS-1 Operations
+ * (derived classes do NOT overload these
+ * methods, instead, overload the
+ * protected versions of these methods). */
+ //@{
+ /** Copy the data of the vector x into this vector (DCOPY). */
+ inline
+ void Copy(const Vector& x);
+
+ /** Scales the vector by scalar alpha (DSCAL) */
+ void Scal(Number alpha);
+
+ /** Add the multiple alpha of vector x to this vector (DAXPY) */
+ inline
+ void Axpy(Number alpha, const Vector &x);
+
+ /** Computes inner product of vector x with this (DDOT) */
+ inline
+ Number Dot(const Vector &x) const;
+
+ /** Computes the 2-norm of this vector (DNRM2) */
+ inline
+ Number Nrm2() const;
+
+ /** Computes the 1-norm of this vector (DASUM) */
+ inline
+ Number Asum() const;
+
+ /** Computes the max-norm of this vector (based on IDAMAX) */
+ inline
+ Number Amax() const;
+ //@}
+
+ /** @name Additional (Non-BLAS) Vector Methods
+ * (derived classes do NOT overload these
+ * methods, instead, overload the
+ * protected versions of these methods). */
+ //@{
+ /** Set each element in the vector to the scalar alpha. */
+ inline
+ void Set(Number alpha);
+
+ /** Element-wise division \f$y_i \gets y_i/x_i\f$*/
+ inline
+ void ElementWiseDivide(const Vector& x);
+
+ /** Element-wise multiplication \f$y_i \gets y_i*x_i\f$ */
+ inline
+ void ElementWiseMultiply(const Vector& x);
+
+ /** Element-wise max against entries in x */
+ inline
+ void ElementWiseMax(const Vector& x);
+
+ /** Element-wise min against entries in x */
+ inline
+ void ElementWiseMin(const Vector& x);
+
+ /** Reciprocates the entries in the vector */
+ inline
+ void ElementWiseReciprocal();
+
+ /** Absolute values of the entries in the vector */
+ inline
+ void ElementWiseAbs();
+
+ /** Element-wise square root of the entries in the vector */
+ inline
+ void ElementWiseSqrt();
+
+ /** Replaces the vector values with their sgn values
+ ( -1 if x_i < 0, 0 if x_i == 0, and 1 if x_i > 0)
+ */
+ inline
+ void ElementWiseSgn();
+
+ /** Add scalar to every vector component */
+ inline
+ void AddScalar(Number scalar);
+
+ /** Returns the maximum value in the vector */
+ inline
+ Number Max() const;
+
+ /** Returns the minimum value in the vector */
+ inline
+ Number Min() const;
+
+ /** Returns the sum of the vector entries */
+ inline
+ Number Sum() const;
+
+ /** Returns the sum of the logs of each vector entry */
+ inline
+ Number SumLogs() const;
+ //@}
+
+ /** @name Methods for specialized operations. A prototype
+ * implementation is provided, but for efficient implementation
+ * those should be specially implemented.
+ */
+ //@{
+ /** Add one vector, y = a * v1 + c * y. This is automatically
+ * reduced to call AddTwoVectors. */
+ inline
+ void AddOneVector(Number a, const Vector& v1, Number c);
+
+ /** Add two vectors, y = a * v1 + b * v2 + c * y. Here, this
+ * vector is y */
+ inline void AddTwoVectors(Number a, const Vector& v1,
+ Number b, const Vector& v2, Number c);
+ /** Fraction to the boundary parameter. Computes \f$\alpha =
+ * \max\{\bar\alpha\in(0,1] : x + \bar\alpha \Delta \geq (1-\tau)x\}\f$
+ */
+ inline
+ Number FracToBound(const Vector& delta, Number tau) const;
+ /** Add the quotient of two vectors, y = a * z/s + c * y. */
+ inline
+ void AddVectorQuotient(Number a, const Vector& z, const Vector& s,
+ Number c);
+ //@}
+
+ /** Method for determining if all stored numbers are valid (i.e.,
+ * no Inf or Nan). */
+ inline
+ bool HasValidNumbers() const;
+
+ /** @name Accessor methods */
+ //@{
+ /** Dimension of the Vector */
+ inline
+ Index Dim() const;
+
+ /** Return the owner VectorSpace*/
+ inline
+ SmartPtr<const VectorSpace> OwnerSpace() const;
+ //@}
+
+ /** @name Output methods
+ * (derived classes do NOT overload these
+ * methods, instead, overload the
+ * protected versions of these methods). */
+ //@{
+ /** Print the entire vector */
+ void Print(SmartPtr<const Journalist> jnlst,
+ EJournalLevel level,
+ EJournalCategory category,
+ const std::string& name,
+ Index indent=0,
+ const std::string& prefix="") const;
+ void Print(const Journalist& jnlst,
+ EJournalLevel level,
+ EJournalCategory category,
+ const std::string& name,
+ Index indent=0,
+ const std::string& prefix="") const;
+ //@}
+
+ protected:
+ /** @name implementation methods (derived classes MUST
+ * overload these pure virtual protected methods.)
+ */
+ //@{
+ /** Copy the data of the vector x into this vector (DCOPY). */
+ virtual void CopyImpl(const Vector& x)=0;
+
+ /** Scales the vector by scalar alpha (DSCAL) */
+ virtual void ScalImpl(Number alpha)=0;
+
+ /** Add the multiple alpha of vector x to this vector (DAXPY) */
+ virtual void AxpyImpl(Number alpha, const Vector &x)=0;
+
+ /** Computes inner product of vector x with this (DDOT) */
+ virtual Number DotImpl(const Vector &x) const =0;
+
+ /** Computes the 2-norm of this vector (DNRM2) */
+ virtual Number Nrm2Impl() const =0;
+
+ /** Computes the 1-norm of this vector (DASUM) */
+ virtual Number AsumImpl() const =0;
+
+ /** Computes the max-norm of this vector (based on IDAMAX) */
+ virtual Number AmaxImpl() const =0;
+
+ /** Set each element in the vector to the scalar alpha. */
+ virtual void SetImpl(Number alpha)=0;
+
+ /** Element-wise division \f$y_i \gets y_i/x_i\f$*/
+ virtual void ElementWiseDivideImpl(const Vector& x)=0;
+
+ /** Element-wise multiplication \f$y_i \gets y_i*x_i\f$ */
+ virtual void ElementWiseMultiplyImpl(const Vector& x)=0;
+
+ /** Element-wise max against entries in x */
+ virtual void ElementWiseMaxImpl(const Vector& x)=0;
+
+ /** Element-wise min against entries in x */
+ virtual void ElementWiseMinImpl(const Vector& x)=0;
+
+ /** Reciprocates the elements of the vector */
+ virtual void ElementWiseReciprocalImpl()=0;
+
+ /** Take elementwise absolute values of the elements of the vector */
+ virtual void ElementWiseAbsImpl()=0;
+
+ /** Take elementwise square-root of the elements of the vector */
+ virtual void ElementWiseSqrtImpl()=0;
+
+ /** Replaces entries with sgn of the entry */
+ virtual void ElementWiseSgnImpl()=0;
+
+ /** Add scalar to every component of vector */
+ virtual void AddScalarImpl(Number scalar)=0;
+
+ /** Max value in the vector */
+ virtual Number MaxImpl() const=0;
+
+ /** Min number in the vector */
+ virtual Number MinImpl() const=0;
+
+ /** Sum of entries in the vector */
+ virtual Number SumImpl() const=0;
+
+ /** Sum of logs of entries in the vector */
+ virtual Number SumLogsImpl() const=0;
+
+ /** Add two vectors (a * v1 + b * v2). Result is stored in this
+ vector. */
+ virtual void AddTwoVectorsImpl(Number a, const Vector& v1,
+ Number b, const Vector& v2, Number c);
+
+ /** Fraction to boundary parameter. */
+ virtual Number FracToBoundImpl(const Vector& delta, Number tau) const;
+
+ /** Add the quotient of two vectors */
+ virtual void AddVectorQuotientImpl(Number a, const Vector& z,
+ const Vector& s, Number c);
+
+ /** Method for determining if all stored numbers are valid (i.e.,
+ * no Inf or Nan). A default implementation using Asum is
+ * provided. */
+ virtual bool HasValidNumbersImpl() const;
+
+ /** Print the entire vector */
+ virtual void PrintImpl(const Journalist& jnlst,
+ EJournalLevel level,
+ EJournalCategory category,
+ const std::string& name,
+ Index indent,
+ const std::string& prefix) const =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 */
+ Vector();
+
+ /** Copy constructor */
+ Vector(const Vector&);
+
+ /** Overloaded Equals Operator */
+ Vector& operator=(const Vector&);
+ //@}
+
+ /** Vector Space */
+ const SmartPtr<const VectorSpace> owner_space_;
+
+ /**@name CachedResults data members */
+ //@{
+ /** Cache for dot products */
+ mutable CachedResults<Number> dot_cache_;
+
+ mutable TaggedObject::Tag nrm2_cache_tag_;
+ mutable Number cached_nrm2_;
+
+ mutable TaggedObject::Tag asum_cache_tag_;
+ mutable Number cached_asum_;
+
+ mutable TaggedObject::Tag amax_cache_tag_;
+ mutable Number cached_amax_;
+
+ mutable TaggedObject::Tag max_cache_tag_;
+ mutable Number cached_max_;
+
+ mutable TaggedObject::Tag min_cache_tag_;
+ mutable Number cached_min_;
+
+ mutable TaggedObject::Tag sum_cache_tag_;
+ mutable Number cached_sum_;
+
+ mutable TaggedObject::Tag sumlogs_cache_tag_;
+ mutable Number cached_sumlogs_;
+
+ mutable TaggedObject::Tag valid_cache_tag_;
+ mutable bool cached_valid_;
+
+ // AW: I removed this cache since it gets in the way for the
+ // quality function search
+ // /** Cache for FracToBound */
+ // mutable CachedResults<Number> frac_to_bound_cache_;
+ //@}
+
+ };
+
+ /** VectorSpace base class, corresponding to the Vector base class.
+ * For each Vector implementation, a corresponding VectorSpace has
+ * to be implemented. A VectorSpace is able to create new Vectors
+ * of a specific type. The VectorSpace should also store
+ * information that is common to all Vectors of that type. For
+ * example, the dimension of a Vector is stored in the VectorSpace
+ * base class.
+ */
+ class VectorSpace : public ReferencedObject
+ {
+ public:
+ /** @name Constructors/Destructors */
+ //@{
+ /** Constructor, given the dimension of all vectors generated by
+ * this VectorSpace.
+ */
+ VectorSpace(Index dim);
+
+ /** Destructor */
+ virtual ~VectorSpace()
+ {}
+ //@}
+
+ /** Pure virtual method for creating a new Vector of the
+ * corresponding type.
+ */
+ virtual Vector* MakeNew() const=0;
+
+ /** Accessor function for the dimension of the vectors of this type.*/
+ Index Dim() const
+ {
+ return dim_;
+ }
+
+ 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 */
+ VectorSpace();
+
+ /** Copy constructor */
+ VectorSpace(const VectorSpace&);
+
+ /** Overloaded Equals Operator */
+ VectorSpace& operator=(const VectorSpace&);
+ //@}
+
+ /** Dimension of the vectors in this vector space. */
+ const Index dim_;
+ };
+
+ /* inline methods */
+ inline
+ Vector::~Vector()
+ {}
+
+ inline
+ Vector::Vector(const VectorSpace* owner_space)
+ :
+ TaggedObject(),
+ owner_space_(owner_space),
+ dot_cache_(10),
+ cached_valid_(0)
+ {
+ DBG_ASSERT(IsValid(owner_space_));
+ }
+
+ inline
+ Vector* Vector::MakeNew() const
+ {
+ return owner_space_->MakeNew();
+ }
+
+ inline
+ Vector* Vector::MakeNewCopy() const
+ {
+ // ToDo: We can probably copy also the cached values for Norms etc here
+ Vector* copy = MakeNew();
+ copy->Copy(*this);
+ return copy;
+ }
+
+ inline
+ void Vector::Copy(const Vector& x)
+ {
+ CopyImpl(x);
+ ObjectChanged();
+ // Also copy any cached scalar values from the original vector
+ // ToDo: Check if that is too much overhead
+ TaggedObject::Tag x_tag = x.GetTag();
+ if (x_tag == x.nrm2_cache_tag_) {
+ nrm2_cache_tag_ = GetTag();
+ cached_nrm2_ = x.cached_nrm2_;
+ }
+ if (x_tag == x.asum_cache_tag_) {
+ asum_cache_tag_ = GetTag();
+ cached_asum_ = x.cached_asum_;
+ }
+ if (x_tag == x.amax_cache_tag_) {
+ amax_cache_tag_ = GetTag();
+ cached_amax_ = x.cached_amax_;
+ }
+ if (x_tag == x.max_cache_tag_) {
+ max_cache_tag_ = GetTag();
+ cached_max_ = x.cached_max_;
+ }
+ if (x_tag == x.min_cache_tag_) {
+ min_cache_tag_ = GetTag();
+ cached_min_ = x.cached_min_;
+ }
+ if (x_tag == x.sum_cache_tag_) {
+ sum_cache_tag_ = GetTag();
+ cached_sum_ = x.cached_sum_;
+ }
+ if (x_tag == x.sumlogs_cache_tag_) {
+ sumlogs_cache_tag_ = GetTag();
+ cached_sumlogs_ = x.cached_sumlogs_;
+ }
+ }
+
+ inline
+ void Vector::Axpy(Number alpha, const Vector &x)
+ {
+ AxpyImpl(alpha, x);
+ ObjectChanged();
+ }
+
+ inline
+ Number Vector::Dot(const Vector &x) const
+ {
+ // The current implementation of the caching doesn't allow to have
+ // a dependency of something with itself. Therefore, we use the
+ // Nrm2 method if the dot product is to be taken with the vector
+ // itself. Might be more efficient anyway.
+ if (this==&x) {
+ Number nrm2 = Nrm2();
+ return nrm2*nrm2;
+ }
+ Number retValue;
+ if (!dot_cache_.GetCachedResult2Dep(retValue, this, &x)) {
+ retValue = DotImpl(x);
+ dot_cache_.AddCachedResult2Dep(retValue, this, &x);
+ }
+ return retValue;
+ }
+
+ inline
+ Number Vector::Nrm2() const
+ {
+ if (nrm2_cache_tag_ != GetTag()) {
+ cached_nrm2_ = Nrm2Impl();
+ nrm2_cache_tag_ = GetTag();
+ }
+ return cached_nrm2_;
+ }
+
+ inline
+ Number Vector::Asum() const
+ {
+ if (asum_cache_tag_ != GetTag()) {
+ cached_asum_ = AsumImpl();
+ asum_cache_tag_ = GetTag();
+ }
+ return cached_asum_;
+ }
+
+ inline
+ Number Vector::Amax() const
+ {
+ if (amax_cache_tag_ != GetTag()) {
+ cached_amax_ = AmaxImpl();
+ amax_cache_tag_ = GetTag();
+ }
+ return cached_amax_;
+ }
+
+ inline
+ Number Vector::Sum() const
+ {
+ if (sum_cache_tag_ != GetTag()) {
+ cached_sum_ = SumImpl();
+ sum_cache_tag_ = GetTag();
+ }
+ return cached_sum_;
+ }
+
+ inline
+ Number Vector::SumLogs() const
+ {
+ if (sumlogs_cache_tag_ != GetTag()) {
+ cached_sumlogs_ = SumLogsImpl();
+ sumlogs_cache_tag_ = GetTag();
+ }
+ return cached_sumlogs_;
+ }
+
+ inline
+ void Vector::ElementWiseSgn()
+ {
+ ElementWiseSgnImpl();
+ ObjectChanged();
+ }
+
+ inline
+ void Vector::Set(Number alpha)
+ {
+ // Could initialize caches here
+ SetImpl(alpha);
+ ObjectChanged();
+ }
+
+ inline
+ void Vector::ElementWiseDivide(const Vector& x)
+ {
+ ElementWiseDivideImpl(x);
+ ObjectChanged();
+ }
+
+ inline
+ void Vector::ElementWiseMultiply(const Vector& x)
+ {
+ ElementWiseMultiplyImpl(x);
+ ObjectChanged();
+ }
+
+ inline
+ void Vector::ElementWiseReciprocal()
+ {
+ ElementWiseReciprocalImpl();
+ ObjectChanged();
+ }
+
+ inline
+ void Vector::ElementWiseMax(const Vector& x)
+ {
+ // Could initialize some caches here
+ ElementWiseMaxImpl(x);
+ ObjectChanged();
+ }
+
+ inline
+ void Vector::ElementWiseMin(const Vector& x)
+ {
+ // Could initialize some caches here
+ ElementWiseMinImpl(x);
+ ObjectChanged();
+ }
+
+ inline
+ void Vector::ElementWiseAbs()
+ {
+ // Could initialize some caches here
+ ElementWiseAbsImpl();
+ ObjectChanged();
+ }
+
+ inline
+ void Vector::ElementWiseSqrt()
+ {
+ ElementWiseSqrtImpl();
+ ObjectChanged();
+ }
+
+ inline
+ void Vector::AddScalar(Number scalar)
+ {
+ // Could initialize some caches here
+ AddScalarImpl(scalar);
+ ObjectChanged();
+ }
+
+ inline
+ Number Vector::Max() const
+ {
+ if (max_cache_tag_ != GetTag()) {
+ cached_max_ = MaxImpl();
+ max_cache_tag_ = GetTag();
+ }
+ return cached_max_;
+ }
+
+ inline
+ Number Vector::Min() const
+ {
+ if (min_cache_tag_ != GetTag()) {
+ cached_min_ = MinImpl();
+ min_cache_tag_ = GetTag();
+ }
+ return cached_min_;
+ }
+
+ inline
+ void Vector::AddOneVector(Number a, const Vector& v1, Number c)
+ {
+ AddTwoVectors(a, v1, 0., v1, c);
+ }
+
+ inline
+ void Vector::AddTwoVectors(Number a, const Vector& v1,
+ Number b, const Vector& v2, Number c)
+ {
+ AddTwoVectorsImpl(a, v1, b, v2, c);
+ ObjectChanged();
+ }
+
+ inline
+ Number Vector::FracToBound(const Vector& delta, Number tau) const
+ {
+ /* AW: I avoid the caching here, since it leads to overhead in the
+ quality function search. Caches for this are in
+ CalculatedQuantities.
+ Number retValue;
+ std::vector<const TaggedObject*> tdeps(1);
+ tdeps[0] = δ
+ std::vector<Number> sdeps(1);
+ sdeps[0] = tau;
+ if (!frac_to_bound_cache_.GetCachedResult(retValue, tdeps, sdeps)) {
+ retValue = FracToBoundImpl(delta, tau);
+ frac_to_bound_cache_.AddCachedResult(retValue, tdeps, sdeps);
+ }
+ return retValue;
+ */
+ return FracToBoundImpl(delta, tau);
+ }
+
+ inline
+ void Vector::AddVectorQuotient(Number a, const Vector& z,
+ const Vector& s, Number c)
+ {
+ AddVectorQuotientImpl(a, z, s, c);
+ ObjectChanged();
+ }
+
+ inline
+ bool Vector::HasValidNumbers() const
+ {
+ if (valid_cache_tag_ != GetTag()) {
+ cached_valid_ = HasValidNumbersImpl();
+ valid_cache_tag_ = GetTag();
+ }
+ return cached_valid_;
+ }
+
+ inline
+ Index Vector::Dim() const
+ {
+ return owner_space_->Dim();
+ }
+
+ inline
+ SmartPtr<const VectorSpace> Vector::OwnerSpace() const
+ {
+ return owner_space_;
+ }
+
+ inline
+ VectorSpace::VectorSpace(Index dim)
+ :
+ dim_(dim)
+ {}
+
+} // namespace Ipopt
+
+// Macro definitions for debugging vectors
+#if COIN_IPOPT_VERBOSITY == 0
+# define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec)
+#else
+# define DBG_PRINT_VECTOR(__verbose_level, __vec_name, __vec) \
+ if (dbg_jrnl.Verbosity() >= (__verbose_level)) { \
+ if (dbg_jrnl.Jnlst()!=NULL) { \
+ (__vec).Print(dbg_jrnl.Jnlst(), \
+ J_ERROR, J_DBG, \
+ __vec_name, \
+ dbg_jrnl.IndentationLevel()*2, \
+ "# "); \
+ } \
+ }
+#endif //if COIN_IPOPT_VERBOSITY == 0
+
+#endif
diff --git a/thirdparty/windows/include/coin/IpoptConfig.h b/thirdparty/windows/include/coin/IpoptConfig.h index 2552d69..4413357 100644 --- a/thirdparty/windows/include/coin/IpoptConfig.h +++ b/thirdparty/windows/include/coin/IpoptConfig.h @@ -1,101 +1,46 @@ -#ifndef HAVE_CONFIG_H -#define HAVE_CONFIG_H -#endif -/* - * Include file for the configuration of Ipopt. - * - * On systems where the code is configured with the configure script - * (i.e., compilation is always done with HAVE_CONFIG_H defined), this - * header file includes the automatically generated header file, and - * undefines macros that might configure with other Config.h files. - * - * On systems that are compiled in other ways (e.g., with the - * Developer Studio), a header files is included to define those - * macros that depend on the operating system and the compiler. The - * macros that define the configuration of the particular user setting - * (e.g., presence of other COIN packages or third party code) are set - * here. The project maintainer needs to remember to update this file - * and choose reasonable defines. A user can modify the default - * setting by editing this file here. - * - */ - -#ifndef __IPOPTCONFIG_H__ -#define __IPOPTCONFIG_H__ - -#ifdef HAVE_CONFIG_H -#include "config_ipopt.h" - -/* undefine macros that could conflict with those in other config.h - files */ -#undef PACKAGE -#undef PACKAGE_BUGREPORT -#undef PACKAGE_NAME -#undef PACKAGE_STRING -#undef PACKAGE_TARNAME -#undef PACKAGE_VERSION -#undef VERSION - -#else /* HAVE_CONFIG_H */ - -/* include the COIN-wide system specific configure header */ -#include "configall_system.h" - -#define IPOPT_VERSION "3.8.0" - -/***************************************************************************/ -/* HERE DEFINE THE CONFIGURATION SPECIFIC MACROS */ -/***************************************************************************/ - -/* Define to the debug sanity check level (0 is no test) */ -#define COIN_IPOPT_CHECKLEVEL 0 - -/* Define to the debug verbosity level (0 is no output) */ -#define COIN_IPOPT_VERBOSITY 0 - -/* If defined, the Ampl Solver Library is available. */ -#define COIN_HAS_ASL 1 - -/* If defined, the BLAS Library is available. */ -#define COIN_HAS_BLAS 1 - -/* Define to 1 if the Ipopt package is used */ -#define COIN_HAS_IPOPT 1 - -/* If defined, the LAPACK Library is available. */ -#define COIN_HAS_LAPACK 1 - -/* Define to 1 if the linear solver loader should be compiled to allow dynamic - loading of shared libraries with linear solvers */ -/* #undef HAVE_LINEARSOLVERLOADER */ - -/* Define to 1 if MA27 is available */ -#define HAVE_MA27 1 - -/* Define to 1 if MA57 is available */ -/* #undef HAVE_MA57 */ - -/* Define to 1 if MC19 is available */ -#define HAVE_MC19 1 - -/* Define to 1 if MUMPS is available */ -/* #undef HAVE_MUMPS */ - -/* Define to 1 if Pardiso is available */ -/* #undef HAVE_PARDISO */ - -/* Define to 1 if you are using the parallel version of Pardiso */ -/* #undef HAVE_PARDISO_PARALLEL */ - -/* Define to 1 if TAUCS is available */ -/* #undef HAVE_TAUCS */ - -/* Define to 1 if WSMP is available */ -/* #undef HAVE_WSMP */ - -#endif /* HAVE_CONFIG_H */ - -/* Type of Fortran integer translated into C */ -typedef FORTRAN_INTEGER_TYPE ipfint; - -#endif /*__IPOPTCONFIG_H__*/ +/* Copyright (C) 2011
+ * All Rights Reserved.
+ * This code is published under the Eclipse Public License.
+ *
+ * $Id: IpoptConfig.h 2005 2011-06-06 12:55:16Z stefan $
+ *
+ * Include file for the configuration of Ipopt.
+ *
+ * On systems where the code is configured with the configure script
+ * (i.e., compilation is always done with HAVE_CONFIG_H defined), this
+ * header file includes the automatically generated header file, and
+ * undefines macros that might configure with other Config.h files.
+ *
+ * On systems that are compiled in other ways (e.g., with the
+ * Developer Studio), a header files is included to define those
+ * macros that depend on the operating system and the compiler. The
+ * macros that define the configuration of the particular user setting
+ * (e.g., presence of other COIN-OR packages or third party code) are set
+ * by the files config_*default.h. The project maintainer needs to remember
+ * to update these file and choose reasonable defines.
+ * A user can modify the default setting by editing the config_*default.h files.
+ *
+ */
+
+#ifndef __IPOPTCONFIG_H__
+#define __IPOPTCONFIG_H__
+
+#ifdef HAVE_CONFIG_H
+
+#ifdef IPOPT_BUILD
+#include "config.h"
+#else
+#include "config_ipopt.h"
+#endif
+
+#else /* HAVE_CONFIG_H */
+
+#ifdef IPOPT_BUILD
+#include "config_default.h"
+#else
+#include "config_ipopt_default.h"
+#endif
+
+#endif /* HAVE_CONFIG_H */
+
+#endif /*__IPOPTCONFIG_H__*/
diff --git a/thirdparty/windows/include/coin/config_ipopt.h b/thirdparty/windows/include/coin/config_ipopt.h index 5de76c8..f3f5653 100644 --- a/thirdparty/windows/include/coin/config_ipopt.h +++ b/thirdparty/windows/include/coin/config_ipopt.h @@ -1,218 +1,6 @@ -/* inc/config_ipopt.h. Generated by configure. */ -/* inc/config_ipopt.h.in. Generated from configure.ac by autoheader. */ - -/* Define to 1 if the inexact linear solver option is included */ -/* #undef BUILD_INEXACT */ - -/* If defined, the Ampl Solver Library is available. */ -#define COIN_HAS_ASL 1 - -/* If defined, the BLAS Library is available. */ -#define COIN_HAS_BLAS 1 - -/* Define to 1 if the Ipopt package is used */ -#define COIN_HAS_IPOPT 1 - -/* If defined, the LAPACK Library is available. */ -#define COIN_HAS_LAPACK 1 - -/* If defined, the METIS library is available. */ -/* #undef COIN_HAS_METIS */ - -/* If defined, the MUMPS Library is available. */ -#define COIN_HAS_MUMPS 1 - -/* Define to the debug sanity check level (0 is no test) */ -#define COIN_IPOPT_CHECKLEVEL 0 - -/* Define to the debug verbosity level (0 is no output) */ -#define COIN_IPOPT_VERBOSITY 0 - -/* Define to dummy `main' function (if any) required to link to the Fortran - libraries. */ -/* #undef F77_DUMMY_MAIN */ - -/* Define to a macro mangling the given C identifier (in lower and upper - case), which must not contain underscores, for linking with Fortran. */ -#define F77_FUNC(name,NAME) name ## _ - -/* As F77_FUNC, but for C identifiers containing underscores. */ -#define F77_FUNC_(name,NAME) name ## __ - -/* Define if F77 and FC dummy `main' functions are identical. */ -/* #undef FC_DUMMY_MAIN_EQ_F77 */ - -/* Define to the C type corresponding to Fortran INTEGER */ -#define FORTRAN_INTEGER_TYPE int - -/* Define to 1 if you have the <assert.h> header file. */ -/* #undef HAVE_ASSERT_H */ - -/* Define to 1 if you have the <cassert> header file. */ -#define HAVE_CASSERT 1 - -/* Define to 1 if you have the <cctype> header file. */ -#define HAVE_CCTYPE 1 - -/* Define to 1 if you have the <cfloat> header file. */ -#define HAVE_CFLOAT 1 - -/* Define to 1 if you have the <cieeefp> header file. */ -/* #undef HAVE_CIEEEFP */ - -/* Define to 1 if you have the <cmath> header file. */ -#define HAVE_CMATH 1 - -/* Define to 1 if you have the <cstdarg> header file. */ -#define HAVE_CSTDARG 1 - -/* Define to 1 if you have the <cstdio> header file. */ -#define HAVE_CSTDIO 1 - -/* Define to 1 if you have the <cstdlib> header file. */ -#define HAVE_CSTDLIB 1 - -/* Define to 1 if you have the <cstring> header file. */ -#define HAVE_CSTRING 1 - -/* Define to 1 if you have the <ctime> header file. */ -#define HAVE_CTIME 1 - -/* Define to 1 if you have the <ctype.h> header file. */ -/* #undef HAVE_CTYPE_H */ - -/* Define to 1 if you have the <dlfcn.h> header file. */ -/* #undef HAVE_DLFCN_H */ - -/* Define to 1 if function drand48 is available */ -/* #undef HAVE_DRAND48 */ - -/* Define to 1 if you have the <float.h> header file. */ -/* #undef HAVE_FLOAT_H */ - -/* Define to 1 if you have the <ieeefp.h> header file. */ -/* #undef HAVE_IEEEFP_H */ - -/* Define to 1 if you have the <inttypes.h> header file. */ -/* #undef HAVE_INTTYPES_H */ - -/* Define to 1 if the linear solver loader should be compiled to allow dynamic - loading of shared libaries with linear solvers */ -#define HAVE_LINEARSOLVERLOADER 1 - -/* Define to 1 if MA27 is available */ -/* #undef HAVE_MA27 */ - -/* Define to 1 if MA28 is available */ -/* #undef HAVE_MA28 */ - -/* Define to 1 if MA57 is available */ -/* #undef HAVE_MA57 */ - -/* Define to 1 if you have the <math.h> header file. */ -/* #undef HAVE_MATH_H */ - -/* Define to 1 if MC19 is available */ -/* #undef HAVE_MC19 */ - -/* Define to 1 if you have the <memory.h> header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if Pardiso is available */ -/* #undef HAVE_PARDISO */ - -/* Define to 1 if you are using at least a 4.0 version of Pardiso */ -/* #undef HAVE_PARDISO_NEWINTERFACE */ - -/* Define to 1 if you are using the parallel version of Pardiso */ -/* #undef HAVE_PARDISO_PARALLEL */ - -/* Define to 1 if function rand is available */ -#define HAVE_RAND 1 - -/* Define to 1 if you have the `snprintf' function. */ -/* #undef HAVE_SNPRINTF */ - -/* Define to 1 if you have the <stdarg.h> header file. */ -/* #undef HAVE_STDARG_H */ - -/* Define to 1 if you have the <stdint.h> header file. */ -/* #undef HAVE_STDINT_H */ - -/* Define to 1 if you have the <stdio.h> header file. */ -/* #undef HAVE_STDIO_H */ - -/* Define to 1 if you have the <stdlib.h> header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if function std::rand is available */ -#define HAVE_STD__RAND 1 - -/* Define to 1 if you have the <strings.h> header file. */ -/* #undef HAVE_STRINGS_H */ - -/* Define to 1 if you have the <string.h> header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the <sys/stat.h> header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the <sys/types.h> header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the <time.h> header file. */ -/* #undef HAVE_TIME_H */ - -/* Define to 1 if you have the <unistd.h> header file. */ -/* #undef HAVE_UNISTD_H */ - -/* Define to 1 if va_copy is avaliable */ -/* #undef HAVE_VA_COPY */ - -/* Define to 1 if you have the `vsnprintf' function. */ -#define HAVE_VSNPRINTF 1 - -/* Define to 1 if you have the <windows.h> header file. */ -#define HAVE_WINDOWS_H 1 - -/* Define to 1 if WSMP is available */ -/* #undef HAVE_WSMP */ - -/* Define to 1 if you have the `_snprintf' function. */ -#define HAVE__SNPRINTF 1 - -/* Define to 1 if you have the `_vsnprintf' function. */ -/* #undef HAVE__VSNPRINTF */ - -/* Define to be the name of C-function for NaNInf check */ -#define MY_C_FINITE _finite - -/* Name of package */ -#define PACKAGE "ipopt" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "http://projects.coin-or.org/Ipopt/newticket" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "Ipopt" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "Ipopt 3.8.0" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "ipopt" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "3.8.0" - -/* Set to extension for shared libraries in quotes. */ -#define SHAREDLIBEXT "dll" - -/* The size of a `int *', as computed by sizeof. */ -#define SIZEOF_INT_P 4 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Version number of package */ -#define VERSION "3.8.0" +#include "config_ipopt_default.h"
+
+/* Define to the C type corresponding to Fortran INTEGER */
+#ifndef FORTRAN_INTEGER_TYPE
+#define FORTRAN_INTEGER_TYPE int
+#endif
diff --git a/thirdparty/windows/include/coin/config_ipopt_default.h b/thirdparty/windows/include/coin/config_ipopt_default.h new file mode 100644 index 0000000..5493dd6 --- /dev/null +++ b/thirdparty/windows/include/coin/config_ipopt_default.h @@ -0,0 +1,17 @@ + +/***************************************************************************/ +/* HERE DEFINE THE PROJECT SPECIFIC PUBLIC MACROS */ +/* These are only in effect in a setting that doesn't use configure */ +/***************************************************************************/ + +/* Version number of project */ +#define IPOPT_VERSION "3.11.0" + +/* Major Version number of project */ +#define IPOPT_VERSION_MAJOR 3 + +/* Minor Version number of project */ +#define IPOPT_VERSION_MINOR 11 + +/* Release Version number of project */ +#define IPOPT_VERSION_RELEASE 0 |