PythonInterface::PythonInterface(const ProblemDescDB& problem_db) : DirectApplicInterface(problem_db), userNumpyFlag(problem_db.get_bool("interface.python.numpy")) { Py_Initialize(); if (Py_IsInitialized()) { if (outputLevel >= NORMAL_OUTPUT) Cout << "Python interpreter initialized for direct function evaluation." << std::endl; } else { Cerr << "Error: Could not initialize Python for direct function " << "evaluation." << std::endl; abort_handler(-1); } if (userNumpyFlag) { #ifdef DAKOTA_PYTHON_NUMPY import_array(); #else Cerr << "\nError: Direct Python interface 'numpy' option requested, but " << "not available." << std::endl; abort_handler(-1); #endif } // prepend sys.path (env PYTHONPATH) with empty string to find module in pwd // This assumes any directory changing in the driver is reversed // between function evaluations PyRun_SimpleString("import sys\nsys.path.insert(0,\"\")"); }
SharedSurfpackApproxData:: SharedSurfpackApproxData(ProblemDescDB& problem_db, size_t num_vars): SharedApproxData(BaseConstructor(), problem_db, num_vars), exportModelName(problem_db.get_string("model.surrogate.export_model_file")), diagnosticSet(problem_db.get_sa("model.metrics")), crossValidateFlag(problem_db.get_bool("model.surrogate.cross_validate")), numFolds(problem_db.get_int("model.surrogate.folds")), percentFold(problem_db.get_real("model.surrogate.percent")), pressFlag(problem_db.get_bool("model.surrogate.press")) { // For Polynomial surface fits if (approxType == "global_polynomial") approxOrder = problem_db.get_short("model.surrogate.polynomial_order"); else if (approxType == "global_kriging") { const String& trend_string = problem_db.get_string("model.surrogate.trend_order"); if (trend_string == "constant") approxOrder = 0; else if (trend_string == "linear") approxOrder = 1; else approxOrder = 2; // empty, reduced_quadratic, quadratic } }