Changeset 487


Ignore:
Timestamp:
Aug 24, 2005 2:01:13 PM (14 years ago)
Author:
andreasw
Message:
  • fixed perturbation handler
  • corrected minor typos
Location:
branches/dev
Files:
6 edited

Legend:

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

    r465 r487  
    199199      exc.ReportException(Jnlst());
    200200      return SUCCESS;
     201    }
     202    catch(INTERNAL_ABORT& exc) {
     203      exc.ReportException(Jnlst());
     204      return INTERNAL_ERROR;
    201205    }
    202206
  • branches/dev/Algorithm/IpPDPerturbationHandler.cpp

    r486 r487  
    173173
    174174    if (hess_degenerate_ == DEGENERATE) {
    175       PerturbForWrongInertia(delta_x, delta_s,
    176                              delta_c, delta_d);
     175      bool retval = get_deltas_for_wrong_inertia(delta_x, delta_s,
     176                    delta_c, delta_d);
     177      ASSERT_EXCEPTION(retval, INTERNAL_ABORT,
     178                       "get_deltas_for_wrong_inertia returns false.");
    177179    }
    178180    else {
     
    198200    DBG_START_METH("PDPerturbationHandler::PerturbForSingularity",
    199201                   dbg_verbosity);
     202
     203    bool retval;
    200204
    201205    // Check for structural degeneracy
     
    212216        else {
    213217          DBG_ASSERT(hess_degenerate_ == NOT_YET_DETERMINED);
    214           PerturbForWrongInertia(delta_x, delta_s,
    215                                  delta_c, delta_d);
    216           DBG_ASSERT(delta_c = delta_cd_val_ && delta_d == delta_cd_val_);
     218          retval = get_deltas_for_wrong_inertia(delta_x, delta_s,
     219                                                delta_c, delta_d);
     220          ASSERT_EXCEPTION(retval, INTERNAL_ABORT,
     221                           "get_deltas_for_wrong_inertia returns false.");
     222          DBG_ASSERT(delta_c == delta_cd_val_ && delta_d == delta_cd_val_);
    217223          test_status_ = TEST_DELTA_C_EQ_0_DELTA_X_GT_0;
    218224        }
     
    222228        DBG_ASSERT(jac_degenerate_ == NOT_YET_DETERMINED);
    223229        delta_d_curr_ = delta_c_curr_ = 0.;
    224         PerturbForWrongInertia(delta_x, delta_s,
    225                                delta_c, delta_d);
     230        retval = get_deltas_for_wrong_inertia(delta_x, delta_s,
     231                                              delta_c, delta_d);
     232        ASSERT_EXCEPTION(retval, INTERNAL_ABORT,
     233                         "get_deltas_for_wrong_inertia returns false.");
    226234        DBG_ASSERT(delta_c == 0. && delta_d == 0.);
    227235        test_status_ = TEST_DELTA_C_EQ_0_DELTA_X_GT_0;
     
    230238        DBG_ASSERT(delta_x_curr_ > 0. && delta_c_curr_ == 0.);
    231239        delta_d_curr_ = delta_c_curr_ = delta_cd_val_;
    232         PerturbForWrongInertia(delta_x, delta_s,
    233                                delta_c, delta_d);
     240        retval = get_deltas_for_wrong_inertia(delta_x, delta_s,
     241                                              delta_c, delta_d);
     242        ASSERT_EXCEPTION(retval, INTERNAL_ABORT,
     243                         "get_deltas_for_wrong_inertia returns false.");
    234244        test_status_ = TEST_DELTA_C_GT_0_DELTA_X_GT_0;
    235245        break;
    236246        case TEST_DELTA_C_GT_0_DELTA_X_GT_0:
    237         PerturbForWrongInertia(delta_x, delta_s,
    238                                delta_c, delta_d);
     247        retval = get_deltas_for_wrong_inertia(delta_x, delta_s,
     248                                              delta_c, delta_d);
     249        ASSERT_EXCEPTION(retval, INTERNAL_ABORT,
     250                         "get_deltas_for_wrong_inertia returns false.");
    239251        break;
    240252        case NO_TEST:
     
    246258        // If we already used a perturbation for the constraints, we do
    247259        // the same thing as if we were encountering negative curvature
    248         PerturbForWrongInertia(delta_x, delta_s,
    249                                delta_c, delta_d);
     260        retval = get_deltas_for_wrong_inertia(delta_x, delta_s,
     261                                              delta_c, delta_d);
     262        ASSERT_EXCEPTION(retval, INTERNAL_ABORT,
     263                         "get_deltas_for_wrong_inertia returns false.");
    250264      }
    251265      else {
     
    269283
    270284  bool
     285  PDPerturbationHandler::get_deltas_for_wrong_inertia(
     286    Number& delta_x, Number& delta_s,
     287    Number& delta_c, Number& delta_d)
     288  {
     289    if (delta_x_curr_ == 0.) {
     290      if (delta_x_last_ == 0.) {
     291        delta_x_curr_ = delta_xs_init_;
     292      }
     293      else {
     294        delta_x_curr_ = Max(delta_xs_min_,
     295                            delta_x_last_*delta_xs_dec_fact_);
     296      }
     297    }
     298    else {
     299      if (delta_x_last_ == 0. || 1e5*delta_x_last_<delta_x_curr_) {
     300        delta_x_curr_ = delta_xs_first_inc_fact_*delta_x_curr_;
     301      }
     302      else {
     303        delta_x_curr_ = delta_xs_inc_fact_*delta_x_curr_;
     304      }
     305    }
     306    if (delta_x_curr_ > delta_xs_max_) {
     307      // Give up trying to solve the linear system
     308      return false;
     309    }
     310
     311    delta_s_curr_ = delta_x_curr_;
     312
     313    delta_x = delta_x_curr_;
     314    delta_s = delta_s_curr_;
     315    delta_c = delta_c_curr_;
     316    delta_d = delta_d_curr_;
     317
     318    IpData().Set_info_regu_x(delta_x);
     319
     320    return true;
     321  }
     322
     323  bool
    271324  PDPerturbationHandler::PerturbForWrongInertia(
    272325    Number& delta_x, Number& delta_s,
     
    281334    finalize_test();
    282335
    283     if (delta_x_curr_ == 0.) {
    284       if (delta_x_last_ == 0.) {
    285         delta_x_curr_ = delta_xs_init_;
    286       }
    287       else {
    288         delta_x_curr_ = Max(delta_xs_min_,
    289                             delta_x_last_*delta_xs_dec_fact_);
    290       }
    291     }
    292     else {
    293       if (delta_x_last_ == 0. || 1e5*delta_x_last_<delta_x_curr_) {
    294         delta_x_curr_ = delta_xs_first_inc_fact_*delta_x_curr_;
    295       }
    296       else {
    297         delta_x_curr_ = delta_xs_inc_fact_*delta_x_curr_;
    298       }
    299     }
    300     if (delta_x_curr_ > delta_xs_max_) {
    301       // Give up trying to solve the linear system
    302       return false;
    303     }
    304 
    305     delta_s_curr_ = delta_x_curr_;
    306 
    307     delta_x = delta_x_curr_;
    308     delta_s = delta_s_curr_;
    309     delta_c = delta_c_curr_;
    310     delta_d = delta_d_curr_;
    311 
    312     IpData().Set_info_regu_x(delta_x);
    313 
    314     return true;
     336    return get_deltas_for_wrong_inertia(delta_x, delta_s, delta_c, delta_d);
    315337  }
    316338
  • branches/dev/Algorithm/IpPDPerturbationHandler.hpp

    r460 r487  
    175175    /** @name Auxilliary methods */
    176176    //@{
     177    /** Internal version of PerturbForWrongInertia with the
     178     *  difference, that finalize_test is not called. */
     179    bool get_deltas_for_wrong_inertia(Number& delta_x, Number& delta_s,
     180                                      Number& delta_c, Number& delta_d);
     181
    177182    /** This method is call whenever a matrix had been factorization
    178183     *  and is not singular.  In here, we can evaluate the outcome of
  • branches/dev/Algorithm/IpRestoIpoptNLP.cpp

    r467 r487  
    136136    // vector x
    137137    Index total_dim = orig_x_space->Dim() + 2*orig_c_space->Dim()
    138                       //orig  + orig_d_l_space->Dim() + orig_d_u_space->Dim();
    139138                      + 2*orig_d_space->Dim();
    140139    x_space_ = new CompoundVectorSpace(5, total_dim);
     
    144143    x_space_->SetCompSpace(3, *orig_d_space); // n_d
    145144    x_space_->SetCompSpace(4, *orig_d_space); // p_d
    146     //orig    x_space_->SetCompSpace(3, *orig_d_l_space); // n_d
    147     //orig    x_space_->SetCompSpace(4, *orig_d_u_space); // p_d
    148145
    149146    DBG_PRINT((1, "Setting the c_space_\n"));
     
    158155    // vector x_L
    159156    total_dim = orig_x_l_space->Dim() + 2*orig_c_space->Dim()
    160                 //orig      + orig_d_l_space->Dim() + orig_d_u_space->Dim();
    161157                + 2*orig_d_space->Dim();
    162158    x_l_space_ = new CompoundVectorSpace(5, total_dim);
     
    166162    x_l_space_->SetCompSpace(3, *orig_d_space); // n_d >=0
    167163    x_l_space_->SetCompSpace(4, *orig_d_space); // p_d >=0
    168     //orig    x_l_space_->SetCompSpace(3, *orig_d_l_space); // n_d >=0
    169     //orig    x_l_space_->SetCompSpace(4, *orig_d_u_space); // p_d >=0
    170164
    171165    DBG_PRINT((1, "Setting the x_u_space_\n"));
     
    176170    // matrix px_l
    177171    Index total_rows = orig_x_space->Dim() + 2*orig_c_space->Dim()
    178                        //orig      + orig_d_l_space->Dim() + orig_d_u_space->Dim();
    179172                       + 2*orig_d_space->Dim();
    180173    Index total_cols = orig_x_l_space->Dim() + 2*orig_c_space->Dim()
    181                        //orig      + orig_d_l_space->Dim() + orig_d_u_space->Dim();
    182174                       + 2*orig_d_space->Dim();
    183175    px_l_space_ = new CompoundMatrixSpace(5, 5, total_rows, total_cols);
     
    187179    px_l_space_->SetBlockRows(3, orig_d_space->Dim());
    188180    px_l_space_->SetBlockRows(4, orig_d_space->Dim());
    189     //orig    px_l_space_->SetBlockRows(3, orig_d_l_space->Dim());
    190     //orig    px_l_space_->SetBlockRows(4, orig_d_u_space->Dim());
    191181    px_l_space_->SetBlockCols(0, orig_x_l_space->Dim());
    192182    px_l_space_->SetBlockCols(1, orig_c_space->Dim());
     
    194184    px_l_space_->SetBlockCols(3, orig_d_space->Dim());
    195185    px_l_space_->SetBlockCols(4, orig_d_space->Dim());
    196     //orig    px_l_space_->SetBlockCols(3, orig_d_l_space->Dim());
    197     //orig    px_l_space_->SetBlockCols(4, orig_d_u_space->Dim());
    198186
    199187    px_l_space_->SetCompSpace(0, 0, *orig_px_l_space);
     
    211199    px_l_space_->SetCompSpace(1, 1, *identity_mat_space_nc, true);
    212200    px_l_space_->SetCompSpace(2, 2, *identity_mat_space_nc, true);
    213     //orig    SmartPtr<const MatrixSpace> identity_mat_space_nd_l
    214     //orig    = new IdentityMatrixSpace(orig_d_l_space->Dim());
    215201    SmartPtr<const MatrixSpace> identity_mat_space_nd
    216202    = new IdentityMatrixSpace(orig_d_space->Dim());
    217     //orig    px_l_space_->SetCompSpace(3, 3, *identity_mat_space_nd_l, true);
    218203    px_l_space_->SetCompSpace(3, 3, *identity_mat_space_nd, true);
    219     //orig    SmartPtr<const MatrixSpace> identity_mat_space_nd_u
    220     //orig      = new IdentityMatrixSpace(orig_d_u_space->Dim());
    221     //orig    px_l_space_->SetCompSpace(4, 4, *identity_mat_space_nd_u, true);
    222204    px_l_space_->SetCompSpace(4, 4, *identity_mat_space_nd, true);
    223205
     
    226208
    227209    total_rows = orig_x_space->Dim() + 2*orig_c_space->Dim()
    228                  //orig      + orig_d_l_space->Dim() + orig_d_u_space->Dim();
    229210                 + 2*orig_d_space->Dim();
    230211    total_cols = orig_x_u_space->Dim();
     
    236217    px_u_space_->SetBlockRows(3, orig_d_space->Dim());
    237218    px_u_space_->SetBlockRows(4, orig_d_space->Dim());
    238     //orig    px_u_space_->SetBlockRows(3, orig_d_l_space->Dim());
    239     //orig    px_u_space_->SetBlockRows(4, orig_d_u_space->Dim());
    240219    px_u_space_->SetBlockCols(0, orig_x_u_space->Dim());
    241220
     
    260239    total_cols = orig_x_space->Dim() + 2*orig_c_space->Dim()
    261240                 + 2*orig_d_space->Dim();
    262     //orig      + orig_d_l_space->Dim() + orig_d_u_space->Dim();
    263241    jac_c_space_ = new CompoundMatrixSpace(1, 5, total_rows, total_cols);
    264242    jac_c_space_->SetBlockRows(0, orig_c_space->Dim());
     
    268246    jac_c_space_->SetBlockCols(3, orig_d_space->Dim());
    269247    jac_c_space_->SetBlockCols(4, orig_d_space->Dim());
    270     //orig    jac_c_space_->SetBlockCols(3, orig_d_l_space->Dim());
    271     //orig    jac_c_space_->SetBlockCols(4, orig_d_u_space->Dim());
    272248
    273249    jac_c_space_->SetCompSpace(0, 0, *orig_jac_c_space);
     
    281257    total_cols = orig_x_space->Dim() + 2*orig_c_space->Dim()
    282258                 + 2*orig_d_space->Dim();
    283     //orig      + orig_d_l_space->Dim() + orig_d_u_space->Dim();
    284259    jac_d_space_ = new CompoundMatrixSpace(1, 5, total_rows, total_cols);
    285260    jac_d_space_->SetBlockRows(0, orig_d_space->Dim());
     
    289264    jac_d_space_->SetBlockCols(3, orig_d_space->Dim());
    290265    jac_d_space_->SetBlockCols(4, orig_d_space->Dim());
    291     //orig    jac_d_space_->SetBlockCols(3, orig_d_l_space->Dim());
    292     //orig    jac_d_space_->SetBlockCols(4, orig_d_u_space->Dim());
    293266
    294267    jac_d_space_->SetCompSpace(0, 0, *orig_jac_d_space);
     268    DBG_PRINT((1, "orig_jac_d_space = %x\n", GetRawPtr(orig_jac_d_space)))
    295269    // Blocks (0,1) and (0,2) are zero'ed out
    296270    jac_d_space_->SetCompSpace(0, 3, *identity_mat_space_nd, true);
    297271    jac_d_space_->SetCompSpace(0, 4, *identity_mat_space_nd, true);
    298     //orig    jac_d_space_->SetCompSpace(0, 3, *orig_pd_l_space, true);
    299     //orig    SmartPtr<SumMatrixSpace> sum_pd_u
    300     //orig    = new SumMatrixSpace(orig_d_space->Dim(), orig_d_u_space->Dim(), 1);
    301     //orig    jac_d_space_->SetCompSpace(0, 4, *sum_pd_u, true);
    302272
    303273    DBG_PRINT((1, "Creating the h_space_\n"));
     
    305275    total_dim = orig_x_space->Dim() + 2*orig_c_space->Dim()
    306276                + 2*orig_d_space->Dim();
    307     //orig      + orig_d_l_space->Dim() + orig_d_u_space->Dim();
    308277    h_space_ = new CompoundSymMatrixSpace(5, total_dim);
    309278    h_space_->SetBlockDim(0, orig_x_space->Dim());
     
    312281    h_space_->SetBlockDim(3, orig_d_space->Dim());
    313282    h_space_->SetBlockDim(4, orig_d_space->Dim());
    314     //orig    h_space_->SetBlockDim(3, orig_d_l_space->Dim());
    315     //orig    h_space_->SetBlockDim(4, orig_d_u_space->Dim());
    316283
    317284    SmartPtr<const MatrixSpace> sumsym_mat_space =
     
    537504    retPtr->Axpy(1., *nd_only);
    538505    retPtr->Axpy(-1., *pd_only);
    539 #ifdef orig
    540 
    541     SmartPtr<Vector> tmp = orig_d->MakeNew();
    542     orig_ip_nlp_->Pd_L()->MultVector(1.0, *nd_only, 0.0, *tmp);
    543     retPtr->Axpy(1.0, *tmp);
    544     orig_ip_nlp_->Pd_U()->MultVector(1.0, *pd_only, 0.0, *tmp);
    545     retPtr->Axpy(-1.0, *tmp);
    546 #endif
    547506
    548507    return GetRawPtr(retPtr);
     
    586545  SmartPtr<const Matrix> RestoIpoptNLP::jac_d(const Vector& x)
    587546  {
     547    DBG_START_METH("RestoIpoptNLP::jac_d", dbg_verbosity);
     548
    588549    // Here, we set the (0,0) block with the values from the
    589550    // original jac_d and set the factor for the -I (jac w.r.t. p_d)
     
    601562    // space (since auto_allocate was set to true in SetCompSpace)
    602563    SmartPtr<CompoundMatrix> retPtr = jac_d_space_->MakeNewCompoundMatrix();
    603 
    604     // Set the block for the original jacobian
     564    DBG_PRINT((1, "jac_d_space_ = %x\n", GetRawPtr(jac_d_space_)))
     565
     566    // Set the block for the original Jacobian
    605567    retPtr->SetComp(0,0,*jac_d_only);
    606568
     
    613575    DBG_ASSERT(jac_d_pd);
    614576    jac_d_pd->SetFactor(-1.0);
    615 
    616 #ifdef orig
    617     // Jacobian of resto d w.r.t. n_d is Pd_L
    618     retPtr->SetComp(0, 3, *orig_ip_nlp_->Pd_L());
    619 
    620     // Change the matrix factor to -1 for Pd_U
    621     // Jacobian of the resto d w.r.t. p_d is -Pd_U
    622     SmartPtr<Matrix> jac_d_pd_mat = retPtr->GetCompNonConst(0,4);
    623     SumMatrix* jac_d_pd_sum = dynamic_cast<SumMatrix*>(GetRawPtr(jac_d_pd_mat));
    624     DBG_ASSERT(jac_d_pd_sum);
    625     jac_d_pd_sum->SetTerm(0, -1.0, *orig_ip_nlp_->Pd_U());
    626 #endif
    627577
    628578    return GetRawPtr(retPtr);
  • branches/dev/Common/IpSmartPtr.hpp

    r432 r487  
    225225    template <class U1, class U2>
    226226    friend
    227     bool operator==(const SmartPtr& lhs, U2* raw_rhs);
     227    bool operator==(const SmartPtr<U1>& lhs, U2* raw_rhs);
    228228
    229229    /** Overloaded equality comparison operator, allows the
  • branches/dev/Interfaces/IpAlgTypes.hpp

    r465 r487  
    3838  DECLARE_STD_EXCEPTION(ACCEPTABLE_POINT_REACHED);
    3939  DECLARE_STD_EXCEPTION(FEASIBILITY_PROBLEM_SOLVED);
     40  DECLARE_STD_EXCEPTION(INTERNAL_ABORT);
    4041  /** Exception FAILED_INITIALIZATION for problem during
    4142   *  initialization of a strategy object (or other problems).  This
Note: See TracChangeset for help on using the changeset viewer.