| 1 | /* $Id: CoinPresolveZeros.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 CoinPresolveZeros_H | 
|---|
| 7 | #define CoinPresolveZeros_H | 
|---|
| 8 |  | 
|---|
| 9 | /*! \file | 
|---|
| 10 |  | 
|---|
| 11 | Drop/reintroduce explicit zeros. | 
|---|
| 12 | */ | 
|---|
| 13 |  | 
|---|
| 14 | #define	DROP_ZERO	8 | 
|---|
| 15 |  | 
|---|
| 16 | /*! \brief Tracking information for an explicit zero coefficient | 
|---|
| 17 |  | 
|---|
| 18 | \todo Why isn't this a nested class in drop_zero_coefficients_action? | 
|---|
| 19 | That would match the structure of other presolve classes. | 
|---|
| 20 | */ | 
|---|
| 21 |  | 
|---|
| 22 | struct dropped_zero { | 
|---|
| 23 | int row; | 
|---|
| 24 | int col; | 
|---|
| 25 | }; | 
|---|
| 26 |  | 
|---|
| 27 | /*! \brief Removal of explicit zeros | 
|---|
| 28 |  | 
|---|
| 29 | The presolve action for this class removes explicit zeros from the constraint | 
|---|
| 30 | matrix. The postsolve action puts them back. | 
|---|
| 31 | */ | 
|---|
| 32 | class drop_zero_coefficients_action : public CoinPresolveAction { | 
|---|
| 33 |  | 
|---|
| 34 | const int nzeros_; | 
|---|
| 35 | const dropped_zero *const zeros_; | 
|---|
| 36 |  | 
|---|
| 37 | drop_zero_coefficients_action(int nzeros, | 
|---|
| 38 | const dropped_zero *zeros, | 
|---|
| 39 | const CoinPresolveAction *next) : | 
|---|
| 40 | CoinPresolveAction(next), | 
|---|
| 41 | nzeros_(nzeros), zeros_(zeros) | 
|---|
| 42 | {} | 
|---|
| 43 |  | 
|---|
| 44 | public: | 
|---|
| 45 | const char *name() const { return ( "drop_zero_coefficients_action"); } | 
|---|
| 46 |  | 
|---|
| 47 | static const CoinPresolveAction *presolve(CoinPresolveMatrix *prob, | 
|---|
| 48 | int *checkcols, | 
|---|
| 49 | int ncheckcols, | 
|---|
| 50 | const CoinPresolveAction *next); | 
|---|
| 51 |  | 
|---|
| 52 | void postsolve(CoinPostsolveMatrix *prob) const; | 
|---|
| 53 |  | 
|---|
| 54 | ~drop_zero_coefficients_action() { deleteAction(zeros_,dropped_zero*); } | 
|---|
| 55 | }; | 
|---|
| 56 |  | 
|---|
| 57 | const CoinPresolveAction *drop_zero_coefficients(CoinPresolveMatrix *prob, | 
|---|
| 58 | const CoinPresolveAction *next); | 
|---|
| 59 |  | 
|---|
| 60 | #endif | 
|---|
| 61 |  | 
|---|