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

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

formatting

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.3 KB
Line 
1/* $Id: ClpDynamicExampleMatrix.hpp 2385 2019-01-06 19:43:06Z unxusr $ */
2// Copyright (C) 2004, International Business Machines
3// Corporation and others.  All Rights Reserved.
4// This code is licensed under the terms of the Eclipse Public License (EPL).
5
6#ifndef ClpDynamicExampleMatrix_H
7#define ClpDynamicExampleMatrix_H
8
9#include "CoinPragma.hpp"
10
11#include "ClpDynamicMatrix.hpp"
12class ClpSimplex;
13/** This implements a dynamic matrix when we have a limit on the number of
14    "interesting rows". This version inherits from ClpDynamicMatrix and knows that
15    the real matrix is gub.  This acts just like ClpDynamicMatrix but generates columns.
16    This "generates" columns by choosing from stored set.  It is maent as a starting point
17    as to how you could use shortest path to generate columns.
18
19    So it has its own copy of all data needed.  It populates ClpDynamicWatrix with enough
20    to allow for gub keys and active variables.  In turn ClpDynamicMatrix populates
21    a CoinPackedMatrix with active columns and rows.
22
23    As there is one copy here and one in ClpDynamicmatrix these names end in Gen_
24
25    It is obviously more efficient to just use ClpDynamicMatrix but the ideas is to
26    show how much code a user would have to write.
27
28    This does not work very well with bounds
29
30*/
31
32class ClpDynamicExampleMatrix : public ClpDynamicMatrix {
33
34public:
35  /**@name Main functions provided */
36  //@{
37  /// Partial pricing
38  virtual void partialPricing(ClpSimplex *model, double start, double end,
39    int &bestSequence, int &numberWanted);
40
41  /** Creates a variable.  This is called after partial pricing and will modify matrix.
42         Will update bestSequence.
43     */
44  virtual void createVariable(ClpSimplex *model, int &bestSequence);
45  /** If addColumn forces compression then this allows descendant to know what to do.
46         If >= then entry stayed in, if -1 then entry went out to lower bound.of zero.
47         Entries at upper bound (really nonzero) never go out (at present).
48     */
49  virtual void packDown(const int *in, int numberToPack);
50  //@}
51
52  /**@name Constructors, destructor */
53  //@{
54  /** Default constructor. */
55  ClpDynamicExampleMatrix();
56  /** This is the real constructor.
57         It assumes factorization frequency will not be changed.
58         This resizes model !!!!
59         The contents of original matrix in model will be taken over and original matrix
60         will be sanitized so can be deleted (to avoid a very small memory leak)
61      */
62  ClpDynamicExampleMatrix(ClpSimplex *model, int numberSets,
63    int numberColumns, const CoinBigIndex *starts,
64    const double *lower, const double *upper,
65    const CoinBigIndex *startColumn, const int *row,
66    const double *element, const double *cost,
67    const double *columnLower = NULL, const double *columnUpper = NULL,
68    const unsigned char *status = NULL,
69    const unsigned char *dynamicStatus = NULL,
70    int numberIds = 0, const int *ids = NULL);
71#if 0
72     /// This constructor just takes over ownership (except for lower, upper)
73     ClpDynamicExampleMatrix(ClpSimplex * model, int numberSets,
74                             int numberColumns, int * starts,
75                             const double * lower, const double * upper,
76                             int * startColumn, int * row,
77                             double * element, double * cost,
78                             double * columnLower = NULL, double * columnUpper = NULL,
79                             const unsigned char * status = NULL,
80                             const unsigned char * dynamicStatus = NULL,
81                             int numberIds = 0, const int *ids = NULL);
82#endif
83  /** Destructor */
84  virtual ~ClpDynamicExampleMatrix();
85  //@}
86
87  /**@name Copy method */
88  //@{
89  /** The copy constructor. */
90  ClpDynamicExampleMatrix(const ClpDynamicExampleMatrix &);
91  ClpDynamicExampleMatrix &operator=(const ClpDynamicExampleMatrix &);
92  /// Clone
93  virtual ClpMatrixBase *clone() const;
94  //@}
95  /**@name gets and sets */
96  //@{
97  /// Starts of each column
98  inline CoinBigIndex *startColumnGen() const
99  {
100    return startColumnGen_;
101  }
102  /// rows
103  inline int *rowGen() const
104  {
105    return rowGen_;
106  }
107  /// elements
108  inline double *elementGen() const
109  {
110    return elementGen_;
111  }
112  /// costs
113  inline double *costGen() const
114  {
115    return costGen_;
116  }
117  /// full starts
118  inline CoinBigIndex *fullStartGen() const
119  {
120    return fullStartGen_;
121  }
122  /// ids in next level matrix
123  inline int *idGen() const
124  {
125    return idGen_;
126  }
127  /// Optional lower bounds on columns
128  inline double *columnLowerGen() const
129  {
130    return columnLowerGen_;
131  }
132  /// Optional upper bounds on columns
133  inline double *columnUpperGen() const
134  {
135    return columnUpperGen_;
136  }
137  /// size
138  inline int numberColumns() const
139  {
140    return numberColumns_;
141  }
142  inline void setDynamicStatusGen(int sequence, DynamicStatus status)
143  {
144    unsigned char &st_byte = dynamicStatusGen_[sequence];
145    st_byte = static_cast< unsigned char >(st_byte & ~7);
146    st_byte = static_cast< unsigned char >(st_byte | status);
147  }
148  inline DynamicStatus getDynamicStatusGen(int sequence) const
149  {
150    return static_cast< DynamicStatus >(dynamicStatusGen_[sequence] & 7);
151  }
152  /// Whether flagged
153  inline bool flaggedGen(int i) const
154  {
155    return (dynamicStatusGen_[i] & 8) != 0;
156  }
157  inline void setFlaggedGen(int i)
158  {
159    dynamicStatusGen_[i] = static_cast< unsigned char >(dynamicStatusGen_[i] | 8);
160  }
161  inline void unsetFlagged(int i)
162  {
163    dynamicStatusGen_[i] = static_cast< unsigned char >(dynamicStatusGen_[i] & ~8);
164  }
165  //@}
166
167protected:
168  /**@name Data members
169        The data members are protected to allow access for derived classes. */
170  //@{
171  /// size
172  int numberColumns_;
173  /// Starts of each column
174  CoinBigIndex *startColumnGen_;
175  /// rows
176  int *rowGen_;
177  /// elements
178  double *elementGen_;
179  /// costs
180  double *costGen_;
181  /// start of each set
182  CoinBigIndex *fullStartGen_;
183  /// for status and which bound
184  unsigned char *dynamicStatusGen_;
185  /** identifier for each variable up one level (startColumn_, etc).  This is
186         of length maximumGubColumns_.  For this version it is just sequence number
187         at this level */
188  int *idGen_;
189  /// Optional lower bounds on columns
190  double *columnLowerGen_;
191  /// Optional upper bounds on columns
192  double *columnUpperGen_;
193  //@}
194};
195
196#endif
197
198/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
199*/
Note: See TracBrowser for help on using the repository browser.