1 /*!\file
2  * \author Matthias Elf
3  *
4  * \brief csense.
5  *
6  * \par License:
7  * This file is part of ABACUS - A Branch And CUt System
8  * Copyright (C) 1995 - 2003
9  * University of Cologne, Germany
10  *
11  * \par
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * \par
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Lesser General Public License for more details.
22  *
23  * \par
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27  *
28  * \see http://www.gnu.org/copyleft/gpl.html
29  */
30 
31 #pragma once
32 
33 #include <ogdf/lib/abacus/abacusroot.h>
34 
35 namespace abacus {
36 
37 class AbacusGlobal;
38 
39 
40 //! Sense of constraints.
41 /**
42  * The most important objects in a cutting plane algorithm are
43  * constraints, which can be equations (\a Equal) or
44  * inequalities with the sense \a Less or \a Greater.
45  * We implement the sense of optimization as a class
46  * since we require it both in the classes Constraint and Row.
47  */
48 class OGDF_EXPORT CSense : public AbacusRoot {
49 public:
50 
51 	enum SENSE { Less, Equal, Greater };
52 
53 	//! Default constructor, sense is undefined.
CSense()54 	CSense() { }
55 
56 	//! Initializes the sense to \a s.
57 	/**
58 	 * \param s  The sense.
59 	 */
CSense(const SENSE s)60 	CSense(const SENSE s) : sense_(s) { }
61 
62 	//! Initializes the sense of the constraint specified with a single letter.
63 	/**
64 	 * \param s  A character representing the sense:
65 	 *           <tt>E</tt> or <tt>e</tt> stand for \a Equal,
66 	 *           <tt>G</tt> and <tt>g</tt> stand for \a Greater, and
67 	 *           <tt>L</tt> or <tt>l</tt> stand for \a Less.
68 	 */
69 	CSense(char s);
70 
71 	//! Output operator for constraint senses.
72 	/**
73 	 * The output operator writes the sense on an output stream in the form \a <=, \a =, or \a >=.
74 	 *
75 	 * \param out The output stream.
76 	 * \param rhs The sense being output.
77 	 *
78 	 * \return The output stream.
79 	 */
80 	friend OGDF_EXPORT std::ostream& operator<<(std::ostream &out, const CSense &rhs);
81 
82 	//! Assignment operator.
83 	/**
84 	 * The default assignment operator is overloaded such that also the
85 	 * enumeration \a SENSE can be used on the right hand side.
86 	 *
87 	 * \param rhs The new sense.
88 	 *
89 	 * \return A reference to the sense.
90 	 */
91 	const CSense &operator=(SENSE rhs) {
92 		sense_ = rhs;
93 		return *this;
94 	}
95 
96 	//! Returns the sense of the constraint.
sense()97 	SENSE sense() const { return sense_; }
98 
99 	//! Changes the sense of the constraint.
100 	/**
101 	 * \param s The new sense.
102 	 */
sense(SENSE s)103 	void sense(SENSE s) { sense_ = s; }
104 
105 	//! Changes the sense of the constraint given a letter \a s.
106 	/**
107 	 * \param s The new sense.
108 	 */
109 	void sense(char s);
110 
111 private:
112 
113 	SENSE sense_; //!< Stores the sense of a constraint.
114 };
115 
116 }
117