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/AbcPrimalColumnSteepest.hpp

    r1910 r2385  
    1313class CoinIndexedVector;
    1414
    15 
    1615/** Primal Column Pivot Steepest Edge Algorithm Class
    1716
     
    2019*/
    2120
    22 
    2321class AbcPrimalColumnSteepest : public AbcPrimalColumnPivot {
    2422
    2523public:
    26 
    27      ///@name Algorithmic methods
    28      //@{
    29 
    30      /** Returns pivot column, -1 if none.
     24  ///@name Algorithmic methods
     25  //@{
     26
     27  /** Returns pivot column, -1 if none.
    3128         The Packed CoinIndexedVector updates has cost updates - for normal LP
    3229         that is just +-weight where a feasibility changed.  It also has
     
    3532         profiling and speed
    3633     */
    37      virtual int pivotColumn(CoinPartitionedVector * updates,
    38                              CoinPartitionedVector * spareRow2,
    39                              CoinPartitionedVector * spareColumn1);
    40      /// Just update djs
    41      void justDjs(CoinIndexedVector * updates,
    42                   CoinIndexedVector * spareColumn1);
    43      /// Update djs doing partial pricing (dantzig)
    44      int partialPricing(CoinIndexedVector * updates,
    45                         int numberWanted,
    46                         int numberLook);
    47      /// Update djs, weights for Devex using djs
    48      void djsAndDevex(CoinIndexedVector * updates,
    49                       CoinIndexedVector * spareRow2,
    50                       CoinIndexedVector * spareColumn1);
    51      /// Update djs, weights for Devex using pivot row
    52      void djsAndDevex2(CoinIndexedVector * updates,
    53                        CoinIndexedVector * spareColumn1);
    54      /// Update weights for Devex
    55      void justDevex(CoinIndexedVector * updates,
    56                     CoinIndexedVector * spareColumn1);
     34  virtual int pivotColumn(CoinPartitionedVector *updates,
     35    CoinPartitionedVector *spareRow2,
     36    CoinPartitionedVector *spareColumn1);
     37  /// Just update djs
     38  void justDjs(CoinIndexedVector *updates,
     39    CoinIndexedVector *spareColumn1);
     40  /// Update djs doing partial pricing (dantzig)
     41  int partialPricing(CoinIndexedVector *updates,
     42    int numberWanted,
     43    int numberLook);
     44  /// Update djs, weights for Devex using djs
     45  void djsAndDevex(CoinIndexedVector *updates,
     46    CoinIndexedVector *spareRow2,
     47    CoinIndexedVector *spareColumn1);
     48  /// Update djs, weights for Devex using pivot row
     49  void djsAndDevex2(CoinIndexedVector *updates,
     50    CoinIndexedVector *spareColumn1);
     51  /// Update weights for Devex
     52  void justDevex(CoinIndexedVector *updates,
     53    CoinIndexedVector *spareColumn1);
    5754  /** Does steepest work
    5855      type -
     
    6259      3 - both using extra array
    6360   */
    64      int doSteepestWork(CoinPartitionedVector * updates,
    65                         CoinPartitionedVector * spareRow2,
    66                         CoinPartitionedVector * spareColumn1,
    67                         int type);
    68 
    69      /// Updates weights - part 1 - also checks accuracy
    70      virtual void updateWeights(CoinIndexedVector * input);
    71 
    72      /// Checks accuracy - just for debug
    73      void checkAccuracy(int sequence, double relativeTolerance,
    74                         CoinIndexedVector * rowArray1);
    75 
    76      /// Initialize weights
    77      void initializeWeights();
    78 
    79      /** Save weights - this may initialize weights as well
     61  int doSteepestWork(CoinPartitionedVector *updates,
     62    CoinPartitionedVector *spareRow2,
     63    CoinPartitionedVector *spareColumn1,
     64    int type);
     65
     66  /// Updates weights - part 1 - also checks accuracy
     67  virtual void updateWeights(CoinIndexedVector *input);
     68
     69  /// Checks accuracy - just for debug
     70  void checkAccuracy(int sequence, double relativeTolerance,
     71    CoinIndexedVector *rowArray1);
     72
     73  /// Initialize weights
     74  void initializeWeights();
     75
     76  /** Save weights - this may initialize weights as well
    8077         mode is -
    8178         1) before factorization
     
    8582         5) at end of values pass (so need initialization)
    8683     */
    87      virtual void saveWeights(AbcSimplex * model, int mode);
    88      /// Gets rid of last update
    89      virtual void unrollWeights();
    90      /// Gets rid of all arrays
    91      virtual void clearArrays();
    92      /// Returns true if would not find any column
    93      virtual bool looksOptimal() const;
    94      /// Called when maximum pivots changes
    95      virtual void maximumPivotsChanged();
    96      //@}
    97 
    98      /**@name gets and sets */
    99      //@{
    100      /// Mode
    101      inline int mode() const {
    102           return mode_;
    103      }
    104 //@}
    105 
    106      /** enums for persistence
    107      */
    108      enum Persistence {
    109           normal = 0x00, // create (if necessary) and destroy
    110           keep = 0x01 // create (if necessary) and leave
    111      };
    112 
    113      ///@name Constructors and destructors
    114      //@{
    115      /** Default Constructor
     84  virtual void saveWeights(AbcSimplex *model, int mode);
     85  /// Gets rid of last update
     86  virtual void unrollWeights();
     87  /// Gets rid of all arrays
     88  virtual void clearArrays();
     89  /// Returns true if would not find any column
     90  virtual bool looksOptimal() const;
     91  /// Called when maximum pivots changes
     92  virtual void maximumPivotsChanged();
     93  //@}
     94
     95  /**@name gets and sets */
     96  //@{
     97  /// Mode
     98  inline int mode() const
     99  {
     100    return mode_;
     101  }
     102  //@}
     103
     104  /** enums for persistence
     105     */
     106  enum Persistence {
     107    normal = 0x00, // create (if necessary) and destroy
     108    keep = 0x01 // create (if necessary) and leave
     109  };
     110
     111  ///@name Constructors and destructors
     112  //@{
     113  /** Default Constructor
    116114         0 is exact devex, 1 full steepest, 2 is partial exact devex
    117115         3 switches between 0 and 2 depending on factorization
     
    121119         This can be faster on very easy problems.
    122120     */
    123      AbcPrimalColumnSteepest(int mode = 3);
    124 
    125      /// Copy constructor
    126      AbcPrimalColumnSteepest(const AbcPrimalColumnSteepest & rhs);
    127 
    128      /// Assignment operator
    129      AbcPrimalColumnSteepest & operator=(const AbcPrimalColumnSteepest& rhs);
    130 
    131      /// Destructor
    132      virtual ~AbcPrimalColumnSteepest ();
    133 
    134      /// Clone
    135      virtual AbcPrimalColumnPivot * clone(bool copyData = true) const;
    136 
    137      //@}
    138 
    139      ///@name Private functions to deal with devex
    140      /** reference would be faster using AbcSimplex's status_,
     121  AbcPrimalColumnSteepest(int mode = 3);
     122
     123  /// Copy constructor
     124  AbcPrimalColumnSteepest(const AbcPrimalColumnSteepest &rhs);
     125
     126  /// Assignment operator
     127  AbcPrimalColumnSteepest &operator=(const AbcPrimalColumnSteepest &rhs);
     128
     129  /// Destructor
     130  virtual ~AbcPrimalColumnSteepest();
     131
     132  /// Clone
     133  virtual AbcPrimalColumnPivot *clone(bool copyData = true) const;
     134
     135  //@}
     136
     137  ///@name Private functions to deal with devex
     138  /** reference would be faster using AbcSimplex's status_,
    141139         but I prefer to keep modularity.
    142140     */
    143      inline bool reference(int i) const {
    144           return ((reference_[i>>5] >> (i & 31)) & 1) != 0;
    145      }
    146      inline void setReference(int i, bool trueFalse) {
    147           unsigned int & value = reference_[i>>5];
    148           int bit = i & 31;
    149           if (trueFalse)
    150                value |= (1 << bit);
    151           else
    152                value &= ~(1 << bit);
    153      }
    154      /// Set/ get persistence
    155      inline void setPersistence(Persistence life) {
    156           persistence_ = life;
    157      }
    158      inline Persistence persistence() const {
    159           return persistence_ ;
    160      }
    161 
    162      //@}
    163      //---------------------------------------------------------------------------
     141  inline bool reference(int i) const
     142  {
     143    return ((reference_[i >> 5] >> (i & 31)) & 1) != 0;
     144  }
     145  inline void setReference(int i, bool trueFalse)
     146  {
     147    unsigned int &value = reference_[i >> 5];
     148    int bit = i & 31;
     149    if (trueFalse)
     150      value |= (1 << bit);
     151    else
     152      value &= ~(1 << bit);
     153  }
     154  /// Set/ get persistence
     155  inline void setPersistence(Persistence life)
     156  {
     157    persistence_ = life;
     158  }
     159  inline Persistence persistence() const
     160  {
     161    return persistence_;
     162  }
     163
     164  //@}
     165  //---------------------------------------------------------------------------
    164166
    165167private:
    166      ///@name Private member data
    167      // Update weight
    168      double devex_;
    169      /// weight array
    170      double * weights_;
    171      /// square of infeasibility array (just for infeasible columns)
    172      CoinIndexedVector * infeasible_;
    173      /// alternate weight array (so we can unroll)
    174      CoinIndexedVector * alternateWeights_;
    175      /// save weight array (so we can use checkpoint)
    176      double * savedWeights_;
    177      // Array for exact devex to say what is in reference framework
    178      unsigned int * reference_;
    179      /** Status
     168  ///@name Private member data
     169  // Update weight
     170  double devex_;
     171  /// weight array
     172  double *weights_;
     173  /// square of infeasibility array (just for infeasible columns)
     174  CoinIndexedVector *infeasible_;
     175  /// alternate weight array (so we can unroll)
     176  CoinIndexedVector *alternateWeights_;
     177  /// save weight array (so we can use checkpoint)
     178  double *savedWeights_;
     179  // Array for exact devex to say what is in reference framework
     180  unsigned int *reference_;
     181  /** Status
    180182         0) Normal
    181183         -1) Needs initialization
    182184         1) Weights are stored by sequence number
    183185     */
    184      int state_;
    185      /**
     186  int state_;
     187  /**
    186188         0 is exact devex, 1 full steepest, 2 is partial exact devex
    187189         3 switches between 0 and 2 depending on factorization
     
    195197
    196198     */
    197      int mode_;
    198      /// Life of weights
    199      Persistence persistence_;
    200      /// Number of times switched from partial dantzig to 0/2
    201      int numberSwitched_;
    202      // This is pivot row (or pivot sequence round re-factorization)
    203      int pivotSequence_;
    204      // This is saved pivot sequence
    205      int savedPivotSequence_;
    206      // This is saved outgoing variable
    207      int savedSequenceOut_;
    208      // Iteration when last rectified
    209      int lastRectified_;
    210      // Size of factorization at invert (used to decide algorithm)
    211      int sizeFactorization_;
    212      //@}
     199  int mode_;
     200  /// Life of weights
     201  Persistence persistence_;
     202  /// Number of times switched from partial dantzig to 0/2
     203  int numberSwitched_;
     204  // This is pivot row (or pivot sequence round re-factorization)
     205  int pivotSequence_;
     206  // This is saved pivot sequence
     207  int savedPivotSequence_;
     208  // This is saved outgoing variable
     209  int savedSequenceOut_;
     210  // Iteration when last rectified
     211  int lastRectified_;
     212  // Size of factorization at invert (used to decide algorithm)
     213  int sizeFactorization_;
     214  //@}
    213215};
    214216
    215217#endif
     218
     219/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
     220*/
Note: See TracChangeset for help on using the changeset viewer.