void Sqpmethod::eval_h(const std::vector<double>& x, const std::vector<double>& lambda, double sigma, Matrix<double>& H) { try { // Get function Function& hessLag = this->hessLag(); // Pass the argument to the function hessLag.setInputNZ(x, HESSLAG_X); hessLag.setInput(input(NLP_SOLVER_P), HESSLAG_P); hessLag.setInput(sigma, HESSLAG_LAM_F); hessLag.setInputNZ(lambda, HESSLAG_LAM_G); // Evaluate hessLag.evaluate(); // Get results hessLag.getOutput(H); if (monitored("eval_h")) { userOut() << "x = " << x << endl; userOut() << "H = " << endl; H.printSparse(); } // Determing regularization parameter with Gershgorin theorem if (regularize_) { reg_ = getRegularization(H); if (reg_ > 0) { regularize(H, reg_); } } } catch(exception& ex) { userOut<true, PL_WARN>() << "eval_h failed: " << ex.what() << endl; throw; } }
void SQPInternal::eval_h(const std::vector<double>& x, const std::vector<double>& lambda, double sigma, Matrix<double>& H){ int n_hess_in = H_.getNumInputs() - (parametric_ ? 1 : 0); H_.setInput(x); if(n_hess_in>1){ H_.setInput(lambda, n_hess_in == 4 ? 2 : 1); H_.setInput(sigma, n_hess_in == 4 ? 3 : 2); } H_.evaluate(); H_.getOutput(H); // Determing regularization parameter with Gershgorin theorem if(regularize_){ reg_ = getRegularization(H); if(reg_ > 0){ regularize(H,reg_); } } if (monitored("eval_h")) { cout << "x = " << x << endl; cout << "H = " << endl; H.printSparse(); } }