Esempio n. 1
0
  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;
  }
Esempio n. 2
0
  bool AmplTNLP::eval_g(Index n, const Number* x, bool new_x, Index m, Number* g)
  {
    DBG_START_METH("AmplTNLP::eval_g", dbg_verbosity);

    DBG_DO(ASL_pfgh* asl = asl_);
    DBG_ASSERT(n == n_var);
    DBG_ASSERT(m == n_con);

    if (!apply_new_x(new_x, n, x)) {
      return false;
    }

    return internal_conval(x, m, g);
  }
Esempio n. 3
0
static bool eval_g(void * amplInfo, int  n, const double * x, bool new_x, double * g)
{
    CbcAmplInfo * info = (CbcAmplInfo *) amplInfo;
#ifndef NDEBUG
    ASL_pfgh* asl = info->asl_;
#endif
    // warning: n_var is a macro that assumes we have a variable called asl
    assert(n == n_var);

    if (!apply_new_x(info, new_x, n, x)) {
        return false;
    }

    return internal_conval(info, g);
}