Ignore:
Timestamp:
Jan 6, 2019 2:43:06 PM (4 months ago)
Author:
unxusr
Message:

formatting

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/ClpNetworkMatrix.hpp

    r2271 r2385  
    77#define ClpNetworkMatrix_H
    88
    9 
    109#include "CoinPragma.hpp"
    1110
     
    2019
    2120public:
    22      /**@name Useful methods */
    23      //@{
    24      /// Return a complete CoinPackedMatrix
    25      virtual CoinPackedMatrix * getPackedMatrix() const;
    26      /** Whether the packed matrix is column major ordered or not. */
    27      virtual bool isColOrdered() const {
    28           return true;
    29      }
    30      /** Number of entries in the packed matrix. */
    31      virtual  CoinBigIndex getNumElements() const {
    32           return 2 * numberColumns_;
    33      }
    34      /** Number of columns. */
    35      virtual int getNumCols() const {
    36           return numberColumns_;
    37      }
    38      /** Number of rows. */
    39      virtual int getNumRows() const {
    40           return numberRows_;
    41      }
    42 
    43      /** A vector containing the elements in the packed matrix. Note that there
     21  /**@name Useful methods */
     22  //@{
     23  /// Return a complete CoinPackedMatrix
     24  virtual CoinPackedMatrix *getPackedMatrix() const;
     25  /** Whether the packed matrix is column major ordered or not. */
     26  virtual bool isColOrdered() const
     27  {
     28    return true;
     29  }
     30  /** Number of entries in the packed matrix. */
     31  virtual CoinBigIndex getNumElements() const
     32  {
     33    return 2 * numberColumns_;
     34  }
     35  /** Number of columns. */
     36  virtual int getNumCols() const
     37  {
     38    return numberColumns_;
     39  }
     40  /** Number of rows. */
     41  virtual int getNumRows() const
     42  {
     43    return numberRows_;
     44  }
     45
     46  /** A vector containing the elements in the packed matrix. Note that there
    4447      might be gaps in this list, entries that do not belong to any
    4548      major-dimension vector. To get the actual elements one should look at
    4649      this vector together with vectorStarts and vectorLengths. */
    47      virtual const double * getElements() const;
    48      /** A vector containing the minor indices of the elements in the packed
     50  virtual const double *getElements() const;
     51  /** A vector containing the minor indices of the elements in the packed
    4952          matrix. Note that there might be gaps in this list, entries that do not
    5053          belong to any major-dimension vector. To get the actual elements one
    5154          should look at this vector together with vectorStarts and
    5255          vectorLengths. */
    53      virtual const int * getIndices() const {
    54           return indices_;
    55      }
    56 
    57      virtual const CoinBigIndex * getVectorStarts() const;
    58      /** The lengths of the major-dimension vectors. */
    59      virtual const int * getVectorLengths() const;
    60 
    61      /** Delete the columns whose indices are listed in <code>indDel</code>. */
    62      virtual void deleteCols(const int numDel, const int * indDel);
    63      /** Delete the rows whose indices are listed in <code>indDel</code>. */
    64      virtual void deleteRows(const int numDel, const int * indDel);
    65      /// Append Columns
    66      virtual void appendCols(int number, const CoinPackedVectorBase * const * columns);
    67      /// Append Rows
    68      virtual void appendRows(int number, const CoinPackedVectorBase * const * rows);
     56  virtual const int *getIndices() const
     57  {
     58    return indices_;
     59  }
     60
     61  virtual const CoinBigIndex *getVectorStarts() const;
     62  /** The lengths of the major-dimension vectors. */
     63  virtual const int *getVectorLengths() const;
     64
     65  /** Delete the columns whose indices are listed in <code>indDel</code>. */
     66  virtual void deleteCols(const int numDel, const int *indDel);
     67  /** Delete the rows whose indices are listed in <code>indDel</code>. */
     68  virtual void deleteRows(const int numDel, const int *indDel);
     69  /// Append Columns
     70  virtual void appendCols(int number, const CoinPackedVectorBase *const *columns);
     71  /// Append Rows
     72  virtual void appendRows(int number, const CoinPackedVectorBase *const *rows);
    6973#ifndef SLIM_CLP
    70      /** Append a set of rows/columns to the end of the matrix. Returns number of errors
     74  /** Append a set of rows/columns to the end of the matrix. Returns number of errors
    7175         i.e. if any of the new rows/columns contain an index that's larger than the
    7276         number of columns-1/rows-1 (if numberOther>0) or duplicates
    7377         If 0 then rows, 1 if columns */
    74      virtual int appendMatrix(int number, int type,
    75                               const CoinBigIndex * starts, const int * index,
    76                               const double * element, int numberOther = -1);
     78  virtual int appendMatrix(int number, int type,
     79    const CoinBigIndex *starts, const int *index,
     80    const double *element, int numberOther = -1);
    7781#endif
    78      /** Returns a new matrix in reverse order without gaps */
    79      virtual ClpMatrixBase * reverseOrderedCopy() const;
    80      /// Returns number of elements in column part of basis
    81      virtual int countBasis(
    82           const int * whichColumn,
    83           int & numberColumnBasic);
    84      /// Fills in column part of basis
    85      virtual void fillBasis(ClpSimplex * model,
    86                             const int * whichColumn,
    87                             int & numberColumnBasic,
    88                             int * row, int * start,
    89                             int * rowCount, int * columnCount,
    90                             CoinFactorizationDouble * element);
    91      /** Given positive integer weights for each row fills in sum of weights
     82  /** Returns a new matrix in reverse order without gaps */
     83  virtual ClpMatrixBase *reverseOrderedCopy() const;
     84  /// Returns number of elements in column part of basis
     85  virtual int countBasis(
     86    const int *whichColumn,
     87    int &numberColumnBasic);
     88  /// Fills in column part of basis
     89  virtual void fillBasis(ClpSimplex *model,
     90    const int *whichColumn,
     91    int &numberColumnBasic,
     92    int *row, int *start,
     93    int *rowCount, int *columnCount,
     94    CoinFactorizationDouble *element);
     95  /** Given positive integer weights for each row fills in sum of weights
    9296         for each column (and slack).
    9397         Returns weights vector
    9498     */
    95      virtual CoinBigIndex * dubiousWeights(const ClpSimplex * model, int * inputWeights) const;
    96      /** Returns largest and smallest elements of both signs.
     99  virtual CoinBigIndex *dubiousWeights(const ClpSimplex *model, int *inputWeights) const;
     100  /** Returns largest and smallest elements of both signs.
    97101         Largest refers to largest absolute value.
    98102     */
    99      virtual void rangeOfElements(double & smallestNegative, double & largestNegative,
    100                                   double & smallestPositive, double & largestPositive);
    101      /** Unpacks a column into an CoinIndexedvector
     103  virtual void rangeOfElements(double &smallestNegative, double &largestNegative,
     104    double &smallestPositive, double &largestPositive);
     105  /** Unpacks a column into an CoinIndexedvector
    102106      */
    103      virtual void unpack(const ClpSimplex * model, CoinIndexedVector * rowArray,
    104                          int column) const ;
    105      /** Unpacks a column into an CoinIndexedvector
     107  virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray,
     108    int column) const;
     109  /** Unpacks a column into an CoinIndexedvector
    106110      ** in packed format
    107111         Note that model is NOT const.  Bounds and objective could
    108112         be modified if doing column generation (just for this variable) */
    109      virtual void unpackPacked(ClpSimplex * model,
    110                                CoinIndexedVector * rowArray,
    111                                int column) const;
    112      /** Adds multiple of a column into an CoinIndexedvector
     113  virtual void unpackPacked(ClpSimplex *model,
     114    CoinIndexedVector *rowArray,
     115    int column) const;
     116  /** Adds multiple of a column into an CoinIndexedvector
    113117         You can use quickAdd to add to vector */
    114      virtual void add(const ClpSimplex * model, CoinIndexedVector * rowArray,
    115                       int column, double multiplier) const ;
    116      /** Adds multiple of a column into an array */
    117      virtual void add(const ClpSimplex * model, double * array,
    118                       int column, double multiplier) const;
    119      /// Allow any parts of a created CoinMatrix to be deleted
    120      virtual void releasePackedMatrix() const ;
    121      /// Says whether it can do partial pricing
    122      virtual bool canDoPartialPricing() const;
    123      /// Partial pricing
    124      virtual void partialPricing(ClpSimplex * model, double start, double end,
    125                                  int & bestSequence, int & numberWanted);
    126      //@}
    127 
    128      /**@name Matrix times vector methods */
    129      //@{
    130      /** Return <code>y + A * scalar *x</code> in <code>y</code>.
     118  virtual void add(const ClpSimplex *model, CoinIndexedVector *rowArray,
     119    int column, double multiplier) const;
     120  /** Adds multiple of a column into an array */
     121  virtual void add(const ClpSimplex *model, double *array,
     122    int column, double multiplier) const;
     123  /// Allow any parts of a created CoinMatrix to be deleted
     124  virtual void releasePackedMatrix() const;
     125  /// Says whether it can do partial pricing
     126  virtual bool canDoPartialPricing() const;
     127  /// Partial pricing
     128  virtual void partialPricing(ClpSimplex *model, double start, double end,
     129    int &bestSequence, int &numberWanted);
     130  //@}
     131
     132  /**@name Matrix times vector methods */
     133  //@{
     134  /** Return <code>y + A * scalar *x</code> in <code>y</code>.
    131135         @pre <code>x</code> must be of size <code>numColumns()</code>
    132136         @pre <code>y</code> must be of size <code>numRows()</code> */
    133      virtual void times(double scalar,
    134                         const double * x, double * y) const;
    135      /// And for scaling
    136      virtual void times(double scalar,
    137                         const double * x, double * y,
    138                         const double * rowScale,
    139                         const double * columnScale) const;
    140      /** Return <code>y + x * scalar * A</code> in <code>y</code>.
     137  virtual void times(double scalar,
     138    const double *x, double *y) const;
     139  /// And for scaling
     140  virtual void times(double scalar,
     141    const double *x, double *y,
     142    const double *rowScale,
     143    const double *columnScale) const;
     144  /** Return <code>y + x * scalar * A</code> in <code>y</code>.
    141145         @pre <code>x</code> must be of size <code>numRows()</code>
    142146         @pre <code>y</code> must be of size <code>numColumns()</code> */
    143      virtual void transposeTimes(double scalar,
    144                                  const double * x, double * y) const;
    145      /// And for scaling
    146      virtual void transposeTimes(double scalar,
    147                                  const double * x, double * y,
    148                                  const double * rowScale,
    149                                  const double * columnScale, double * spare = NULL) const;
    150      /** Return <code>x * scalar * A + y</code> in <code>z</code>.
     147  virtual void transposeTimes(double scalar,
     148    const double *x, double *y) const;
     149  /// And for scaling
     150  virtual void transposeTimes(double scalar,
     151    const double *x, double *y,
     152    const double *rowScale,
     153    const double *columnScale, double *spare = NULL) const;
     154  /** Return <code>x * scalar * A + y</code> in <code>z</code>.
    151155     Can use y as temporary array (will be empty at end)
    152156     Note - If x packed mode - then z packed mode
    153157     Squashes small elements and knows about ClpSimplex */
    154      virtual void transposeTimes(const ClpSimplex * model, double scalar,
    155                                  const CoinIndexedVector * x,
    156                                  CoinIndexedVector * y,
    157                                  CoinIndexedVector * z) const;
    158      /** Return <code>x *A</code> in <code>z</code> but
     158  virtual void transposeTimes(const ClpSimplex *model, double scalar,
     159    const CoinIndexedVector *x,
     160    CoinIndexedVector *y,
     161    CoinIndexedVector *z) const;
     162  /** Return <code>x *A</code> in <code>z</code> but
    159163     just for indices in y.
    160164     Note - z always packed mode */
    161      virtual void subsetTransposeTimes(const ClpSimplex * model,
    162                                        const CoinIndexedVector * x,
    163                                        const CoinIndexedVector * y,
    164                                        CoinIndexedVector * z) const;
    165      //@}
    166 
    167      /**@name Other */
    168      //@{
    169      /// Return true if really network, false if has slacks
    170      inline bool trueNetwork() const {
    171           return trueNetwork_;
    172      }
    173      //@}
    174 
    175 
    176      /**@name Constructors, destructor */
    177      //@{
    178      /** Default constructor. */
    179      ClpNetworkMatrix();
    180      /** Constructor from two arrays */
    181      ClpNetworkMatrix(int numberColumns, const int * head,
    182                       const int * tail);
    183      /** Destructor */
    184      virtual ~ClpNetworkMatrix();
    185      //@}
    186 
    187      /**@name Copy method */
    188      //@{
    189      /** The copy constructor. */
    190      ClpNetworkMatrix(const ClpNetworkMatrix&);
    191      /** The copy constructor from an CoinNetworkMatrix. */
    192      ClpNetworkMatrix(const CoinPackedMatrix&);
    193 
    194      ClpNetworkMatrix& operator=(const ClpNetworkMatrix&);
    195      /// Clone
    196      virtual ClpMatrixBase * clone() const ;
    197      /** Subset constructor (without gaps).  Duplicates are allowed
     165  virtual void subsetTransposeTimes(const ClpSimplex *model,
     166    const CoinIndexedVector *x,
     167    const CoinIndexedVector *y,
     168    CoinIndexedVector *z) const;
     169  //@}
     170
     171  /**@name Other */
     172  //@{
     173  /// Return true if really network, false if has slacks
     174  inline bool trueNetwork() const
     175  {
     176    return trueNetwork_;
     177  }
     178  //@}
     179
     180  /**@name Constructors, destructor */
     181  //@{
     182  /** Default constructor. */
     183  ClpNetworkMatrix();
     184  /** Constructor from two arrays */
     185  ClpNetworkMatrix(int numberColumns, const int *head,
     186    const int *tail);
     187  /** Destructor */
     188  virtual ~ClpNetworkMatrix();
     189  //@}
     190
     191  /**@name Copy method */
     192  //@{
     193  /** The copy constructor. */
     194  ClpNetworkMatrix(const ClpNetworkMatrix &);
     195  /** The copy constructor from an CoinNetworkMatrix. */
     196  ClpNetworkMatrix(const CoinPackedMatrix &);
     197
     198  ClpNetworkMatrix &operator=(const ClpNetworkMatrix &);
     199  /// Clone
     200  virtual ClpMatrixBase *clone() const;
     201  /** Subset constructor (without gaps).  Duplicates are allowed
    198202         and order is as given */
    199      ClpNetworkMatrix (const ClpNetworkMatrix & wholeModel,
    200                        int numberRows, const int * whichRows,
    201                        int numberColumns, const int * whichColumns);
    202      /** Subset clone (without gaps).  Duplicates are allowed
     203  ClpNetworkMatrix(const ClpNetworkMatrix &wholeModel,
     204    int numberRows, const int *whichRows,
     205    int numberColumns, const int *whichColumns);
     206  /** Subset clone (without gaps).  Duplicates are allowed
    203207         and order is as given */
    204      virtual ClpMatrixBase * subsetClone (
    205           int numberRows, const int * whichRows,
    206           int numberColumns, const int * whichColumns) const ;
    207      //@}
    208 
     208  virtual ClpMatrixBase *subsetClone(
     209    int numberRows, const int *whichRows,
     210    int numberColumns, const int *whichColumns) const;
     211  //@}
    209212
    210213protected:
    211      /**@name Data members
     214  /**@name Data members
    212215        The data members are protected to allow access for derived classes. */
    213      //@{
    214      /// For fake CoinPackedMatrix
    215      mutable CoinPackedMatrix * matrix_;
    216      mutable int * lengths_;
    217      /// Data -1, then +1 rows in pairs (row==-1 if one entry)
    218      int * indices_;
    219      /// Number of rows
    220      int numberRows_;
    221      /// Number of columns
    222      int numberColumns_;
    223      /// True if all entries have two elements
    224      bool trueNetwork_;
    225 
    226      //@}
     216  //@{
     217  /// For fake CoinPackedMatrix
     218  mutable CoinPackedMatrix *matrix_;
     219  mutable int *lengths_;
     220  /// Data -1, then +1 rows in pairs (row==-1 if one entry)
     221  int *indices_;
     222  /// Number of rows
     223  int numberRows_;
     224  /// Number of columns
     225  int numberColumns_;
     226  /// True if all entries have two elements
     227  bool trueNetwork_;
     228
     229  //@}
    227230};
    228231
    229232#endif
     233
     234/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
     235*/
Note: See TracChangeset for help on using the changeset viewer.