source: trunk/Clp/src/AbcWarmStart.hpp @ 2385

Last change on this file since 2385 was 2385, checked in by unxusr, 4 months ago

formatting

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