Problem.h

00001 #ifndef PROBLEM_H
00002 #define PROBLEM_H
00003 
00004 #ifdef HAVE_CONFIG_H
00005 #include "OPT++_config.h"
00006 #endif
00007 
00008 #include <iostream>
00009 #include <string>
00010 #include <vector>
00011 #include <dlfcn.h>
00012 #include <sys/wait.h>
00013 #include <unistd.h>
00014 #ifdef HAVE_STD
00015 #include <cstdlib>
00016 #else
00017 #include <stdlib.h>
00018 #endif
00019 
00020 #include "xercesc/dom/DOM.hpp"
00021 #include "xercesc/util/PlatformUtils.hpp"
00022 
00023 #include "Opt.h"
00024 #include "AppLauncher.h"
00025 #include "VariableList.h"
00026 #include "NLFAPP.h"
00027 #include "BoundConstraint.h"
00028 #include "NonLinearEquation.h"
00029 #include "CompoundConstraint.h"
00030 
00031 using std::string;
00032 
00033 namespace OPTPP {
00034 
00035 typedef struct{
00036         int value;
00037         string msg;
00038 } OptError;
00039 
00043 class Problem
00044 {
00045         private:
00046                 DOMElement* solverXML_;
00047                 bool hasSubroutineXML_;
00048                 bool hasParameterXML_;
00049                 bool useApplicationOptimizer_;
00050                 bool hasNumVar_;
00051                 bool hasDerivOrder_;
00052                 OptimizeClass * objfcn_;
00053                 NLP0 * func_;
00054                 int numVar_;
00055                 int derivOrder_;
00056                 DOMElement* subroutineXML_;
00057                 DOMElement* applicationXML_;
00058                 VariableList variables_;
00059                 
00060                 
00061 
00062                 AppLauncher launcher_;
00063 
00064                 vector<void *> loadedLibs_;
00065 
00070                 void * GetFunction(string libName, string funcName);
00071         
00075                 void CloseLoadedLibs();
00076 
00077         protected:
00078                 // this needs to be set by each individual subclass
00079                 DOMElement* parameterXML_;
00080                 
00082                 int GetNumVar();
00083 
00085                 int GetDerivOrder();
00086 
00090                 DOMElement* GetSubroutineXML();
00091 
00095                 DOMElement* GetSolverXML();
00096 
00100                 DOMElement* GetParameterXML();
00101                         
00106                 virtual DOMElement* FindParameterXML() = 0;
00107                 
00109                 USERFCN0 GetUserFunction0();
00110 
00112                 USERFCN1 GetUserFunction1();
00113 
00115                 USERFCN2 GetUserFunction2();
00116 
00118                 INITFCN GetInitFunction();
00119 
00124                 AppLauncher * GetAppLauncher();
00125                 
00129                 virtual void SetParameters(OptimizeClass* objfcn);
00130 
00135                 VariableList * GetVariables();
00136 
00141                 CompoundConstraint * GetConstraints();
00142 
00147                 virtual OptError CreateFunctionOptimizer(OptimizeClass * &objfcn, NLP0* &func) = 0;
00148 
00153                 virtual OptError CreateApplicationOptimizer(OptimizeClass * &objfcn, NLP0* &func) = 0;
00154                 
00155         public:
00157                 Problem(DOMElement* solverXML):
00158                         solverXML_(solverXML),
00159                         hasSubroutineXML_(false),
00160                         hasParameterXML_(false),
00161                         useApplicationOptimizer_(false),
00162                         hasNumVar_(false),
00163                         hasDerivOrder_(false)
00164                 {;}
00165 
00166                 /* Destructor */
00167 
00168                 virtual ~Problem(){}
00169                 
00171                 OptError optimize();
00172                 
00174                 void SetProblemXML(DOMElement* applicationXML);
00175 };
00176 
00177 } // namespace OPTPP
00178 
00179 #endif
Generated on Mon Jan 24 12:04:37 2011 for FASTlib by  doxygen 1.6.3