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-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/spxsumst.h"
20 #include "soplex/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  assert(base.nRows() > 0);
33  assert(base.nCols() > 0);
34 
35  rowLen.reDim(base.nRows(), true);
36  work.reDim(base.nCols(), true);
37  delta.reDim(base.nCols(), true);
38 
39  Real* wrk = work.get_ptr();
40  const Real* lhs = base.lhs().get_const_ptr();
41  const Real* rhs = base.rhs().get_const_ptr();
42  const Real* up = base.upper().get_const_ptr();
43  const Real* low = base.lower().get_const_ptr();
44 
45  for(i = base.nRows(); --i >= 0;)
46  {
47  rowLen[i] = base.rowVector(i).length2();
48 
49  if(lhs[i] > 0)
50  delta.multAdd(lhs[i] / rowLen[i], base.rowVector(i));
51  else if(rhs[i] < 0)
52  delta.multAdd(rhs[i] / rowLen[i], base.rowVector(i));
53  }
54 
55  for(count = 0;; count++)
56  {
57  work += delta;
58 
59  for(i = base.nCols(); --i >= 0;)
60  {
61  if(wrk[i] > up[i])
62  wrk[i] = up[i];
63 
64  if(wrk[i] < low[i])
65  wrk[i] = low[i];
66  }
67 
68  // std::cout << -(work * base.maxObj()) << std::endl;
69  if(count >= 12)
70  break;
71 
72  delta.clear();
73 
74  for(i = base.nRows(); --i >= 0;)
75  {
76  x = base.rowVector(i) * work;
77 
78  if(lhs[i] > x)
79  delta.multAdd((lhs[i] - x) / rowLen[i], base.rowVector(i));
80  else if(rhs[i] < x)
81  delta.multAdd((rhs[i] - x) / rowLen[i], base.rowVector(i));
82  }
83  }
84 
85  primal(work);
87 }
88 } // namespace soplex
const VectorBase< R > & rhs() const
Returns right hand side vector.
Definition: spxlpbase.h:221
void reDim(int newdim, const bool setZero=true)
Resets DVectorBase&#39;s dimension to newdim.
Definition: dvectorbase.h:253
const VectorBase< R > & upper() const
Returns upper bound vector.
Definition: spxlpbase.h:461
Dense vector for linear algebra.
int nRows() const
Returns number of rows in LP.
Definition: spxlpbase.h:152
R * get_ptr()
Conversion to C-style pointer.
Definition: vectorbase.h:446
double Real
Definition: spxdefines.h:218
void setupWeights(SPxSolver &base)
sets up variable weights.
Definition: spxsumst.cpp:25
void setupWeights(SPxSolver &base)
sets up variable weights.
Definition: spxvectorst.cpp:25
const VectorBase< R > & lhs() const
Returns left hand side vector.
Definition: spxlpbase.h:255
Simple heuristic SPxStarter.
Debugging, floating point type and parameter definitions.
Sequential object-oriented SimPlex.SPxSolver is an LP solver class using the revised Simplex algorith...
Definition: spxsolver.h:85
VectorBase< R > & multAdd(const S &x, const VectorBase< T > &vec)
Addition of scaled vector.
Definition: vectorbase.h:412
Everything should be within this namespace.
const SVectorBase< R > & rowVector(int i) const
Gets row vector of row i.
Definition: spxlpbase.h:206
void primal(const Vector &v)
sets up primal solution vector.
Definition: spxvectorst.h:118
void clear()
Set vector to 0.
Definition: vectorbase.h:262
int nCols() const
Returns number of columns in LP.
Definition: spxlpbase.h:158
const VectorBase< R > & lower() const
Returns (internal and possibly scaled) lower bound vector.
Definition: spxlpbase.h:488