source: trunk/Bonmin/src/IpoptInterface/IpoptWarmStart.hpp @ 1

Last change on this file since 1 was 1, checked in by andreasw, 13 years ago

imported initial code

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