23 #ifdef _POSIX_C_SOURCE
24 #undef _POSIX_C_SOURCE
37 using namespace YACS::ENGINE;
48 const std::string& symbolNameToOptimizerAlgBaseInstanceFactory,
49 bool algInitOnFile,
bool initAlgo,
Proc * procForTypes):
50 OptimizerLoop(name,algLibWthOutExt,symbolNameToOptimizerAlgBaseInstanceFactory,algInitOnFile,false)
56 setAlgorithm(algLibWthOutExt, symbolNameToOptimizerAlgBaseInstanceFactory,
true, procForTypes);
79 if (procForTypes == NULL) {
81 procForTypes =
const_cast<Proc *
>(origProc);
100 PyGILState_STATE gstate=PyGILState_Ensure();
102 PyObject* mainmod = PyImport_AddModule(
"__main__");
103 PyObject* globals = PyModule_GetDict(mainmod);
105 std::string pyscript;
106 pyscript=
"import sys\n"
107 "import SALOMERuntime\n"
110 pyscript=pyscript+
"import os\n"
112 "rep,mod=os.path.split(os.path.splitext(filename)[0])\n"
114 " sys.path.insert(0,rep)\n"
115 "algomodule=__import__(mod)\n"
118 "algoclass= getattr(algomodule,entry)\n"
119 "algo= algoclass()\n"
120 "swigalgo= algo.this\n"
123 PyObject* res=PyRun_String(pyscript.c_str(), Py_file_input, globals, globals );
130 PySys_SetObject((
char*)
"stderr", new_stderr);
132 PySys_SetObject((
char*)
"stderr", PySys_GetObject((
char*)
"__stderr__"));
133 Py_DECREF(new_stderr);
135 PyGILState_Release(gstate);
150 SwigPyObject* pyalgo = (SwigPyObject*)PyDict_GetItemString(globals,
"swigalgo");
155 PyGILState_Release(gstate);