Scippy

SoPlex

Sequential object-oriented simPlex

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-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 #include <iostream>
17 
18 #include "soplex/spxdefines.h"
19 #include "soplex/spxbasis.h"
20 #include "soplex/spxsolver.h"
21 
22 namespace soplex
23 {
24 
26 {
27  reSize(base.nRows(), base.nCols());
28 
29  if(base.rep() == SPxSolver::ROW)
30  {
31  stat = &rowstat;
32  costat = &colstat;
33  }
34  else
35  {
36  assert(base.rep() == SPxSolver::COLUMN);
37 
38  stat = &colstat;
39  costat = &rowstat;
40  }
41 
42  assert(Desc::isConsistent());
43 }
44 
46  : rowstat(old.rowstat)
47  , colstat(old.colstat)
48 {
49  if(old.stat == &old.rowstat)
50  {
51  assert(old.costat == &old.colstat);
52 
53  stat = &rowstat;
54  costat = &colstat;
55  }
56  else
57  {
58  assert(old.costat == &old.rowstat);
59 
60  stat = &colstat;
61  costat = &rowstat;
62  }
63 
64  assert(Desc::isConsistent());
65 }
66 
68 {
69  if(this != &rhs)
70  {
71  rowstat = rhs.rowstat;
72  colstat = rhs.colstat;
73 
74  if(rhs.stat == &rhs.rowstat)
75  {
76  assert(rhs.costat == &rhs.colstat);
77 
78  stat = &rowstat;
79  costat = &colstat;
80  }
81  else
82  {
83  assert(rhs.costat == &rhs.rowstat);
84 
85  stat = &colstat;
86  costat = &rowstat;
87  }
88 
89  assert(Desc::isConsistent());
90  }
91 
92  return *this;
93 }
94 
95 void SPxBasis::Desc::reSize(int rowDim, int colDim)
96 {
97 
98  assert(rowDim >= 0);
99  assert(colDim >= 0);
100 
101  int noldrows = rowstat.size();
102  int noldcols = colstat.size();
103 
104  rowstat.reSize(rowDim);
105  colstat.reSize(colDim);
106 
107  for(int i = rowDim - 1; i >= noldrows; i--)
108  rowstat[i] = D_UNDEFINED;
109 
110  for(int i = colDim - 1; i >= noldcols; i--)
111  colstat[i] = D_UNDEFINED;
112 }
113 
115 {
116  int i;
117 
118  // Dump regardless of the verbosity level if this method is called.
119 
120  std::cout << "DBDESC01 column status: ";
121 
122  for(i = 0; i < nCols(); i++)
123  std::cout << colStatus(i);
124 
125  std::cout << std::endl;
126 
127  std::cout << "DBDESC02 row status: ";
128 
129  for(i = 0; i < nRows(); i++)
130  std::cout << rowStatus(i);
131 
132  std::cout << std::endl;
133 }
134 
136 {
137 #ifdef ENABLE_CONSISTENCY_CHECKS
139 #else
140  return true;
141 #endif
142 }
143 
144 std::ostream& operator<<(std::ostream& os, const SPxBasis::Desc::Status& stat)
145 {
146  char text;
147 
148  switch(stat)
149  {
151  text = 'L';
152  break;
153 
155  text = 'U';
156  break;
157 
159  text = 'F';
160  break;
161 
163  text = 'X';
164  break;
165 
167  text = 'f';
168  break;
169 
171  text = 'u';
172  break;
173 
175  text = 'l';
176  break;
177 
179  text = 'x';
180  break;
181 
183  text = '.';
184  break;
185 
186  default :
187  os << std::endl << "Invalid status <" << int(stat) << ">" << std::endl;
188  throw SPxInternalCodeException("XSPXDE01 This should never happen.");
189  }
190 
191  os << text;
192 
193  return os;
194 }
195 
196 } // namespace soplex
Exception class for things that should NEVER happen.This class is derived from the SoPlex exception b...
Definition: exceptions.h:109
const Status * colStatus(void) const
returns the array of column Statuses.
Definition: spxbasis.h:264
bool isConsistent() const
consistency check
Definition: dataarray.h:298
primal variable is fixed to both bounds
Definition: spxbasis.h:190
primal or dual variable is undefined
Definition: spxbasis.h:195
bool isConsistent() const
consistency check.
Definition: spxdesc.cpp:135
DataArray< Status > * stat
basis&#39; status.
Definition: spxbasis.h:209
Desc & operator=(const Desc &rhs)
assignment operator
Definition: spxdesc.cpp:67
void reSize(int rowDim, int colDim)
resets dimensions.
Definition: spxdesc.cpp:95
void dump() const
Prints out status.
Definition: spxdesc.cpp:114
rowwise representation.
Definition: spxsolver.h:107
int nCols() const
returns number of columns.
Definition: spxbasis.h:219
dual variable is left free, but unset
Definition: spxbasis.h:191
int nRows() const
Returns number of rows in LP.
Definition: spxlpbase.h:152
primal variable is set to its upper bound
Definition: spxbasis.h:188
Desc()
default constructor
Definition: spxbasis.h:316
dual variable is set to its upper bound
Definition: spxbasis.h:192
main LP solver class
primal variable is left free, but unset
Definition: spxbasis.h:189
Basis descriptor.
Definition: spxbasis.h:104
DataArray< Status > rowstat
status of rows.
Definition: spxbasis.h:207
Debugging, floating point type and parameter definitions.
Simplex basis.
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.
primal variable is set to its lower bound
Definition: spxbasis.h:187
dual variable is set to its lower bound
Definition: spxbasis.h:193
DataArray< Status > * costat
cobasis&#39; status.
Definition: spxbasis.h:210
int size() const
return nr. of elements.
Definition: dataarray.h:214
const Status * rowStatus(void) const
returns the array of row Statuses.
Definition: spxbasis.h:249
int nCols() const
Returns number of columns in LP.
Definition: spxlpbase.h:158
DataArray< Status > colstat
status of columns.
Definition: spxbasis.h:208
dual variable has two bounds
Definition: spxbasis.h:194
int nRows() const
returns number of rows.
Definition: spxbasis.h:224
Status
Status of a variable.
Definition: spxbasis.h:185
void reSize(int newsize)
reset size to newsize.
Definition: dataarray.h:226
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:506
columnwise representation.
Definition: spxsolver.h:108
friend std::ostream & operator<<(std::ostream &os, const Status &stat)
Definition: spxdesc.cpp:144