SoPlex Doxygen Documentation
spxdesc.cpp
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-2012 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 //#define DEBUGGING 1
17 
18 #include <iostream>
19 
20 #include "spxdefines.h"
21 #include "spxbasis.h"
22 #include "spxsolver.h"
23 #include "exceptions.h"
24 
25 namespace soplex
26 {
27 
29 {
30  reSize(base.nRows(), base.nCols());
31 
32  if (base.rep() == SPxSolver::ROW)
33  {
34  stat = &rowstat;
35  costat = &colstat;
36  }
37  else
38  {
39  assert(base.rep() == SPxSolver::COLUMN);
40 
41  stat = &colstat;
42  costat = &rowstat;
43  }
44 
45  assert(Desc::isConsistent());
46 }
47 
49  : rowstat(old.rowstat)
50  , colstat(old.colstat)
51 {
52  if (old.stat == &old.rowstat)
53  {
54  assert(old.costat == &old.colstat);
55 
56  stat = &rowstat;
57  costat = &colstat;
58  }
59  else
60  {
61  assert(old.costat == &old.rowstat);
62 
63  stat = &colstat;
64  costat = &rowstat;
65  }
66 
67  assert(Desc::isConsistent());
68 }
69 
71 {
72  if (this != &rhs)
73  {
74  rowstat = rhs.rowstat;
75  colstat = rhs.colstat;
76 
77  if (rhs.stat == &rhs.rowstat)
78  {
79  assert(rhs.costat == &rhs.colstat);
80 
81  stat = &rowstat;
82  costat = &colstat;
83  }
84  else
85  {
86  assert(rhs.costat == &rhs.rowstat);
87 
88  stat = &colstat;
89  costat = &rowstat;
90  }
91 
92  assert(Desc::isConsistent());
93  }
94  return *this;
95 }
96 
97 void SPxBasis::Desc::reSize(int rowDim, int colDim)
98 {
99  METHOD( "SPxBasis::Desc::reSize()" );
100 
101  assert(rowDim >= 0);
102  assert(colDim >= 0);
103 
104  int noldrows = rowstat.size();
105  int noldcols = colstat.size();
106 
107  rowstat.reSize(rowDim);
108  colstat.reSize(colDim);
109 
110  for( int i = rowDim - 1; i >= noldrows; i-- )
111  rowstat[i] = D_UNDEFINED;
112 
113  for( int i = colDim - 1; i >= noldcols; i-- )
114  colstat[i] = D_UNDEFINED;
115 }
116 
118 {
119  METHOD( "SPxBasis::Desc::dump()" );
120  int i;
121 
122  // Dump regardless of the verbosity level if this method is called.
123  const SPxOut::Verbosity tmp_verbosity = spxout.getVerbosity();
125 
126  spxout << "DBDESC01 column status: ";
127  for(i = 0; i < nCols(); i++)
128  spxout << colStatus(i);
129  spxout << std::endl;
130 
131  spxout << "DBDESC02 row status: ";
132  for(i = 0; i < nRows(); i++)
133  spxout << rowStatus(i);
134  spxout << std::endl;
135  spxout.setVerbosity( tmp_verbosity );
136 }
137 
139 {
140 #ifdef ENABLE_CONSISTENCY_CHECKS
141  METHOD( "SPxBasis::Desc::isConsistent()" );
142  return rowstat.isConsistent() && colstat.isConsistent();
143 #else
144  return true;
145 #endif
146 }
147 
148 std::ostream& operator<<(std::ostream& os, const SPxBasis::Desc::Status& stat)
149 {
150  char text;
151 
152  switch(stat)
153  {
155  text = 'L';
156  break;
158  text = 'U';
159  break;
161  text = 'F';
162  break;
164  text = 'X';
165  break;
167  text = 'f';
168  break;
170  text = 'u';
171  break;
173  text = 'l';
174  break;
176  text = 'x';
177  break;
179  text = '.';
180  break;
181  default :
182  os << std::endl << "Invalid status <" << int(stat) << ">" << std::endl;
183  throw SPxInternalCodeException("XSPXDE01 This should never happen.");
184  }
185  os << text;
186 
187  return os;
188 }
189 
190 } // namespace soplex
191 
192 //-----------------------------------------------------------------------------
193 //Emacs Local Variables:
194 //Emacs mode:c++
195 //Emacs c-basic-offset:3
196 //Emacs tab-width:8
197 //Emacs indent-tabs-mode:nil
198 //Emacs End:
199 //-----------------------------------------------------------------------------