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

    r2235 r2385  
    1313class CoinIndexedVector;
    1414
    15 
    1615/** Primal Column Pivot Steepest Edge Algorithm Class
    1716
     
    2019*/
    2120
    22 
    2321class ClpPrimalColumnSteepest : public ClpPrimalColumnPivot {
    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(CoinIndexedVector * updates,
    38                              CoinIndexedVector * spareRow1,
    39                              CoinIndexedVector * spareRow2,
    40                              CoinIndexedVector * spareColumn1,
    41                              CoinIndexedVector * spareColumn2);
    42      /// For quadratic or funny nonlinearities
    43      int pivotColumnOldMethod(CoinIndexedVector * updates,
    44                               CoinIndexedVector * spareRow1,
    45                               CoinIndexedVector * spareRow2,
    46                               CoinIndexedVector * spareColumn1,
    47                               CoinIndexedVector * spareColumn2);
    48      /// Just update djs
    49      void justDjs(CoinIndexedVector * updates,
    50                   CoinIndexedVector * spareRow2,
    51                   CoinIndexedVector * spareColumn1,
    52                   CoinIndexedVector * spareColumn2);
    53      /// Update djs doing partial pricing (dantzig)
    54      int partialPricing(CoinIndexedVector * updates,
    55                         CoinIndexedVector * spareRow2,
    56                         int numberWanted,
    57                         int numberLook);
    58      /// Update djs, weights for Devex using djs
    59      void djsAndDevex(CoinIndexedVector * updates,
    60                       CoinIndexedVector * spareRow2,
    61                       CoinIndexedVector * spareColumn1,
    62                       CoinIndexedVector * spareColumn2);
    63      /** Update djs, weights for Steepest using djs
     34  virtual int pivotColumn(CoinIndexedVector *updates,
     35    CoinIndexedVector *spareRow1,
     36    CoinIndexedVector *spareRow2,
     37    CoinIndexedVector *spareColumn1,
     38    CoinIndexedVector *spareColumn2);
     39  /// For quadratic or funny nonlinearities
     40  int pivotColumnOldMethod(CoinIndexedVector *updates,
     41    CoinIndexedVector *spareRow1,
     42    CoinIndexedVector *spareRow2,
     43    CoinIndexedVector *spareColumn1,
     44    CoinIndexedVector *spareColumn2);
     45  /// Just update djs
     46  void justDjs(CoinIndexedVector *updates,
     47    CoinIndexedVector *spareRow2,
     48    CoinIndexedVector *spareColumn1,
     49    CoinIndexedVector *spareColumn2);
     50  /// Update djs doing partial pricing (dantzig)
     51  int partialPricing(CoinIndexedVector *updates,
     52    CoinIndexedVector *spareRow2,
     53    int numberWanted,
     54    int numberLook);
     55  /// Update djs, weights for Devex using djs
     56  void djsAndDevex(CoinIndexedVector *updates,
     57    CoinIndexedVector *spareRow2,
     58    CoinIndexedVector *spareColumn1,
     59    CoinIndexedVector *spareColumn2);
     60  /** Update djs, weights for Steepest using djs
    6461         sets best sequence (possibly) */
    65      void djsAndSteepest(CoinIndexedVector * updates,
    66                          CoinIndexedVector * spareRow2,
    67                          CoinIndexedVector * spareColumn1,
    68                          CoinIndexedVector * spareColumn2);
    69      /// Update djs, weights for Devex using pivot row
    70      void djsAndDevex2(CoinIndexedVector * updates,
    71                        CoinIndexedVector * spareRow2,
    72                        CoinIndexedVector * spareColumn1,
    73                        CoinIndexedVector * spareColumn2);
    74      /// Update djs, weights for Steepest using pivot row
    75      void djsAndSteepest2(CoinIndexedVector * updates,
    76                           CoinIndexedVector * spareRow2,
    77                           CoinIndexedVector * spareColumn1,
    78                           CoinIndexedVector * spareColumn2);
    79      /// Update weights for Devex
    80      void justDevex(CoinIndexedVector * updates,
    81                     CoinIndexedVector * spareRow2,
    82                     CoinIndexedVector * spareColumn1,
    83                     CoinIndexedVector * spareColumn2);
    84      /// Update weights for Steepest
    85      void justSteepest(CoinIndexedVector * updates,
    86                        CoinIndexedVector * spareRow2,
    87                        CoinIndexedVector * spareColumn1,
    88                        CoinIndexedVector * spareColumn2);
    89      /// Updates two arrays for steepest
    90      int transposeTimes2(const CoinIndexedVector * pi1, CoinIndexedVector * dj1,
    91                           const CoinIndexedVector * pi2, CoinIndexedVector * dj2,
    92                           CoinIndexedVector * spare, double scaleFactor);
    93 
    94      /// Updates weights - part 1 - also checks accuracy
    95      virtual void updateWeights(CoinIndexedVector * input);
    96 
    97      /// Checks accuracy - just for debug
    98      void checkAccuracy(int sequence, double relativeTolerance,
    99                         CoinIndexedVector * rowArray1,
    100                         CoinIndexedVector * rowArray2);
    101 
    102      /// Initialize weights
    103      void initializeWeights();
    104 
    105      /** Save weights - this may initialize weights as well
     62  void djsAndSteepest(CoinIndexedVector *updates,
     63    CoinIndexedVector *spareRow2,
     64    CoinIndexedVector *spareColumn1,
     65    CoinIndexedVector *spareColumn2);
     66  /// Update djs, weights for Devex using pivot row
     67  void djsAndDevex2(CoinIndexedVector *updates,
     68    CoinIndexedVector *spareRow2,
     69    CoinIndexedVector *spareColumn1,
     70    CoinIndexedVector *spareColumn2);
     71  /// Update djs, weights for Steepest using pivot row
     72  void djsAndSteepest2(CoinIndexedVector *updates,
     73    CoinIndexedVector *spareRow2,
     74    CoinIndexedVector *spareColumn1,
     75    CoinIndexedVector *spareColumn2);
     76  /// Update weights for Devex
     77  void justDevex(CoinIndexedVector *updates,
     78    CoinIndexedVector *spareRow2,
     79    CoinIndexedVector *spareColumn1,
     80    CoinIndexedVector *spareColumn2);
     81  /// Update weights for Steepest
     82  void justSteepest(CoinIndexedVector *updates,
     83    CoinIndexedVector *spareRow2,
     84    CoinIndexedVector *spareColumn1,
     85    CoinIndexedVector *spareColumn2);
     86  /// Updates two arrays for steepest
     87  int transposeTimes2(const CoinIndexedVector *pi1, CoinIndexedVector *dj1,
     88    const CoinIndexedVector *pi2, CoinIndexedVector *dj2,
     89    CoinIndexedVector *spare, double scaleFactor);
     90
     91  /// Updates weights - part 1 - also checks accuracy
     92  virtual void updateWeights(CoinIndexedVector *input);
     93
     94  /// Checks accuracy - just for debug
     95  void checkAccuracy(int sequence, double relativeTolerance,
     96    CoinIndexedVector *rowArray1,
     97    CoinIndexedVector *rowArray2);
     98
     99  /// Initialize weights
     100  void initializeWeights();
     101
     102  /** Save weights - this may initialize weights as well
    106103         mode is -
    107104         1) before factorization
     
    111108         5) at end of values pass (so need initialization)
    112109     */
    113      virtual void saveWeights(ClpSimplex * model, int mode);
    114      /// redo infeasibilities
    115      void redoInfeasibilities();
    116      /// Gets rid of last update
    117      virtual void unrollWeights();
    118      /// Gets rid of all arrays
    119      virtual void clearArrays();
    120      /// Returns true if would not find any column
    121      virtual bool looksOptimal() const;
    122      /// Called when maximum pivots changes
    123      virtual void maximumPivotsChanged();
    124      //@}
    125 
    126      /**@name gets and sets */
    127      //@{
    128      /// Mode
    129      inline int mode() const {
    130           return mode_;
    131      }
    132      /// Set mode
    133      inline void setMode(int mode) {
    134           mode_ = mode;
    135      }
    136      /// square of infeasibility array (just for infeasible columns)
    137      inline CoinIndexedVector * infeasible() const {
    138        return infeasible_;
    139      }
    140      /// Weights
    141      inline const double * weights() const {
    142        return weights_;
    143      }
    144      /// alternate weight array
    145      inline CoinIndexedVector * alternateWeights() const {
    146        return alternateWeights_;
    147      }
    148      /** Returns number of extra columns for sprint algorithm - 0 means off.
     110  virtual void saveWeights(ClpSimplex *model, int mode);
     111  /// redo infeasibilities
     112  void redoInfeasibilities();
     113  /// Gets rid of last update
     114  virtual void unrollWeights();
     115  /// Gets rid of all arrays
     116  virtual void clearArrays();
     117  /// Returns true if would not find any column
     118  virtual bool looksOptimal() const;
     119  /// Called when maximum pivots changes
     120  virtual void maximumPivotsChanged();
     121  //@}
     122
     123  /**@name gets and sets */
     124  //@{
     125  /// Mode
     126  inline int mode() const
     127  {
     128    return mode_;
     129  }
     130  /// Set mode
     131  inline void setMode(int mode)
     132  {
     133    mode_ = mode;
     134  }
     135  /// square of infeasibility array (just for infeasible columns)
     136  inline CoinIndexedVector *infeasible() const
     137  {
     138    return infeasible_;
     139  }
     140  /// Weights
     141  inline const double *weights() const
     142  {
     143    return weights_;
     144  }
     145  /// alternate weight array
     146  inline CoinIndexedVector *alternateWeights() const
     147  {
     148    return alternateWeights_;
     149  }
     150  /** Returns number of extra columns for sprint algorithm - 0 means off.
    149151         Also number of iterations before recompute
    150152     */
    151      virtual int numberSprintColumns(int & numberIterations) const;
    152      /// Switch off sprint idea
    153      virtual void switchOffSprint();
    154 
    155 //@}
    156 
    157      /** enums for persistence
    158      */
    159      enum Persistence {
    160           normal = 0x00, // create (if necessary) and destroy
    161           keep = 0x01 // create (if necessary) and leave
    162      };
    163 
    164      ///@name Constructors and destructors
    165      //@{
    166      /** Default Constructor
     153  virtual int numberSprintColumns(int &numberIterations) const;
     154  /// Switch off sprint idea
     155  virtual void switchOffSprint();
     156
     157  //@}
     158
     159  /** enums for persistence
     160     */
     161  enum Persistence {
     162    normal = 0x00, // create (if necessary) and destroy
     163    keep = 0x01 // create (if necessary) and leave
     164  };
     165
     166  ///@name Constructors and destructors
     167  //@{
     168  /** Default Constructor
    167169         0 is exact devex, 1 full steepest, 2 is partial exact devex
    168170         3 switches between 0 and 2 depending on factorization
     
    172174         This can be faster on very easy problems.
    173175     */
    174      ClpPrimalColumnSteepest(int mode = 3);
    175 
    176      /// Copy constructor
    177      ClpPrimalColumnSteepest(const ClpPrimalColumnSteepest & rhs);
    178 
    179      /// Assignment operator
    180      ClpPrimalColumnSteepest & operator=(const ClpPrimalColumnSteepest& rhs);
    181 
    182      /// Destructor
    183      virtual ~ClpPrimalColumnSteepest ();
    184 
    185      /// Clone
    186      virtual ClpPrimalColumnPivot * clone(bool copyData = true) const;
    187 
    188      //@}
    189 
    190      ///@name Private functions to deal with devex
    191      /** reference would be faster using ClpSimplex's status_,
     176  ClpPrimalColumnSteepest(int mode = 3);
     177
     178  /// Copy constructor
     179  ClpPrimalColumnSteepest(const ClpPrimalColumnSteepest &rhs);
     180
     181  /// Assignment operator
     182  ClpPrimalColumnSteepest &operator=(const ClpPrimalColumnSteepest &rhs);
     183
     184  /// Destructor
     185  virtual ~ClpPrimalColumnSteepest();
     186
     187  /// Clone
     188  virtual ClpPrimalColumnPivot *clone(bool copyData = true) const;
     189
     190  //@}
     191
     192  ///@name Private functions to deal with devex
     193  /** reference would be faster using ClpSimplex's status_,
    192194         but I prefer to keep modularity.
    193195     */
    194      inline bool reference(int i) const {
    195           return ((reference_[i>>5] >> (i & 31)) & 1) != 0;
    196      }
    197      inline void setReference(int i, bool trueFalse) {
    198           unsigned int & value = reference_[i>>5];
    199           int bit = i & 31;
    200           if (trueFalse)
    201                value |= (1 << bit);
    202           else
    203                value &= ~(1 << bit);
    204      }
    205      /// Set/ get persistence
    206      inline void setPersistence(Persistence life) {
    207           persistence_ = life;
    208      }
    209      inline Persistence persistence() const {
    210           return persistence_ ;
    211      }
    212 
    213      //@}
    214      //---------------------------------------------------------------------------
     196  inline bool reference(int i) const
     197  {
     198    return ((reference_[i >> 5] >> (i & 31)) & 1) != 0;
     199  }
     200  inline void setReference(int i, bool trueFalse)
     201  {
     202    unsigned int &value = reference_[i >> 5];
     203    int bit = i & 31;
     204    if (trueFalse)
     205      value |= (1 << bit);
     206    else
     207      value &= ~(1 << bit);
     208  }
     209  /// Set/ get persistence
     210  inline void setPersistence(Persistence life)
     211  {
     212    persistence_ = life;
     213  }
     214  inline Persistence persistence() const
     215  {
     216    return persistence_;
     217  }
     218
     219  //@}
     220  //---------------------------------------------------------------------------
    215221
    216222protected:
    217      ///@name Protected member data
    218      // Update weight
    219      double devex_;
    220      /// weight array
    221      double * weights_;
    222      /// square of infeasibility array (just for infeasible columns)
    223      CoinIndexedVector * infeasible_;
    224      /// alternate weight array (so we can unroll)
    225      CoinIndexedVector * alternateWeights_;
    226      /// save weight array (so we can use checkpoint)
    227      double * savedWeights_;
    228      // Array for exact devex to say what is in reference framework
    229      unsigned int * reference_;
    230      /** Status
     223  ///@name Protected member data
     224  // Update weight
     225  double devex_;
     226  /// weight array
     227  double *weights_;
     228  /// square of infeasibility array (just for infeasible columns)
     229  CoinIndexedVector *infeasible_;
     230  /// alternate weight array (so we can unroll)
     231  CoinIndexedVector *alternateWeights_;
     232  /// save weight array (so we can use checkpoint)
     233  double *savedWeights_;
     234  // Array for exact devex to say what is in reference framework
     235  unsigned int *reference_;
     236  /** Status
    231237         0) Normal
    232238         -1) Needs initialization
    233239         1) Weights are stored by sequence number
    234240     */
    235      int state_;
    236      /**
     241  int state_;
     242  /**
    237243         0 is exact devex, 1 full steepest, 2 is partial exact devex
    238244         3 switches between 0 and 2 depending on factorization
     
    246252
    247253     */
    248      int mode_;
    249      /* Infeasibility state i.e. array of infeasibilities and sequenceIn-
     254  int mode_;
     255  /* Infeasibility state i.e. array of infeasibilities and sequenceIn-
    250256        0 - correct
    251257        1 - needs correcting
    252258        2 - not known but column sequence has been chosen
    253259     */
    254      int infeasibilitiesState_;
    255      /// Life of weights
    256      Persistence persistence_;
    257      /// Number of times switched from partial dantzig to 0/2
    258      int numberSwitched_;
    259      // This is pivot row (or pivot sequence round re-factorization)
    260      int pivotSequence_;
    261      // This is saved pivot sequence
    262      int savedPivotSequence_;
    263      // This is saved outgoing variable
    264      int savedSequenceOut_;
    265      // Iteration when last rectified
    266      int lastRectified_;
    267      // Size of factorization at invert (used to decide algorithm)
    268      int sizeFactorization_;
    269      //@}
     260  int infeasibilitiesState_;
     261  /// Life of weights
     262  Persistence persistence_;
     263  /// Number of times switched from partial dantzig to 0/2
     264  int numberSwitched_;
     265  // This is pivot row (or pivot sequence round re-factorization)
     266  int pivotSequence_;
     267  // This is saved pivot sequence
     268  int savedPivotSequence_;
     269  // This is saved outgoing variable
     270  int savedSequenceOut_;
     271  // Iteration when last rectified
     272  int lastRectified_;
     273  // Size of factorization at invert (used to decide algorithm)
     274  int sizeFactorization_;
     275  //@}
    270276};
    271277
    272278#endif
     279
     280/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
     281*/
Note: See TracChangeset for help on using the changeset viewer.