Scippy

SoPlex

Sequential object-oriented simPlex

spxsumst.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 <iostream>
17 
18 #include "spxdefines.h"
19 #include "spxsumst.h"
20 #include "vector.h"
21 
22 namespace soplex
23 {
24 
26 {
27  int count;
28  int i;
29  Real x;
30  DVector work, delta, rowLen;
31 
32  rowLen.reDim( base.nRows() );
33  work.reDim (base.nCols());
34  delta.reDim (base.nCols());
35 
36  Real* wrk = work.get_ptr();
37  const Real* lhs = base.lhs().get_const_ptr();
38  const Real* rhs = base.rhs().get_const_ptr();
39  const Real* up = base.upper().get_const_ptr();
40  const Real* low = base.lower().get_const_ptr();
41 
42  for (i = base.nRows(); --i >= 0;)
43  {
44  rowLen[i] = base.rowVector(i).length2();
45  if (lhs[i] > 0)
46  delta.multAdd(lhs[i] / rowLen[i], base.rowVector(i));
47  else if (rhs[i] < 0)
48  delta.multAdd(rhs[i] / rowLen[i], base.rowVector(i));
49  }
50 
51  for (count = 0;; count++)
52  {
53  work += delta;
54  for (i = base.nCols(); --i >= 0;)
55  {
56  if (wrk[i] > up[i])
57  wrk[i] = up[i];
58  if (wrk[i] < low[i])
59  wrk[i] = low[i];
60  }
61 
62  // std::cout << -(work * base.maxObj()) << std::endl;
63  if (count >= 12)
64  break;
65 
66  delta.clear();
67  for (i = base.nRows(); --i >= 0;)
68  {
69  x = base.rowVector(i) * work;
70  if (lhs[i] > x)
71  delta.multAdd((lhs[i] - x) / rowLen[i], base.rowVector(i));
72  else if (rhs[i] < x)
73  delta.multAdd((rhs[i] - x) / rowLen[i], base.rowVector(i));
74  }
75  }
76 
77  primal(work);
79 }
80 } // namespace soplex
void reDim(int newdim, const bool setZero=true)
Resets DVectorBase&#39;s dimension to newdim.
Definition: dvectorbase.h:249
const R * get_const_ptr() const
Conversion to C-style pointer.
Definition: vectorbase.h:412
const VectorBase< R > & lower() const
Returns lower bound vector.
Definition: spxlpbase.h:420
const VectorBase< R > & upper() const
Returns upper bound vector.
Definition: spxlpbase.h:402
Dense vector for linear algebra.
R * get_ptr()
Conversion to C-style pointer.
Definition: vectorbase.h:403
double Real
SOPLEX_DEBUG.
Definition: spxdefines.h:200
void setupWeights(SPxSolver &base)
sets up variable weights.
Definition: spxsumst.cpp:25
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
Simple heuristic SPxStarter.
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
VectorBase< R > & multAdd(const S &x, const VectorBase< T > &vec)
Addition of scaled vector.
Definition: vectorbase.h:369
const VectorBase< R > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:242
Everything should be within this namespace.
R length2() const
Squared norm.
Definition: svectorbase.h:477
void primal(const Vector &v)
sets up primal solution vector.
Definition: spxvectorst.h:118
void clear()
Set vector to 0.
Definition: vectorbase.h:219
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