| 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()) { |
| 84 | const auto x_py = to_const_array(x.data(), this->number_variables); |
| 85 | auto gradient_py = to_array(gradient.data(), this->number_variables); |
| 86 | |
| 87 | // evaluate objective gradient |
| 88 | try { |
| 89 | (*this->user_model.objective_gradient)(x_py, gradient_py); |
| 90 | view(gradient, 0, this->number_variables).scale(this->optimization_sense); |
| 91 | ++this->number_model_evaluations.objective_gradient; |
| 92 | } |
| 93 | catch (const std::exception&) { |
| 94 | throw GradientEvaluationError(); |
| 95 | } |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | void PythonModel::compute_jacobian_sparsity(uno_int * row_indices, uno_int * column_indices, uno_int row_offset, |
| 100 | uno_int column_offset, uno_int solver_indexing, MatrixOrder /*matrix_format*/) const { |
nothing calls this directly
no test coverage detected