Changeset 489


Ignore:
Timestamp:
Aug 24, 2005 3:25:38 PM (14 years ago)
Author:
andreasw
Message:

corrected bug for the case that there are no equality or inequalty

constraints and the problem is scaled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dev/Algorithm/IpOrigIpoptNLP.cpp

    r467 r489  
    313313  {
    314314    SmartPtr<const Vector> retValue;
    315     SmartPtr<const Vector> dep;
    316315    if (c_space_->Dim()==0) {
    317316      // We do this caching of an empty vector so that the returned
    318317      // Vector has always the same tag (this might make a difference
    319318      // in cases where only the constraints are supposed to change...
    320       dep = NULL;
     319      SmartPtr<const Vector> dep = NULL;
    321320      if (!c_cache_.GetCachedResult1Dep(retValue, GetRawPtr(dep))) {
    322321        retValue = c_space_->MakeNew();
     
    325324    }
    326325    else {
    327       dep = &x;
    328     }
    329     if (!c_cache_.GetCachedResult1Dep(retValue, GetRawPtr(dep))) {
    330       SmartPtr<Vector> unscaled_c = c_space_->MakeNew();
    331       c_evals_++;
    332       SmartPtr<const Vector> unscaled_x = NLP_scaling()->unapply_vector_scaling_x(&x);
    333       bool success = nlp_->Eval_c(*unscaled_x, *unscaled_c);
    334       ASSERT_EXCEPTION(success && IsFiniteNumber(unscaled_c->Nrm2()),
    335                        Eval_Error, "Error evaluating the equality constraints");
    336       retValue = NLP_scaling()->apply_vector_scaling_c(ConstPtr(unscaled_c));
    337       c_cache_.AddCachedResult1Dep(retValue, GetRawPtr(dep));
     326      if (!c_cache_.GetCachedResult1Dep(retValue, x)) {
     327        SmartPtr<Vector> unscaled_c = c_space_->MakeNew();
     328        c_evals_++;
     329        SmartPtr<const Vector> unscaled_x = NLP_scaling()->unapply_vector_scaling_x(&x);
     330        bool success = nlp_->Eval_c(*unscaled_x, *unscaled_c);
     331        ASSERT_EXCEPTION(success && IsFiniteNumber(unscaled_c->Nrm2()),
     332                         Eval_Error, "Error evaluating the equality constraints");
     333        retValue = NLP_scaling()->apply_vector_scaling_c(ConstPtr(unscaled_c));
     334        c_cache_.AddCachedResult1Dep(retValue, x);
     335      }
    338336    }
    339337
     
    345343    DBG_START_METH("OrigIpoptNLP::d", dbg_verbosity);
    346344    SmartPtr<const Vector> retValue;
    347     SmartPtr<const Vector> dep;
    348345    if (d_space_->Dim()==0) {
    349346      // We do this caching of an empty vector so that the returned
    350347      // Vector has always the same tag (this might make a difference
    351348      // in cases where only the constraints are supposed to change...
    352       dep = NULL;
     349      SmartPtr<const Vector> dep = NULL;
    353350      if (!d_cache_.GetCachedResult1Dep(retValue, GetRawPtr(dep))) {
    354351        retValue = d_space_->MakeNew();
     
    357354    }
    358355    else {
    359       dep = &x;
    360     }
    361     if (!d_cache_.GetCachedResult1Dep(retValue, GetRawPtr(dep))) {
    362       d_evals_++;
    363       SmartPtr<Vector> unscaled_d = d_space_->MakeNew();
    364 
    365       DBG_PRINT_VECTOR(2, "scaled_x", x);
    366       SmartPtr<const Vector> unscaled_x = NLP_scaling()->unapply_vector_scaling_x(&x);
    367       bool success = nlp_->Eval_d(*unscaled_x, *unscaled_d);
    368       DBG_PRINT_VECTOR(2, "unscaled_d", *unscaled_d);
    369       ASSERT_EXCEPTION(success && IsFiniteNumber(unscaled_d->Nrm2()),
    370                        Eval_Error, "Error evaluating the inequality constraints");
    371       retValue = NLP_scaling()->apply_vector_scaling_d(ConstPtr(unscaled_d));
    372       d_cache_.AddCachedResult1Dep(retValue, GetRawPtr(dep));
     356      if (!d_cache_.GetCachedResult1Dep(retValue, x)) {
     357        d_evals_++;
     358        SmartPtr<Vector> unscaled_d = d_space_->MakeNew();
     359
     360        DBG_PRINT_VECTOR(2, "scaled_x", x);
     361        SmartPtr<const Vector> unscaled_x = NLP_scaling()->unapply_vector_scaling_x(&x);
     362        bool success = nlp_->Eval_d(*unscaled_x, *unscaled_d);
     363        DBG_PRINT_VECTOR(2, "unscaled_d", *unscaled_d);
     364        ASSERT_EXCEPTION(success && IsFiniteNumber(unscaled_d->Nrm2()),
     365                         Eval_Error, "Error evaluating the inequality constraints");
     366        retValue = NLP_scaling()->apply_vector_scaling_d(ConstPtr(unscaled_d));
     367        d_cache_.AddCachedResult1Dep(retValue, x);
     368      }
    373369    }
    374370
     
    379375  {
    380376    SmartPtr<const Matrix> retValue;
    381     SmartPtr<const Vector> dep;
    382377    if (c_space_->Dim()==0) {
    383378      // We do this caching of an empty vector so that the returned
    384379      // Matrix has always the same tag
    385       dep = NULL;
     380      SmartPtr<const Vector> dep = NULL;
    386381      if (!jac_c_cache_.GetCachedResult1Dep(retValue, GetRawPtr(dep))) {
    387         retValue = jac_c_space_->MakeNew();
     382        SmartPtr<Matrix> unscaled_jac_c = jac_c_space_->MakeNew();
     383        retValue = NLP_scaling()->apply_jac_c_scaling(ConstPtr(unscaled_jac_c));
    388384        jac_c_cache_.AddCachedResult1Dep(retValue, GetRawPtr(dep));
    389385      }
    390386    }
    391387    else {
    392       dep = &x;
    393     }
    394     if (!jac_c_cache_.GetCachedResult1Dep(retValue, GetRawPtr(dep))) {
    395       jac_c_evals_++;
    396       SmartPtr<Matrix> unscaled_jac_c = jac_c_space_->MakeNew();
    397 
    398       SmartPtr<const Vector> unscaled_x = NLP_scaling()->unapply_vector_scaling_x(&x);
    399       bool success = nlp_->Eval_jac_c(*unscaled_x, *unscaled_jac_c);
    400       ASSERT_EXCEPTION(success, Eval_Error, "Error evaluating the jacobian of the equality constraints");
    401       retValue = NLP_scaling()->apply_jac_c_scaling(ConstPtr(unscaled_jac_c));
    402       jac_c_cache_.AddCachedResult1Dep(retValue, GetRawPtr(dep));
     388      if (!jac_c_cache_.GetCachedResult1Dep(retValue, x)) {
     389        jac_c_evals_++;
     390        SmartPtr<Matrix> unscaled_jac_c = jac_c_space_->MakeNew();
     391
     392        SmartPtr<const Vector> unscaled_x = NLP_scaling()->unapply_vector_scaling_x(&x);
     393        bool success = nlp_->Eval_jac_c(*unscaled_x, *unscaled_jac_c);
     394        ASSERT_EXCEPTION(success, Eval_Error, "Error evaluating the jacobian of the equality constraints");
     395        retValue = NLP_scaling()->apply_jac_c_scaling(ConstPtr(unscaled_jac_c));
     396        jac_c_cache_.AddCachedResult1Dep(retValue, x);
     397      }
    403398    }
    404399
     
    409404  {
    410405    SmartPtr<const Matrix> retValue;
    411     SmartPtr<const Vector> dep;
    412406    if (d_space_->Dim()==0) {
    413407      // We do this caching of an empty vector so that the returned
    414408      // Matrix has always the same tag
    415       dep = NULL;
     409      SmartPtr<const Vector> dep = NULL;
    416410      if (!jac_d_cache_.GetCachedResult1Dep(retValue, GetRawPtr(dep))) {
    417         retValue = jac_d_space_->MakeNew();
     411        SmartPtr<Matrix> unscaled_jac_d = jac_d_space_->MakeNew();
     412        retValue = NLP_scaling()->apply_jac_d_scaling(ConstPtr(unscaled_jac_d));
    418413        jac_d_cache_.AddCachedResult1Dep(retValue, GetRawPtr(dep));
    419414      }
    420415    }
    421416    else {
    422       dep = &x;
    423     }
    424     if (!jac_d_cache_.GetCachedResult1Dep(retValue, GetRawPtr(dep))) {
    425       jac_d_evals_++;
    426       SmartPtr<Matrix> unscaled_jac_d = jac_d_space_->MakeNew();
    427 
    428       SmartPtr<const Vector> unscaled_x = NLP_scaling()->unapply_vector_scaling_x(&x);
    429       bool success = nlp_->Eval_jac_d(*unscaled_x, *unscaled_jac_d);
    430       ASSERT_EXCEPTION(success, Eval_Error, "Error evaluating the jacobian of the inequality constraints");
    431       retValue = NLP_scaling()->apply_jac_d_scaling(ConstPtr(unscaled_jac_d));
    432       jac_d_cache_.AddCachedResult1Dep(retValue, GetRawPtr(dep));
     417      if (!jac_d_cache_.GetCachedResult1Dep(retValue, x)) {
     418        jac_d_evals_++;
     419        SmartPtr<Matrix> unscaled_jac_d = jac_d_space_->MakeNew();
     420
     421        SmartPtr<const Vector> unscaled_x = NLP_scaling()->unapply_vector_scaling_x(&x);
     422        bool success = nlp_->Eval_jac_d(*unscaled_x, *unscaled_jac_d);
     423        ASSERT_EXCEPTION(success, Eval_Error, "Error evaluating the jacobian of the inequality constraints");
     424        retValue = NLP_scaling()->apply_jac_d_scaling(ConstPtr(unscaled_jac_d));
     425        jac_d_cache_.AddCachedResult1Dep(retValue, x);
     426      }
    433427    }
    434428
Note: See TracChangeset for help on using the changeset viewer.