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

formatting

File:
1 edited

Legend:

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

    r2271 r2385  
    77#define ClpPlusMinusOneMatrix_H
    88
    9 
    109#include "CoinPragma.hpp"
    1110
     
    1918
    2019public:
    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      /** Number of entries in the packed matrix. */
    28      virtual  CoinBigIndex getNumElements() const;
    29      /** Number of columns. */
    30      virtual int getNumCols() const {
    31           return numberColumns_;
    32      }
    33      /** Number of rows. */
    34      virtual int getNumRows() const {
    35           return numberRows_;
    36      }
    37 
    38      /** A vector containing the elements in the packed matrix. Note that there
     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;
     26  /** Number of entries in the packed matrix. */
     27  virtual CoinBigIndex getNumElements() const;
     28  /** Number of columns. */
     29  virtual int getNumCols() const
     30  {
     31    return numberColumns_;
     32  }
     33  /** Number of rows. */
     34  virtual int getNumRows() const
     35  {
     36    return numberRows_;
     37  }
     38
     39  /** A vector containing the elements in the packed matrix. Note that there
    3940      might be gaps in this list, entries that do not belong to any
    4041      major-dimension vector. To get the actual elements one should look at
    4142      this vector together with vectorStarts and vectorLengths. */
    42      virtual const double * getElements() const;
    43      /** A vector containing the minor indices of the elements in the packed
     43  virtual const double *getElements() const;
     44  /** A vector containing the minor indices of the elements in the packed
    4445          matrix. Note that there might be gaps in this list, entries that do not
    4546          belong to any major-dimension vector. To get the actual elements one
    4647          should look at this vector together with vectorStarts and
    4748          vectorLengths. */
    48      virtual const int * getIndices() const {
    49           return indices_;
    50      }
    51      // and for advanced use
    52      int * getMutableIndices() const {
    53           return indices_;
    54      }
    55 
    56      virtual const CoinBigIndex * getVectorStarts() const;
    57      /** The lengths of the major-dimension vectors. */
    58      virtual const int * getVectorLengths() const;
    59 
    60      /** Delete the columns whose indices are listed in <code>indDel</code>. */
    61      virtual void deleteCols(const int numDel, const int * indDel);
    62      /** Delete the rows whose indices are listed in <code>indDel</code>. */
    63      virtual void deleteRows(const int numDel, const int * indDel);
    64      /// Append Columns
    65      virtual void appendCols(int number, const CoinPackedVectorBase * const * columns);
    66      /// Append Rows
    67      virtual void appendRows(int number, const CoinPackedVectorBase * const * rows);
     49  virtual const int *getIndices() const
     50  {
     51    return indices_;
     52  }
     53  // and for advanced use
     54  int *getMutableIndices() const
     55  {
     56    return indices_;
     57  }
     58
     59  virtual const CoinBigIndex *getVectorStarts() const;
     60  /** The lengths of the major-dimension vectors. */
     61  virtual const int *getVectorLengths() const;
     62
     63  /** Delete the columns whose indices are listed in <code>indDel</code>. */
     64  virtual void deleteCols(const int numDel, const int *indDel);
     65  /** Delete the rows whose indices are listed in <code>indDel</code>. */
     66  virtual void deleteRows(const int numDel, const int *indDel);
     67  /// Append Columns
     68  virtual void appendCols(int number, const CoinPackedVectorBase *const *columns);
     69  /// Append Rows
     70  virtual void appendRows(int number, const CoinPackedVectorBase *const *rows);
    6871#ifndef SLIM_CLP
    69      /** Append a set of rows/columns to the end of the matrix. Returns number of errors
     72  /** Append a set of rows/columns to the end of the matrix. Returns number of errors
    7073         i.e. if any of the new rows/columns contain an index that's larger than the
    7174         number of columns-1/rows-1 (if numberOther>0) or duplicates
    7275         If 0 then rows, 1 if columns */
    73      virtual int appendMatrix(int number, int type,
    74                               const CoinBigIndex * starts, const int * index,
    75                               const double * element, int numberOther = -1);
     76  virtual int appendMatrix(int number, int type,
     77    const CoinBigIndex *starts, const int *index,
     78    const double *element, int numberOther = -1);
    7679#endif
    77      /** Returns a new matrix in reverse order without gaps */
    78      virtual ClpMatrixBase * reverseOrderedCopy() const;
    79      /// Returns number of elements in column part of basis
    80      virtual int countBasis(
    81           const int * whichColumn,
    82           int & numberColumnBasic);
    83      /// Fills in column part of basis
    84      virtual void fillBasis(ClpSimplex * model,
    85                             const int * whichColumn,
    86                             int & numberColumnBasic,
    87                             int * row, int * start,
    88                             int * rowCount, int * columnCount,
    89                             CoinFactorizationDouble * element);
    90      /** Given positive integer weights for each row fills in sum of weights
     80  /** Returns a new matrix in reverse order without gaps */
     81  virtual ClpMatrixBase *reverseOrderedCopy() const;
     82  /// Returns number of elements in column part of basis
     83  virtual int countBasis(
     84    const int *whichColumn,
     85    int &numberColumnBasic);
     86  /// Fills in column part of basis
     87  virtual void fillBasis(ClpSimplex *model,
     88    const int *whichColumn,
     89    int &numberColumnBasic,
     90    int *row, int *start,
     91    int *rowCount, int *columnCount,
     92    CoinFactorizationDouble *element);
     93  /** Given positive integer weights for each row fills in sum of weights
    9194         for each column (and slack).
    9295         Returns weights vector
    9396     */
    94      virtual CoinBigIndex * dubiousWeights(const ClpSimplex * model, int * inputWeights) const;
    95      /** Returns largest and smallest elements of both signs.
     97  virtual CoinBigIndex *dubiousWeights(const ClpSimplex *model, int *inputWeights) const;
     98  /** Returns largest and smallest elements of both signs.
    9699         Largest refers to largest absolute value.
    97100     */
    98      virtual void rangeOfElements(double & smallestNegative, double & largestNegative,
    99                                   double & smallestPositive, double & largestPositive);
    100      /** Unpacks a column into an CoinIndexedvector
     101  virtual void rangeOfElements(double &smallestNegative, double &largestNegative,
     102    double &smallestPositive, double &largestPositive);
     103  /** Unpacks a column into an CoinIndexedvector
    101104      */
    102      virtual void unpack(const ClpSimplex * model, CoinIndexedVector * rowArray,
    103                          int column) const ;
    104      /** Unpacks a column into an CoinIndexedvector
     105  virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray,
     106    int column) const;
     107  /** Unpacks a column into an CoinIndexedvector
    105108      ** in packed foramt
    106109         Note that model is NOT const.  Bounds and objective could
    107110         be modified if doing column generation (just for this variable) */
    108      virtual void unpackPacked(ClpSimplex * model,
    109                                CoinIndexedVector * rowArray,
    110                                int column) const;
    111      /** Adds multiple of a column into an CoinIndexedvector
     111  virtual void unpackPacked(ClpSimplex *model,
     112    CoinIndexedVector *rowArray,
     113    int column) const;
     114  /** Adds multiple of a column into an CoinIndexedvector
    112115         You can use quickAdd to add to vector */
    113      virtual void add(const ClpSimplex * model, CoinIndexedVector * rowArray,
    114                       int column, double multiplier) const ;
    115      /** Adds multiple of a column into an array */
    116      virtual void add(const ClpSimplex * model, double * array,
    117                       int column, double multiplier) const;
    118      /// Allow any parts of a created CoinMatrix to be deleted
    119      virtual void releasePackedMatrix() const;
    120      /** Set the dimensions of the matrix. In effect, append new empty
     116  virtual void add(const ClpSimplex *model, CoinIndexedVector *rowArray,
     117    int column, double multiplier) const;
     118  /** Adds multiple of a column into an array */
     119  virtual void add(const ClpSimplex *model, double *array,
     120    int column, double multiplier) const;
     121  /// Allow any parts of a created CoinMatrix to be deleted
     122  virtual void releasePackedMatrix() const;
     123  /** Set the dimensions of the matrix. In effect, append new empty
    121124         columns/rows to the matrix. A negative number for either dimension
    122125         means that that dimension doesn't change. Otherwise the new dimensions
    123126         MUST be at least as large as the current ones otherwise an exception
    124127         is thrown. */
    125      virtual void setDimensions(int numrows, int numcols);
    126      /// Just checks matrix valid - will say if dimensions not quite right if detail
    127      void checkValid(bool detail) const;
    128      //@}
    129 
    130      /**@name Matrix times vector methods */
    131      //@{
    132      /** Return <code>y + A * scalar *x</code> in <code>y</code>.
     128  virtual void setDimensions(int numrows, int numcols);
     129  /// Just checks matrix valid - will say if dimensions not quite right if detail
     130  void checkValid(bool detail) const;
     131  //@}
     132
     133  /**@name Matrix times vector methods */
     134  //@{
     135  /** Return <code>y + A * scalar *x</code> in <code>y</code>.
    133136         @pre <code>x</code> must be of size <code>numColumns()</code>
    134137         @pre <code>y</code> must be of size <code>numRows()</code> */
    135      virtual void times(double scalar,
    136                         const double * x, double * y) const;
    137      /// And for scaling
    138      virtual void times(double scalar,
    139                         const double * x, double * y,
    140                         const double * rowScale,
    141                         const double * columnScale) const;
    142      /** Return <code>y + x * scalar * A</code> in <code>y</code>.
     138  virtual void times(double scalar,
     139    const double *x, double *y) const;
     140  /// And for scaling
     141  virtual void times(double scalar,
     142    const double *x, double *y,
     143    const double *rowScale,
     144    const double *columnScale) const;
     145  /** Return <code>y + x * scalar * A</code> in <code>y</code>.
    143146         @pre <code>x</code> must be of size <code>numRows()</code>
    144147         @pre <code>y</code> must be of size <code>numColumns()</code> */
    145      virtual void transposeTimes(double scalar,
    146                                  const double * x, double * y) const;
    147      /// And for scaling
    148      virtual void transposeTimes(double scalar,
    149                                  const double * x, double * y,
    150                                  const double * rowScale,
    151                                  const double * columnScale, double * spare = NULL) const;
    152      /** Return <code>x * scalar * A + y</code> in <code>z</code>.
     148  virtual void transposeTimes(double scalar,
     149    const double *x, double *y) const;
     150  /// And for scaling
     151  virtual void transposeTimes(double scalar,
     152    const double *x, double *y,
     153    const double *rowScale,
     154    const double *columnScale, double *spare = NULL) const;
     155  /** Return <code>x * scalar * A + y</code> in <code>z</code>.
    153156     Can use y as temporary array (will be empty at end)
    154157     Note - If x packed mode - then z packed mode
    155158     Squashes small elements and knows about ClpSimplex */
    156      virtual void transposeTimes(const ClpSimplex * model, double scalar,
    157                                  const CoinIndexedVector * x,
    158                                  CoinIndexedVector * y,
    159                                  CoinIndexedVector * z) const;
    160      /** Return <code>x * scalar * A + y</code> in <code>z</code>.
     159  virtual void transposeTimes(const ClpSimplex *model, double scalar,
     160    const CoinIndexedVector *x,
     161    CoinIndexedVector *y,
     162    CoinIndexedVector *z) const;
     163  /** Return <code>x * scalar * A + y</code> in <code>z</code>.
    161164     Can use y as temporary array (will be empty at end)
    162165     Note - If x packed mode - then z packed mode
    163166     Squashes small elements and knows about ClpSimplex.
    164167     This version uses row copy*/
    165      virtual void transposeTimesByRow(const ClpSimplex * model, double scalar,
    166                                       const CoinIndexedVector * x,
    167                                       CoinIndexedVector * y,
    168                                       CoinIndexedVector * z) const;
    169      /** Return <code>x *A</code> in <code>z</code> but
     168  virtual void transposeTimesByRow(const ClpSimplex *model, double scalar,
     169    const CoinIndexedVector *x,
     170    CoinIndexedVector *y,
     171    CoinIndexedVector *z) const;
     172  /** Return <code>x *A</code> in <code>z</code> but
    170173     just for indices in y.
    171174     Note - z always packed mode */
    172      virtual void subsetTransposeTimes(const ClpSimplex * model,
    173                                        const CoinIndexedVector * x,
    174                                        const CoinIndexedVector * y,
    175                                        CoinIndexedVector * z) const;
    176      /** Returns true if can combine transposeTimes and subsetTransposeTimes
     175  virtual void subsetTransposeTimes(const ClpSimplex *model,
     176    const CoinIndexedVector *x,
     177    const CoinIndexedVector *y,
     178    CoinIndexedVector *z) const;
     179  /** Returns true if can combine transposeTimes and subsetTransposeTimes
    177180         and if it would be faster */
    178      virtual bool canCombine(const ClpSimplex * model,
    179                              const CoinIndexedVector * pi) const;
    180      /** Updates two arrays for steepest and does devex weights
     181  virtual bool canCombine(const ClpSimplex *model,
     182    const CoinIndexedVector *pi) const;
     183  /** Updates two arrays for steepest and does devex weights
    181184         Returns nonzero if updates reduced cost and infeas -
    182185         new infeas in dj1 */
    183      virtual int transposeTimes2(const ClpSimplex * model,
    184                                  const CoinIndexedVector * pi1, CoinIndexedVector * dj1,
    185                                  const CoinIndexedVector * pi2,
    186                                  CoinIndexedVector * spare,
    187                                  double * infeas, double * reducedCost,
    188                                   double referenceIn, double devex,
    189                                   // Array for exact devex to say what is in reference framework
    190                                   unsigned int * reference,
    191                                   double * weights, double scaleFactor);
    192      /// Updates second array for steepest and does devex weights
    193      virtual void subsetTimes2(const ClpSimplex * model,
    194                                CoinIndexedVector * dj1,
    195                                const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
    196                                double referenceIn, double devex,
    197                                // Array for exact devex to say what is in reference framework
    198                                unsigned int * reference,
    199                                double * weights, double scaleFactor);
    200      //@}
    201 
    202      /**@name Other */
    203      //@{
    204      /// Return starts of +1s
    205      inline CoinBigIndex * startPositive() const {
    206           return startPositive_;
    207      }
    208      /// Return starts of -1s
    209      inline CoinBigIndex * startNegative() const {
    210           return startNegative_;
    211      }
    212      //@}
    213 
    214 
    215      /**@name Constructors, destructor */
    216      //@{
    217      /** Default constructor. */
    218      ClpPlusMinusOneMatrix();
    219      /** Destructor */
    220      virtual ~ClpPlusMinusOneMatrix();
    221      //@}
    222 
    223      /**@name Copy method */
    224      //@{
    225      /** The copy constructor. */
    226      ClpPlusMinusOneMatrix(const ClpPlusMinusOneMatrix&);
    227      /** The copy constructor from an CoinPlusMinusOneMatrix.
     186  virtual int transposeTimes2(const ClpSimplex *model,
     187    const CoinIndexedVector *pi1, CoinIndexedVector *dj1,
     188    const CoinIndexedVector *pi2,
     189    CoinIndexedVector *spare,
     190    double *infeas, double *reducedCost,
     191    double referenceIn, double devex,
     192    // Array for exact devex to say what is in reference framework
     193    unsigned int *reference,
     194    double *weights, double scaleFactor);
     195  /// Updates second array for steepest and does devex weights
     196  virtual void subsetTimes2(const ClpSimplex *model,
     197    CoinIndexedVector *dj1,
     198    const CoinIndexedVector *pi2, CoinIndexedVector *dj2,
     199    double referenceIn, double devex,
     200    // Array for exact devex to say what is in reference framework
     201    unsigned int *reference,
     202    double *weights, double scaleFactor);
     203  //@}
     204
     205  /**@name Other */
     206  //@{
     207  /// Return starts of +1s
     208  inline CoinBigIndex *startPositive() const
     209  {
     210    return startPositive_;
     211  }
     212  /// Return starts of -1s
     213  inline CoinBigIndex *startNegative() const
     214  {
     215    return startNegative_;
     216  }
     217  //@}
     218
     219  /**@name Constructors, destructor */
     220  //@{
     221  /** Default constructor. */
     222  ClpPlusMinusOneMatrix();
     223  /** Destructor */
     224  virtual ~ClpPlusMinusOneMatrix();
     225  //@}
     226
     227  /**@name Copy method */
     228  //@{
     229  /** The copy constructor. */
     230  ClpPlusMinusOneMatrix(const ClpPlusMinusOneMatrix &);
     231  /** The copy constructor from an CoinPlusMinusOneMatrix.
    228232         If not a valid matrix then getIndices will be NULL and
    229233         startPositive[0] will have number of +1,
     
    231235         startPositive[2] will have number of others,
    232236     */
    233      ClpPlusMinusOneMatrix(const CoinPackedMatrix&);
    234      /// Constructor from arrays
    235      ClpPlusMinusOneMatrix(int numberRows, int numberColumns,
    236                            bool columnOrdered, const int * indices,
    237                            const CoinBigIndex * startPositive, const CoinBigIndex * startNegative);
    238      /** Subset constructor (without gaps).  Duplicates are allowed
     237  ClpPlusMinusOneMatrix(const CoinPackedMatrix &);
     238  /// Constructor from arrays
     239  ClpPlusMinusOneMatrix(int numberRows, int numberColumns,
     240    bool columnOrdered, const int *indices,
     241    const CoinBigIndex *startPositive, const CoinBigIndex *startNegative);
     242  /** Subset constructor (without gaps).  Duplicates are allowed
    239243         and order is as given */
    240      ClpPlusMinusOneMatrix (const ClpPlusMinusOneMatrix & wholeModel,
    241                             int numberRows, const int * whichRows,
    242                             int numberColumns, const int * whichColumns);
    243 
    244      ClpPlusMinusOneMatrix& operator=(const ClpPlusMinusOneMatrix&);
    245      /// Clone
    246      virtual ClpMatrixBase * clone() const ;
    247      /** Subset clone (without gaps).  Duplicates are allowed
     244  ClpPlusMinusOneMatrix(const ClpPlusMinusOneMatrix &wholeModel,
     245    int numberRows, const int *whichRows,
     246    int numberColumns, const int *whichColumns);
     247
     248  ClpPlusMinusOneMatrix &operator=(const ClpPlusMinusOneMatrix &);
     249  /// Clone
     250  virtual ClpMatrixBase *clone() const;
     251  /** Subset clone (without gaps).  Duplicates are allowed
    248252         and order is as given */
    249      virtual ClpMatrixBase * subsetClone (
    250           int numberRows, const int * whichRows,
    251           int numberColumns, const int * whichColumns) const ;
    252      /// pass in copy (object takes ownership)
    253      void passInCopy(int numberRows, int numberColumns,
    254                      bool columnOrdered, int * indices,
    255                      CoinBigIndex * startPositive, CoinBigIndex * startNegative);
    256      /// Says whether it can do partial pricing
    257      virtual bool canDoPartialPricing() const;
    258      /// Partial pricing
    259      virtual void partialPricing(ClpSimplex * model, double start, double end,
    260                                  int & bestSequence, int & numberWanted);
    261      //@}
    262 
     253  virtual ClpMatrixBase *subsetClone(
     254    int numberRows, const int *whichRows,
     255    int numberColumns, const int *whichColumns) const;
     256  /// pass in copy (object takes ownership)
     257  void passInCopy(int numberRows, int numberColumns,
     258    bool columnOrdered, int *indices,
     259    CoinBigIndex *startPositive, CoinBigIndex *startNegative);
     260  /// Says whether it can do partial pricing
     261  virtual bool canDoPartialPricing() const;
     262  /// Partial pricing
     263  virtual void partialPricing(ClpSimplex *model, double start, double end,
     264    int &bestSequence, int &numberWanted);
     265  //@}
    263266
    264267protected:
    265      /**@name Data members
     268  /**@name Data members
    266269        The data members are protected to allow access for derived classes. */
    267      //@{
    268      /// For fake CoinPackedMatrix
    269      mutable CoinPackedMatrix * matrix_;
    270      mutable int * lengths_;
    271      /// Start of +1's for each
    272      CoinBigIndex * COIN_RESTRICT startPositive_;
    273      /// Start of -1's for each
    274      CoinBigIndex * COIN_RESTRICT startNegative_;
    275      /// Data -1, then +1 rows in pairs (row==-1 if one entry)
    276      int * COIN_RESTRICT indices_;
    277      /// Number of rows
    278      int numberRows_;
    279      /// Number of columns
    280      int numberColumns_;
     270  //@{
     271  /// For fake CoinPackedMatrix
     272  mutable CoinPackedMatrix *matrix_;
     273  mutable int *lengths_;
     274  /// Start of +1's for each
     275  CoinBigIndex *COIN_RESTRICT startPositive_;
     276  /// Start of -1's for each
     277  CoinBigIndex *COIN_RESTRICT startNegative_;
     278  /// Data -1, then +1 rows in pairs (row==-1 if one entry)
     279  int *COIN_RESTRICT indices_;
     280  /// Number of rows
     281  int numberRows_;
     282  /// Number of columns
     283  int numberColumns_;
    281284#ifdef CLP_PLUS_ONE_MATRIX
    282      /** Other flags (could have columnOrdered_?)
     285  /** Other flags (could have columnOrdered_?)
    283286         1 bit - says just +1
    284287     */
    285      mutable int otherFlags_;
     288  mutable int otherFlags_;
    286289#endif
    287      /// True if column ordered
    288      bool columnOrdered_;
    289 
    290      //@}
     290  /// True if column ordered
     291  bool columnOrdered_;
     292
     293  //@}
    291294};
    292295#if CLP_POOL_MATRIX
     
    294297    as derived from ClpMatrixBase.  This version only up to 65K rows
    295298*/
    296 #define CLP_POOL_SIZE 32-CLP_POOL_MATRIX
    297 #if CLP_POOL_MATRIX==16
     299#define CLP_POOL_SIZE 32 - CLP_POOL_MATRIX
     300#if CLP_POOL_MATRIX == 16
    298301typedef struct {
    299302  unsigned short row_;
     
    302305#else
    303306typedef struct {
    304 unsigned int row_:CLP_POOL_MATRIX;
    305 unsigned short pool_:CLP_POOL_SIZE;
     307  unsigned int row_ : CLP_POOL_MATRIX;
     308  unsigned short pool_ : CLP_POOL_SIZE;
    306309} poolInfo;
    307310#endif
     
    310313
    311314public:
    312      /**@name Useful methods */
    313      //@{
    314      /// Return a complete CoinPackedMatrix
    315      virtual CoinPackedMatrix * getPackedMatrix() const;
    316      /** Whether the packed matrix is column major ordered or not. */
    317      virtual bool isColOrdered() const ;
    318      /** Number of entries in the packed matrix. */
    319      virtual  CoinBigIndex getNumElements() const;
    320      /** Number of different entries in the packed matrix. */
    321      inline int getNumDifferentElements() const
    322      { return numberDifferent_;}
    323      /** Number of columns. */
    324      virtual int getNumCols() const {
    325           return numberColumns_;
    326      }
    327      /** Number of rows. */
    328      virtual int getNumRows() const {
    329           return numberRows_;
    330      }
    331 
    332      /** A vector containing the elements in the packed matrix. Note that there
     315  /**@name Useful methods */
     316  //@{
     317  /// Return a complete CoinPackedMatrix
     318  virtual CoinPackedMatrix *getPackedMatrix() const;
     319  /** Whether the packed matrix is column major ordered or not. */
     320  virtual bool isColOrdered() const;
     321  /** Number of entries in the packed matrix. */
     322  virtual CoinBigIndex getNumElements() const;
     323  /** Number of different entries in the packed matrix. */
     324  inline int getNumDifferentElements() const
     325  {
     326    return numberDifferent_;
     327  }
     328  /** Number of columns. */
     329  virtual int getNumCols() const
     330  {
     331    return numberColumns_;
     332  }
     333  /** Number of rows. */
     334  virtual int getNumRows() const
     335  {
     336    return numberRows_;
     337  }
     338
     339  /** A vector containing the elements in the packed matrix. Note that there
    333340      might be gaps in this list, entries that do not belong to any
    334341      major-dimension vector. To get the actual elements one should look at
    335342      this vector together with vectorStarts and vectorLengths. */
    336      virtual const double * getElements() const;
    337      /** A vector containing the minor indices of the elements in the packed
     343  virtual const double *getElements() const;
     344  /** A vector containing the minor indices of the elements in the packed
    338345          matrix. Note that there might be gaps in this list, entries that do not
    339346          belong to any major-dimension vector. To get the actual elements one
    340347          should look at this vector together with vectorStarts and
    341348          vectorLengths. */
    342      virtual const int * getIndices() const;
    343      // and for advanced use
    344      int * getMutableIndices() const;
    345      
    346      virtual const CoinBigIndex * getVectorStarts() const;
    347      /** The lengths of the major-dimension vectors. */
    348      virtual const int * getVectorLengths() const;
    349      /** The length of a major-dimension vector. */
    350      virtual int getVectorLength(int index) const;
    351      /** Delete the columns whose indices are listed in <code>indDel</code>. */
    352      virtual void deleteCols(const int numDel, const int * indDel);
    353      /** Delete the rows whose indices are listed in <code>indDel</code>. */
    354      virtual void deleteRows(const int numDel, const int * indDel);
    355      /** Returns a new matrix in reverse order without gaps */
    356      virtual ClpMatrixBase * reverseOrderedCopy() const;
    357      /// Returns number of elements in column part of basis
    358      virtual int countBasis(
    359           const int * whichColumn,
    360           int & numberColumnBasic);
    361      /// Fills in column part of basis
    362      virtual void fillBasis(ClpSimplex * model,
    363                             const int * whichColumn,
    364                             int & numberColumnBasic,
    365                             int * row, int * start,
    366                             int * rowCount, int * columnCount,
    367                             CoinFactorizationDouble * element);
    368      /** Returns largest and smallest elements of both signs.
     349  virtual const int *getIndices() const;
     350  // and for advanced use
     351  int *getMutableIndices() const;
     352
     353  virtual const CoinBigIndex *getVectorStarts() const;
     354  /** The lengths of the major-dimension vectors. */
     355  virtual const int *getVectorLengths() const;
     356  /** The length of a major-dimension vector. */
     357  virtual int getVectorLength(int index) const;
     358  /** Delete the columns whose indices are listed in <code>indDel</code>. */
     359  virtual void deleteCols(const int numDel, const int *indDel);
     360  /** Delete the rows whose indices are listed in <code>indDel</code>. */
     361  virtual void deleteRows(const int numDel, const int *indDel);
     362  /** Returns a new matrix in reverse order without gaps */
     363  virtual ClpMatrixBase *reverseOrderedCopy() const;
     364  /// Returns number of elements in column part of basis
     365  virtual int countBasis(
     366    const int *whichColumn,
     367    int &numberColumnBasic);
     368  /// Fills in column part of basis
     369  virtual void fillBasis(ClpSimplex *model,
     370    const int *whichColumn,
     371    int &numberColumnBasic,
     372    int *row, int *start,
     373    int *rowCount, int *columnCount,
     374    CoinFactorizationDouble *element);
     375  /** Returns largest and smallest elements of both signs.
    369376         Largest refers to largest absolute value.
    370377     */
    371      virtual void rangeOfElements(double & smallestNegative, double & largestNegative,
    372                                   double & smallestPositive, double & largestPositive);
    373      /** Unpacks a column into an CoinIndexedvector
     378  virtual void rangeOfElements(double &smallestNegative, double &largestNegative,
     379    double &smallestPositive, double &largestPositive);
     380  /** Unpacks a column into an CoinIndexedvector
    374381      */
    375      virtual void unpack(const ClpSimplex * model, CoinIndexedVector * rowArray,
    376                          int column) const ;
    377      /** Unpacks a column into an CoinIndexedvector
     382  virtual void unpack(const ClpSimplex *model, CoinIndexedVector *rowArray,
     383    int column) const;
     384  /** Unpacks a column into an CoinIndexedvector
    378385      ** in packed foramt
    379386         Note that model is NOT const.  Bounds and objective could
    380387         be modified if doing column generation (just for this variable) */
    381      virtual void unpackPacked(ClpSimplex * model,
    382                                CoinIndexedVector * rowArray,
    383                                int column) const;
    384      /** Adds multiple of a column into an CoinIndexedvector
     388  virtual void unpackPacked(ClpSimplex *model,
     389    CoinIndexedVector *rowArray,
     390    int column) const;
     391  /** Adds multiple of a column into an CoinIndexedvector
    385392         You can use quickAdd to add to vector */
    386      virtual void add(const ClpSimplex * model, CoinIndexedVector * rowArray,
    387                       int column, double multiplier) const ;
    388      /** Adds multiple of a column into an array */
    389      virtual void add(const ClpSimplex * model, double * array,
    390                       int column, double multiplier) const;
    391      /// Allow any parts of a created CoinMatrix to be deleted
    392      virtual void releasePackedMatrix() const;
    393      /** Set the dimensions of the matrix. In effect, append new empty
     393  virtual void add(const ClpSimplex *model, CoinIndexedVector *rowArray,
     394    int column, double multiplier) const;
     395  /** Adds multiple of a column into an array */
     396  virtual void add(const ClpSimplex *model, double *array,
     397    int column, double multiplier) const;
     398  /// Allow any parts of a created CoinMatrix to be deleted
     399  virtual void releasePackedMatrix() const;
     400  /** Set the dimensions of the matrix. In effect, append new empty
    394401         columns/rows to the matrix. A negative number for either dimension
    395402         means that that dimension doesn't change. Otherwise the new dimensions
    396403         MUST be at least as large as the current ones otherwise an exception
    397404         is thrown. */
    398      virtual void setDimensions(int numrows, int numcols);
    399      /// Just checks matrix valid - will say if dimensions not quite right if detail
    400      void checkValid(bool detail) const;
    401      //@}
    402 
    403      /**@name Matrix times vector methods */
    404      //@{
    405      /** Return <code>y + A * scalar *x</code> in <code>y</code>.
     405  virtual void setDimensions(int numrows, int numcols);
     406  /// Just checks matrix valid - will say if dimensions not quite right if detail
     407  void checkValid(bool detail) const;
     408  //@}
     409
     410  /**@name Matrix times vector methods */
     411  //@{
     412  /** Return <code>y + A * scalar *x</code> in <code>y</code>.
    406413         @pre <code>x</code> must be of size <code>numColumns()</code>
    407414         @pre <code>y</code> must be of size <code>numRows()</code> */
    408      virtual void times(double scalar,
    409                         const double * x, double * y) const;
    410      /// And for scaling
    411      virtual void times(double scalar,
    412                         const double * x, double * y,
    413                         const double * rowScale,
    414                         const double * columnScale) const;
    415      /** Return <code>y + x * scalar * A</code> in <code>y</code>.
     415  virtual void times(double scalar,
     416    const double *x, double *y) const;
     417  /// And for scaling
     418  virtual void times(double scalar,
     419    const double *x, double *y,
     420    const double *rowScale,
     421    const double *columnScale) const;
     422  /** Return <code>y + x * scalar * A</code> in <code>y</code>.
    416423         @pre <code>x</code> must be of size <code>numRows()</code>
    417424         @pre <code>y</code> must be of size <code>numColumns()</code> */
    418      virtual void transposeTimes(double scalar,
    419                                  const double * x, double * y) const;
    420      /// And for scaling
    421      virtual void transposeTimes(double scalar,
    422                                  const double * x, double * y,
    423                                  const double * rowScale,
    424                                  const double * columnScale, double * spare = NULL) const;
    425      /** Return <code>x * scalar * A + y</code> in <code>z</code>.
     425  virtual void transposeTimes(double scalar,
     426    const double *x, double *y) const;
     427  /// And for scaling
     428  virtual void transposeTimes(double scalar,
     429    const double *x, double *y,
     430    const double *rowScale,
     431    const double *columnScale, double *spare = NULL) const;
     432  /** Return <code>x * scalar * A + y</code> in <code>z</code>.
    426433     Can use y as temporary array (will be empty at end)
    427434     Note - If x packed mode - then z packed mode
    428435     Squashes small elements and knows about ClpSimplex */
    429      virtual void transposeTimes(const ClpSimplex * model, double scalar,
    430                                  const CoinIndexedVector * x,
    431                                  CoinIndexedVector * y,
    432                                  CoinIndexedVector * z) const;
    433      /** Return <code>x * scalar * A + y</code> in <code>z</code>.
     436  virtual void transposeTimes(const ClpSimplex *model, double scalar,
     437    const CoinIndexedVector *x,
     438    CoinIndexedVector *y,
     439    CoinIndexedVector *z) const;
     440  /** Return <code>x * scalar * A + y</code> in <code>z</code>.
    434441     Can use y as temporary array (will be empty at end)
    435442     Note - If x packed mode - then z packed mode
    436443     Squashes small elements and knows about ClpSimplex.
    437444     This version uses row copy*/
    438      virtual void transposeTimesByRow(const ClpSimplex * model, double scalar,
    439                                       const CoinIndexedVector * x,
    440                                       CoinIndexedVector * y,
    441                                       CoinIndexedVector * z) const;
    442      /** Return <code>x *A</code> in <code>z</code> but
     445  virtual void transposeTimesByRow(const ClpSimplex *model, double scalar,
     446    const CoinIndexedVector *x,
     447    CoinIndexedVector *y,
     448    CoinIndexedVector *z) const;
     449  /** Return <code>x *A</code> in <code>z</code> but
    443450     just for indices in y.
    444451     Note - z always packed mode */
    445      virtual void subsetTransposeTimes(const ClpSimplex * model,
    446                                        const CoinIndexedVector * x,
    447                                        const CoinIndexedVector * y,
    448                                        CoinIndexedVector * z) const;
    449      /** Returns true if can combine transposeTimes and subsetTransposeTimes
     452  virtual void subsetTransposeTimes(const ClpSimplex *model,
     453    const CoinIndexedVector *x,
     454    const CoinIndexedVector *y,
     455    CoinIndexedVector *z) const;
     456  /** Returns true if can combine transposeTimes and subsetTransposeTimes
    450457         and if it would be faster */
    451      virtual bool canCombine(const ClpSimplex * model,
    452                              const CoinIndexedVector * pi) const
    453      { return true;}
    454      /** Updates two arrays for steepest and does devex weights
     458  virtual bool canCombine(const ClpSimplex *model,
     459    const CoinIndexedVector *pi) const
     460  {
     461    return true;
     462  }
     463  /** Updates two arrays for steepest and does devex weights
    455464         Returns nonzero if updates reduced cost and infeas -
    456465         new infeas in dj1 */
    457      virtual int transposeTimes2(const ClpSimplex * model,
    458                                  const CoinIndexedVector * pi1, CoinIndexedVector * dj1,
    459                                  const CoinIndexedVector * pi2,
    460                                  CoinIndexedVector * spare,
    461                                  double * infeas, double * reducedCost,
    462                                   double referenceIn, double devex,
    463                                   // Array for exact devex to say what is in reference framework
    464                                   unsigned int * reference,
    465                                   double * weights, double scaleFactor);
    466      /// Updates second array for steepest and does devex weights
    467      virtual void subsetTimes2(const ClpSimplex * model,
    468                                CoinIndexedVector * dj1,
    469                                const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
    470                                double referenceIn, double devex,
    471                                // Array for exact devex to say what is in reference framework
    472                                unsigned int * reference,
    473                                double * weights, double scaleFactor);
    474      //@}
    475 
    476      /**@name Other */
    477      //@{
    478      /// Return column starts
    479      inline CoinBigIndex * columnStart() const {
    480           return columnStart_;
    481      }
    482      //@}
    483 
    484 
    485      /**@name Constructors, destructor */
    486      //@{
    487      /** Default constructor. */
    488      ClpPoolMatrix();
    489      /** Destructor */
    490      virtual ~ClpPoolMatrix();
    491      //@}
    492 
    493      /**@name Copy method */
    494      //@{
    495      /** The copy constructor. */
    496      ClpPoolMatrix(const ClpPoolMatrix&);
    497      /** The copy constructor from an CoinPoolMatrix.
     466  virtual int transposeTimes2(const ClpSimplex *model,
     467    const CoinIndexedVector *pi1, CoinIndexedVector *dj1,
     468    const CoinIndexedVector *pi2,
     469    CoinIndexedVector *spare,
     470    double *infeas, double *reducedCost,
     471    double referenceIn, double devex,
     472    // Array for exact devex to say what is in reference framework
     473    unsigned int *reference,
     474    double *weights, double scaleFactor);
     475  /// Updates second array for steepest and does devex weights
     476  virtual void subsetTimes2(const ClpSimplex *model,
     477    CoinIndexedVector *dj1,
     478    const CoinIndexedVector *pi2, CoinIndexedVector *dj2,
     479    double referenceIn, double devex,
     480    // Array for exact devex to say what is in reference framework
     481    unsigned int *reference,
     482    double *weights, double scaleFactor);
     483  //@}
     484
     485  /**@name Other */
     486  //@{
     487  /// Return column starts
     488  inline CoinBigIndex *columnStart() const
     489  {
     490    return columnStart_;
     491  }
     492  //@}
     493
     494  /**@name Constructors, destructor */
     495  //@{
     496  /** Default constructor. */
     497  ClpPoolMatrix();
     498  /** Destructor */
     499  virtual ~ClpPoolMatrix();
     500  //@}
     501
     502  /**@name Copy method */
     503  //@{
     504  /** The copy constructor. */
     505  ClpPoolMatrix(const ClpPoolMatrix &);
     506  /** The copy constructor from an CoinPoolMatrix.
    498507     */
    499      ClpPoolMatrix(const CoinPackedMatrix&);
    500      /// Constructor from arrays
    501      ClpPoolMatrix(int numberRows, int numberColumns,
    502                    const int * indices, const double * elements,
    503                            const CoinBigIndex * columnStart);
    504      /// Constructor from arrays - handing over ownership
    505      ClpPoolMatrix(int numberColumns,CoinBigIndex * columnStart,
    506                    poolInfo * stuff, double * elements);
    507      /** Subset constructor (without gaps).  Duplicates are allowed
     508  ClpPoolMatrix(const CoinPackedMatrix &);
     509  /// Constructor from arrays
     510  ClpPoolMatrix(int numberRows, int numberColumns,
     511    const int *indices, const double *elements,
     512    const CoinBigIndex *columnStart);
     513  /// Constructor from arrays - handing over ownership
     514  ClpPoolMatrix(int numberColumns, CoinBigIndex *columnStart,
     515    poolInfo *stuff, double *elements);
     516  /** Subset constructor (without gaps).  Duplicates are allowed
    508517         and order is as given */
    509      ClpPoolMatrix (const ClpPoolMatrix & wholeModel,
    510                             int numberRows, const int * whichRows,
    511                             int numberColumns, const int * whichColumns);
    512 
    513      ClpPoolMatrix& operator=(const ClpPoolMatrix&);
    514      /// Clone
    515      virtual ClpMatrixBase * clone() const ;
    516      /** Subset clone (without gaps).  Duplicates are allowed
     518  ClpPoolMatrix(const ClpPoolMatrix &wholeModel,
     519    int numberRows, const int *whichRows,
     520    int numberColumns, const int *whichColumns);
     521
     522  ClpPoolMatrix &operator=(const ClpPoolMatrix &);
     523  /// Clone
     524  virtual ClpMatrixBase *clone() const;
     525  /** Subset clone (without gaps).  Duplicates are allowed
    517526         and order is as given */
    518      virtual ClpMatrixBase * subsetClone (
    519           int numberRows, const int * whichRows,
    520           int numberColumns, const int * whichColumns) const ;
    521      /// Says whether it can do partial pricing
    522      virtual bool canDoPartialPricing() const;
    523      /// Partial pricing
    524      virtual void partialPricing(ClpSimplex * model, double start, double end,
    525                                  int & bestSequence, int & numberWanted);
    526      //@}
    527 
     527  virtual ClpMatrixBase *subsetClone(
     528    int numberRows, const int *whichRows,
     529    int numberColumns, const int *whichColumns) const;
     530  /// Says whether it can do partial pricing
     531  virtual bool canDoPartialPricing() const;
     532  /// Partial pricing
     533  virtual void partialPricing(ClpSimplex *model, double start, double end,
     534    int &bestSequence, int &numberWanted);
     535  //@}
    528536
    529537protected:
    530      /// Create matrix_
    531      ClpPackedMatrix * createMatrix() const;
    532      /**@name Data members
     538  /// Create matrix_
     539  ClpPackedMatrix *createMatrix() const;
     540  /**@name Data members
    533541        The data members are protected to allow access for derived classes. */
    534      //@{
    535      /// For fake ClpPackedMatrix
    536      mutable ClpPackedMatrix * matrix_;
    537      mutable int * lengths_;
    538      /// Unique values
    539      double * COIN_RESTRICT elements_;
    540      /// Column starts
    541      CoinBigIndex * COIN_RESTRICT columnStart_;
    542      /// Rows and values
    543      poolInfo * COIN_RESTRICT stuff_;
    544      /// Number of rows
    545      int numberRows_;
    546      /// Number of columns
    547      int numberColumns_;
    548      /// Number of different elements
    549      int numberDifferent_;
    550 
    551      //@}
     542  //@{
     543  /// For fake ClpPackedMatrix
     544  mutable ClpPackedMatrix *matrix_;
     545  mutable int *lengths_;
     546  /// Unique values
     547  double *COIN_RESTRICT elements_;
     548  /// Column starts
     549  CoinBigIndex *COIN_RESTRICT columnStart_;
     550  /// Rows and values
     551  poolInfo *COIN_RESTRICT stuff_;
     552  /// Number of rows
     553  int numberRows_;
     554  /// Number of columns
     555  int numberColumns_;
     556  /// Number of different elements
     557  int numberDifferent_;
     558
     559  //@}
    552560};
    553561#endif
    554562#endif
     563
     564/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
     565*/
Note: See TracChangeset for help on using the changeset viewer.