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
163
164
165
166
|
/* $Id: CoinWarmStartDual.hpp 1372 2011-01-03 23:31:00Z lou $ */
// Copyright (C) 2000, International Business Machines
// Corporation and others. All Rights Reserved.
// This code is licensed under the terms of the Eclipse Public License (EPL).
#ifndef CoinWarmStartDual_H
#define CoinWarmStartDual_H
#include "CoinHelperFunctions.hpp"
#include "CoinWarmStart.hpp"
#include "CoinWarmStartVector.hpp"
//#############################################################################
/** WarmStart information that is only a dual vector */
class CoinWarmStartDual : public virtual CoinWarmStart {
public:
/// return the size of the dual vector
inline int size() const { return dual_.size(); }
/// return a pointer to the array of duals
inline const double * dual() const { return dual_.values(); }
/** Assign the dual vector to be the warmstart information. In this method
the object assumes ownership of the pointer and upon return "dual" will
be a NULL pointer. If copying is desirable use the constructor. */
inline void assignDual(int size, double *& dual)
{ dual_.assignVector(size, dual); }
CoinWarmStartDual() {}
CoinWarmStartDual(int size, const double * dual) : dual_(size, dual) {}
CoinWarmStartDual(const CoinWarmStartDual& rhs) : dual_(rhs.dual_) {}
CoinWarmStartDual& operator=(const CoinWarmStartDual& rhs) {
if (this != &rhs) {
dual_ = rhs.dual_;
}
return *this;
}
/** `Virtual constructor' */
virtual CoinWarmStart *clone() const {
return new CoinWarmStartDual(*this);
}
virtual ~CoinWarmStartDual() {}
/*! \name Dual warm start `diff' methods */
//@{
/*! \brief Generate a `diff' that can convert the warm start passed as a
parameter to the warm start specified by \c this.
The capabilities are limited: the basis passed as a parameter can be no
larger than the basis pointed to by \c this.
*/
virtual CoinWarmStartDiff*
generateDiff (const CoinWarmStart *const oldCWS) const ;
/*! \brief Apply \p diff to this warm start.
Update this warm start by applying \p diff. It's assumed that the
allocated capacity of the warm start is sufficiently large.
*/
virtual void applyDiff (const CoinWarmStartDiff *const cwsdDiff) ;
#if 0
protected:
inline const CoinWarmStartVector<double>& warmStartVector() const { return dual_; }
#endif
//@}
private:
///@name Private data members
CoinWarmStartVector<double> dual_;
};
//#############################################################################
/*! \class CoinWarmStartDualDiff
\brief A `diff' between two CoinWarmStartDual objects
This class exists in order to hide from the world the details of
calculating and representing a `diff' between two CoinWarmStartDual
objects. For convenience, assignment, cloning, and deletion are visible to
the world, and default and copy constructors are made available to derived
classes. Knowledge of the rest of this structure, and of generating and
applying diffs, is restricted to the friend functions
CoinWarmStartDual::generateDiff() and CoinWarmStartDual::applyDiff().
The actual data structure is a pair of vectors, #diffNdxs_ and #diffVals_.
*/
class CoinWarmStartDualDiff : public virtual CoinWarmStartDiff
{ public:
/*! \brief `Virtual constructor' */
virtual CoinWarmStartDiff *clone() const
{
return new CoinWarmStartDualDiff(*this) ;
}
/*! \brief Assignment */
virtual CoinWarmStartDualDiff &operator= (const CoinWarmStartDualDiff &rhs)
{
if (this != &rhs) {
diff_ = rhs.diff_;
}
return *this;
}
/*! \brief Destructor */
virtual ~CoinWarmStartDualDiff() {}
protected:
/*! \brief Default constructor
This is protected (rather than private) so that derived classes can
see it when they make <i>their</i> default constructor protected or
private.
*/
CoinWarmStartDualDiff () : diff_() {}
/*! \brief Copy constructor
For convenience when copying objects containing CoinWarmStartDualDiff
objects. But consider whether you should be using #clone() to retain
polymorphism.
This is protected (rather than private) so that derived classes can
see it when the make <i>their</i> copy constructor protected or
private.
*/
CoinWarmStartDualDiff (const CoinWarmStartDualDiff &rhs) :
diff_(rhs.diff_) {}
private:
friend CoinWarmStartDiff*
CoinWarmStartDual::generateDiff(const CoinWarmStart *const oldCWS) const ;
friend void
CoinWarmStartDual::applyDiff(const CoinWarmStartDiff *const diff) ;
/*! \brief Standard constructor */
CoinWarmStartDualDiff (int sze, const unsigned int *const diffNdxs,
const double *const diffVals) :
diff_(sze, diffNdxs, diffVals) {}
/*!
\brief The difference in the dual vector is simply the difference in a
vector.
*/
CoinWarmStartVectorDiff<double> diff_;
};
#endif
|