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

Method evaluate_constraints

interfaces/Python/cpp_classes/PythonModel.cpp:66–80  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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()) {

Callers

nothing calls this directly

Calls 4

to_const_arrayFunction · 0.85
to_arrayFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected