| 64 | } |
| 65 | |
| 66 | void PythonModel::evaluate_constraints(const Vector<double>& x, Vector<double>& constraints) const { |
| 67 | if (this->user_model.constraint_functions.has_value()) { |
| 68 | const auto x_py = to_const_array(x.data(), this->number_variables); |
| 69 | auto constraints_py = to_array(constraints.data(), this->number_constraints); |
| 70 | |
| 71 | // evaluate constraints |
| 72 | try { |
| 73 | (*this->user_model.constraint_functions)(x_py, constraints_py); |
| 74 | ++this->number_model_evaluations.constraints; |
| 75 | } |
| 76 | catch (const std::exception&) { |
| 77 | throw FunctionEvaluationError(); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void PythonModel::evaluate_objective_gradient(const Vector<double>& x, Vector<double>& gradient) const { |
| 83 | if (this->user_model.objective_gradient.has_value()) { |
nothing calls this directly
no test coverage detected