source: stable/1.15/Clp/src/AbcWarmStart.hpp @ 1989

Last change on this file since 1989 was 1910, checked in by stefan, 7 years ago
  • add configure option --enable-aboca={1,2,3,4,yes,no}
  • compile Aboca source only if --enable-aboca set (instead of compiling empty source files)
  • fix svn properties
  • Property svn:keywords set to Id
File size: 6.9 KB
Line 
1/* $Id: AbcWarmStart.hpp 1910 2013-01-27 02:00:13Z forrest $ */
2/*! \legal
3  Copyright (C) 2002, International Business Machines
4  Corporation and others, Copyright (C) 2012, FasterCoin.  All Rights Reserved.
5  This code is licensed under the terms of the Eclipse Public License (EPL).
6*/
7
8
9#ifndef AbcWarmStart_H
10#define AbcWarmStart_H
11#include "AbcCommon.hpp"
12#include "CoinWarmStartBasis.hpp"
13// could test using ClpSimplex (or for fans)
14#define CLP_WARMSTART
15#ifdef CLP_WARMSTART
16#include "ClpSimplex.hpp"
17#define AbcSimplex ClpSimplex
18#else
19#include "AbcSimplex.hpp"
20#endif
21class AbcWarmStart;
22//#############################################################################
23class AbcWarmStartOrganizer {
24public:
25  /// Create Basis type 0
26  void createBasis0();
27  /// Create Basis type 1,2
28  void createBasis12();
29  /// Create Basis type 3,4
30  void createBasis34();
31  /// delete basis
32  void deleteBasis(AbcWarmStart * basis);
33/*! \name Constructors, destructors, and related functions */
34
35//@{
36
37  /** Default constructor
38
39    Creates a warm start object organizer
40  */
41  AbcWarmStartOrganizer(AbcSimplex * model=NULL);
42
43  /** Copy constructor */
44  AbcWarmStartOrganizer(const AbcWarmStartOrganizer& ws) ;
45
46  /** Destructor */
47  virtual ~AbcWarmStartOrganizer();
48
49  /** Assignment */
50
51  virtual AbcWarmStartOrganizer& operator=(const AbcWarmStartOrganizer& rhs) ;
52//@}
53
54protected:
55  /** \name Protected data members */
56  //@{
57  /// Pointer to AbcSimplex (can only be applied to that)
58  AbcSimplex * model_;
59  /// Pointer to first basis
60  AbcWarmStart * firstBasis_;
61  /// Pointer to last basis
62  AbcWarmStart * lastBasis_;
63  /// Number of bases
64  int numberBases_;
65  /// Size of bases (extra)
66  int sizeBases_;
67  //@}
68};
69
70/*! \class AbcWarmStart
71  As CoinWarmStartBasis but with alternatives
72  (Also uses Clp status meaning for slacks)
73*/
74
75class AbcWarmStart : public virtual CoinWarmStartBasis {
76public:
77/*! \name Methods to modify the warm start object */
78//@{
79
80  /*! \brief Set basis capacity; existing basis is discarded.
81
82    After execution of this routine, the warm start object does not describe
83    a valid basis: all structural and artificial variables have status isFree.
84  */
85  virtual void setSize(int ns, int na) ;
86
87  /*! \brief Set basis capacity; existing basis is maintained.
88
89    After execution of this routine, the warm start object describes a valid
90    basis: the status of new structural variables (added columns) is set to
91    nonbasic at lower bound, and the status of new artificial variables
92    (added rows) is set to basic. (The basis can be invalid if new structural
93    variables do not have a finite lower bound.)
94  */
95  virtual void resize (int newNumberRows, int newNumberColumns);
96
97  /** \brief Delete a set of rows from the basis
98
99    \warning
100    This routine assumes that the set of indices to be deleted is sorted in
101    ascending order and contains no duplicates. Use deleteRows() if this is
102    not the case.
103
104    \warning
105    The resulting basis is guaranteed valid only if all deleted
106    constraints are slack (hence the associated logicals are basic).
107
108    Removal of a tight constraint with a nonbasic logical implies that
109    some basic variable must be made nonbasic. This correction is left to
110    the client.
111  */
112
113  virtual void compressRows (int tgtCnt, const int *tgts) ;
114
115  /** \brief Delete a set of rows from the basis
116
117    \warning
118    The resulting basis is guaranteed valid only if all deleted
119    constraints are slack (hence the associated logicals are basic).
120
121    Removal of a tight constraint with a nonbasic logical implies that
122    some basic variable must be made nonbasic. This correction is left to
123    the client.
124  */
125
126  virtual void deleteRows(int rawTgtCnt, const int *rawTgts) ;
127
128  /** \brief Delete a set of columns from the basis
129
130    \warning
131    The resulting basis is guaranteed valid only if all deleted variables
132    are nonbasic.
133
134    Removal of a basic variable implies that some nonbasic variable must be
135    made basic. This correction is left to the client.
136 */
137
138  virtual void deleteColumns(int number, const int * which);
139  /// Set model
140  inline void setModel(AbcSimplex * model)
141  { model_=model;}
142  /// Get model
143  inline AbcSimplex * model() const
144  { return model_;}
145  /// Create Basis type 0
146  void createBasis0(const AbcSimplex * model);
147  /// Create Basis type 12
148  void createBasis12(const AbcSimplex * model);
149  /// Create Basis type 34
150  void createBasis34(const AbcSimplex * model);
151/*! \name Constructors, destructors, and related functions */
152
153//@{
154
155  /** Default constructor
156
157    Creates a warm start object representing an empty basis
158    (0 rows, 0 columns).
159  */
160  AbcWarmStart();
161
162  /** Constructs a warm start object with the specified status vectors.
163
164    The parameters are copied.
165    Consider assignBasisStatus(int,int,char*&,char*&) if the object should
166    assume ownership.
167
168    \sa AbcWarmStart::Status for a description of the packing used in
169    the status arrays.
170  */
171  AbcWarmStart(AbcSimplex * model,int type) ;
172
173  /** Copy constructor */
174  AbcWarmStart(const AbcWarmStart& ws) ;
175
176  /** `Virtual constructor' */
177  virtual CoinWarmStart *clone() const
178  {
179     return new AbcWarmStart(*this);
180  }
181
182  /** Destructor */
183  virtual ~AbcWarmStart();
184
185  /** Assignment */
186
187  virtual AbcWarmStart& operator=(const AbcWarmStart& rhs) ;
188
189  /** Assign the status vectors to be the warm start information.
190 
191      In this method the AbcWarmStart object assumes ownership of the
192      pointers and upon return the argument pointers will be NULL.
193      If copying is desirable, use the
194      \link AbcWarmStart(int,int,const char*,const char*)
195            array constructor \endlink
196      or the
197      \link operator=(const AbcWarmStart&)
198            assignment operator \endlink.
199
200      \note
201      The pointers passed to this method will be
202      freed using delete[], so they must be created using new[].
203  */
204  virtual void assignBasisStatus(int ns, int na, char*& sStat, char*& aStat) ;
205//@}
206
207protected:
208  /** \name Protected data members */
209  //@{
210  /** Type of basis (always status arrays)
211  0 - as CoinWarmStartBasis
212  1,2 - plus factor order as shorts or ints (top bit set means column)
213  3,4 - plus compact saved factorization
214  add 8 to say steepest edge weights stored (as floats)
215  may want to change next,previous to tree info
216  so can use a different basis for weights
217  */
218  int typeExtraInformation_;
219  /// Length of extra information in bytes
220  int lengthExtraInformation_;
221  /// The extra information.
222  char * extraInformation_;
223  /// Pointer back to AbcSimplex (can only be applied to that)
224  AbcSimplex * model_;
225  /// Pointer back to AbcWarmStartOrganizer for organization
226  AbcWarmStartOrganizer * organizer_;
227  /// Pointer to previous basis
228  AbcWarmStart * previousBasis_;
229  /// Pointer to next basis
230  AbcWarmStart * nextBasis_;
231  /// Sequence stamp for deletion
232  int stamp_;
233  /** Number of valid rows (rest should have slacks)
234      Check to see if weights are OK for these rows
235      and then just btran new ones for weights
236   */
237  int numberValidRows_;
238  //@}
239};
240#endif
Note: See TracBrowser for help on using the repository browser.