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   	
26   	/**@file  spxstarter.h
27   	 * @brief SoPlex start basis generation base class.
28   	 */
29   	#ifndef _SPXDSTARTER_H_
30   	#define _SPXDSTARTER_H_
31   	
32   	#include <assert.h>
33   	
34   	#include "soplex/spxdefines.h"
35   	#include "soplex/spxsolver.h"
36   	
37   	namespace soplex
38   	{
39   	
40   	/**@brief   SoPlex start basis generation base class.
41   	   @ingroup Algo
42   	
43   	   SPxStarter is the virtual base class for classes generating a starter basis
44   	   for the Simplex solver SoPlex. When a SPxStarter object has been loaded
45   	   to a SoPlex solver, the latter will call method #generate() in order to
46   	   have a start basis generated. Implementations of method #generate() must
47   	   terminate by \ref soplex::SPxSolver::load() "loading" the generated basis to
48   	   SoPlex. Loaded bases must be nonsingular.
49   	*/
50   	template <class R>
51   	class SPxStarter
52   	{
53   	protected:
54   	
55   	   //-------------------------------------
56   	   /**@name Data */
57   	   ///@{
58   	   /// name of the starter
59   	   const char* m_name;
60   	   /// tolerances for the starter
61   	   std::shared_ptr<Tolerances> _tolerances;
62   	   ///@}
63   	
64   	public:
65   	
66   	   //-------------------------------------
67   	   /**@name Data */
68   	   ///@{
69   	   /// constructor
70   	   explicit SPxStarter(const char* name)
71   	      : m_name(name)
72   	   {}
73   	   /// copy constructor
74   	   SPxStarter(const SPxStarter& old)
75   	      : m_name(old.m_name)
76   	   {}
77   	   /// assignment operator
78   	   SPxStarter& operator=(const SPxStarter& rhs)
79   	   {
80   	      if(this != &rhs)
81   	      {
82   	         m_name = rhs.m_name;
83   	      }
84   	
85   	      return *this;
86   	   }
87   	   /// destructor.
88   	   virtual ~SPxStarter()
89   	   {
90   	      m_name = 0;
91   	   }
92   	   /// clone function for polymorphism
93   	   virtual SPxStarter* clone()const = 0;
94   	   ///@}
95   	
96   	   //-------------------------------------
97   	   /**@name Access */
98   	   ///@{
99   	   /// get name of starter.
100  	   virtual const char* getName() const
101  	   {
102  	      return m_name;
103  	   }
104  	   ///@}
105  	
106  	   //-------------------------------------
107  	   /**@name Starting */
108  	   ///@{
109  	   /// generates start basis for loaded basis.
110  	   virtual void generate(SPxSolverBase<R>& base) = 0;
111  	   ///@}
112  	
113  	   /// set the tolerances to be used by the starter
114  	   virtual void setTolerances(const std::shared_ptr<Tolerances>& tolerances)
115  	   {
116  	      _tolerances = tolerances;
117  	   }
118  	   /// get the toelrances used by the starter
119  	   virtual const std::shared_ptr<Tolerances>& tolerances() const
120  	   {
121  	      return _tolerances;
122  	   }
123  	
124  	   //-------------------------------------
125  	   /**@name Misc */
126  	   ///@{
127  	   /// checks consistency.
128  	   virtual bool isConsistent() const;
129  	   ///@}
130  	
131  	private:
132  	
133  	   //------------------------------------
134  	   /**@name Blocked */
135  	   ///@{
136  	   /// we have no default constructor.
137  	   SPxStarter();
138  	   ///@}
139  	
140  	};
141  	} // namespace soplex
142  	
143  	// For general templated functions
144  	#include "spxstarter.hpp"
145  	
146  	#endif // _SPXDSTARTER_H_
147