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-2015 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