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

    r2024 r2385  
    66#ifndef AbcNonLinearCost_H
    77#define AbcNonLinearCost_H
    8 
    98
    109#include "CoinPragma.hpp"
     
    5049  return (status >> 4);
    5150}
    52 inline void setOriginalStatus(unsigned char & status, int value)
    53 {
    54   status = static_cast<unsigned char>(status & ~15);
    55   status = static_cast<unsigned char>(status | value);
     51inline void setOriginalStatus(unsigned char &status, int value)
     52{
     53  status = static_cast< unsigned char >(status & ~15);
     54  status = static_cast< unsigned char >(status | value);
    5655}
    5756inline void setCurrentStatus(unsigned char &status, int value)
    5857{
    59   status = static_cast<unsigned char>(status & ~(15 << 4));
    60   status = static_cast<unsigned char>(status | (value << 4));
     58  status = static_cast< unsigned char >(status & ~(15 << 4));
     59  status = static_cast< unsigned char >(status | (value << 4));
    6160}
    6261inline void setInitialStatus(unsigned char &status)
    6362{
    64   status = static_cast<unsigned char>(CLP_FEASIBLE | (CLP_SAME << 4));
     63  status = static_cast< unsigned char >(CLP_FEASIBLE | (CLP_SAME << 4));
    6564}
    6665inline void setSameStatus(unsigned char &status)
    6766{
    68   status = static_cast<unsigned char>(status & ~(15 << 4));
    69   status = static_cast<unsigned char>(status | (CLP_SAME << 4));
     67  status = static_cast< unsigned char >(status & ~(15 << 4));
     68  status = static_cast< unsigned char >(status | (CLP_SAME << 4));
    7069}
    7170#endif
    72 class AbcNonLinearCost  {
    73  
     71class AbcNonLinearCost {
     72
    7473public:
    75  
    7674  /**@name Constructors, destructor */
    7775  //@{
     
    8280      later may do dual analysis and even finding duplicate columns .
    8381  */
    84   AbcNonLinearCost(AbcSimplex * model);
     82  AbcNonLinearCost(AbcSimplex *model);
    8583  /// Destructor
    8684  ~AbcNonLinearCost();
    8785  // Copy
    88   AbcNonLinearCost(const AbcNonLinearCost&);
     86  AbcNonLinearCost(const AbcNonLinearCost &);
    8987  // Assignment
    90   AbcNonLinearCost& operator=(const AbcNonLinearCost&);
    91   //@}
    92  
    93  
     88  AbcNonLinearCost &operator=(const AbcNonLinearCost &);
     89  //@}
     90
    9491  /**@name Actual work in primal */
    9592  //@{
     
    10299      The indices are row indices and need converting to sequences
    103100  */
    104   void checkInfeasibilities(int numberInArray, const int * index);
     101  void checkInfeasibilities(int numberInArray, const int *index);
    105102  /** Puts back correct infeasible costs for each variable
    106103      The input indices are row indices and need converting to sequences
     
    109106      changed costs will be stored as normal CoinIndexedVector
    110107  */
    111   void checkChanged(int numberInArray, CoinIndexedVector * update);
     108  void checkChanged(int numberInArray, CoinIndexedVector *update);
    112109  /** Goes through one bound for each variable.
    113110      If multiplier*work[iRow]>0 goes down, otherwise up.
     
    117114  */
    118115  void goThru(int numberInArray, double multiplier,
    119               const int * index, const double * work,
    120               double * rhs);
     116    const int *index, const double *work,
     117    double *rhs);
    121118  /** Takes off last iteration (i.e. offsets closer to 0)
    122119   */
    123   void goBack(int numberInArray, const int * index,
    124               double * rhs);
     120  void goBack(int numberInArray, const int *index,
     121    double *rhs);
    125122  /** Puts back correct infeasible costs for each variable
    126123      The input indices are row indices and need converting to sequences
     
    128125      At the end of this all temporary offsets are zero
    129126  */
    130   void goBackAll(const CoinIndexedVector * update);
     127  void goBackAll(const CoinIndexedVector *update);
    131128  /// Temporary zeroing of feasible costs
    132129  void zapCosts();
    133130  /// Refreshes costs always makes row costs zero
    134   void refreshCosts(const double * columnCosts);
     131  void refreshCosts(const double *columnCosts);
    135132  /// Puts feasible bounds into lower and upper
    136133  void feasibleBounds();
     
    156153      Value is current - new
    157154  */
    158   inline double changeInCost(int /*sequence*/, double alpha) const {
     155  inline double changeInCost(int /*sequence*/, double alpha) const
     156  {
    159157    return (alpha > 0.0) ? infeasibilityWeight_ : -infeasibilityWeight_;
    160158  }
    161   inline double changeUpInCost(int /*sequence*/) const {
     159  inline double changeUpInCost(int /*sequence*/) const
     160  {
    162161    return -infeasibilityWeight_;
    163162  }
    164   inline double changeDownInCost(int /*sequence*/) const {
     163  inline double changeDownInCost(int /*sequence*/) const
     164  {
    165165    return infeasibilityWeight_;
    166166  }
    167167  /// This also updates next bound
    168   inline double changeInCost(int iRow, double alpha, double &rhs) {
    169     int sequence=model_->pivotVariable()[iRow];
     168  inline double changeInCost(int iRow, double alpha, double &rhs)
     169  {
     170    int sequence = model_->pivotVariable()[iRow];
    170171    double returnValue = 0.0;
    171172    unsigned char iStatus = status_[sequence];
     
    176177    if (iWhere == CLP_FEASIBLE) {
    177178      if (alpha > 0.0) {
    178         // going below
    179         iWhere = CLP_BELOW_LOWER;
    180         rhs = COIN_DBL_MAX;
     179        // going below
     180        iWhere = CLP_BELOW_LOWER;
     181        rhs = COIN_DBL_MAX;
    181182      } else {
    182         // going above
    183         iWhere = CLP_ABOVE_UPPER;
    184         rhs = COIN_DBL_MAX;
     183        // going above
     184        iWhere = CLP_ABOVE_UPPER;
     185        rhs = COIN_DBL_MAX;
    185186      }
    186187    } else if (iWhere == CLP_BELOW_LOWER) {
    187       assert (alpha < 0);
     188      assert(alpha < 0);
    188189      // going feasible
    189190      iWhere = CLP_FEASIBLE;
    190191      rhs += bound_[sequence] - model_->upperRegion()[sequence];
    191192    } else {
    192       assert (iWhere == CLP_ABOVE_UPPER);
     193      assert(iWhere == CLP_ABOVE_UPPER);
    193194      // going feasible
    194195      iWhere = CLP_FEASIBLE;
     
    200201  }
    201202  //@}
    202  
    203  
     203
    204204  /**@name Gets and sets */
    205205  //@{
    206206  /// Number of infeasibilities
    207   inline int numberInfeasibilities() const {
     207  inline int numberInfeasibilities() const
     208  {
    208209    return numberInfeasibilities_;
    209210  }
    210211  /// Change in cost
    211   inline double changeInCost() const {
     212  inline double changeInCost() const
     213  {
    212214    return changeCost_;
    213215  }
    214216  /// Feasible cost
    215   inline double feasibleCost() const {
     217  inline double feasibleCost() const
     218  {
    216219    return feasibleCost_;
    217220  }
     
    219222  double feasibleReportCost() const;
    220223  /// Sum of infeasibilities
    221   inline double sumInfeasibilities() const {
     224  inline double sumInfeasibilities() const
     225  {
    222226    return sumInfeasibilities_;
    223227  }
    224228  /// Largest infeasibility
    225   inline double largestInfeasibility() const {
     229  inline double largestInfeasibility() const
     230  {
    226231    return largestInfeasibility_;
    227232  }
    228233  /// Average theta
    229   inline double averageTheta() const {
     234  inline double averageTheta() const
     235  {
    230236    return averageTheta_;
    231237  }
    232   inline void setAverageTheta(double value) {
     238  inline void setAverageTheta(double value)
     239  {
    233240    averageTheta_ = value;
    234241  }
    235   inline void setChangeInCost(double value) {
     242  inline void setChangeInCost(double value)
     243  {
    236244    changeCost_ = value;
    237245  }
    238246  //@}
    239247  ///@name Private functions to deal with infeasible regions
    240   inline unsigned char * statusArray() const {
     248  inline unsigned char *statusArray() const
     249  {
    241250    return status_;
    242251  }
    243252  inline int getCurrentStatus(int sequence)
    244   {return (status_[sequence] >> 4);}
     253  {
     254    return (status_[sequence] >> 4);
     255  }
    245256  /// For debug
    246257  void validate();
    247258  //@}
    248  
     259
    249260private:
    250261  /**@name Data members */
     
    267278  int numberColumns_;
    268279  /// Model
    269   AbcSimplex * model_;
     280  AbcSimplex *model_;
    270281  /// Number of infeasibilities found
    271282  int numberInfeasibilities_;
    272283  // new stuff
    273284  /// Contains status at beginning and current
    274   unsigned char * status_;
     285  unsigned char *status_;
    275286  /// Bound which has been replaced in lower_ or upper_
    276   double * bound_;
     287  double *bound_;
    277288  /// Feasible cost array
    278   double * cost_;
     289  double *cost_;
    279290  //@}
    280291};
    281292
    282293#endif
     294
     295/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
     296*/
Note: See TracChangeset for help on using the changeset viewer.