static bool eval_f(void * amplInfo, int n, const double * x, bool new_x, double & obj_value) { CbcAmplInfo * info = (CbcAmplInfo *) amplInfo; if (!apply_new_x(info, new_x, n, x)) { return false; } return internal_objval(info, obj_value); }
bool AmplTNLP::eval_f(Index n, const Number* x, bool new_x, Number& obj_value) { DBG_START_METH("AmplTNLP::eval_f", dbg_verbosity); if (!apply_new_x(new_x, n, x)) { return false; } return internal_objval(x, obj_value); }
bool AmplTNLP::eval_h(Index n, const Number* x, bool new_x, Number obj_factor, Index m, const Number* lambda, bool new_lambda, Index nele_hess, Index* iRow, Index* jCol, Number* values) { DBG_START_METH("AmplTNLP::eval_h", dbg_verbosity); ASL_pfgh* asl = asl_; DBG_ASSERT(asl_); DBG_ASSERT(n == n_var); DBG_ASSERT(m == n_con); if (iRow && jCol && !values) { // setup the structure int k=0; for (int i=0; i<n; i++) { for (int j=sputinfo->hcolstarts[i]; j<sputinfo->hcolstarts[i+1]; j++) { iRow[k] = i + 1; jCol[k] = sputinfo->hrownos[j]+1; k++; } } DBG_ASSERT(k==nele_hess); return true; } else if (!iRow & !jCol && values) { if (!apply_new_x(new_x, n, x)) { return false; } if (!objval_called_with_current_x_) { Number dummy; internal_objval(x, dummy); internal_conval(x, m); } if (!conval_called_with_current_x_) { internal_conval(x, m); } real* OW = new real[Max(1,n_obj)]; if (n_obj>0) { for (Index i=0; i<n_obj; i++) { OW[i] = 0.; } OW[obj_no] = obj_sign_*obj_factor; } sphes(values, -1, OW, const_cast<Number*>(lambda)); delete [] OW; return true; } else { DBG_ASSERT(false && "Invalid combination of iRow, jCol, and values pointers"); } return false; }