File: column.h

package info (click to toggle)
tulip 4.8.0dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 179,264 kB
  • ctags: 64,517
  • sloc: cpp: 600,444; ansic: 36,311; makefile: 22,136; python: 1,304; sh: 946; yacc: 522; xml: 337; pascal: 157; php: 66; lex: 55
file content (162 lines) | stat: -rw-r--r-- 4,878 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * $Revision: 3386 $
 *
 * last checkin:
 *   $Author: gutwenger $
 *   $Date: 2013-04-10 14:00:02 +0200 (Wed, 10 Apr 2013) $
 ***************************************************************/

/*!\file
 * \author Matthias Elf
 * \brief column.
 *
 * \par License:
 * This file is part of ABACUS - A Branch And CUt System
 * Copyright (C) 1995 - 2003
 * University of Cologne, Germany
 *
 * \par
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * \par
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * \par
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * \see http://www.gnu.org/copyleft/gpl.html
 */

#ifndef ABA__COLUMN_H
#define ABA__COLUMN_H

#include <ogdf/abacus/sparvec.h>

namespace abacus {

//! Representation of variables in column format.
/**
 * The class Column refines SparVec for the representation of variables in column format.
 * In the same way as the class Row refines the class SparVec for the
 * representation of constraints in row format, the class Column refines
 * SparVec for the representation of variables in column format.
 * This class should not be confused with the class Variable for the
 * abstract representation of variables within the framework. Again, there
 * is a class ColVar derived from Variable having a member of type
 * Column, but there are also other classes derived from Variable.
 */
class  Column :  public SparVec  {
public:

	//! Creates and initializes a column.
	/**
	 * \param glob A pointer to the corresponding global object.
	 * \param obj  The objective function coefficient.
	 * \param lb   The lower bound.
	 * \param ub   The upper bound.
	 * \param nnz  The number of nonzero elements stored in the arrays \a s and \a c.
	 * \param s    An array of the nonzero elements of the column.
	 * \param c    An array of the nonzero coefficients associated with the elements of \a s.
	 */
	Column(AbacusGlobal *glob,
		double obj,
		double lb,
		double ub,
		int nnz,
		Array<int> &s,
		Array<double> &c)
		: SparVec(glob, nnz, s, c), obj_(obj), lBound_(lb), uBound_(ub) { }

	//! Creates an uninitialized column.
	/**
	 * \param glob   A pointer to the corresponding global object.
	 * \param maxNnz The maximal number of nonzero elements that can be stored in the row.
	 */
	Column(AbacusGlobal *glob, int maxNnz) : SparVec(glob, maxNnz) { }

	//! Creates a column initialized by a sparse vector \a vec.
	/**
	 * \param glob  A pointer to the corresponding global object.
	 * \param obj   The objective function coefficient.
	 * \param lb    The lower bound.
	 * \param ub    The upper bound.
	 * \param vec   A sparse vector storing the support and the coefficients of the column.
	 */
	Column(AbacusGlobal *glob,
		double obj,
		double lb,
		double ub,
		SparVec &vec)
		: SparVec(vec), obj_(obj), lBound_(lb), uBound_(ub) { }

	~Column() { }

	//! The output operator.
	/**
	 * \param out The output stream.
	 * \param rhs The column being output.
	 *
	 * \return A reference to the output stream.
	 */
	friend ostream& operator<<(ostream &out, const Column &rhs);

	//! Returns the objective function coefficient of the column.
	double obj() const { return obj_; }


	//! Sets the objective function coefficient of the column to \ c.
	/**
	 * \param c The new value of the objective function coefficient.
	 */
	void obj(double c) { obj_ = c; }


	//! Returns the lower bound of the column.
	double lBound() const { return lBound_; }


	//! Sets the lower bound of the column to \a l.
	/**
	 * \param l The new value of the lower bound.
	 */
	void lBound(double l) { lBound_ = l; }


	//! Returns the upper bound of the column.
	double uBound() const { return uBound_; }


	//! Sets the upper bound of the column to \a u.
	/**
	 * \param u The new value of the upper bound.
	 */
	void uBound(double u) { uBound_ = u; }


	//! Copies column \a col.
	/**
	 * Is very similar to the assignment operator, yet the columns do not have
	 * to be of equal size. A reallocation is performed if required.
	 *
	 * \param col The column that is copied.
	 */
	void copy(const Column &col);

private:

	double obj_;     //!< The objective function coefficient of the column.
	double lBound_;  //!< The lower bound of the column.
	double uBound_;  //!< The upper bound of the column.
};

} //namespace abacus

#endif  // Column_H