| 46 | } |
| 47 | |
| 48 | double PythonModel::evaluate_objective(const Vector<double>& x) const { |
| 49 | double objective_value = 0.; |
| 50 | if (this->user_model.objective_function.has_value()) { |
| 51 | const auto x_py = to_const_array(x.data(), this->number_variables); |
| 52 | |
| 53 | // evaluate objective |
| 54 | try { |
| 55 | objective_value = (*this->user_model.objective_function)(x_py); |
| 56 | objective_value *= this->optimization_sense; |
| 57 | ++this->number_model_evaluations.objective; |
| 58 | } |
| 59 | catch (const std::exception&) { |
| 60 | throw FunctionEvaluationError(); |
| 61 | } |
| 62 | } |
| 63 | return objective_value; |
| 64 | } |
| 65 | |
| 66 | void PythonModel::evaluate_constraints(const Vector<double>& x, Vector<double>& constraints) const { |
| 67 | if (this->user_model.constraint_functions.has_value()) { |
nothing calls this directly
no test coverage detected