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-2017 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 "spxdefines.h"
19 #include "spxbasis.h"
20 #include "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  return *this;
92 }
93 
94 void SPxBasis::Desc::reSize(int rowDim, int colDim)
95 {
96 
97  assert(rowDim >= 0);
98  assert(colDim >= 0);
99 
100  int noldrows = rowstat.size();
101  int noldcols = colstat.size();
102 
103  rowstat.reSize(rowDim);
104  colstat.reSize(colDim);
105 
106  for( int i = rowDim - 1; i >= noldrows; i-- )
107  rowstat[i] = D_UNDEFINED;
108 
109  for( int i = colDim - 1; i >= noldcols; i-- )
110  colstat[i] = D_UNDEFINED;
111 }
112 
114 {
115  int i;
116 
117  // Dump regardless of the verbosity level if this method is called.
118 
119  std::cout << "DBDESC01 column status: ";
120  for(i = 0; i < nCols(); i++)
121  std::cout << colStatus(i);
122  std::cout << std::endl;
123 
124  std::cout << "DBDESC02 row status: ";
125  for(i = 0; i < nRows(); i++)
126  std::cout << rowStatus(i);
127  std::cout << std::endl;
128 }
129 
131 {
132 #ifdef ENABLE_CONSISTENCY_CHECKS
134 #else
135  return true;
136 #endif
137 }
138 
139 std::ostream& operator<<(std::ostream& os, const SPxBasis::Desc::Status& stat)
140 {
141  char text;
142 
143  switch(stat)
144  {
146  text = 'L';
147  break;
149  text = 'U';
150  break;
152  text = 'F';
153  break;
155  text = 'X';
156  break;
158  text = 'f';
159  break;
161  text = 'u';
162  break;
164  text = 'l';
165  break;
167  text = 'x';
168  break;
170  text = '.';
171  break;
172  default :
173  os << std::endl << "Invalid status <" << int(stat) << ">" << std::endl;
174  throw SPxInternalCodeException("XSPXDE01 This should never happen.");
175  }
176  os << text;
177 
178  return os;
179 }
180 
181 } // 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:288
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:130
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:94
void dump() const
Prints out status.
Definition: spxdesc.cpp:113
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:151
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:84
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:211
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:157
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:223
Representation rep() const
return the current basis representation.
Definition: spxsolver.h:478
columnwise representation.
Definition: spxsolver.h:108
friend std::ostream & operator<<(std::ostream &os, const Status &stat)
Definition: spxdesc.cpp:139