Exemplo n.º 1
0
  bool AmplTMINLP::eval_grad_gi(Index n, const Number* x, bool new_x,
      Index i, Index& nele_grad_gi, Index* jCol,
      Number* values)
  {
    ASL_pfgh* asl = ampl_tnlp_->AmplSolverObject();

    if (jCol) {
      // Only compute the number of nonzeros and the indices
      DBG_ASSERT(!values);
      nele_grad_gi = 0;
      for (cgrad* cg=Cgrad[i]; cg; cg = cg->next) {
        jCol[nele_grad_gi++] = cg->varno + 1;
      }
      return true;
    }
    DBG_ASSERT(values);

    // ignore new_x for now
    xunknown();

    asl->i.congrd_mode = 1;
    fint nerror = 0;
    congrd(i, const_cast<real*>(x), values, &nerror);
    if (nerror!=0) {
      return false;
    }
    else {
      return true;
    }
  }
//can be called if hessian is returned in triangular form, otherwise more works need to be done as the get_matrices routine
void
ampl_GetHessianInit(double *varsX, double *Helts,double *Yelts)
{
  OW[0] = 1;

  if(varsX==NULL)
  	xunknown();
  if(Yelts)
    sphes(Helts, -1, OW, Yelts);
  else{
  	double *tempY = (double*)malloc(n_con*sizeof(double));
    sphes(Helts, -1, OW, tempY);
	delete tempY;
  }
}
Exemplo n.º 3
0
  bool AmplTMINLP::eval_gi(Index n, const Number* x, bool new_x,
      Index i, Number& gi)
  {
    ASL_pfgh* asl = ampl_tnlp_->AmplSolverObject();

    // ignore new_x for now
    xunknown();

    fint nerror = 0;
    gi = conival(i, const_cast<real*>(x), &nerror);
    if (nerror!=0) {
      return false;
    }
    else {
      return true;
    }
  }