| 1 | /* $Id: CoinPresolveEmpty.hpp 1372 2011-01-03 23:31:00Z lou $ */ | 
|---|
| 2 | // Copyright (C) 2002, International Business Machines | 
|---|
| 3 | // Corporation and others.  All Rights Reserved. | 
|---|
| 4 | // This code is licensed under the terms of the Eclipse Public License (EPL). | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef CoinPresolveEmpty_H | 
|---|
| 7 | #define CoinPresolveEmpty_H | 
|---|
| 8 |  | 
|---|
| 9 | /*! \file | 
|---|
| 10 |  | 
|---|
| 11 | Drop/reinsert empty rows/columns. | 
|---|
| 12 | */ | 
|---|
| 13 |  | 
|---|
| 14 | const int DROP_ROW = 3; | 
|---|
| 15 | const int DROP_COL = 4; | 
|---|
| 16 |  | 
|---|
| 17 | /*! \class drop_empty_cols_action | 
|---|
| 18 | \brief Physically removes empty columns in presolve, and reinserts | 
|---|
| 19 | empty columns in postsolve. | 
|---|
| 20 |  | 
|---|
| 21 | Physical removal of rows and columns should be the last activities | 
|---|
| 22 | performed during presolve. Do them exactly once. The row-major matrix | 
|---|
| 23 | is <b>not</b> maintained by this transform. | 
|---|
| 24 |  | 
|---|
| 25 | To physically drop the columns, CoinPrePostsolveMatrix::mcstrt_ and | 
|---|
| 26 | CoinPrePostsolveMatrix::hincol_ are compressed, along with column bounds, | 
|---|
| 27 | objective, and (if present) the column portions of the solution. This | 
|---|
| 28 | renumbers the columns. drop_empty_cols_action::presolve will reconstruct | 
|---|
| 29 | CoinPresolveMatrix::clink_. | 
|---|
| 30 |  | 
|---|
| 31 | \todo Confirm correct behaviour with solution in presolve. | 
|---|
| 32 | */ | 
|---|
| 33 |  | 
|---|
| 34 | class drop_empty_cols_action : public CoinPresolveAction { | 
|---|
| 35 | private: | 
|---|
| 36 | const int nactions_; | 
|---|
| 37 |  | 
|---|
| 38 | struct action { | 
|---|
| 39 | double clo; | 
|---|
| 40 | double cup; | 
|---|
| 41 | double cost; | 
|---|
| 42 | double sol; | 
|---|
| 43 | int jcol; | 
|---|
| 44 | }; | 
|---|
| 45 | const action *const actions_; | 
|---|
| 46 |  | 
|---|
| 47 | drop_empty_cols_action(int nactions, | 
|---|
| 48 | const action *const actions, | 
|---|
| 49 | const CoinPresolveAction *next) : | 
|---|
| 50 | CoinPresolveAction(next), | 
|---|
| 51 | nactions_(nactions), | 
|---|
| 52 | actions_(actions) | 
|---|
| 53 | {} | 
|---|
| 54 |  | 
|---|
| 55 | public: | 
|---|
| 56 | const char *name() const { return ( "drop_empty_cols_action"); } | 
|---|
| 57 |  | 
|---|
| 58 | static const CoinPresolveAction *presolve(CoinPresolveMatrix *, | 
|---|
| 59 | int *ecols, | 
|---|
| 60 | int necols, | 
|---|
| 61 | const CoinPresolveAction*); | 
|---|
| 62 |  | 
|---|
| 63 | static const CoinPresolveAction *presolve(CoinPresolveMatrix *prob, | 
|---|
| 64 | const CoinPresolveAction *next); | 
|---|
| 65 |  | 
|---|
| 66 | void postsolve(CoinPostsolveMatrix *prob) const; | 
|---|
| 67 |  | 
|---|
| 68 | ~drop_empty_cols_action() { deleteAction(actions_,action*); } | 
|---|
| 69 | }; | 
|---|
| 70 |  | 
|---|
| 71 |  | 
|---|
| 72 | /*! \class drop_empty_rows_action | 
|---|
| 73 | \brief Physically removes empty rows in presolve, and reinserts | 
|---|
| 74 | empty rows in postsolve. | 
|---|
| 75 |  | 
|---|
| 76 | Physical removal of rows and columns should be the last activities | 
|---|
| 77 | performed during presolve. Do them exactly once. The row-major matrix | 
|---|
| 78 | is <b>not</b> maintained by this transform. | 
|---|
| 79 |  | 
|---|
| 80 | To physically drop the rows, the rows are renumbered, excluding empty | 
|---|
| 81 | rows. This involves rewriting CoinPrePostsolveMatrix::hrow_ and compressing | 
|---|
| 82 | the row bounds and (if present) the row portions of the solution. | 
|---|
| 83 |  | 
|---|
| 84 | \todo Confirm behaviour when a solution is present in presolve. | 
|---|
| 85 | */ | 
|---|
| 86 | class drop_empty_rows_action : public CoinPresolveAction { | 
|---|
| 87 | private: | 
|---|
| 88 | struct action { | 
|---|
| 89 | double rlo; | 
|---|
| 90 | double rup; | 
|---|
| 91 | int row; | 
|---|
| 92 | int fill_row;	// which row was moved into position row to fill it | 
|---|
| 93 | }; | 
|---|
| 94 |  | 
|---|
| 95 | const int nactions_; | 
|---|
| 96 | const action *const actions_; | 
|---|
| 97 |  | 
|---|
| 98 | drop_empty_rows_action(int nactions, | 
|---|
| 99 | const action *actions, | 
|---|
| 100 | const CoinPresolveAction *next) : | 
|---|
| 101 | CoinPresolveAction(next), | 
|---|
| 102 | nactions_(nactions), actions_(actions) | 
|---|
| 103 | {} | 
|---|
| 104 |  | 
|---|
| 105 | public: | 
|---|
| 106 | const char *name() const { return ( "drop_empty_rows_action"); } | 
|---|
| 107 |  | 
|---|
| 108 | static const CoinPresolveAction *presolve(CoinPresolveMatrix *prob, | 
|---|
| 109 | const CoinPresolveAction *next); | 
|---|
| 110 |  | 
|---|
| 111 | void postsolve(CoinPostsolveMatrix *prob) const; | 
|---|
| 112 |  | 
|---|
| 113 | ~drop_empty_rows_action() { deleteAction(actions_,action*); } | 
|---|
| 114 | }; | 
|---|
| 115 | #endif | 
|---|
| 116 |  | 
|---|