MCPcopy Create free account
hub / github.com/cvanaret/Uno / compute_jacobian_vector_product

Method compute_jacobian_vector_product

interfaces/Python/cpp_classes/PythonModel.cpp:184–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182 }
183
184 void PythonModel::compute_jacobian_vector_product(const double* x, const double* vector, double* result) const {
185 if (this->user_model.jacobian_operator.has_value()) {
186 const auto x_py = to_const_array(x, this->number_variables);
187 const auto vector_py = to_const_array(vector, this->number_variables);
188 auto result_py = to_array(result, this->number_constraints);
189
190 // evaluate Jacobian-vector product
191 try {
192 (*this->user_model.jacobian_operator)(x_py, true, vector_py, result_py);
193 }
194 catch (const std::exception&) {
195 throw GradientEvaluationError();
196 }
197 }
198 else {
199 throw std::runtime_error("compute_jacobian_vector_product not implemented");
200 }
201 }
202
203 void PythonModel::compute_jacobian_transposed_vector_product(const double* x, const double* vector, double* result) const {
204 if (this->user_model.jacobian_transposed_operator.has_value()) {

Callers

nothing calls this directly

Calls 3

to_const_arrayFunction · 0.85
to_arrayFunction · 0.85

Tested by

no test coverage detected