Changeset 489
 Timestamp:
 Aug 24, 2005 3:25:38 PM (14 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/dev/Algorithm/IpOrigIpoptNLP.cpp
r467 r489 313 313 { 314 314 SmartPtr<const Vector> retValue; 315 SmartPtr<const Vector> dep;316 315 if (c_space_>Dim()==0) { 317 316 // We do this caching of an empty vector so that the returned 318 317 // Vector has always the same tag (this might make a difference 319 318 // in cases where only the constraints are supposed to change... 320 dep = NULL;319 SmartPtr<const Vector> dep = NULL; 321 320 if (!c_cache_.GetCachedResult1Dep(retValue, GetRawPtr(dep))) { 322 321 retValue = c_space_>MakeNew(); … … 325 324 } 326 325 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 } 338 336 } 339 337 … … 345 343 DBG_START_METH("OrigIpoptNLP::d", dbg_verbosity); 346 344 SmartPtr<const Vector> retValue; 347 SmartPtr<const Vector> dep;348 345 if (d_space_>Dim()==0) { 349 346 // We do this caching of an empty vector so that the returned 350 347 // Vector has always the same tag (this might make a difference 351 348 // in cases where only the constraints are supposed to change... 352 dep = NULL;349 SmartPtr<const Vector> dep = NULL; 353 350 if (!d_cache_.GetCachedResult1Dep(retValue, GetRawPtr(dep))) { 354 351 retValue = d_space_>MakeNew(); … … 357 354 } 358 355 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 } 373 369 } 374 370 … … 379 375 { 380 376 SmartPtr<const Matrix> retValue; 381 SmartPtr<const Vector> dep;382 377 if (c_space_>Dim()==0) { 383 378 // We do this caching of an empty vector so that the returned 384 379 // Matrix has always the same tag 385 dep = NULL;380 SmartPtr<const Vector> dep = NULL; 386 381 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)); 388 384 jac_c_cache_.AddCachedResult1Dep(retValue, GetRawPtr(dep)); 389 385 } 390 386 } 391 387 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 } 403 398 } 404 399 … … 409 404 { 410 405 SmartPtr<const Matrix> retValue; 411 SmartPtr<const Vector> dep;412 406 if (d_space_>Dim()==0) { 413 407 // We do this caching of an empty vector so that the returned 414 408 // Matrix has always the same tag 415 dep = NULL;409 SmartPtr<const Vector> dep = NULL; 416 410 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)); 418 413 jac_d_cache_.AddCachedResult1Dep(retValue, GetRawPtr(dep)); 419 414 } 420 415 } 421 416 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 } 433 427 } 434 428
Note: See TracChangeset
for help on using the changeset viewer.