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

    r2259 r2385  
    1515class ClpPresolve {
    1616public:
    17      /**@name Main Constructor, destructor */
    18      //@{
    19      /// Default constructor
    20      ClpPresolve();
    21 
    22      /// Virtual destructor
    23      virtual ~ClpPresolve();
    24      //@}
    25      /**@name presolve - presolves a model, transforming the model
     17  /**@name Main Constructor, destructor */
     18  //@{
     19  /// Default constructor
     20  ClpPresolve();
     21
     22  /// Virtual destructor
     23  virtual ~ClpPresolve();
     24  //@}
     25  /**@name presolve - presolves a model, transforming the model
    2626      * and saving information in the ClpPresolve object needed for postsolving.
    2727      * This underlying (protected) method is virtual; the idea is that in the future,
     
    3939         Names will be dropped in presolved model if asked
    4040     */
    41      ClpSimplex * presolvedModel(ClpSimplex & si,
    42                                  double feasibilityTolerance = 0.0,
    43                                  bool keepIntegers = true,
    44                                  int numberPasses = 5,
    45                                  bool dropNames = false,
    46                                  bool doRowObjective = false,
    47                                  const char * prohibitedRows=NULL,
    48                                  const char * prohibitedColumns=NULL);
     41  ClpSimplex *presolvedModel(ClpSimplex &si,
     42    double feasibilityTolerance = 0.0,
     43    bool keepIntegers = true,
     44    int numberPasses = 5,
     45    bool dropNames = false,
     46    bool doRowObjective = false,
     47    const char *prohibitedRows = NULL,
     48    const char *prohibitedColumns = NULL);
    4949#ifndef CLP_NO_STD
    50      /** This version saves data in a file.  The passed in model
     50  /** This version saves data in a file.  The passed in model
    5151         is updated to be presolved model. 
    5252         Returns non-zero if infeasible*/
    53      int presolvedModelToFile(ClpSimplex &si, std::string fileName,
    54                               double feasibilityTolerance = 0.0,
    55                               bool keepIntegers = true,
    56                               int numberPasses = 5,
    57                               bool dropNames = false,
    58                               bool doRowObjective = false);
     53  int presolvedModelToFile(ClpSimplex &si, std::string fileName,
     54    double feasibilityTolerance = 0.0,
     55    bool keepIntegers = true,
     56    int numberPasses = 5,
     57    bool dropNames = false,
     58    bool doRowObjective = false);
    5959#endif
    60      /** Return pointer to presolved model,
     60  /** Return pointer to presolved model,
    6161         Up to user to destroy */
    62      ClpSimplex * model() const;
    63      /// Return pointer to original model
    64      ClpSimplex * originalModel() const;
    65      /// Set pointer to original model
    66      void setOriginalModel(ClpSimplex * model);
    67 
    68      /// return pointer to original columns
    69      const int * originalColumns() const;
    70      /// return pointer to original rows
    71      const int * originalRows() const;
    72      /** "Magic" number. If this is non-zero then any elements with this value
     62  ClpSimplex *model() const;
     63  /// Return pointer to original model
     64  ClpSimplex *originalModel() const;
     65  /// Set pointer to original model
     66  void setOriginalModel(ClpSimplex *model);
     67
     68  /// return pointer to original columns
     69  const int *originalColumns() const;
     70  /// return pointer to original rows
     71  const int *originalRows() const;
     72  /** "Magic" number. If this is non-zero then any elements with this value
    7373         may change and so presolve is very limited in what can be done
    7474         to the row and column.  This is for non-linear problems.
    7575     */
    76      inline void setNonLinearValue(double value) {
    77           nonLinearValue_ = value;
    78      }
    79      inline double nonLinearValue() const {
    80           return nonLinearValue_;
    81      }
    82      /// Whether we want to do dual part of presolve
    83      inline bool doDual() const {
    84           return (presolveActions_ & 1) == 0;
    85      }
    86      inline void setDoDual(bool doDual) {
    87           if (doDual) presolveActions_  &= ~1;
    88           else presolveActions_ |= 1;
    89      }
    90      /// Whether we want to do singleton part of presolve
    91      inline bool doSingleton() const {
    92           return (presolveActions_ & 2) == 0;
    93      }
    94      inline void setDoSingleton(bool doSingleton) {
    95           if (doSingleton) presolveActions_  &= ~2;
    96           else presolveActions_ |= 2;
    97      }
    98      /// Whether we want to do doubleton part of presolve
    99      inline bool doDoubleton() const {
    100           return (presolveActions_ & 4) == 0;
    101      }
    102      inline void setDoDoubleton(bool doDoubleton) {
    103           if (doDoubleton) presolveActions_  &= ~4;
    104           else presolveActions_ |= 4;
    105      }
    106      /// Whether we want to do tripleton part of presolve
    107      inline bool doTripleton() const {
    108           return (presolveActions_ & 8) == 0;
    109      }
    110      inline void setDoTripleton(bool doTripleton) {
    111           if (doTripleton) presolveActions_  &= ~8;
    112           else presolveActions_ |= 8;
    113      }
    114      /// Whether we want to do tighten part of presolve
    115      inline bool doTighten() const {
    116           return (presolveActions_ & 16) == 0;
    117      }
    118      inline void setDoTighten(bool doTighten) {
    119           if (doTighten) presolveActions_  &= ~16;
    120           else presolveActions_ |= 16;
    121      }
    122      /// Whether we want to do forcing part of presolve
    123      inline bool doForcing() const {
    124           return (presolveActions_ & 32) == 0;
    125      }
    126      inline void setDoForcing(bool doForcing) {
    127           if (doForcing) presolveActions_  &= ~32;
    128           else presolveActions_ |= 32;
    129      }
    130      /// Whether we want to do impliedfree part of presolve
    131      inline bool doImpliedFree() const {
    132           return (presolveActions_ & 64) == 0;
    133      }
    134      inline void setDoImpliedFree(bool doImpliedfree) {
    135           if (doImpliedfree) presolveActions_  &= ~64;
    136           else presolveActions_ |= 64;
    137      }
    138      /// Whether we want to do dupcol part of presolve
    139      inline bool doDupcol() const {
    140           return (presolveActions_ & 128) == 0;
    141      }
    142      inline void setDoDupcol(bool doDupcol) {
    143           if (doDupcol) presolveActions_  &= ~128;
    144           else presolveActions_ |= 128;
    145      }
    146      /// Whether we want to do duprow part of presolve
    147      inline bool doDuprow() const {
    148           return (presolveActions_ & 256) == 0;
    149      }
    150      inline void setDoDuprow(bool doDuprow) {
    151           if (doDuprow) presolveActions_  &= ~256;
    152           else presolveActions_ |= 256;
    153      }
    154      /// Whether we want to do dependency part of presolve
    155      inline bool doDependency() const {
    156           return (presolveActions_ & 32768) != 0;
    157      }
    158      inline void setDoDependency(bool doDependency) {
    159           if (doDependency) presolveActions_  |= 32768;
    160           else presolveActions_ &= ~32768;
    161      }
    162      /// Whether we want to do transfer part of presolve
    163      inline bool doTransfer() const {
    164           return (presolveActions_ & 65536) != 0;
    165      }
    166      inline void setDoTransfer(bool doTransfer) {
    167           if (doTransfer) presolveActions_  |= 65536;
    168           else presolveActions_ &= ~65536;
    169      }
    170      /// Whether we want to do singleton column part of presolve
    171      inline bool doSingletonColumn() const {
    172           return (presolveActions_ & 512) == 0;
    173      }
    174      inline void setDoSingletonColumn(bool doSingleton) {
    175           if (doSingleton) presolveActions_  &= ~512;
    176           else presolveActions_ |= 512;
    177      }
    178      /// Whether we want to do gubrow part of presolve
    179      inline bool doGubrow() const {
    180           return (presolveActions_ & 1024) == 0;
    181      }
    182      inline void setDoGubrow(bool doGubrow) {
    183           if (doGubrow) presolveActions_  &= ~1024;
    184           else presolveActions_ |= 1024;
    185      }
    186      /// Whether we want to do twoxtwo part of presolve
    187      inline bool doTwoxTwo() const {
    188           return (presolveActions_ & 2048) != 0;
    189      }
    190      inline void setDoTwoxtwo(bool doTwoxTwo) {
    191           if (!doTwoxTwo) presolveActions_  &= ~2048;
    192           else presolveActions_ |= 2048;
    193      }
    194      /// Whether we want to allow duplicate intersections
    195      inline bool doIntersection() const {
    196           return (presolveActions_ & 4096) != 0;
    197      }
    198      inline void setDoIntersection(bool doIntersection) {
    199           if (doIntersection) presolveActions_  &= ~4096;
    200           else presolveActions_ |= 4096;
    201      }
    202      /** How much we want to zero small values from aggregation - ratio
     76  inline void setNonLinearValue(double value)
     77  {
     78    nonLinearValue_ = value;
     79  }
     80  inline double nonLinearValue() const
     81  {
     82    return nonLinearValue_;
     83  }
     84  /// Whether we want to do dual part of presolve
     85  inline bool doDual() const
     86  {
     87    return (presolveActions_ & 1) == 0;
     88  }
     89  inline void setDoDual(bool doDual)
     90  {
     91    if (doDual)
     92      presolveActions_ &= ~1;
     93    else
     94      presolveActions_ |= 1;
     95  }
     96  /// Whether we want to do singleton part of presolve
     97  inline bool doSingleton() const
     98  {
     99    return (presolveActions_ & 2) == 0;
     100  }
     101  inline void setDoSingleton(bool doSingleton)
     102  {
     103    if (doSingleton)
     104      presolveActions_ &= ~2;
     105    else
     106      presolveActions_ |= 2;
     107  }
     108  /// Whether we want to do doubleton part of presolve
     109  inline bool doDoubleton() const
     110  {
     111    return (presolveActions_ & 4) == 0;
     112  }
     113  inline void setDoDoubleton(bool doDoubleton)
     114  {
     115    if (doDoubleton)
     116      presolveActions_ &= ~4;
     117    else
     118      presolveActions_ |= 4;
     119  }
     120  /// Whether we want to do tripleton part of presolve
     121  inline bool doTripleton() const
     122  {
     123    return (presolveActions_ & 8) == 0;
     124  }
     125  inline void setDoTripleton(bool doTripleton)
     126  {
     127    if (doTripleton)
     128      presolveActions_ &= ~8;
     129    else
     130      presolveActions_ |= 8;
     131  }
     132  /// Whether we want to do tighten part of presolve
     133  inline bool doTighten() const
     134  {
     135    return (presolveActions_ & 16) == 0;
     136  }
     137  inline void setDoTighten(bool doTighten)
     138  {
     139    if (doTighten)
     140      presolveActions_ &= ~16;
     141    else
     142      presolveActions_ |= 16;
     143  }
     144  /// Whether we want to do forcing part of presolve
     145  inline bool doForcing() const
     146  {
     147    return (presolveActions_ & 32) == 0;
     148  }
     149  inline void setDoForcing(bool doForcing)
     150  {
     151    if (doForcing)
     152      presolveActions_ &= ~32;
     153    else
     154      presolveActions_ |= 32;
     155  }
     156  /// Whether we want to do impliedfree part of presolve
     157  inline bool doImpliedFree() const
     158  {
     159    return (presolveActions_ & 64) == 0;
     160  }
     161  inline void setDoImpliedFree(bool doImpliedfree)
     162  {
     163    if (doImpliedfree)
     164      presolveActions_ &= ~64;
     165    else
     166      presolveActions_ |= 64;
     167  }
     168  /// Whether we want to do dupcol part of presolve
     169  inline bool doDupcol() const
     170  {
     171    return (presolveActions_ & 128) == 0;
     172  }
     173  inline void setDoDupcol(bool doDupcol)
     174  {
     175    if (doDupcol)
     176      presolveActions_ &= ~128;
     177    else
     178      presolveActions_ |= 128;
     179  }
     180  /// Whether we want to do duprow part of presolve
     181  inline bool doDuprow() const
     182  {
     183    return (presolveActions_ & 256) == 0;
     184  }
     185  inline void setDoDuprow(bool doDuprow)
     186  {
     187    if (doDuprow)
     188      presolveActions_ &= ~256;
     189    else
     190      presolveActions_ |= 256;
     191  }
     192  /// Whether we want to do dependency part of presolve
     193  inline bool doDependency() const
     194  {
     195    return (presolveActions_ & 32768) != 0;
     196  }
     197  inline void setDoDependency(bool doDependency)
     198  {
     199    if (doDependency)
     200      presolveActions_ |= 32768;
     201    else
     202      presolveActions_ &= ~32768;
     203  }
     204  /// Whether we want to do transfer part of presolve
     205  inline bool doTransfer() const
     206  {
     207    return (presolveActions_ & 65536) != 0;
     208  }
     209  inline void setDoTransfer(bool doTransfer)
     210  {
     211    if (doTransfer)
     212      presolveActions_ |= 65536;
     213    else
     214      presolveActions_ &= ~65536;
     215  }
     216  /// Whether we want to do singleton column part of presolve
     217  inline bool doSingletonColumn() const
     218  {
     219    return (presolveActions_ & 512) == 0;
     220  }
     221  inline void setDoSingletonColumn(bool doSingleton)
     222  {
     223    if (doSingleton)
     224      presolveActions_ &= ~512;
     225    else
     226      presolveActions_ |= 512;
     227  }
     228  /// Whether we want to do gubrow part of presolve
     229  inline bool doGubrow() const
     230  {
     231    return (presolveActions_ & 1024) == 0;
     232  }
     233  inline void setDoGubrow(bool doGubrow)
     234  {
     235    if (doGubrow)
     236      presolveActions_ &= ~1024;
     237    else
     238      presolveActions_ |= 1024;
     239  }
     240  /// Whether we want to do twoxtwo part of presolve
     241  inline bool doTwoxTwo() const
     242  {
     243    return (presolveActions_ & 2048) != 0;
     244  }
     245  inline void setDoTwoxtwo(bool doTwoxTwo)
     246  {
     247    if (!doTwoxTwo)
     248      presolveActions_ &= ~2048;
     249    else
     250      presolveActions_ |= 2048;
     251  }
     252  /// Whether we want to allow duplicate intersections
     253  inline bool doIntersection() const
     254  {
     255    return (presolveActions_ & 4096) != 0;
     256  }
     257  inline void setDoIntersection(bool doIntersection)
     258  {
     259    if (doIntersection)
     260      presolveActions_ &= ~4096;
     261    else
     262      presolveActions_ |= 4096;
     263  }
     264  /** How much we want to zero small values from aggregation - ratio
    203265         0 - 1.0e-12, 1 1.0e-11, 2 1.0e-10, 3 1.0e-9 */
    204      inline int zeroSmall() const {
    205           return (presolveActions_&(8192|16384))>>13;
    206      }
    207      inline void setZeroSmall(int value) {
    208          presolveActions_  &= ~(8192|16384);
    209          presolveActions_ |= value<<13;
    210      }
    211      /// Set whole group
    212      inline int presolveActions() const {
    213           return presolveActions_ & 0xffffff;
    214      }
    215      inline void setPresolveActions(int action) {
    216           presolveActions_  = (presolveActions_ & 0xff000000) | (action & 0xffffff);
    217      }
    218      /// Substitution level
    219      inline void setSubstitution(int value) {
    220           substitution_ = value;
    221      }
    222      /// Asks for statistics
    223      inline void statistics() {
    224           presolveActions_ |= 0x80000000;
    225      }
    226      /// Return presolve status (0,1,2)
    227      int presolveStatus() const;
    228 
    229      /**@name postsolve - postsolve the problem.  If the problem
     266  inline int zeroSmall() const
     267  {
     268    return (presolveActions_ & (8192 | 16384)) >> 13;
     269  }
     270  inline void setZeroSmall(int value)
     271  {
     272    presolveActions_ &= ~(8192 | 16384);
     273    presolveActions_ |= value << 13;
     274  }
     275  /// Set whole group
     276  inline int presolveActions() const
     277  {
     278    return presolveActions_ & 0xffffff;
     279  }
     280  inline void setPresolveActions(int action)
     281  {
     282    presolveActions_ = (presolveActions_ & 0xff000000) | (action & 0xffffff);
     283  }
     284  /// Substitution level
     285  inline void setSubstitution(int value)
     286  {
     287    substitution_ = value;
     288  }
     289  /// Asks for statistics
     290  inline void statistics()
     291  {
     292    presolveActions_ |= 0x80000000;
     293  }
     294  /// Return presolve status (0,1,2)
     295  int presolveStatus() const;
     296
     297  /**@name postsolve - postsolve the problem.  If the problem
    230298       has not been solved to optimality, there are no guarantees.
    231299      If you are using an algorithm like simplex that has a concept
     
    235303      then you must ``undo'' these modifications before calling postsolve.
    236304     This version updates original*/
    237      virtual void postsolve(bool updateStatus = true);
    238 
    239      /// Gets rid of presolve actions (e.g.when infeasible)
    240      void destroyPresolve();
    241 
    242      /**@name private or protected data */
     305  virtual void postsolve(bool updateStatus = true);
     306
     307  /// Gets rid of presolve actions (e.g.when infeasible)
     308  void destroyPresolve();
     309
     310  /**@name private or protected data */
    243311private:
    244      /// Original model - must not be destroyed before postsolve
    245      ClpSimplex * originalModel_;
    246 
    247      /// ClpPresolved model - up to user to destroy by deleteClpPresolvedModel
    248      ClpSimplex * presolvedModel_;
    249      /** "Magic" number. If this is non-zero then any elements with this value
     312  /// Original model - must not be destroyed before postsolve
     313  ClpSimplex *originalModel_;
     314
     315  /// ClpPresolved model - up to user to destroy by deleteClpPresolvedModel
     316  ClpSimplex *presolvedModel_;
     317  /** "Magic" number. If this is non-zero then any elements with this value
    250318         may change and so presolve is very limited in what can be done
    251319         to the row and column.  This is for non-linear problems.
    252320         One could also allow for cases where sign of coefficient is known.
    253321     */
    254      double nonLinearValue_;
    255      /// Original column numbers
    256      int * originalColumn_;
    257      /// Original row numbers
    258      int * originalRow_;
    259      /// Row objective
    260      double * rowObjective_;
    261      /// The list of transformations applied.
    262      const CoinPresolveAction *paction_;
    263 
    264      /// The postsolved problem will expand back to its former size
    265      /// as postsolve transformations are applied.
    266      /// It is efficient to allocate data structures for the final size
    267      /// of the problem rather than expand them as needed.
    268      /// These fields give the size of the original problem.
    269      int ncols_;
    270      int nrows_;
    271      CoinBigIndex nelems_;
    272      /// Number of major passes
    273      int numberPasses_;
    274      /// Substitution level
    275      int substitution_;
     322  double nonLinearValue_;
     323  /// Original column numbers
     324  int *originalColumn_;
     325  /// Original row numbers
     326  int *originalRow_;
     327  /// Row objective
     328  double *rowObjective_;
     329  /// The list of transformations applied.
     330  const CoinPresolveAction *paction_;
     331
     332  /// The postsolved problem will expand back to its former size
     333  /// as postsolve transformations are applied.
     334  /// It is efficient to allocate data structures for the final size
     335  /// of the problem rather than expand them as needed.
     336  /// These fields give the size of the original problem.
     337  int ncols_;
     338  int nrows_;
     339  CoinBigIndex nelems_;
     340  /// Number of major passes
     341  int numberPasses_;
     342  /// Substitution level
     343  int substitution_;
    276344#ifndef CLP_NO_STD
    277      /// Name of saved model file
    278      std::string saveFile_;
     345  /// Name of saved model file
     346  std::string saveFile_;
    279347#endif
    280      /** Whether we want to skip dual part of presolve etc.
     348  /** Whether we want to skip dual part of presolve etc.
    281349         512 bit allows duplicate column processing on integer columns
    282350         and dual stuff on integers
    283351     */
    284      int presolveActions_;
     352  int presolveActions_;
     353
    285354protected:
    286      /// If you want to apply the individual presolve routines differently,
    287      /// or perhaps add your own to the mix,
    288      /// define a derived class and override this method
    289      virtual const CoinPresolveAction *presolve(CoinPresolveMatrix *prob);
    290 
    291      /// Postsolving is pretty generic; just apply the transformations
    292      /// in reverse order.
    293      /// You will probably only be interested in overriding this method
    294      /// if you want to add code to test for consistency
    295      /// while debugging new presolve techniques.
    296      virtual void postsolve(CoinPostsolveMatrix &prob);
    297      /** This is main part of Presolve */
    298      virtual ClpSimplex * gutsOfPresolvedModel(ClpSimplex * originalModel,
    299                double feasibilityTolerance,
    300                bool keepIntegers,
    301                int numberPasses,
    302                bool dropNames,
    303                                                bool doRowObjective,
    304                                                const char * prohibitedRows=NULL,
    305                                                const char * prohibitedColumns=NULL);
     355  /// If you want to apply the individual presolve routines differently,
     356  /// or perhaps add your own to the mix,
     357  /// define a derived class and override this method
     358  virtual const CoinPresolveAction *presolve(CoinPresolveMatrix *prob);
     359
     360  /// Postsolving is pretty generic; just apply the transformations
     361  /// in reverse order.
     362  /// You will probably only be interested in overriding this method
     363  /// if you want to add code to test for consistency
     364  /// while debugging new presolve techniques.
     365  virtual void postsolve(CoinPostsolveMatrix &prob);
     366  /** This is main part of Presolve */
     367  virtual ClpSimplex *gutsOfPresolvedModel(ClpSimplex *originalModel,
     368    double feasibilityTolerance,
     369    bool keepIntegers,
     370    int numberPasses,
     371    bool dropNames,
     372    bool doRowObjective,
     373    const char *prohibitedRows = NULL,
     374    const char *prohibitedColumns = NULL);
    306375};
    307376#endif
     377
     378/* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
     379*/
Note: See TracChangeset for help on using the changeset viewer.