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

Method evaluate_objective

interfaces/Python/cpp_classes/PythonModel.cpp:48–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 }
47
48 double PythonModel::evaluate_objective(const Vector<double>& x) const {
49 double objective_value = 0.;
50 if (this->user_model.objective_function.has_value()) {
51 const auto x_py = to_const_array(x.data(), this->number_variables);
52
53 // evaluate objective
54 try {
55 objective_value = (*this->user_model.objective_function)(x_py);
56 objective_value *= this->optimization_sense;
57 ++this->number_model_evaluations.objective;
58 }
59 catch (const std::exception&) {
60 throw FunctionEvaluationError();
61 }
62 }
63 return objective_value;
64 }
65
66 void PythonModel::evaluate_constraints(const Vector<double>& x, Vector<double>& constraints) const {
67 if (this->user_model.constraint_functions.has_value()) {

Callers

nothing calls this directly

Calls 3

to_const_arrayFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected