IpIpoptData.hpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. // Copyright (C) 2004, 2009 International Business Machines and others.
  2. // All Rights Reserved.
  3. // This code is published under the Eclipse Public License.
  4. //
  5. // $Id: IpIpoptData.hpp 2276 2013-05-05 12:33:44Z stefan $
  6. //
  7. // Authors: Carl Laird, Andreas Waechter IBM 2004-08-13
  8. #ifndef __IPIPOPTDATA_HPP__
  9. #define __IPIPOPTDATA_HPP__
  10. #include "IpSymMatrix.hpp"
  11. #include "IpOptionsList.hpp"
  12. #include "IpIteratesVector.hpp"
  13. #include "IpRegOptions.hpp"
  14. #include "IpTimingStatistics.hpp"
  15. namespace Ipopt
  16. {
  17. /* Forward declaration */
  18. class IpoptNLP;
  19. /** Base class for additional data that is special to a particular
  20. * type of algorithm, such as the CG penalty function, or using
  21. * iterative linear solvers. The regular IpoptData object should
  22. * be given a derivation of this base class when it is created. */
  23. class IpoptAdditionalData : public ReferencedObject
  24. {
  25. public:
  26. /**@name Constructors/Destructors */
  27. //@{
  28. /** Default Constructor */
  29. IpoptAdditionalData()
  30. {}
  31. /** Default destructor */
  32. virtual ~IpoptAdditionalData()
  33. {}
  34. //@}
  35. /** This method is called to initialize the global algorithmic
  36. * parameters. The parameters are taken from the OptionsList
  37. * object. */
  38. virtual bool Initialize(const Journalist& jnlst,
  39. const OptionsList& options,
  40. const std::string& prefix) = 0;
  41. /** Initialize Data Structures at the beginning. */
  42. virtual bool InitializeDataStructures() = 0;
  43. /** Do whatever is necessary to accept a trial point as current
  44. * iterate. This is also used to finish an iteration, i.e., to
  45. * release memory, and to reset any flags for a new iteration. */
  46. virtual void AcceptTrialPoint() = 0;
  47. private:
  48. /**@name Default Compiler Generated Methods
  49. * (Hidden to avoid implicit creation/calling).
  50. * These methods are not implemented and
  51. * we do not want the compiler to implement
  52. * them for us, so we declare them private
  53. * and do not define them. This ensures that
  54. * they will not be implicitly created/called. */
  55. //@{
  56. /** Copy Constructor */
  57. IpoptAdditionalData(const IpoptAdditionalData&);
  58. /** Overloaded Equals Operator */
  59. void operator=(const IpoptAdditionalData&);
  60. //@}
  61. };
  62. /** Class to organize all the data required by the algorithm.
  63. * Internally, once this Data object has been initialized, all
  64. * internal curr_ vectors must always be set (so that prototyes are
  65. * available). The current values can only be set from the trial
  66. * values. The trial values can be set by copying from a vector or
  67. * by adding some fraction of a step to the current values. This
  68. * object also stores steps, which allows to easily communicate the
  69. * step from the step computation object to the line search object.
  70. */
  71. class IpoptData : public ReferencedObject
  72. {
  73. public:
  74. /**@name Constructors/Destructors */
  75. //@{
  76. /** Constructor */
  77. IpoptData(SmartPtr<IpoptAdditionalData> add_data = NULL,
  78. Number cpu_time_start = -1.);
  79. /** Default destructor */
  80. virtual ~IpoptData();
  81. //@}
  82. /** Initialize Data Structures */
  83. bool InitializeDataStructures(IpoptNLP& ip_nlp,
  84. bool want_x,
  85. bool want_y_c,
  86. bool want_y_d,
  87. bool want_z_L,
  88. bool want_z_U);
  89. /** This method must be called to initialize the global
  90. * algorithmic parameters. The parameters are taken from the
  91. * OptionsList object. */
  92. bool Initialize(const Journalist& jnlst,
  93. const OptionsList& options,
  94. const std::string& prefix);
  95. /** @name Get Methods for Iterates */
  96. //@{
  97. /** Current point */
  98. inline
  99. SmartPtr<const IteratesVector> curr() const;
  100. /** Get the current point in a copied container that is non-const.
  101. The entries in the container cannot be modified, but
  102. the container can be modified to point to new entries.
  103. */
  104. // SmartPtr<IteratesVector> curr_container() const;
  105. /** Get Trial point */
  106. inline
  107. SmartPtr<const IteratesVector> trial() const;
  108. /** Get Trial point in a copied container that is non-const.
  109. * The entries in the container can not be modified, but
  110. * the container can be modified to point to new entries.
  111. */
  112. //SmartPtr<IteratesVector> trial_container() const;
  113. /** Set the trial point - this method copies the pointer for
  114. * efficiency (no copy and to keep cache tags the same) so
  115. * after you call set you cannot modify the data again
  116. */
  117. inline
  118. void set_trial(SmartPtr<IteratesVector>& trial);
  119. /** Set the values of the primal trial variables (x and s) from
  120. * provided Step with step length alpha.
  121. */
  122. void SetTrialPrimalVariablesFromStep(Number alpha,
  123. const Vector& delta_x,
  124. const Vector& delta_s);
  125. /** Set the values of the trial values for the equality constraint
  126. * multipliers (y_c and y_d) from provided step with step length
  127. * alpha.
  128. */
  129. void SetTrialEqMultipliersFromStep(Number alpha,
  130. const Vector& delta_y_c,
  131. const Vector& delta_y_d);
  132. /** Set the value of the trial values for the bound multipliers
  133. * (z_L, z_U, v_L, v_U) from provided step with step length
  134. * alpha.
  135. */
  136. void SetTrialBoundMultipliersFromStep(Number alpha,
  137. const Vector& delta_z_L,
  138. const Vector& delta_z_U,
  139. const Vector& delta_v_L,
  140. const Vector& delta_v_U);
  141. /** ToDo: I may need to add versions of set_trial like the
  142. * following, but I am not sure
  143. */
  144. // void set_trial(const SmartPtr<IteratesVector>& trial_iterates);
  145. // void set_trial(SmartPtr<const IteratesVector>& trial_iterates);
  146. /** get the current delta */
  147. inline
  148. SmartPtr<const IteratesVector> delta() const;
  149. /** Set the current delta - like the trial point, this method copies
  150. * the pointer for efficiency (no copy and to keep cache tags the
  151. * same) so after you call set, you cannot modify the data
  152. */
  153. inline
  154. void set_delta(SmartPtr<IteratesVector>& delta);
  155. /** Set the current delta - like the trial point, this method
  156. * copies the pointer for efficiency (no copy and to keep cache
  157. * tags the same) so after you call set, you cannot modify the
  158. * data. This is the version that is happy with a pointer to
  159. * const IteratesVector.
  160. */
  161. inline
  162. void set_delta(SmartPtr<const IteratesVector>& delta);
  163. /** Affine Delta */
  164. inline
  165. SmartPtr<const IteratesVector> delta_aff() const;
  166. /** Set the affine delta - like the trial point, this method copies
  167. * the pointer for efficiency (no copy and to keep cache tags the
  168. * same) so after you call set, you cannot modify the data
  169. */
  170. inline
  171. void set_delta_aff(SmartPtr<IteratesVector>& delta_aff);
  172. /** Hessian or Hessian approximation (do not hold on to it, it might be changed) */
  173. SmartPtr<const SymMatrix> W()
  174. {
  175. DBG_ASSERT(IsValid(W_));
  176. return W_;
  177. }
  178. /** Set Hessian approximation */
  179. void Set_W(SmartPtr<const SymMatrix> W)
  180. {
  181. W_ = W;
  182. }
  183. /** @name ("Main") Primal-dual search direction. Those fields are
  184. * used to store the search directions computed from solving the
  185. * primal-dual system, and can be used in the line search. They
  186. * are overwritten in every iteration, so do not hold on to the
  187. * pointers (make copies instead) */
  188. //@{
  189. /** Returns true, if the primal-dual step have been already
  190. * computed for the current iteration. This flag is reset after
  191. * every call of AcceptTrialPoint(). If the search direction is
  192. * computed during the computation of the barrier parameter, the
  193. * method computing the barrier parameter should call
  194. * SetHaveDeltas(true) to tell the IpoptAlgorithm object that it
  195. * doesn't need to recompute the primal-dual step. */
  196. bool HaveDeltas() const
  197. {
  198. return have_deltas_;
  199. }
  200. /** Method for setting the HaveDeltas flag. This method should be
  201. * called if some method computes the primal-dual step (and
  202. * stores it in the delta_ fields of IpoptData) at an early part
  203. * of the iteration. If that flag is set to true, the
  204. * IpoptAlgorithm object will not recompute the step. */
  205. void SetHaveDeltas(bool have_deltas)
  206. {
  207. have_deltas_ = have_deltas;
  208. }
  209. //@}
  210. /** @name Affine-scaling step. Those fields can be used to store
  211. * the affine scaling step. For example, if the method for
  212. * computing the current barrier parameter computes the affine
  213. * scaling steps, then the corrector step in the line search does
  214. * not have to recompute those solutions of the linear system. */
  215. //@{
  216. /** Returns true, if the affine-scaling step have been already
  217. * computed for the current iteration. This flag is reset after
  218. * every call of AcceptTrialPoint(). If the search direction is
  219. * computed during the computation of the barrier parameter, the
  220. * method computing the barrier parameter should call
  221. * SetHaveDeltas(true) to tell the line search does not have to
  222. * recompute them in case it wants to do a corrector step. */
  223. bool HaveAffineDeltas() const
  224. {
  225. return have_affine_deltas_;
  226. }
  227. /** Method for setting the HaveDeltas flag. This method should be
  228. * called if some method computes the primal-dual step (and
  229. * stores it in the delta_ fields of IpoptData) at an early part
  230. * of the iteration. If that flag is set to true, the
  231. * IpoptAlgorithm object will not recompute the step. */
  232. void SetHaveAffineDeltas(bool have_affine_deltas)
  233. {
  234. have_affine_deltas_ = have_affine_deltas;
  235. }
  236. //@}
  237. /** @name Public Methods for updating iterates */
  238. //@{
  239. /** Copy the trial values to the current values */
  240. inline
  241. void CopyTrialToCurrent();
  242. /** Set the current iterate values from the
  243. * trial values. */
  244. void AcceptTrialPoint();
  245. //@}
  246. /** @name General algorithmic data */
  247. //@{
  248. Index iter_count() const
  249. {
  250. return iter_count_;
  251. }
  252. void Set_iter_count(Index iter_count)
  253. {
  254. iter_count_ = iter_count;
  255. }
  256. Number curr_mu() const
  257. {
  258. DBG_ASSERT(mu_initialized_);
  259. return curr_mu_;
  260. }
  261. void Set_mu(Number mu)
  262. {
  263. curr_mu_ = mu;
  264. mu_initialized_ = true;
  265. }
  266. bool MuInitialized() const
  267. {
  268. return mu_initialized_;
  269. }
  270. Number curr_tau() const
  271. {
  272. DBG_ASSERT(tau_initialized_);
  273. return curr_tau_;
  274. }
  275. void Set_tau(Number tau)
  276. {
  277. curr_tau_ = tau;
  278. tau_initialized_ = true;
  279. }
  280. bool TauInitialized() const
  281. {
  282. return tau_initialized_;
  283. }
  284. void SetFreeMuMode(bool free_mu_mode)
  285. {
  286. free_mu_mode_ = free_mu_mode;
  287. }
  288. bool FreeMuMode() const
  289. {
  290. return free_mu_mode_;
  291. }
  292. /** Setting the flag that indicates if a tiny step (below machine
  293. * precision) has been detected */
  294. void Set_tiny_step_flag(bool flag)
  295. {
  296. tiny_step_flag_ = flag;
  297. }
  298. bool tiny_step_flag()
  299. {
  300. return tiny_step_flag_;
  301. }
  302. //@}
  303. /** Overall convergence tolerance. It is used in the convergence
  304. * test, but also in some other parts of the algorithm that
  305. * depend on the specified tolerance, such as the minimum value
  306. * for the barrier parameter. */
  307. //@{
  308. /** Obtain the tolerance. */
  309. Number tol() const
  310. {
  311. DBG_ASSERT(initialize_called_);
  312. return tol_;
  313. }
  314. /** Set a new value for the tolerance. One should be very careful
  315. * when using this, since changing the predefined tolerance might
  316. * have unexpected consequences. This method is for example used
  317. * in the restoration convergence checker to tighten the
  318. * restoration phase convergence tolerance, if the restoration
  319. * phase converged to a point that has not a large value for the
  320. * constraint violation. */
  321. void Set_tol(Number tol)
  322. {
  323. tol_ = tol;
  324. }
  325. //@}
  326. /** Cpu time counter at the beginning of the optimization. This
  327. * is useful to see how much CPU time has been spent in this
  328. * optimization run. */
  329. Number cpu_time_start() const
  330. {
  331. return cpu_time_start_;
  332. }
  333. /** @name Information gathered for iteration output */
  334. //@{
  335. Number info_regu_x() const
  336. {
  337. return info_regu_x_;
  338. }
  339. void Set_info_regu_x(Number regu_x)
  340. {
  341. info_regu_x_ = regu_x;
  342. }
  343. Number info_alpha_primal() const
  344. {
  345. return info_alpha_primal_;
  346. }
  347. void Set_info_alpha_primal(Number alpha_primal)
  348. {
  349. info_alpha_primal_ = alpha_primal;
  350. }
  351. char info_alpha_primal_char() const
  352. {
  353. return info_alpha_primal_char_;
  354. }
  355. void Set_info_alpha_primal_char(char info_alpha_primal_char)
  356. {
  357. info_alpha_primal_char_ = info_alpha_primal_char;
  358. }
  359. Number info_alpha_dual() const
  360. {
  361. return info_alpha_dual_;
  362. }
  363. void Set_info_alpha_dual(Number alpha_dual)
  364. {
  365. info_alpha_dual_ = alpha_dual;
  366. }
  367. Index info_ls_count() const
  368. {
  369. return info_ls_count_;
  370. }
  371. void Set_info_ls_count(Index ls_count)
  372. {
  373. info_ls_count_ = ls_count;
  374. }
  375. bool info_skip_output() const
  376. {
  377. return info_skip_output_;
  378. }
  379. void Append_info_string(const std::string& add_str)
  380. {
  381. info_string_ += add_str;
  382. }
  383. const std::string& info_string() const
  384. {
  385. return info_string_;
  386. }
  387. /** Set this to true, if the next time when output is written, the
  388. * summary line should not be printed. */
  389. void Set_info_skip_output(bool info_skip_output)
  390. {
  391. info_skip_output_ = info_skip_output;
  392. }
  393. /** gives time when the last summary output line was printed */
  394. Number info_last_output()
  395. {
  396. return info_last_output_;
  397. }
  398. /** sets time when the last summary output line was printed */
  399. void Set_info_last_output(Number info_last_output)
  400. {
  401. info_last_output_ = info_last_output;
  402. }
  403. /** gives number of iteration summaries actually printed
  404. * since last summary header was printed */
  405. int info_iters_since_header()
  406. {
  407. return info_iters_since_header_;
  408. }
  409. /** increases number of iteration summaries actually printed
  410. * since last summary header was printed */
  411. void Inc_info_iters_since_header()
  412. {
  413. info_iters_since_header_++;
  414. }
  415. /** sets number of iteration summaries actually printed
  416. * since last summary header was printed */
  417. void Set_info_iters_since_header(int info_iters_since_header)
  418. {
  419. info_iters_since_header_ = info_iters_since_header;
  420. }
  421. /** Reset all info fields */
  422. void ResetInfo()
  423. {
  424. info_regu_x_ = 0;
  425. info_alpha_primal_ = 0;
  426. info_alpha_dual_ = 0.;
  427. info_alpha_primal_char_ = ' ';
  428. info_skip_output_ = false;
  429. info_string_.erase();
  430. }
  431. //@}
  432. /** Return Timing Statistics Object */
  433. TimingStatistics& TimingStats()
  434. {
  435. return timing_statistics_;
  436. }
  437. /** Check if additional data has been set */
  438. bool HaveAddData()
  439. {
  440. return IsValid(add_data_);
  441. }
  442. /** Get access to additional data object */
  443. IpoptAdditionalData& AdditionalData()
  444. {
  445. return *add_data_;
  446. }
  447. /** Set a new pointer for additional Ipopt data */
  448. void SetAddData(SmartPtr<IpoptAdditionalData> add_data)
  449. {
  450. DBG_ASSERT(!HaveAddData());
  451. add_data_ = add_data;
  452. }
  453. /** Set the perturbation of the primal-dual system */
  454. void setPDPert(Number pd_pert_x, Number pd_pert_s,
  455. Number pd_pert_c, Number pd_pert_d)
  456. {
  457. pd_pert_x_ = pd_pert_x;
  458. pd_pert_s_ = pd_pert_s;
  459. pd_pert_c_ = pd_pert_c;
  460. pd_pert_d_ = pd_pert_d;
  461. }
  462. /** Get the current perturbation of the primal-dual system */
  463. void getPDPert(Number& pd_pert_x, Number& pd_pert_s,
  464. Number& pd_pert_c, Number& pd_pert_d)
  465. {
  466. pd_pert_x = pd_pert_x_;
  467. pd_pert_s = pd_pert_s_;
  468. pd_pert_c = pd_pert_c_;
  469. pd_pert_d = pd_pert_d_;
  470. }
  471. /** Methods for IpoptType */
  472. //@{
  473. static void RegisterOptions(const SmartPtr<RegisteredOptions>& roptions);
  474. //@}
  475. private:
  476. /** @name Iterates */
  477. //@{
  478. /** Main iteration variables
  479. * (current iteration) */
  480. SmartPtr<const IteratesVector> curr_;
  481. /** Main iteration variables
  482. * (trial calculations) */
  483. SmartPtr<const IteratesVector> trial_;
  484. /** Hessian (approximation) - might be changed elsewhere! */
  485. SmartPtr<const SymMatrix> W_;
  486. /** @name Primal-dual Step */
  487. //@{
  488. SmartPtr<const IteratesVector> delta_;
  489. /** The following flag is set to true, if some other part of the
  490. * algorithm (like the method for computing the barrier
  491. * parameter) has already computed the primal-dual search
  492. * direction. This flag is reset when the AcceptTrialPoint
  493. * method is called.
  494. * ToDo: we could cue off of a null delta_;
  495. */
  496. bool have_deltas_;
  497. //@}
  498. /** @name Affine-scaling step. This used to transfer the
  499. * information about the affine-scaling step from the computation
  500. * of the barrier parameter to the corrector (in the line
  501. * search). */
  502. //@{
  503. SmartPtr<const IteratesVector> delta_aff_;
  504. /** The following flag is set to true, if some other part of the
  505. * algorithm (like the method for computing the barrier
  506. * parameter) has already computed the affine-scaling step. This
  507. * flag is reset when the AcceptTrialPoint method is called.
  508. * ToDo: we could cue off of a null delta_aff_;
  509. */
  510. bool have_affine_deltas_;
  511. //@}
  512. /** iteration count */
  513. Index iter_count_;
  514. /** current barrier parameter */
  515. Number curr_mu_;
  516. bool mu_initialized_;
  517. /** current fraction to the boundary parameter */
  518. Number curr_tau_;
  519. bool tau_initialized_;
  520. /** flag indicating if Initialize method has been called (for
  521. * debugging) */
  522. bool initialize_called_;
  523. /** flag for debugging whether we have already curr_ values
  524. * available (from which new Vectors can be generated */
  525. bool have_prototypes_;
  526. /** @name Global algorithm parameters. Those are options that can
  527. * be modified by the user and appear at different places in the
  528. * algorithm. They are set using an OptionsList object in the
  529. * Initialize method. */
  530. //@{
  531. /** Overall convergence tolerance */
  532. Number tol_;
  533. //@}
  534. /** @name Status data **/
  535. //@{
  536. /** flag indicating whether the algorithm is in the free mu mode */
  537. bool free_mu_mode_;
  538. /** flag indicating if a tiny step has been detected */
  539. bool tiny_step_flag_;
  540. //@}
  541. /** @name Gathered information for iteration output */
  542. //@{
  543. /** Size of regularization for the Hessian */
  544. Number info_regu_x_;
  545. /** Primal step size */
  546. Number info_alpha_primal_;
  547. /** Info character for primal step size */
  548. char info_alpha_primal_char_;
  549. /** Dual step size */
  550. Number info_alpha_dual_;
  551. /** Number of backtracking trial steps */
  552. Index info_ls_count_;
  553. /** true, if next summary output line should not be printed (eg
  554. * after restoration phase. */
  555. bool info_skip_output_;
  556. /** any string of characters for the end of the output line */
  557. std::string info_string_;
  558. /** time when the last summary output line was printed */
  559. Number info_last_output_;
  560. /** number of iteration summaries actually printed since last
  561. * summary header was printed */
  562. int info_iters_since_header_;
  563. //@}
  564. /** VectorSpace for all the iterates */
  565. SmartPtr<IteratesVectorSpace> iterates_space_;
  566. /** TimingStatistics object collecting all Ipopt timing
  567. * statistics */
  568. TimingStatistics timing_statistics_;
  569. /** CPU time counter at initialization. */
  570. Number cpu_time_start_;
  571. /** Object for the data specific for the Chen-Goldfarb penalty
  572. * method algorithm */
  573. SmartPtr<IpoptAdditionalData> add_data_;
  574. /** @name Information about the perturbation of the primal-dual
  575. * system */
  576. //@{
  577. Number pd_pert_x_;
  578. Number pd_pert_s_;
  579. Number pd_pert_c_;
  580. Number pd_pert_d_;
  581. //@}
  582. /**@name Default Compiler Generated Methods
  583. * (Hidden to avoid implicit creation/calling).
  584. * These methods are not implemented and
  585. * we do not want the compiler to implement
  586. * them for us, so we declare them private
  587. * and do not define them. This ensures that
  588. * they will not be implicitly created/called. */
  589. //@{
  590. /** Copy Constructor */
  591. IpoptData(const IpoptData&);
  592. /** Overloaded Equals Operator */
  593. void operator=(const IpoptData&);
  594. //@}
  595. #if COIN_IPOPT_CHECKLEVEL > 0
  596. /** Some debug flags to make sure vectors are not changed
  597. * behind the IpoptData's back
  598. */
  599. //@{
  600. TaggedObject::Tag debug_curr_tag_;
  601. TaggedObject::Tag debug_trial_tag_;
  602. TaggedObject::Tag debug_delta_tag_;
  603. TaggedObject::Tag debug_delta_aff_tag_;
  604. TaggedObject::Tag debug_curr_tag_sum_;
  605. TaggedObject::Tag debug_trial_tag_sum_;
  606. TaggedObject::Tag debug_delta_tag_sum_;
  607. TaggedObject::Tag debug_delta_aff_tag_sum_;
  608. //@}
  609. #endif
  610. };
  611. inline
  612. SmartPtr<const IteratesVector> IpoptData::curr() const
  613. {
  614. DBG_ASSERT(IsNull(curr_) || (curr_->GetTag() == debug_curr_tag_ && curr_->GetTagSum() == debug_curr_tag_sum_) );
  615. return curr_;
  616. }
  617. inline
  618. SmartPtr<const IteratesVector> IpoptData::trial() const
  619. {
  620. DBG_ASSERT(IsNull(trial_) || (trial_->GetTag() == debug_trial_tag_ && trial_->GetTagSum() == debug_trial_tag_sum_) );
  621. return trial_;
  622. }
  623. inline
  624. SmartPtr<const IteratesVector> IpoptData::delta() const
  625. {
  626. DBG_ASSERT(IsNull(delta_) || (delta_->GetTag() == debug_delta_tag_ && delta_->GetTagSum() == debug_delta_tag_sum_) );
  627. return delta_;
  628. }
  629. inline
  630. SmartPtr<const IteratesVector> IpoptData::delta_aff() const
  631. {
  632. DBG_ASSERT(IsNull(delta_aff_) || (delta_aff_->GetTag() == debug_delta_aff_tag_ && delta_aff_->GetTagSum() == debug_delta_aff_tag_sum_) );
  633. return delta_aff_;
  634. }
  635. inline
  636. void IpoptData::CopyTrialToCurrent()
  637. {
  638. curr_ = trial_;
  639. #if COIN_IPOPT_CHECKLEVEL > 0
  640. if (IsValid(curr_)) {
  641. debug_curr_tag_ = curr_->GetTag();
  642. debug_curr_tag_sum_ = curr_->GetTagSum();
  643. }
  644. else {
  645. debug_curr_tag_ = TaggedObject::Tag();
  646. debug_curr_tag_sum_ = TaggedObject::Tag();
  647. }
  648. #endif
  649. }
  650. inline
  651. void IpoptData::set_trial(SmartPtr<IteratesVector>& trial)
  652. {
  653. trial_ = ConstPtr(trial);
  654. #if COIN_IPOPT_CHECKLEVEL > 0
  655. // verify the correct space
  656. DBG_ASSERT(trial_->OwnerSpace() == (VectorSpace*)GetRawPtr(iterates_space_));
  657. if (IsValid(trial)) {
  658. debug_trial_tag_ = trial->GetTag();
  659. debug_trial_tag_sum_ = trial->GetTagSum();
  660. }
  661. else {
  662. debug_trial_tag_ = TaggedObject::Tag();
  663. debug_trial_tag_sum_ = TaggedObject::Tag();
  664. }
  665. #endif
  666. trial = NULL;
  667. }
  668. inline
  669. void IpoptData::set_delta(SmartPtr<IteratesVector>& delta)
  670. {
  671. delta_ = ConstPtr(delta);
  672. #if COIN_IPOPT_CHECKLEVEL > 0
  673. if (IsValid(delta)) {
  674. debug_delta_tag_ = delta->GetTag();
  675. debug_delta_tag_sum_ = delta->GetTagSum();
  676. }
  677. else {
  678. debug_delta_tag_ = TaggedObject::Tag();
  679. debug_delta_tag_sum_ = TaggedObject::Tag();
  680. }
  681. #endif
  682. delta = NULL;
  683. }
  684. inline
  685. void IpoptData::set_delta(SmartPtr<const IteratesVector>& delta)
  686. {
  687. delta_ = delta;
  688. #if COIN_IPOPT_CHECKLEVEL > 0
  689. if (IsValid(delta)) {
  690. debug_delta_tag_ = delta->GetTag();
  691. debug_delta_tag_sum_ = delta->GetTagSum();
  692. }
  693. else {
  694. debug_delta_tag_ = TaggedObject::Tag();
  695. debug_delta_tag_sum_ = TaggedObject::Tag();
  696. }
  697. #endif
  698. delta = NULL;
  699. }
  700. inline
  701. void IpoptData::set_delta_aff(SmartPtr<IteratesVector>& delta_aff)
  702. {
  703. delta_aff_ = ConstPtr(delta_aff);
  704. #if COIN_IPOPT_CHECKLEVEL > 0
  705. if (IsValid(delta_aff)) {
  706. debug_delta_aff_tag_ = delta_aff->GetTag();
  707. debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
  708. }
  709. else {
  710. debug_delta_aff_tag_ = TaggedObject::Tag();
  711. debug_delta_aff_tag_sum_ = delta_aff->GetTagSum();
  712. }
  713. #endif
  714. delta_aff = NULL;
  715. }
  716. } // namespace Ipopt
  717. #endif