Scippy

SoPlex

Sequential object-oriented simPlex

spxscaler.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2 /* */
3 /* This file is part of the class library */
4 /* SoPlex --- the Sequential object-oriented simPlex. */
5 /* */
6 /* Copyright (C) 1996-2016 Konrad-Zuse-Zentrum */
7 /* fuer Informationstechnik Berlin */
8 /* */
9 /* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10 /* */
11 /* You should have received a copy of the ZIB Academic License */
12 /* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13 /* */
14 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15 
16 /**@file spxscaler.h
17  * @brief LP scaling base class.
18  */
19 #ifndef _SPXSCALER_H_
20 #define _SPXSCALER_H_
21 
22 #include <assert.h>
23 
24 #include "spxdefines.h"
25 #include "dataarray.h"
26 #include "spxlp.h"
27 
28 namespace soplex
29 {
30 /**@brief LP scaler abstract base class.
31  @ingroup Algo
32 
33  Instances of classes derived from SPxScaler may be loaded to SoPlex in
34  order to scale LPs before solving them. SoPlex will load() itself to
35  the SPxScaler and then call #scale(). Generally any SPxLP can be
36  loaded to a SPxScaler for #scale()%ing it. The scaling can
37  be undone by calling unscale().
38 */
39 class SPxScaler
40 {
41 protected:
42 
43  //-------------------------------------
44  /**@name Data */
45  //@{
46  const char* m_name; ///< Name of the scaler
47  DataArray < Real > m_colscale; ///< column scaling factors
48  DataArray < Real > m_rowscale; ///< row scaling factors
49  bool m_colFirst; ///< do column scaling first
50  bool m_doBoth; ///< do columns and rows
51  SPxOut* spxout; ///< message handler
52  //@}
53 
54  //-------------------------------------
55  /**@name Protected helpers */
56  //@{
57  /// setup scale array for the LP.
58  virtual void setup(SPxLP& lp);
59  /// computes scaling value for a minimum and maximum pair.
60  virtual Real computeScale(Real mini, Real maxi) const;
61  /// iterates through vecset and calls computeScale() for each vector.
62  /**@return maximum ratio between absolute biggest and smallest element for any vector.
63  */
64  virtual Real computeScalingVecs( const SVSet* vecset,
65  const DataArray<Real>& coScaleval,
66  DataArray<Real>& scaleval );
67  /// applies m_colscale and m_rowscale to the \p lp.
68  virtual void applyScaling(SPxLP& lp);
69  //@}
70 
71 public:
72 
73  friend std::ostream& operator<<(std::ostream& s, const SPxScaler& sc);
74 
75  //-------------------------------------
76  /**@name Construction / destruction */
77  //@{
78  /// constructor
79  explicit SPxScaler(const char* name, bool colFirst = false, bool doBoth = true, SPxOut* spxout = NULL);
80  /// copy constructor
81  SPxScaler(const SPxScaler& );
82  /// assignment operator
83  SPxScaler& operator=(const SPxScaler& );
84  /// destructor.
85  virtual ~SPxScaler();
86  /// clone function for polymorphism
87  virtual SPxScaler* clone() const = 0;
88  //@}
89 
90  //-------------------------------------
91  /**@name Access / modification */
92  //@{
93  /// get name of scaler.
94  virtual const char* getName() const;
95  /// set scaling order.
96  virtual void setOrder(bool colFirst);
97  /// set wether column and row scaling should be performed.
98  virtual void setBoth(bool both);
99  /// set message handler
100  virtual void setOutstream(SPxOut& newOutstream)
101  {
102  spxout = &newOutstream;
103  }
104  //@}
105 
106  //-------------------------------------
107  /**@name Scaling */
108  //@{
109  /// scale SPxLP.
110  virtual void scale(SPxLP& lp) = 0;
111  /// unscale dense primal solution vector given in \p x.
112  virtual void unscalePrimal(Vector& x) const;
113  /// unscale dense slack vector given in \p s.
114  virtual void unscaleSlacks(Vector& s) const;
115  /// unscale dense dual solution vector given in \p pi.
116  virtual void unscaleDual(Vector& pi) const;
117  /// unscale dense reduced cost vector given in \p r.
118  virtual void unscaleRedCost(Vector& r) const;
119 
120  /// absolute smallest column scaling factor
121  virtual Real minAbsColscale() const;
122  /// absolute biggest column scaling factor
123  virtual Real maxAbsColscale() const;
124  /// absolute smallest row scaling factor
125  virtual Real minAbsRowscale() const;
126  /// absolute biggest row scaling factor
127  virtual Real maxAbsRowscale() const;
128  /// maximum ratio between absolute biggest and smallest element in any column.
129  virtual Real maxColRatio(const SPxLP& lp) const;
130  /// maximum ratio between absolute biggest and smallest element in any row.
131  virtual Real maxRowRatio(const SPxLP& lp) const;
132  //@}
133 
134  //-------------------------------------
135  /**@name Debugging */
136  //@{
137  /// consistency check
138  virtual bool isConsistent() const;
139  //@}
140 };
141 } // namespace soplex
142 #endif // _SPXSCALER_H_
virtual void scale(SPxLP &lp)=0
scale SPxLP.
virtual void setBoth(bool both)
set wether column and row scaling should be performed.
Definition: spxscaler.cpp:109
virtual void setOrder(bool colFirst)
set scaling order.
Definition: spxscaler.cpp:103
virtual void unscaleSlacks(Vector &s) const
unscale dense slack vector given in s.
Definition: spxscaler.cpp:279
friend std::ostream & operator<<(std::ostream &s, const SPxScaler &sc)
Definition: spxscaler.cpp:35
virtual void unscaleDual(Vector &pi) const
unscale dense dual solution vector given in pi.
Definition: spxscaler.cpp:296
virtual void applyScaling(SPxLP &lp)
applies m_colscale and m_rowscale to the lp.
Definition: spxscaler.cpp:186
virtual ~SPxScaler()
destructor.
Definition: spxscaler.cpp:75
virtual Real maxColRatio(const SPxLP &lp) const
maximum ratio between absolute biggest and smallest element in any column.
Definition: spxscaler.cpp:399
virtual Real computeScalingVecs(const SVSet *vecset, const DataArray< Real > &coScaleval, DataArray< Real > &scaleval)
iterates through vecset and calls computeScale() for each vector.
Definition: spxscaler.cpp:140
virtual void setOutstream(SPxOut &newOutstream)
set message handler
Definition: spxscaler.h:100
double Real
SOPLEX_DEBUG.
Definition: spxdefines.h:200
virtual Real minAbsColscale() const
absolute smallest column scaling factor
Definition: spxscaler.cpp:330
SPxOut * spxout
message handler
Definition: spxscaler.h:51
DataArray< Real > m_colscale
column scaling factors
Definition: spxscaler.h:47
Wrapper for several output streams. A verbosity level is used to decide which stream to use and wheth...
Definition: spxout.h:63
virtual Real maxAbsRowscale() const
absolute biggest row scaling factor
Definition: spxscaler.cpp:379
virtual Real maxRowRatio(const SPxLP &lp) const
maximum ratio between absolute biggest and smallest element in any row.
Definition: spxscaler.cpp:431
virtual void unscalePrimal(Vector &x) const
unscale dense primal solution vector given in x.
Definition: spxscaler.cpp:262
virtual bool isConsistent() const
consistency check
Definition: spxscaler.cpp:459
virtual SPxScaler * clone() const =0
clone function for polymorphism
virtual Real computeScale(Real mini, Real maxi) const
computes scaling value for a minimum and maximum pair.
Definition: spxscaler.cpp:134
DataArray< Real > m_rowscale
row scaling factors
Definition: spxscaler.h:48
Debugging, floating point type and parameter definitions.
virtual void unscaleRedCost(Vector &r) const
unscale dense reduced cost vector given in r.
Definition: spxscaler.cpp:313
Everything should be within this namespace.
bool m_colFirst
do column scaling first
Definition: spxscaler.h:49
SPxScaler(const char *name, bool colFirst=false, bool doBoth=true, SPxOut *spxout=NULL)
constructor
Definition: spxscaler.cpp:51
Saving LPs in a form suitable for SoPlex.
LP scaler abstract base class.Instances of classes derived from SPxScaler may be loaded to SoPlex in ...
Definition: spxscaler.h:39
virtual void setup(SPxLP &lp)
setup scale array for the LP.
Definition: spxscaler.cpp:115
virtual Real minAbsRowscale() const
absolute smallest row scaling factor
Definition: spxscaler.cpp:363
bool m_doBoth
do columns and rows
Definition: spxscaler.h:50
Save arrays of data objects.
virtual const char * getName() const
get name of scaler.
Definition: spxscaler.cpp:97
virtual Real maxAbsColscale() const
absolute biggest column scaling factor
Definition: spxscaler.cpp:346
const char * m_name
Name of the scaler.
Definition: spxscaler.h:46
SPxScaler & operator=(const SPxScaler &)
assignment operator
Definition: spxscaler.cpp:80