Toggle navigation
SCIP Optimization Suite
SCIP
SoPlex
ZIMPL
UG
GCG
Documentation
SoPlex 6.0.3
SoPlex 5.0.2
SoPlex 4.0.2
SoPlex 3.1.0
SoPlex 3.0.1
SoPlex 2.2.1
SoPlex
Sequential object-oriented simPlex
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
soplex-repo
src
spxweightst.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-2015 Konrad-Zuse-Zentrum */
7
/* fuer Informationstechnik Berlin */
8
/* */
9
/* SoPlex is distributed under the terms of the ZIB Academic Licence. */
10
/* */
11
/* You should have received a copy of the ZIB Academic License */
12
/* along with SoPlex; see the file COPYING. If not email to soplex@zib.de. */
13
/* */
14
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
15
16
17
/**@file spxweightst.h
18
* @brief Weighted start basis.
19
*/
20
#ifndef _SPXWEIGHTST_H_
21
#define _SPXWEIGHTST_H_
22
23
24
#include <assert.h>
25
26
#include "
spxdefines.h
"
27
#include "
spxstarter.h
"
28
#include "
dataarray.h
"
29
30
namespace
soplex
31
{
32
33
/**@brief Weighted start basis.
34
@ingroup Algo
35
36
Class SPxWeightST is an implementation of a SPxStarter for generating a
37
Simplex starting basis. Using method #setupWeights() it sets up arrays
38
#weight and #coWeight, or equivalently #rowWeight and #colWeight.
39
(#rowWeight and #colWeight are just pointers initialized to #weight and
40
#coWeight according to the representation of SoPlex \p base passed to
41
method #generate().)
42
43
The weight values are then used to setup a starting basis for the LP:
44
vectors with low values are likely to become dual (i.e. basic for a column
45
basis) and such with high values are likely to become primal (i.e. nonbasic
46
for a column basis).
47
48
However, if a variable having an upper and lower bound is to become primal,
49
there is still a choice for setting it either to its upper or lower bound.
50
Members #rowRight and #colUp are used to determine where to set a primal
51
variable. If #rowRight[i] is set to a nonzero value, the right-hand side
52
inequality is set tightly for the \p i 'th to become primal. Analogously, If
53
#colUp[j] is nonzero, the \p j 'th variable will be set to its upper bound
54
if it becomes primal.
55
*/
56
class
SPxWeightST
:
public
SPxStarter
57
{
58
private
:
59
60
//-----------------------------------
61
/**@name Private data */
62
//@{
63
///
64
DataArray < int >
forbidden
;
65
///
66
DataArray < Real >
*
weight
;
67
///
68
DataArray < Real >
*
coWeight
;
69
//@}
70
71
//-----------------------------------
72
/**@name Private helpers */
73
//@{
74
///
75
void
setPrimalStatus
(
SPxBasis::Desc
&,
const
SPxSolver
&,
const
SPxId
&);
76
//@}
77
78
protected
:
79
80
//-----------------------------------
81
/**@name Protected data */
82
//@{
83
/// weight value for LP rows.
84
DataArray < Real >
rowWeight
;
85
/// weight value for LP columns.
86
DataArray < Real >
colWeight
;
87
/// set variable to rhs?.
88
DataArray < bool >
rowRight
;
89
/// set primal variable to upper bound.
90
DataArray < bool >
colUp
;
91
//@}
92
93
//-----------------------------------
94
/**@name Protected helpers */
95
//@{
96
/// sets up variable weights.
97
/** This method is called in order to setup the weights for all
98
variables. It has been declared \c virtual in order to allow for
99
derived classes to compute other weight values.
100
*/
101
virtual
void
setupWeights
(
SPxSolver
& base);
102
//@}
103
104
public
:
105
106
//-----------------------------------
107
/**@name Construction / destruction */
108
//@{
109
/// default constructor.
110
SPxWeightST
()
111
:
SPxStarter
(
"Weight"
)
112
{
113
weight
= 0;
114
coWeight
= 0;
115
assert(
isConsistent
());
116
}
117
/// copy constructor
118
SPxWeightST
(
const
SPxWeightST
& old)
119
:
SPxStarter
(old)
120
,
forbidden
(old.
forbidden
)
121
,
rowWeight
(old.
rowWeight
)
122
,
colWeight
(old.
colWeight
)
123
,
rowRight
(old.
rowRight
)
124
,
colUp
(old.
colUp
)
125
{
126
if
(old.
weight
== &old.
colWeight
)
127
{
128
weight
= &
colWeight
;
129
coWeight
= &
rowWeight
;
130
}
131
else
if
(old.
weight
== &old.
rowWeight
)
132
{
133
weight
= &
rowWeight
;
134
coWeight
= &
colWeight
;
135
}
136
else
// old.weight and old.coWeight are not set correctly, do nothing.
137
{
138
weight
= 0;
139
coWeight
= 0;
140
}
141
142
assert(
isConsistent
());
143
}
144
/// assignment operator
145
SPxWeightST
&
operator=
(
const
SPxWeightST
& rhs)
146
{
147
if
(
this
!= &rhs)
148
{
149
SPxStarter::operator=
(rhs);
150
forbidden
= rhs.
forbidden
;
151
rowWeight
= rhs.
rowWeight
;
152
colWeight
= rhs.
colWeight
;
153
rowRight
= rhs.
rowRight
;
154
colUp
= rhs.
colUp
;
155
156
if
(rhs.
weight
== &rhs.
colWeight
)
157
{
158
weight
= &
colWeight
;
159
coWeight
= &
rowWeight
;
160
}
161
else
if
(rhs.
weight
== &rhs.
rowWeight
)
162
{
163
weight
= &
rowWeight
;
164
coWeight
= &
colWeight
;
165
}
166
else
// old.weight and old.coWeight are not set correctly, do nothing.
167
{}
168
169
assert(
isConsistent
());
170
}
171
172
return
*
this
;
173
}
174
/// destructor.
175
virtual
~SPxWeightST
()
176
{
177
weight
= 0;
178
coWeight
= 0;
179
}
180
/// clone function for polymorphism
181
inline
virtual
SPxStarter
*
clone
()
const
182
{
183
return
new
SPxWeightST
(*
this
);
184
}
185
//@}
186
187
//-----------------------------------
188
/**@name Generation of a start basis */
189
//@{
190
/// generates start basis for loaded basis.
191
void
generate
(
SPxSolver
& base);
192
//@}
193
194
//-----------------------------------
195
/**@name Debugging */
196
//@{
197
/// consistency check.
198
virtual
bool
isConsistent
()
const
;
199
//@}
200
201
};
202
203
}
// namespace soplex
204
#endif // _SPXWEIGHTST_H_