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

Method compute_hessian_sparsity

interfaces/Python/cpp_classes/PythonModel.cpp:118–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116 }
117
118 void PythonModel::compute_hessian_sparsity(uno_int *row_indices, uno_int *column_indices, uno_int solver_indexing) const {
119 // copy the indices of the user sparsity patterns to the Uno vectors
120 const size_t number_hessian_nonzeros = this->number_hessian_nonzeros();
121 std::copy_n(this->user_model.hessian_row_indices.data(), number_hessian_nonzeros, row_indices);
122 std::copy_n(this->user_model.hessian_column_indices.data(), number_hessian_nonzeros, column_indices);
123
124 // handle the solver indexing
125 if (this->user_model.base_indexing != solver_indexing) {
126 const int indexing_difference = solver_indexing - this->user_model.base_indexing;
127 for (size_t index: Range(number_hessian_nonzeros)) {
128 row_indices[index] += indexing_difference;
129 column_indices[index] += indexing_difference;
130 }
131 }
132 }
133
134 void PythonModel::evaluate_jacobian(const Vector<double>& x, double* jacobian_values) const {
135 if (this->user_model.jacobian.has_value()) {

Callers

nothing calls this directly

Calls 3

RangeClass · 0.85
dataMethod · 0.45

Tested by

no test coverage detected