Scippy

SoPlex

Sequential object-oriented simPlex

spxvectorst.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-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 #include <assert.h>
17 #include <iostream>
18 
19 #include "spxdefines.h"
20 #include "spxvectorst.h"
21 
22 namespace soplex
23 {
24 
26 {
27  if (state == PVEC)
28  {
29  if (vec.dim() != base.nCols())
30  {
32  return;
33  }
34 
35  const Vector& obj = base.maxObj();
36  Real eps = base.epsilon();
37  Real bias = 10000 * eps;
38  Real x, y;
39  int i;
40 
41  MSG_DEBUG( std::cout << "DVECST01 colWeight[]: "; )
42  for (i = base.nCols(); i--;)
43  {
44  x = vec[i] - base.SPxLP::lower(i);
45  y = base.SPxLP::upper(i) - vec[i];
46  if (x < y)
47  {
48  colWeight[i] = -x - bias * obj[i];
49  colUp[i] = 0;
50  }
51  else
52  {
53  colWeight[i] = -y + bias * obj[i];
54  colUp[i] = 1;
55  }
56  MSG_DEBUG( std::cout << colWeight[i] << " "; )
57  }
58  MSG_DEBUG( std::cout << std::endl << std::endl; )
59 
60  MSG_DEBUG( std::cout << "DVECST02 rowWeight[]: "; )
61  for (i = base.nRows(); i--;)
62  {
63  const SVector& row = base.rowVector(i);
64  y = vec * row;
65  x = (y - base.lhs(i));
66  y = (base.rhs(i) - y);
67  if (x < y)
68  {
69  rowWeight[i] = -x - eps * row.size() - bias * (obj * row);
70  rowRight[i] = 0;
71  }
72  else
73  {
74  rowWeight[i] = -y - eps * row.size() + bias * (obj * row);
75  rowRight[i] = 1;
76  }
77  MSG_DEBUG( std::cout << rowWeight[i] << " "; )
78  }
79  MSG_DEBUG( std::cout << std::endl; )
80  }
81 
82  else if (state == DVEC)
83  {
84  if (vec.dim() != base.nRows())
85  {
87  return;
88  }
89 
90  Real x, y, len;
91  int i, j;
92  for (i = base.nRows(); i--;)
93  rowWeight[i] += spxAbs(vec[i]);
94 
95  for (i = base.nCols(); i--;)
96  {
97  const SVector& col = base.colVector(i);
98  for (y = len = 0, j = col.size(); j--;)
99  {
100  x = col.value(j);
101  y += vec[col.index(j)] * x;
102  len += x * x;
103  }
104  if (len > 0)
105  colWeight[i] += spxAbs(y / len - base.maxObj(i));
106  }
107  }
108  else
110 }
111 } // namespace soplex
Rational spxAbs(const Rational &r)
Absolute.
Definition: rational.cpp:3925
const VectorBase< R > & maxObj() const
Returns objective vector for maximization problem.
Definition: spxlpbase.h:384
Solution vector based start basis.
const SVectorBase< R > & colVector(int i) const
Returns column vector of column i.
Definition: spxlpbase.h:341
int size() const
Number of used indices.
Definition: svectorbase.h:152
R & value(int n)
Reference to value of n &#39;th nonzero.
Definition: svectorbase.h:254
DataArray< Real > rowWeight
weight value for LP rows.
Definition: spxweightst.h:84
virtual void setupWeights(SPxSolver &base)
sets up variable weights.
double Real
SOPLEX_DEBUG.
Definition: spxdefines.h:200
#define MSG_DEBUG(x)
Definition: spxdefines.h:127
int & index(int n)
Reference to index of n &#39;th nonzero.
Definition: svectorbase.h:236
void setupWeights(SPxSolver &base)
sets up variable weights.
Definition: spxvectorst.cpp:25
int nCols() const
Returns number of columns in LP.
Definition: spxlpbase.h:133
int size() const
return nr. of elements.
Definition: dataarray.h:211
DVector vec
the current (approximate) primal or dual vector
Definition: spxvectorst.h:59
int dim() const
Dimension of vector.
Definition: vectorbase.h:174
Debugging, floating point type and parameter definitions.
int nRows() const
Returns number of rows in LP.
Definition: spxlpbase.h:127
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Definition: spxsolver.h:84
const VectorBase< R > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:242
Everything should be within this namespace.
Real epsilon() const
values are considered to be 0.
Definition: spxsolver.h:670
enum soplex::SPxVectorST::@17 state
specifies whether to work on the primal, the dual, or not at all.
const VectorBase< R > & rhs() const
Returns right hand side vector.
Definition: spxlpbase.h:224
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
Definition: spxlpbase.h:212
DataArray< Real > colWeight
weight value for LP columns.
Definition: spxweightst.h:86
DataArray< bool > colUp
set primal variable to upper bound.
Definition: spxweightst.h:90
DataArray< bool > rowRight
set variable to rhs?.
Definition: spxweightst.h:88