Scippy

SoPlex

Sequential object-oriented simPlex

spxweightst.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-2019 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 
17 /**@file spxweightst.h
18  * @brief Weighted start basis.
19  */
20 #ifndef _SPXWEIGHTST_H_
21 #define _SPXWEIGHTST_H_
22 
23 
24 #include <assert.h>
25 
26 #include "soplex/spxdefines.h"
27 #include "soplex/spxstarter.h"
28 #include "soplex/dataarray.h"
29 
30 namespace soplex
31 {
32 
33 /**@brief Weighted start basis.
34  @ingroup Algo
35 
36  Class SPxWeightST is an implementation of a SPxStarter for generating a
37  Simplex starting basis. Using method #setupWeights() it sets up arrays
38  #weight and #coWeight, or equivalently #rowWeight and #colWeight.
39  (#rowWeight and #colWeight are just pointers initialized to #weight and
40  #coWeight according to the representation of SoPlex \p base passed to
41  method #generate().)
42 
43  The weight values are then used to setup a starting basis for the LP:
44  vectors with low values are likely to become dual (i.e. basic for a column
45  basis) and such with high values are likely to become primal (i.e. nonbasic
46  for a column basis).
47 
48  However, if a variable having an upper and lower bound is to become primal,
49  there is still a choice for setting it either to its upper or lower bound.
50  Members #rowRight and #colUp are used to determine where to set a primal
51  variable. If #rowRight[i] is set to a nonzero value, the right-hand side
52  inequality is set tightly for the \p i 'th to become primal. Analogously, If
53  #colUp[j] is nonzero, the \p j 'th variable will be set to its upper bound
54  if it becomes primal.
55 */
56 class SPxWeightST : public SPxStarter
57 {
58 private:
59 
60  //-----------------------------------
61  /**@name Private data */
62  //@{
63  ///
65  ///
67  ///
69  //@}
70 
71  //-----------------------------------
72  /**@name Private helpers */
73  //@{
74  ///
75  void setPrimalStatus(SPxBasis::Desc&, const SPxSolver&, const SPxId&);
76  //@}
77 
78 protected:
79 
80  //-----------------------------------
81  /**@name Protected data */
82  //@{
83  /// weight value for LP rows.
85  /// weight value for LP columns.
87  /// set variable to rhs?.
89  /// set primal variable to upper bound.
91  //@}
92 
93  //-----------------------------------
94  /**@name Protected helpers */
95  //@{
96  /// sets up variable weights.
97  /** This method is called in order to setup the weights for all
98  variables. It has been declared \c virtual in order to allow for
99  derived classes to compute other weight values.
100  */
101  virtual void setupWeights(SPxSolver& base);
102  //@}
103 
104 public:
105 
106  //-----------------------------------
107  /**@name Construction / destruction */
108  //@{
109  /// default constructor.
111  : SPxStarter("Weight")
112  {
113  weight = 0;
114  coWeight = 0;
115  assert(isConsistent());
116  }
117  /// copy constructor
119  : SPxStarter(old)
120  , forbidden(old.forbidden)
121  , rowWeight(old.rowWeight)
122  , colWeight(old.colWeight)
123  , rowRight(old.rowRight)
124  , colUp(old.colUp)
125  {
126  if(old.weight == &old.colWeight)
127  {
128  weight = &colWeight;
129  coWeight = &rowWeight;
130  }
131  else if(old.weight == &old.rowWeight)
132  {
133  weight = &rowWeight;
134  coWeight = &colWeight;
135  }
136  else // old.weight and old.coWeight are not set correctly, do nothing.
137  {
138  weight = 0;
139  coWeight = 0;
140  }
141 
142  assert(isConsistent());
143  }
144  /// assignment operator
146  {
147  if(this != &rhs)
148  {
150  forbidden = rhs.forbidden;
151  rowWeight = rhs.rowWeight;
152  colWeight = rhs.colWeight;
153  rowRight = rhs.rowRight;
154  colUp = rhs.colUp;
155 
156  if(rhs.weight == &rhs.colWeight)
157  {
158  weight = &colWeight;
159  coWeight = &rowWeight;
160  }
161  else if(rhs.weight == &rhs.rowWeight)
162  {
163  weight = &rowWeight;
164  coWeight = &colWeight;
165  }
166  else // old.weight and old.coWeight are not set correctly, do nothing.
167  {}
168 
169  assert(isConsistent());
170  }
171 
172  return *this;
173  }
174  /// destructor.
175  virtual ~SPxWeightST()
176  {
177  weight = 0;
178  coWeight = 0;
179  }
180  /// clone function for polymorphism
181  inline virtual SPxStarter* clone() const
182  {
183  return new SPxWeightST(*this);
184  }
185  //@}
186 
187  //-----------------------------------
188  /**@name Generation of a start basis */
189  //@{
190  /// generates start basis for loaded basis.
191  void generate(SPxSolver& base);
192  //@}
193 
194  //-----------------------------------
195  /**@name Debugging */
196  //@{
197  /// consistency check.
198  virtual bool isConsistent() const;
199  //@}
200 
201 };
202 
203 } // namespace soplex
204 #endif // _SPXWEIGHTST_H_
DataArray< Real > * weight
Definition: spxweightst.h:66
SoPlex start basis generation base class.
virtual ~SPxWeightST()
destructor.
Definition: spxweightst.h:175
SoPlex start basis generation base class.SPxStarter is the virtual base class for classes generating ...
Definition: spxstarter.h:41
DataArray< Real > rowWeight
weight value for LP rows.
Definition: spxweightst.h:84
SPxStarter & operator=(const SPxStarter &rhs)
assignment operator
Definition: spxstarter.h:66
virtual void setupWeights(SPxSolver &base)
sets up variable weights.
Generic Ids for LP rows or columns.Both SPxColIds and SPxRowIds may be treated uniformly as SPxIds: ...
Definition: spxid.h:85
virtual SPxStarter * clone() const
clone function for polymorphism
Definition: spxweightst.h:181
void generate(SPxSolver &base)
generates start basis for loaded basis.
Basis descriptor.
Definition: spxbasis.h:104
Debugging, floating point type and parameter definitions.
SPxWeightST()
default constructor.
Definition: spxweightst.h:110
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Definition: spxsolver.h:85
Everything should be within this namespace.
SPxWeightST(const SPxWeightST &old)
copy constructor
Definition: spxweightst.h:118
Weighted start basis.Class SPxWeightST is an implementation of a SPxStarter for generating a Simplex ...
Definition: spxweightst.h:56
DataArray< Real > * coWeight
Definition: spxweightst.h:68
DataArray< Real > colWeight
weight value for LP columns.
Definition: spxweightst.h:86
Save arrays of data objects.
DataArray< int > forbidden
Definition: spxweightst.h:64
SPxWeightST & operator=(const SPxWeightST &rhs)
assignment operator
Definition: spxweightst.h:145
void setPrimalStatus(SPxBasis::Desc &, const SPxSolver &, const SPxId &)
Definition: spxweightst.cpp:62
virtual bool isConsistent() const
consistency check.
Definition: spxweightst.cpp:31
DataArray< bool > colUp
set primal variable to upper bound.
Definition: spxweightst.h:90
DataArray< bool > rowRight
set variable to rhs?.
Definition: spxweightst.h:88