Example #1
0
//------------------------------------------------------------------------
// Initialization subroutine
//------------------------------------------------------------------------
void OptBCEllipsoid::initOpt()
{
  NLP1         *nlp = nlprob();
  int          i,n = nlp->getDim();
  double       dtmp=0.0;
  time_t       t;
  char         *c;

  // Get date and print out header
  t = time(NULL);
  c = asctime(localtime(&t));
  *optout << "**********************************************************\n";
  *optout << "OPT++ version " << OPT_GLOBALS::OPT_VERSION << "\n";
  *optout << "Job run at " << c << "\n";
  copyright();
  *optout << "**********************************************************\n";

  // Read in OPT++ input file if it exists. Be aware that anything in 
  // the input file will override any variable set so far

  nlp->initFcn();
  SerialDenseVector<int,double> xc(nlp->getXc().length());
  xc = nlp->getXc();
  readOptInput();

  if (debug_)
    nlp->setDebug();

  ret_code = 0;

  if(nlp->hasConstraints()){
    CompoundConstraint* constraints = nlp->getConstraints();
    SerialDenseVector<int,double> xstart(nlp->getXc().length());
    xstart = nlp->getXc();
    double feas_tol = tol.getCTol();
    bool feasible = constraints->amIFeasible(xstart, feas_tol);
    if (!feasible) {
      *optout << "OptBCEllipsoid WARNING:  Initial guess not feasible.\n"
	      << "Ellipsoid may be unable to make progress." << endl;
    }
  }

  if (ret_code == 0) {
    nlp->evalF();

    // if initial radius of ellipsoid is not specified, set it to something
    if (initial_radius < 0.0e0) {
      for (i=1; i<=n; i++) dtmp = max(dtmp, fabs(xc(i))); 
      initial_radius = 1.0e1 * dtmp + 1.0e5; 
    }
  
    *optout << "\n  Iter      F(x)   Steplength   "
	    << "fevals    gevals\n\n";
    
    if(debug_)
      *optout << "Radius of initial ellipsoid = " << initial_radius << "\n";  
  }
}