source: branches/devel/Cbc/examples/CoinWarmStartBasisDynamic.hpp @ 403

Last change on this file since 403 was 403, checked in by forrest, 13 years ago

adding some examples

File size: 7.0 KB
Line 
1/*! \legal
2  Copyright (C) 2006, International Business Machines Corporation
3  and others.  All Rights Reserved.
4*/
5
6/*! \file CoinWarmStartBasisDynamic.hpp
7  \brief Declaration of the dynamic simplex (basis-oriented) warm start
8  class.
9*/
10
11#ifndef CoinWarmStartBasisDynamic_H
12#define CoinWarmStartBasisDynamic_H
13
14#include "CoinWarmStartBasis.hpp"
15
16//#############################################################################
17
18/*! \class CoinWarmStartBasisDynamic
19  \brief The dynamic COIN simplex (basis-oriented) warm start class
20 
21  CoinWarmStartBasisDynamic provides for a warm start object which contains the
22  status of each variable (structural and artificial) and a list of variables in problem.
23 
24*/
25
26class CoinWarmStartBasisDynamic : public CoinWarmStartBasis {
27 
28public:
29 
30  /*! \name Methods to get and set basis information.
31   
32  By "common" I mean in all problems
33 
34  Much of this is in CoinWarmStartBasis
35  */
36  //@{
37  /// Return the number of common variables
38  inline int getNumCommonVariables() const { return numberCommonVariables_; }
39  /// Set the number of common variables
40  inline void setNumCommonVariables(int number) { numberCommonVariables_ = number; }
41 
42  /// Return the number of dynamic variables
43  inline int getNumDynamicVariables() const { return numberDynamicVariables_; }
44 
45  /// Return the number of common rows (probably not used)
46  inline int getNumCommonRows() const { return numberCommonRows_; }
47 
48  /** Return the list of identifiers for the dynamic structural variables
49     
50  There will be numDynamicVariables entries
51  The encoding is not defined
52  */
53  inline const int * getDynamicVariables() const { return dynamicVariables_; }
54 
55  /**  Save list of dynamic variables */
56 
57  void setDynamicVariables(int numberDynamicVariables, const int * dynamicVariables);
58 
59  //@}
60 
61  /** \brief Delete a set of columns from the basis
62     
63  \warning
64  The resulting basis is guaranteed valid only if all deleted variables
65  are nonbasic.
66 
67  Removal of a basic variable implies that some nonbasic variable must be
68  made basic. This correction is left to the client.
69  */
70 
71  virtual void deleteColumns(int number, const int * which);
72 
73  //@}
74 
75  /*! \name Constructors, destructors, and related functions */
76 
77  //@{
78 
79  /** Default constructor
80     
81  Creates a warm start object representing an empty basis
82  (0 rows, 0 columns).
83  */
84  CoinWarmStartBasisDynamic();
85 
86  /** Constructs a warm start object with the specified status vectors.
87     
88  The parameters are copied.
89  Consider assignBasisStatus(int,int,char*&,char*&) if the object should
90  assume ownership.
91 
92  \sa CoinWarmStartBasis::Status for a description of the packing used in
93  the status arrays.
94  */
95  CoinWarmStartBasisDynamic(int ns, int na, const char* sStat, const char* aStat,
96                            int numberCommon, int numberDynamicVariables, const int * dynamicVariables) ;
97 
98  /** Copy constructor */
99  CoinWarmStartBasisDynamic(const CoinWarmStartBasisDynamic& rhs) ;
100 
101  /** `Virtual constructor' */
102  virtual CoinWarmStart *clone() const
103  {
104    return new CoinWarmStartBasisDynamic(*this);
105  }
106 
107  /** Destructor */
108  virtual ~CoinWarmStartBasisDynamic();
109 
110  /** Assignment */
111 
112  virtual CoinWarmStartBasisDynamic& operator=(const CoinWarmStartBasisDynamic& rhs) ;
113 
114  /** Assign the status vectors to be the warm start information.
115     
116  In this method the CoinWarmStartBasis object assumes ownership of the
117  pointers and upon return the argument pointers will be NULL.
118  If copying is desirable, use the
119  \link CoinWarmStartBasis(int,int,const char*,const char*)
120  array constructor \endlink
121  or the
122  \link operator=(const CoinWarmStartBasis&)
123  assignment operator \endlink.
124 
125  \note
126  The pointers passed to this method will be
127  freed using delete[], so they must be created using new[].
128  */
129  virtual void assignBasisStatus(int ns, int na, char*& sStat, char*& aStat,
130                                 int numberCommon, int numberDynamicVariables, int *& dynamicVariables) ;
131  //@}
132 
133  /*! \name Miscellaneous methods */
134  //@{
135 
136  /// Prints in readable format (for debug)
137  virtual void print() const;
138 
139  /*! \brief Generate a `diff' that can convert the warm start basis passed as
140             a parameter to the warm start basis specified by \c this.
141
142    The capabilities are limited: the basis passed as a parameter can be no
143    larger than the basis pointed to by \c this.
144  */
145
146  virtual CoinWarmStartDiff*
147  generateDiff (const CoinWarmStart *const oldCWS) const ;
148  //@}
149 
150private:
151  /** \name Private data members
152     
153  \sa CoinWarmStartBasis::Status for a description of the packing used in
154  the status arrays.
155  */
156  //@{
157  /// The number of common variables
158  int numberCommonVariables_;
159  /// The number of common rows
160  int numberCommonRows_;
161  /// The number of dynamic variables
162  int numberDynamicVariables_;
163  /** The dynamic variables. */
164  int * dynamicVariables_;
165  //@}
166};
167
168
169/*! \class CoinWarmStartBasisDiffDynamic
170    \brief A `diff' between two CoinWarmStartBasisDynamic objects
171
172    See CoinWarmStartBasis(Diff) for most ideas
173    This version just saves new list
174*/
175
176class CoinWarmStartBasisDiffDynamic : public CoinWarmStartBasisDiff
177{ 
178public:
179
180  /*! \brief `Virtual constructor' */
181  virtual CoinWarmStartDiff *clone() const
182  { CoinWarmStartBasisDiffDynamic *cwsbd =  new CoinWarmStartBasisDiffDynamic(*this) ;
183    return (dynamic_cast<CoinWarmStartDiff *>(cwsbd)) ; }
184
185  /*! \brief Assignment */
186  virtual
187    CoinWarmStartBasisDiffDynamic &operator= (const CoinWarmStartBasisDiffDynamic &rhs) ;
188
189  /*! \brief Destructor */
190  virtual ~CoinWarmStartBasisDiffDynamic()
191  { delete[] dynamic_; }
192
193  protected:
194
195  /*! \brief Default constructor
196 
197    This is protected (rather than private) so that derived classes can
198    see it when they make <i>their</i> default constructor protected or
199    private.
200  */
201  CoinWarmStartBasisDiffDynamic () : CoinWarmStartBasisDiff(),numberDynamic_(0),
202                                     dynamic_(NULL) { } ;
203
204  /*! \brief Copy constructor
205 
206    For convenience when copying objects containing CoinWarmStartBasisDiff
207    objects. But consider whether you should be using #clone() to retain
208    polymorphism.
209
210    This is protected (rather than private) so that derived classes can
211    see it when the make <i>their</i> copy constructor protected or
212    private.
213  */
214  CoinWarmStartBasisDiffDynamic (const CoinWarmStartBasisDiffDynamic &rhs) ;
215  private:
216
217  /*! \brief Standard constructor */
218  CoinWarmStartBasisDiffDynamic (int sze, const unsigned int *const diffNdxs,
219                                 const unsigned int *const diffVals,
220                                 int numberDynamic, const int * dynamic) ;
221  friend CoinWarmStartDiff *
222    CoinWarmStartBasisDynamic::generateDiff(const CoinWarmStart *const oldCWS) const ;
223  /* friend void
224     CoinWarmStartBasis::applyDiff(const CoinWarmStartDiffDynamic *const diff) ;*/
225
226 
227  /*! \brief Number of entries (and allocated capacity), in units of \c int. */
228  int sze_ ;
229
230  /*! \brief Number of entries  */
231
232  int numberDynamic_ ;
233
234  /*! \brief Array of column indices */
235
236  int *dynamic_ ;
237} ;
238
239#endif
Note: See TracBrowser for help on using the repository browser.