source: branches/devel/Bonmin/src/Interfaces/Ipopt/BonIpoptWarmStart.hpp @ 104

Last change on this file since 104 was 86, checked in by pbonami, 13 years ago

New directory layout regroup interfercaces in same subdirectory

  • Property svn:eol-style set to native
  • Property svn:keywords set to "Author Date Id Revision"
File size: 4.6 KB
Line 
1// (C) Copyright International Business Machines Corporation, Carnegie Mellon University 2006
2// All Rights Reserved.
3// This code is published under the Common Public License.
4//
5// Authors :
6// Pierre Bonami, Carnegie Mellon University,
7// Andreas Waechter, International Business Machines Corporation
8//
9// Date : 02/15/2006
10
11
12#ifndef IpoptWarmStart_HPP
13#define IpoptWarmStart_HPP
14#include "CoinWarmStartBasis.hpp"
15#include "CoinPackedVector.hpp"
16#include "BonIpoptInteriorWarmStarter.hpp"
17
18
19namespace Bonmin {
20class TMINLP2TNLP;
21
22/** \brief Class for storing warm start informations for Ipopt.<br>
23 * For practical reason (integration in Cbc) this class inherits from
24 * CoinWarmStartBasis. <br>
25 * This class stores a starting point (primal and dual values) for Ipopt.
26 */
27class IpoptWarmStart : public CoinWarmStartBasis
28{
29public:
30
31  /// Default constructor
32  IpoptWarmStart(bool empty = 1, int numvars = 0, int numcont = 0);
33  /// Usefull constructor, stores the current optimum of ipopt
34  IpoptWarmStart(const Ipopt::SmartPtr<TMINLP2TNLP> tnlp,
35      SmartPtr<IpoptInteriorWarmStarter> warm_starter);
36  /// Copy constructor
37  IpoptWarmStart( const IpoptWarmStart &other, bool ownValues = 1);
38  /// Abstract destructor
39  virtual ~IpoptWarmStart();
40
41  /// `Virtual constructor'
42  virtual CoinWarmStart *clone() const
43  {
44    return new IpoptWarmStart(*this,1);
45  }
46
47  /** Generate the "differences" between two IpoptWarmStart.*/
48  virtual CoinWarmStartDiff*
49  generateDiff(const CoinWarmStart *const oldCWS) const;
50  /** \brief Apply 'differences' to an Ipopt warm start.
51   * What this actually does is get a copy to the vector of values stored
52   in IpoptWarmStartDiff.*/
53  virtual void
54  applyDiff (const CoinWarmStartDiff *const cwsdDiff);
55  /** Access to values_ vector. */
56  const CoinPackedVector * values() const
57  {
58    if(tempValues_)
59      return tempValues_;
60    else
61      return &values_;
62  }
63  /** Accessor to warm start information obecjt */
64  SmartPtr<IpoptInteriorWarmStarter> warm_starter() const
65  {
66    return warm_starter_;
67  }
68
69  /// flush the starting point
70  void flushPoint();
71
72  ///Is this an empty warm start?
73  bool empty() const
74  {
75    return empty_;
76  }
77private:
78  /** Non zero values of the starting point. Primal and dual values are stored in the following order <p>
79      <UL>
80      <li> From 1 to CoinWarmStartBasis::numStrtucturals_ : values for primal variables (\f$ x \f$ ),
81      <li> From numStructurals_+1 to  2numStructurals_ : values for dual variables associated to lower bound constraints on structurals (constraints \f$ l \leq x \f$).
82      <li> From 2 numStructurals_+1 to  3 numStructurals_ : values for dual variables associated to lower bound constraints on structurals (constraints \f$ x \leq u\f$).
83      <li> From 3 numStructurals_+1 to  3 numStructurals_ + numArtificials_ : values for dual varaibles associated with regular constraints (constraints \f$ g(x) = 0 \f$).
84      </UL>
85  */
86  mutable CoinPackedVector values_;
87  /** Temporary values not owned by this. */
88  mutable CoinPackedVector * tempValues_;
89  /** warm start information object */
90  mutable SmartPtr<IpoptInteriorWarmStarter> warm_starter_;
91  ///Say if warm start is empty
92  bool empty_;
93};
94
95/** \brief Diff class for IpoptWarmStart.
96 * Actually get the differences from CoinWarmStartBasis and stores the
97 whole vector of values.
98 \todo Find a way to free unused values.
99*/
100class IpoptWarmStartDiff : public CoinWarmStartBasisDiff
101{
102public:
103  friend class IpoptWarmStart;
104  /** Usefull constructor*/
105  IpoptWarmStartDiff(CoinWarmStartBasisDiff * diff, const CoinPackedVector &values,
106      SmartPtr<IpoptInteriorWarmStarter> warm_starter):
107      CoinWarmStartBasisDiff(*diff),
108      diffValues_(NULL),
109      warm_starter_(NULL)//(warm_starter)
110  {
111    if(values.getNumElements()>0)
112      diffValues_ = new CoinPackedVector(values);
113  }
114  /** Copy constructor. */
115  IpoptWarmStartDiff(const IpoptWarmStartDiff &other):
116      CoinWarmStartBasisDiff(other),
117      diffValues_(NULL),
118      warm_starter_(NULL)//other.warm_starter_)
119  {
120    if(other.diffValues_)
121      diffValues_ = new CoinPackedVector(*other.diffValues_);
122  }
123
124  /// Abstract destructor
125  virtual ~IpoptWarmStartDiff()
126  {
127    delete diffValues_;
128  }
129
130  /// `Virtual constructor'
131  virtual CoinWarmStartDiff *clone() const
132  {
133    return new IpoptWarmStartDiff(*this);
134  }
135
136  /** Accessor to warm start information obecjt */
137  SmartPtr<IpoptInteriorWarmStarter> warm_starter() const
138  {
139    return warm_starter_;
140  }
141  void flushPoint();
142private:
143  /** Values of the vector. */
144  CoinPackedVector * diffValues_;
145
146  /** warm start information object */
147  SmartPtr<IpoptInteriorWarmStarter> warm_starter_;
148};
149
150}
151#endif
Note: See TracBrowser for help on using the repository browser.