source: branches/unlabeled-1.1.2/include/ClpNetworkMatrix.hpp

Last change on this file was 121, checked in by forrest, 17 years ago

devel-1 ???

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 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 basis
57      column is basic if entry >=0 */
58  virtual CoinBigIndex numberInBasis(const int * columnIsBasic) const ;
59  /// Fills in basis (Returns number of elements and updates numberBasic)
60  virtual CoinBigIndex fillBasis(const ClpSimplex * model,
61                                const int * columnIsBasic, int & numberBasic,
62                                int * row, int * column,
63                                double * element) const ;
64  /** Unpacks a column into an CoinIndexedvector
65      Note that model is NOT const.  Bounds and objective could
66      be modified if doing column generation */
67  virtual void unpack(const ClpSimplex * model,CoinIndexedVector * rowArray,
68                   int column) const ;
69  /** Adds multiple of a column into an CoinIndexedvector
70      You can use quickAdd to add to vector */
71  virtual void add(const ClpSimplex * model,CoinIndexedVector * rowArray,
72                   int column, double multiplier) const ;
73   /// Allow any parts of a created CoinMatrix to be deleted
74   virtual void releaseNetworkMatrix() const { };
75   //@}
76
77  /**@name Matrix times vector methods */
78  //@{
79    /** Return <code>y + A * scalar *x</code> in <code>y</code>.
80        @pre <code>x</code> must be of size <code>numColumns()</code>
81        @pre <code>y</code> must be of size <code>numRows()</code> */
82  virtual void times(double scalar,
83                       const double * x, double * y) const;
84  /// And for scaling
85  virtual void times(double scalar,
86                     const double * x, double * y,
87                     const double * rowScale, 
88                     const double * columnScale) const;
89    /** Return <code>y + x * scalar * A</code> in <code>y</code>.
90        @pre <code>x</code> must be of size <code>numRows()</code>
91        @pre <code>y</code> must be of size <code>numColumns()</code> */
92    virtual void transposeTimes(double scalar,
93                                const double * x, double * y) const;
94  /// And for scaling
95    virtual void transposeTimes(double scalar,
96                                const double * x, double * y,
97                                const double * rowScale, 
98                                const double * columnScale) const;
99    /** Return <code>x * scalar * A + y</code> in <code>z</code>.
100        Can use y as temporary array (will be empty at end)
101        Squashes small elements and knows about ClpSimplex */
102  virtual void transposeTimes(const ClpSimplex * model, double scalar,
103                              const CoinIndexedVector * x,
104                              CoinIndexedVector * y,
105                              CoinIndexedVector * z) const;
106    /** Return <code>x *A</code> in <code>z</code> but
107        just for indices in y.
108        Squashes small elements and knows about ClpSimplex */
109  virtual void subsetTransposeTimes(const ClpSimplex * model,
110                                    const CoinIndexedVector * x,
111                                    const CoinIndexedVector * y,
112                                    CoinIndexedVector * z) const;
113  //@}
114
115  /**@name Other */
116   //@{
117  /// Return true if really network, false if has slacks
118  inline bool trueNetwork() const
119  { return trueNetwork_;};
120   //@}
121
122
123  /**@name Constructors, destructor */
124   //@{
125   /** Default constructor. */
126   ClpNetworkMatrix();
127  /** Constructor from two arrays */
128  ClpNetworkMatrix(int numberColumns, const int * head,
129                   const int * tail);
130   /** Destructor */
131   virtual ~ClpNetworkMatrix();
132   //@}
133
134   /**@name Copy method */
135   //@{
136   /** The copy constructor. */
137   ClpNetworkMatrix(const ClpNetworkMatrix&);
138   /** The copy constructor from an CoinNetworkMatrix. */
139   ClpNetworkMatrix(const CoinPackedMatrix&);
140
141   ClpNetworkMatrix& operator=(const ClpNetworkMatrix&);
142  /// Clone
143  virtual ClpMatrixBase * clone() const ;
144   //@}
145   
146   
147protected:
148   /**@name Data members
149      The data members are protected to allow access for derived classes. */
150   //@{
151  /// For fake CoinPackedMatrix
152  mutable double * elements_;
153  mutable int * starts_;
154  mutable int * lengths_;
155  /// Data -1, then +1 rows in pairs (row==-1 if one entry)
156  int * indices_;
157  /// Number of rows
158  int numberRows_;
159  /// Number of columns
160  int numberColumns_;
161  /// True if all entries have two elements
162  bool trueNetwork_;
163 
164   //@}
165};
166
167#endif
Note: See TracBrowser for help on using the repository browser.