1 /* $Id: CoinPresolveSingleton.hpp 2083 2019-01-06 19:38:09Z unxusr $ */
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 CoinPresolveSingleton_H
7 #define CoinPresolveSingleton_H
8 #define SLACK_DOUBLETON 2
9 #define SLACK_SINGLETON 8
10 
11 /*!
12   \file
13 */
14 
15 //const int MAX_SLACK_DOUBLETONS	= 1000;
16 
17 /*! \class slack_doubleton_action
18     \brief Convert an explicit bound constraint to a column bound
19 
20   This transform looks for explicit bound constraints for a variable and
21   transfers the bound to the appropriate column bound array.
22   The constraint is removed from the constraint system.
23 */
24 class slack_doubleton_action : public CoinPresolveAction {
25   struct action {
26     double clo;
27     double cup;
28 
29     double rlo;
30     double rup;
31 
32     double coeff;
33 
34     int col;
35     int row;
36   };
37 
38   const int nactions_;
39   const action *const actions_;
40 
slack_doubleton_action(int nactions,const action * actions,const CoinPresolveAction * next)41   slack_doubleton_action(int nactions,
42     const action *actions,
43     const CoinPresolveAction *next)
44     : CoinPresolveAction(next)
45     , nactions_(nactions)
46     , actions_(actions)
47   {
48   }
49 
50 public:
name() const51   const char *name() const { return ("slack_doubleton_action"); }
52 
53   /*! \brief Convert explicit bound constraints to column bounds.
54 
55     Not now There is a hard limit (#MAX_SLACK_DOUBLETONS) on the number of
56     constraints processed in a given call. \p notFinished is set to true
57     if candidates remain.
58   */
59   static const CoinPresolveAction *presolve(CoinPresolveMatrix *prob,
60     const CoinPresolveAction *next,
61     bool &notFinished);
62 
63   void postsolve(CoinPostsolveMatrix *prob) const;
64 
~slack_doubleton_action()65   virtual ~slack_doubleton_action() { deleteAction(actions_, action *); }
66 };
67 /*! \class slack_singleton_action
68     \brief For variables with one entry
69 
70     If we have a variable with one entry and no cost then we can
71     transform the row from E to G etc.
72     If there is a row objective region then we may be able to do
73     this even with a cost.
74 */
75 class slack_singleton_action : public CoinPresolveAction {
76   struct action {
77     double clo;
78     double cup;
79 
80     double rlo;
81     double rup;
82 
83     double coeff;
84 
85     int col;
86     int row;
87   };
88 
89   const int nactions_;
90   const action *const actions_;
91 
slack_singleton_action(int nactions,const action * actions,const CoinPresolveAction * next)92   slack_singleton_action(int nactions,
93     const action *actions,
94     const CoinPresolveAction *next)
95     : CoinPresolveAction(next)
96     , nactions_(nactions)
97     , actions_(actions)
98   {
99   }
100 
101 public:
name() const102   const char *name() const { return ("slack_singleton_action"); }
103 
104   static const CoinPresolveAction *presolve(CoinPresolveMatrix *prob,
105     const CoinPresolveAction *next,
106     double *rowObjective);
107 
108   void postsolve(CoinPostsolveMatrix *prob) const;
109 
~slack_singleton_action()110   virtual ~slack_singleton_action() { deleteAction(actions_, action *); }
111 };
112 #endif
113 
114 /* vi: softtabstop=2 shiftwidth=2 expandtab tabstop=2
115 */
116