Esempio n. 1
0
void OptHOM::evalObjGrad(const alglib::real_1d_array &x, double &Obj,
                         alglib::real_1d_array &gradObj)
{
  NEVAL++;
  mesh.updateMesh(x.getcontent());

  Obj = 0.;
  for (int i = 0; i < gradObj.length(); i++) gradObj[i] = 0.;

  //  printf("Computing Obj : ");
  /// control Jacobians
  addJacObjGrad(Obj, gradObj);
  /// Control distance to the straight sided mesh
  addDistObjGrad(lambda, Obj, gradObj);

  if(_optimizeMetricMin)
    addMetricMinObjGrad(Obj, gradObj);
  if(_optimizeCAD)
    addBndObjGrad(lambda3, Obj, gradObj);

  //  printf("Obj = %12.5E\n",Obj);

  if ((minJac > barrier_min) && (maxJac < barrier_max || !_optimizeBarrierMax) && (maxDistCAD < distance_max|| !_optimizeCAD) ) {
    Msg::Info("Reached %s (%g %g) requirements, setting null gradient",
              _optimizeMetricMin ? "svd" : "jacobian", minJac, maxJac);
    Obj = 0.;
    for (int i = 0; i < gradObj.length(); i++) gradObj[i] = 0.;
  }
}
Esempio n. 2
0
void MeshOpt::evalObjGrad(const alglib::real_1d_array &x, double &obj,
                                         alglib::real_1d_array &gradObj)
{
  patch.updateMesh(x.getcontent());
  _objFunc->compute(obj, gradObj);
  if (_objFunc->targetReached()) {
    if (_verbose > 2) Msg::Info("Reached target values, setting null gradient");
    obj = 0.;
    for (int i = 0; i < gradObj.length(); i++) gradObj[i] = 0.;
  }
}