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-2023 Zuse Institute Berlin (ZIB) */
7 /* */
8 /* Licensed under the Apache License, Version 2.0 (the "License"); */
9 /* you may not use this file except in compliance with the License. */
10 /* You may obtain a copy of the License at */
11 /* */
12 /* http://www.apache.org/licenses/LICENSE-2.0 */
13 /* */
14 /* Unless required by applicable law or agreed to in writing, software */
15 /* distributed under the License is distributed on an "AS IS" BASIS, */
16 /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17 /* See the License for the specific language governing permissions and */
18 /* limitations under the License. */
19 /* */
20 /* You should have received a copy of the Apache-2.0 license */
21 /* along with SoPlex; see the file LICENSE. If not email to soplex@zib.de. */
22 /* */
23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24 
25 /**@file spxvectorst.h
26  * @brief Solution vector based start basis.
27  */
28 #ifndef _SPXVECTORST_H_
29 #define _SPXVECTORST_H_
30 
31 #include <assert.h>
32 
33 #include "soplex/spxweightst.h"
34 #include "soplex/vector.h"
35 
36 namespace soplex
37 {
38 
39 /**@brief Solution vector based start basis.
40  @ingroup Algo
41 
42  This version of SPxWeightST can be used to construct a starting basis for
43  an LP to be solved with SoPlex if an approximate solution vector or dual
44  vector (possibly optained by a heuristic) is available. This is done by
45  setting up weights for the SPxWeightST it is derived from.
46 
47  The primal vector to be used is loaded by calling method #primal() while
48  #dual() setups for the dual vector. Methods #primal() or #dual() must be
49  called \em before #generate() is called by SoPlex to set up a
50  starting basis. If more than one call of method #primal() or #dual()
51  occurred only the most recent one is valid for generating the starting base.
52 */
53 template <class R>
54 class SPxVectorST : public SPxWeightST<R>
55 {
56 private:
57 
58  //-------------------------------------
59  /**@name Types */
60  ///@{
61  /// specifies whether to work on the primal, the dual, or not at all.
62  enum { NONE, PVEC, DVEC } state;
63  ///@}
64 
65  //-------------------------------------
66  /**@name Data */
67  ///@{
68  /// the current (approximate) primal or dual vector
70  ///@}
71 
72 protected:
73 
74  //-------------------------------------
75  /**@name Protected helpers */
76  ///@{
77  /// sets up variable weights.
78  void setupWeights(SPxSolverBase<R>& base);
79  ///@}
80 
81 public:
82 
83  //-------------------------------------
84  /**@name Construction / destruction */
85  ///@{
86  /// default constructor.
88  : state(NONE)
89  {
90  this->m_name = "vector";
91  }
92  /// copy constructor
94  : SPxWeightST<R>(old)
95  , state(old.state)
96  , vec(old.vec)
97  {
98  assert(this->isConsistent());
99  }
100  /// assignment operator
102  {
103  if(this != &rhs)
104  {
106  state = rhs.state;
107  vec = rhs.vec;
108 
109  assert(this->isConsistent());
110  }
111 
112  return *this;
113  }
114  /// destructor.
115  virtual ~SPxVectorST()
116  {}
117  /// clone function for polymorphism
118  inline virtual SPxStarter<R>* clone() const
119  {
120  return new SPxVectorST(*this);
121  }
122  ///@}
123 
124  //-------------------------------------
125  /**@name Modification */
126  ///@{
127  /// sets up primal solution vector.
128  void primal(const VectorBase<R>& v)
129  {
130  vec = v;
131  state = PVEC;
132  }
133  /// sets up primal solution vector.
134  void dual(const VectorBase<R>& v)
135  {
136  vec = v;
137  state = DVEC;
138  }
139  ///@}
140 
141 };
142 
143 } // namespace soplex
144 
145 // For general templated files
146 #include "spxvectorst.hpp"
147 #endif // _SPXVECTORST_H_
void dual(const VectorBase< R > &v)
sets up primal solution vector.
Definition: spxvectorst.h:134
void primal(const VectorBase< R > &v)
sets up primal solution vector.
Definition: spxvectorst.h:128
virtual ~SPxVectorST()
destructor.
Definition: spxvectorst.h:115
Dense vector.Class VectorBase provides dense linear algebra vectors. Internally, VectorBase wraps std...
Definition: dsvectorbase.h:37
VectorBase< R > vec
the current (approximate) primal or dual vector
Definition: spxvectorst.h:69
Sequential object-oriented SimPlex.SPxSolverBase is an LP solver class using the revised Simplex algo...
Definition: spxbasis.h:58
SoPlex start basis generation base class.SPxStarter is the virtual base class for classes generating ...
Definition: spxsolver.h:68
const char * m_name
name of the starter
Definition: spxstarter.h:59
enum soplex::SPxVectorST::@14 state
specifies whether to work on the primal, the dual, or not at all.
Dense vector for linear algebra.
SPxVectorST(const SPxVectorST &old)
copy constructor
Definition: spxvectorst.h:93
Solution vector based start basis.This version of SPxWeightST can be used to construct a starting bas...
Definition: spxvectorst.h:54
Everything should be within this namespace.
SPxVectorST()
default constructor.
Definition: spxvectorst.h:87
virtual SPxStarter< R > * clone() const
clone function for polymorphism
Definition: spxvectorst.h:118
Weighted start basis.
Weighted start basis.Class SPxWeightST is an implementation of a SPxStarter for generating a Simplex ...
Definition: spxweightst.h:66
SPxVectorST & operator=(const SPxVectorST &rhs)
assignment operator
Definition: spxvectorst.h:101
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:155