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

Last change on this file since 2271 was 2271, checked in by forrest, 2 years ago

change some ints to CoinBigIndex?

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