source: branches/devel/Clp/src/ClpNetworkMatrix.hpp @ 900

Last change on this file since 900 was 900, checked in by forrest, 14 years ago

stop warning about hidden virtual

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 KB
Line 
1// Copyright (C) 2003, International Business Machines
2// Corporation and others.  All Rights Reserved.
3#ifndef ClpNetworkMatrix_H
4#define ClpNetworkMatrix_H
5
6
7#include "CoinPragma.hpp"
8
9#include "ClpMatrixBase.hpp"
10
11/** This implements a simple network matrix as derived from ClpMatrixBase.
12
13If you want more sophisticated version then you could inherit from this.
14Also you might want to allow networks with gain */
15
16class ClpNetworkMatrix : public ClpMatrixBase {
17 
18public:
19  /**@name Useful methods */
20   //@{
21   /// Return a complete CoinPackedMatrix
22   virtual CoinPackedMatrix * getPackedMatrix() const;
23    /** Whether the packed matrix is column major ordered or not. */
24   virtual bool isColOrdered() const { return true; }
25   /** Number of entries in the packed matrix. */
26  virtual  CoinBigIndex getNumElements() const 
27  { return 2*numberColumns_; }
28   /** Number of columns. */
29   virtual int getNumCols() const { return numberColumns_; }
30   /** Number of rows. */
31  virtual int getNumRows() const { return numberRows_; };
32
33   /** A vector containing the elements in the packed matrix. Note that there
34        might be gaps in this list, entries that do not belong to any
35        major-dimension vector. To get the actual elements one should look at
36        this vector together with vectorStarts and vectorLengths. */
37  virtual const double * getElements() const; 
38   /** A vector containing the minor indices of the elements in the packed
39        matrix. Note that there might be gaps in this list, entries that do not
40        belong to any major-dimension vector. To get the actual elements one
41        should look at this vector together with vectorStarts and
42        vectorLengths. */
43  virtual const int * getIndices() const
44  { return indices_;};
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  /// Returns number of elements in column part of basis
57  virtual CoinBigIndex countBasis(ClpSimplex * model,
58                                 const int * whichColumn, 
59                                 int numberRowBasic,
60                                  int & numberColumnBasic);
61  /// Fills in column part of basis
62  virtual void fillBasis(ClpSimplex * model,
63                                 const int * whichColumn, 
64                                 int & numberColumnBasic,
65                                 int * row, int * start,
66                                 int * rowCount, int * columnCount,
67                                 double * element);
68  /** Given positive integer weights for each row fills in sum of weights
69      for each column (and slack).
70      Returns weights vector
71  */
72  virtual CoinBigIndex * dubiousWeights(const ClpSimplex * model,int * inputWeights) const;
73  /** Returns largest and smallest elements of both signs.
74      Largest refers to largest absolute value.
75  */
76  virtual void rangeOfElements(double & smallestNegative, double & largestNegative,
77                       double & smallestPositive, double & largestPositive);
78  /** Unpacks a column into an CoinIndexedvector
79   */
80  virtual void unpack(const ClpSimplex * model,CoinIndexedVector * rowArray,
81                   int column) const ;
82  /** Unpacks a column into an CoinIndexedvector
83   ** in packed format
84      Note that model is NOT const.  Bounds and objective could
85      be modified if doing column generation (just for this variable) */
86  virtual void unpackPacked(ClpSimplex * model,
87                            CoinIndexedVector * rowArray,
88                            int column) const;
89  /** Adds multiple of a column into an CoinIndexedvector
90      You can use quickAdd to add to vector */
91  virtual void add(const ClpSimplex * model,CoinIndexedVector * rowArray,
92                   int column, double multiplier) const ;
93  /** Adds multiple of a column into an array */
94  virtual void add(const ClpSimplex * model,double * array,
95                   int column, double multiplier) const;
96   /// Allow any parts of a created CoinMatrix to be deleted
97   virtual void releasePackedMatrix() const ;
98  /// Says whether it can do partial pricing
99  virtual bool canDoPartialPricing() const;
100  /// Partial pricing
101  virtual void partialPricing(ClpSimplex * model, double start, double end,
102                      int & bestSequence, int & numberWanted);
103   //@}
104
105  /**@name Matrix times vector methods */
106  //@{
107    /** Return <code>y + A * scalar *x</code> in <code>y</code>.
108        @pre <code>x</code> must be of size <code>numColumns()</code>
109        @pre <code>y</code> must be of size <code>numRows()</code> */
110  virtual void times(double scalar,
111                       const double * x, double * y) const;
112  /// And for scaling
113  virtual void times(double scalar,
114                     const double * x, double * y,
115                     const double * rowScale, 
116                     const double * columnScale) const;
117    /** Return <code>y + x * scalar * A</code> in <code>y</code>.
118        @pre <code>x</code> must be of size <code>numRows()</code>
119        @pre <code>y</code> must be of size <code>numColumns()</code> */
120    virtual void transposeTimes(double scalar,
121                                const double * x, double * y) const;
122  /// And for scaling
123    virtual void transposeTimes(double scalar,
124                                const double * x, double * y,
125                                const double * rowScale, 
126                                const double * columnScale, double * spare=NULL) const;
127    /** Return <code>x * scalar * A + y</code> in <code>z</code>.
128        Can use y as temporary array (will be empty at end)
129        Note - If x packed mode - then z packed mode
130        Squashes small elements and knows about ClpSimplex */
131  virtual void transposeTimes(const ClpSimplex * model, double scalar,
132                              const CoinIndexedVector * x,
133                              CoinIndexedVector * y,
134                              CoinIndexedVector * z) const;
135    /** Return <code>x *A</code> in <code>z</code> but
136        just for indices in y.
137        Note - z always packed mode */
138  virtual void subsetTransposeTimes(const ClpSimplex * model,
139                                    const CoinIndexedVector * x,
140                                    const CoinIndexedVector * y,
141                                    CoinIndexedVector * z) const;
142  //@}
143
144  /**@name Other */
145   //@{
146  /// Return true if really network, false if has slacks
147  inline bool trueNetwork() const
148  { return trueNetwork_;};
149   //@}
150
151
152  /**@name Constructors, destructor */
153   //@{
154   /** Default constructor. */
155   ClpNetworkMatrix();
156  /** Constructor from two arrays */
157  ClpNetworkMatrix(int numberColumns, const int * head,
158                   const int * tail);
159   /** Destructor */
160   virtual ~ClpNetworkMatrix();
161   //@}
162
163   /**@name Copy method */
164   //@{
165   /** The copy constructor. */
166   ClpNetworkMatrix(const ClpNetworkMatrix&);
167   /** The copy constructor from an CoinNetworkMatrix. */
168   ClpNetworkMatrix(const CoinPackedMatrix&);
169
170   ClpNetworkMatrix& operator=(const ClpNetworkMatrix&);
171  /// Clone
172  virtual ClpMatrixBase * clone() const ;
173   //@}
174   
175   
176protected:
177   /**@name Data members
178      The data members are protected to allow access for derived classes. */
179   //@{
180  /// For fake CoinPackedMatrix
181  mutable double * elements_;
182  mutable CoinBigIndex * starts_;
183  mutable int * lengths_;
184  /// Data -1, then +1 rows in pairs (row==-1 if one entry)
185  int * indices_;
186  /// Number of rows
187  int numberRows_;
188  /// Number of columns
189  int numberColumns_;
190  /// True if all entries have two elements
191  bool trueNetwork_;
192 
193   //@}
194};
195
196#endif
Note: See TracBrowser for help on using the repository browser.