Scippy

SoPlex

Sequential object-oriented simPlex

spxvectorst.h
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-2022 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 /**@file spxvectorst.h
17  * @brief Solution vector based start basis.
18  */
19 #ifndef _SPXVECTORST_H_
20 #define _SPXVECTORST_H_
21 
22 #include <assert.h>
23 
24 #include "soplex/spxweightst.h"
25 #include "soplex/vector.h"
26 
27 namespace soplex
28 {
29 
30 /**@brief Solution vector based start basis.
31  @ingroup Algo
32 
33  This version of SPxWeightST can be used to construct a starting basis for
34  an LP to be solved with SoPlex if an approximate solution vector or dual
35  vector (possibly optained by a heuristic) is available. This is done by
36  setting up weights for the SPxWeightST it is derived from.
37 
38  The primal vector to be used is loaded by calling method #primal() while
39  #dual() setups for the dual vector. Methods #primal() or #dual() must be
40  called \em before #generate() is called by SoPlex to set up a
41  starting basis. If more than one call of method #primal() or #dual()
42  occurred only the most recent one is valid for generating the starting base.
43 */
44 template <class R>
45 class SPxVectorST : public SPxWeightST<R>
46 {
47 private:
48 
49  //-------------------------------------
50  /**@name Types */
51  ///@{
52  /// specifies whether to work on the primal, the dual, or not at all.
53  enum { NONE, PVEC, DVEC } state;
54  ///@}
55 
56  //-------------------------------------
57  /**@name Data */
58  ///@{
59  /// the current (approximate) primal or dual vector
61  ///@}
62 
63 protected:
64 
65  //-------------------------------------
66  /**@name Protected helpers */
67  ///@{
68  /// sets up variable weights.
69  void setupWeights(SPxSolverBase<R>& base);
70  ///@}
71 
72 public:
73 
74  //-------------------------------------
75  /**@name Construction / destruction */
76  ///@{
77  /// default constructor.
79  : state(NONE)
80  {
81  this->m_name = "vector";
82  }
83  /// copy constructor
85  : SPxWeightST<R>(old)
86  , state(old.state)
87  , vec(old.vec)
88  {
89  assert(this->isConsistent());
90  }
91  /// assignment operator
93  {
94  if(this != &rhs)
95  {
97  state = rhs.state;
98  vec = rhs.vec;
99 
100  assert(this->isConsistent());
101  }
102 
103  return *this;
104  }
105  /// destructor.
106  virtual ~SPxVectorST()
107  {}
108  /// clone function for polymorphism
109  inline virtual SPxStarter<R>* clone() const
110  {
111  return new SPxVectorST(*this);
112  }
113  ///@}
114 
115  //-------------------------------------
116  /**@name Modification */
117  ///@{
118  /// sets up primal solution vector.
119  void primal(const VectorBase<R>& v)
120  {
121  vec = v;
122  state = PVEC;
123  }
124  /// sets up primal solution vector.
125  void dual(const VectorBase<R>& v)
126  {
127  vec = v;
128  state = DVEC;
129  }
130  ///@}
131 
132 };
133 
134 } // namespace soplex
135 
136 // For general templated files
137 #include "spxvectorst.hpp"
138 #endif // _SPXVECTORST_H_
void dual(const VectorBase< R > &v)
sets up primal solution vector.
Definition: spxvectorst.h:125
void primal(const VectorBase< R > &v)
sets up primal solution vector.
Definition: spxvectorst.h:119
virtual ~SPxVectorST()
destructor.
Definition: spxvectorst.h:106
Dense vector.Class VectorBase provides dense linear algebra vectors. Internally, VectorBase wraps std...
Definition: dsvectorbase.h:28
VectorBase< R > vec
the current (approximate) primal or dual vector
Definition: spxvectorst.h:60
Sequential object-oriented SimPlex.SPxSolverBase is an LP solver class using the revised Simplex algo...
Definition: spxbasis.h:49
SoPlex start basis generation base class.SPxStarter is the virtual base class for classes generating ...
Definition: spxsolver.h:59
const char * m_name
name of the starter
Definition: spxstarter.h:50
Dense vector for linear algebra.
SPxVectorST(const SPxVectorST &old)
copy constructor
Definition: spxvectorst.h:84
Solution vector based start basis.This version of SPxWeightST can be used to construct a starting bas...
Definition: spxvectorst.h:45
enum soplex::SPxVectorST::@1 state
specifies whether to work on the primal, the dual, or not at all.
Everything should be within this namespace.
SPxVectorST()
default constructor.
Definition: spxvectorst.h:78
virtual SPxStarter< R > * clone() const
clone function for polymorphism
Definition: spxvectorst.h:109
Weighted start basis.
Weighted start basis.Class SPxWeightST is an implementation of a SPxStarter for generating a Simplex ...
Definition: spxweightst.h:57
SPxVectorST & operator=(const SPxVectorST &rhs)
assignment operator
Definition: spxvectorst.h:92
virtual bool isConsistent() const
consistency check.
void setupWeights(SPxSolverBase< R > &base)
sets up variable weights.
SPxWeightST & operator=(const SPxWeightST &rhs)
assignment operator
Definition: spxweightst.h:146