source: trunk/include/ClpDummyMatrix.hpp @ 451

Last change on this file since 451 was 451, checked in by forrest, 16 years ago

Changes to make a difficult problem faster (dual) + quadratic

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.0 KB
Line 
1// Copyright (C) 2003, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef ClpDummyMatrix_H
4#define ClpDummyMatrix_H
5
6
7#include "CoinPragma.hpp"
8
9#include "ClpMatrixBase.hpp"
10
11/** This implements a dummy matrix as derived from ClpMatrixBase.
12    This is so you can do ClpPdco but may come in useful elsewhere.
13    It just has dimensions but no data
14*/
15
16
17class ClpDummyMatrix : public ClpMatrixBase {
18 
19public:
20  /**@name Useful methods */
21   //@{
22   /// Return a complete CoinPackedMatrix
23   virtual CoinPackedMatrix * getPackedMatrix() const;
24    /** Whether the packed matrix is column major ordered or not. */
25   virtual bool isColOrdered() const { return true; }
26   /** Number of entries in the packed matrix. */
27  virtual  CoinBigIndex getNumElements() const 
28  { return numberElements_; }
29   /** Number of columns. */
30   virtual int getNumCols() const { return numberColumns_; }
31   /** Number of rows. */
32  virtual int getNumRows() const { return numberRows_; };
33
34   /** A vector containing the elements in the packed matrix. Note that there
35        might be gaps in this list, entries that do not belong to any
36        major-dimension vector. To get the actual elements one should look at
37        this vector together with vectorStarts and vectorLengths. */
38  virtual const double * getElements() const; 
39   /** A vector containing the minor indices of the elements in the packed
40        matrix. Note that there might be gaps in this list, entries that do not
41        belong to any major-dimension vector. To get the actual elements one
42        should look at this vector together with vectorStarts and
43        vectorLengths. */
44  virtual const int * getIndices() const;
45
46  virtual const CoinBigIndex * getVectorStarts() const;
47   /** The lengths of the major-dimension vectors. */
48  virtual const int * getVectorLengths() const;
49
50    /** Delete the columns whose indices are listed in <code>indDel</code>. */
51  virtual void deleteCols(const int numDel, const int * indDel);
52    /** Delete the rows whose indices are listed in <code>indDel</code>. */
53  virtual void deleteRows(const int numDel, const int * indDel);
54  /** Returns a new matrix in reverse order without gaps */
55  virtual ClpMatrixBase * reverseOrderedCopy() const;
56  /** If element NULL returns number of elements in column part of basis,
57      If not NULL fills in as well */
58  virtual CoinBigIndex fillBasis(ClpSimplex * model,
59                                 const int * whichColumn, 
60                                 int numberRowBasic,
61                                 int & numberColumnBasic,
62                                 int * row, int * column,
63                                 double * element)  ;
64  /** Unpacks a column into an CoinIndexedvector
65   */
66  virtual void unpack(const ClpSimplex * model,CoinIndexedVector * rowArray,
67                   int column) const ;
68  /** Unpacks a column into an CoinIndexedvector
69   ** in packed foramt
70      Note that model is NOT const.  Bounds and objective could
71      be modified if doing column generation (just for this variable) */
72  virtual void unpackPacked(ClpSimplex * model,
73                            CoinIndexedVector * rowArray,
74                            int column) const;
75  /** Adds multiple of a column into an CoinIndexedvector
76      You can use quickAdd to add to vector */
77  virtual void add(const ClpSimplex * model,CoinIndexedVector * rowArray,
78                   int column, double multiplier) const ;
79  /** Adds multiple of a column into an array */
80  virtual void add(const ClpSimplex * model,double * array,
81                   int column, double multiplier) const;
82   /// Allow any parts of a created CoinMatrix to be deleted
83  /// Allow any parts of a created CoinPackedMatrix to be deleted
84   virtual void releasePackedMatrix() const {};
85   //@}
86
87  /**@name Matrix times vector methods */
88  //@{
89    /** Return <code>y + A * scalar *x</code> in <code>y</code>.
90        @pre <code>x</code> must be of size <code>numColumns()</code>
91        @pre <code>y</code> must be of size <code>numRows()</code> */
92  virtual void times(double scalar,
93                       const double * x, double * y) const;
94  /// And for scaling
95  virtual void times(double scalar,
96                     const double * x, double * y,
97                     const double * rowScale, 
98                     const double * columnScale) const;
99    /** Return <code>y + x * scalar * A</code> in <code>y</code>.
100        @pre <code>x</code> must be of size <code>numRows()</code>
101        @pre <code>y</code> must be of size <code>numColumns()</code> */
102    virtual void transposeTimes(double scalar,
103                                const double * x, double * y) const;
104  /// And for scaling
105    virtual void transposeTimes(double scalar,
106                                const double * x, double * y,
107                                const double * rowScale, 
108                                const double * columnScale) const;
109    /** Return <code>x * scalar * A + y</code> in <code>z</code>.
110        Can use y as temporary array (will be empty at end)
111        Note - If x packed mode - then z packed mode */
112  virtual void transposeTimes(const ClpSimplex * model, double scalar,
113                              const CoinIndexedVector * x,
114                              CoinIndexedVector * y,
115                              CoinIndexedVector * z) const;
116    /** Return <code>x *A</code> in <code>z</code> but
117        just for indices in y.
118        Note - If x packed mode - then z packed mode
119        Squashes small elements and knows about ClpSimplex */
120  virtual void subsetTransposeTimes(const ClpSimplex * model,
121                                    const CoinIndexedVector * x,
122                                    const CoinIndexedVector * y,
123                                    CoinIndexedVector * z) const;
124  //@}
125
126  /**@name Other */
127   //@{
128   //@}
129
130
131  /**@name Constructors, destructor */
132   //@{
133   /** Default constructor. */
134   ClpDummyMatrix();
135  /// Constructor with data
136  ClpDummyMatrix(int numberColumns, int numberRows,
137                   int numberElements);
138   /** Destructor */
139   virtual ~ClpDummyMatrix();
140   //@}
141
142   /**@name Copy method */
143   //@{
144   /** The copy constructor. */
145   ClpDummyMatrix(const ClpDummyMatrix&);
146   /** The copy constructor from an CoinDummyMatrix. */
147   ClpDummyMatrix(const CoinPackedMatrix&);
148
149   ClpDummyMatrix& operator=(const ClpDummyMatrix&);
150  /// Clone
151  virtual ClpMatrixBase * clone() const ;
152   //@}
153   
154   
155protected:
156   /**@name Data members
157      The data members are protected to allow access for derived classes. */
158   //@{
159  /// Number of rows
160  int numberRows_;
161  /// Number of columns
162  int numberColumns_;
163  /// Number of elements
164  int numberElements_;
165 
166   //@}
167};
168
169#endif
Note: See TracBrowser for help on using the repository browser.