/home/coin/SVN-release/CoinAll-1.1.0/Ipopt/examples/ScalableProblems/RegisteredTNLP.hpp

Go to the documentation of this file.
00001 // Copyright (C) 2005, 2006 International Business Machines and others.
00002 // All Rights Reserved.
00003 // This code is published under the Common Public License.
00004 //
00005 // $Id: RegisteredTNLP.hpp 699 2006-04-05 21:05:18Z andreasw $
00006 //
00007 // Authors:  Andreas Waechter            IBM    2005-10-20
00008 
00009 #ifndef __REGISTEREDTNLPS_HPP__
00010 #define __REGISTEREDTNLPS_HPP__
00011 
00012 #include "IpTNLP.hpp"
00013 #include <map>
00014 
00015 using namespace Ipopt;
00016 
00020 class RegisteredTNLP : public TNLP
00021 {
00022 public:
00026   virtual bool InitializeProblem(Index N) = 0;
00027 };
00028 
00029 class RegisteredTNLPs
00030 {
00031 public:
00032   RegisteredTNLPs(const SmartPtr<RegisteredTNLP>& tnlp, const std::string name)
00033   {
00034     RegisterTNLP(tnlp, name);
00035   }
00036   virtual ~RegisteredTNLPs()
00037   {}
00038   static SmartPtr<RegisteredTNLP> GetTNLP(const std::string name);
00039   static void PrintRegisteredProblems();
00040 private:
00041   void RegisterTNLP(const SmartPtr<RegisteredTNLP>& tnlp,
00042                     const std::string name);
00043   SmartPtr<RegisteredTNLP> tnlp_;
00044 };
00045 
00046 #define REGISTER_TNLP(class_constructor, name) \
00047 class RegisteredTNLP_Setup_ ## name : public RegisteredTNLPs \
00048 { \
00049 public: \
00050   RegisteredTNLP_Setup_ ## name() \
00051     : \
00052     RegisteredTNLPs(new class_constructor, #name) \
00053   { } \
00054   RegisteredTNLP_Setup_ ## name* KeepCompilerFromRemovingThis(); \
00055 }; \
00056  \
00057 RegisteredTNLP_Setup_ ## name RegisteredTNLP_Setup_ ## name ## instance_; \
00058 RegisteredTNLP_Setup_ ## name* \
00059 RegisteredTNLP_Setup_ ## name::KeepCompilerFromRemovingThis() \
00060 { return &RegisteredTNLP_Setup_ ## name ## instance_; }
00061 
00062 
00063 //static RegisteredTNLP_Setup_ ## name RegisteredTNLP_Setup_ ## name ## instance
00064 #endif

Generated on Sun Nov 14 14:06:34 2010 for Coin-All by  doxygen 1.4.7