| ... | ... |
@@ -161,30 +161,34 @@ |
| 161 | 161 |
|
| 162 | 162 |
private: |
| 163 | 163 |
|
| 164 | 164 |
TEMPLATE_DIGRAPH_TYPEDEFS(GR); |
| 165 | 165 |
|
| 166 | 166 |
typedef std::vector<int> IntVector; |
| 167 | 167 |
typedef std::vector<Value> ValueVector; |
| 168 | 168 |
typedef std::vector<Cost> CostVector; |
| 169 | 169 |
typedef std::vector<char> BoolVector; |
| 170 | 170 |
// Note: vector<char> is used instead of vector<bool> for efficiency reasons |
| 171 | 171 |
|
| 172 | 172 |
// State constants for arcs |
| 173 |
enum |
|
| 173 |
enum ArcState {
|
|
| 174 | 174 |
STATE_UPPER = -1, |
| 175 | 175 |
STATE_TREE = 0, |
| 176 | 176 |
STATE_LOWER = 1 |
| 177 | 177 |
}; |
| 178 | 178 |
|
| 179 |
typedef std::vector<signed char> StateVector; |
|
| 180 |
// Note: vector<signed char> is used instead of vector<ArcState> for |
|
| 181 |
// efficiency reasons |
|
| 182 |
|
|
| 179 | 183 |
private: |
| 180 | 184 |
|
| 181 | 185 |
// Data related to the underlying digraph |
| 182 | 186 |
const GR &_graph; |
| 183 | 187 |
int _node_num; |
| 184 | 188 |
int _arc_num; |
| 185 | 189 |
int _all_arc_num; |
| 186 | 190 |
int _search_arc_num; |
| 187 | 191 |
|
| 188 | 192 |
// Parameters of the problem |
| 189 | 193 |
bool _have_lower; |
| 190 | 194 |
SupplyType _stype; |
| ... | ... |
@@ -206,25 +210,25 @@ |
| 206 | 210 |
ValueVector _flow; |
| 207 | 211 |
CostVector _pi; |
| 208 | 212 |
|
| 209 | 213 |
// Data for storing the spanning tree structure |
| 210 | 214 |
IntVector _parent; |
| 211 | 215 |
IntVector _pred; |
| 212 | 216 |
IntVector _thread; |
| 213 | 217 |
IntVector _rev_thread; |
| 214 | 218 |
IntVector _succ_num; |
| 215 | 219 |
IntVector _last_succ; |
| 216 | 220 |
IntVector _dirty_revs; |
| 217 | 221 |
BoolVector _forward; |
| 218 |
|
|
| 222 |
StateVector _state; |
|
| 219 | 223 |
int _root; |
| 220 | 224 |
|
| 221 | 225 |
// Temporary data used in the current pivot iteration |
| 222 | 226 |
int in_arc, join, u_in, v_in, u_out, v_out; |
| 223 | 227 |
int first, second, right, last; |
| 224 | 228 |
int stem, par_stem, new_stem; |
| 225 | 229 |
Value delta; |
| 226 | 230 |
|
| 227 | 231 |
const Value MAX; |
| 228 | 232 |
|
| 229 | 233 |
public: |
| 230 | 234 |
|
| ... | ... |
@@ -237,25 +241,25 @@ |
| 237 | 241 |
|
| 238 | 242 |
private: |
| 239 | 243 |
|
| 240 | 244 |
// Implementation of the First Eligible pivot rule |
| 241 | 245 |
class FirstEligiblePivotRule |
| 242 | 246 |
{
|
| 243 | 247 |
private: |
| 244 | 248 |
|
| 245 | 249 |
// References to the NetworkSimplex class |
| 246 | 250 |
const IntVector &_source; |
| 247 | 251 |
const IntVector &_target; |
| 248 | 252 |
const CostVector &_cost; |
| 249 |
const |
|
| 253 |
const StateVector &_state; |
|
| 250 | 254 |
const CostVector &_pi; |
| 251 | 255 |
int &_in_arc; |
| 252 | 256 |
int _search_arc_num; |
| 253 | 257 |
|
| 254 | 258 |
// Pivot rule data |
| 255 | 259 |
int _next_arc; |
| 256 | 260 |
|
| 257 | 261 |
public: |
| 258 | 262 |
|
| 259 | 263 |
// Constructor |
| 260 | 264 |
FirstEligiblePivotRule(NetworkSimplex &ns) : |
| 261 | 265 |
_source(ns._source), _target(ns._target), |
| ... | ... |
@@ -289,25 +293,25 @@ |
| 289 | 293 |
}; //class FirstEligiblePivotRule |
| 290 | 294 |
|
| 291 | 295 |
|
| 292 | 296 |
// Implementation of the Best Eligible pivot rule |
| 293 | 297 |
class BestEligiblePivotRule |
| 294 | 298 |
{
|
| 295 | 299 |
private: |
| 296 | 300 |
|
| 297 | 301 |
// References to the NetworkSimplex class |
| 298 | 302 |
const IntVector &_source; |
| 299 | 303 |
const IntVector &_target; |
| 300 | 304 |
const CostVector &_cost; |
| 301 |
const |
|
| 305 |
const StateVector &_state; |
|
| 302 | 306 |
const CostVector &_pi; |
| 303 | 307 |
int &_in_arc; |
| 304 | 308 |
int _search_arc_num; |
| 305 | 309 |
|
| 306 | 310 |
public: |
| 307 | 311 |
|
| 308 | 312 |
// Constructor |
| 309 | 313 |
BestEligiblePivotRule(NetworkSimplex &ns) : |
| 310 | 314 |
_source(ns._source), _target(ns._target), |
| 311 | 315 |
_cost(ns._cost), _state(ns._state), _pi(ns._pi), |
| 312 | 316 |
_in_arc(ns.in_arc), _search_arc_num(ns._search_arc_num) |
| 313 | 317 |
{}
|
| ... | ... |
@@ -328,25 +332,25 @@ |
| 328 | 332 |
}; //class BestEligiblePivotRule |
| 329 | 333 |
|
| 330 | 334 |
|
| 331 | 335 |
// Implementation of the Block Search pivot rule |
| 332 | 336 |
class BlockSearchPivotRule |
| 333 | 337 |
{
|
| 334 | 338 |
private: |
| 335 | 339 |
|
| 336 | 340 |
// References to the NetworkSimplex class |
| 337 | 341 |
const IntVector &_source; |
| 338 | 342 |
const IntVector &_target; |
| 339 | 343 |
const CostVector &_cost; |
| 340 |
const |
|
| 344 |
const StateVector &_state; |
|
| 341 | 345 |
const CostVector &_pi; |
| 342 | 346 |
int &_in_arc; |
| 343 | 347 |
int _search_arc_num; |
| 344 | 348 |
|
| 345 | 349 |
// Pivot rule data |
| 346 | 350 |
int _block_size; |
| 347 | 351 |
int _next_arc; |
| 348 | 352 |
|
| 349 | 353 |
public: |
| 350 | 354 |
|
| 351 | 355 |
// Constructor |
| 352 | 356 |
BlockSearchPivotRule(NetworkSimplex &ns) : |
| ... | ... |
@@ -401,25 +405,25 @@ |
| 401 | 405 |
}; //class BlockSearchPivotRule |
| 402 | 406 |
|
| 403 | 407 |
|
| 404 | 408 |
// Implementation of the Candidate List pivot rule |
| 405 | 409 |
class CandidateListPivotRule |
| 406 | 410 |
{
|
| 407 | 411 |
private: |
| 408 | 412 |
|
| 409 | 413 |
// References to the NetworkSimplex class |
| 410 | 414 |
const IntVector &_source; |
| 411 | 415 |
const IntVector &_target; |
| 412 | 416 |
const CostVector &_cost; |
| 413 |
const |
|
| 417 |
const StateVector &_state; |
|
| 414 | 418 |
const CostVector &_pi; |
| 415 | 419 |
int &_in_arc; |
| 416 | 420 |
int _search_arc_num; |
| 417 | 421 |
|
| 418 | 422 |
// Pivot rule data |
| 419 | 423 |
IntVector _candidates; |
| 420 | 424 |
int _list_length, _minor_limit; |
| 421 | 425 |
int _curr_length, _minor_count; |
| 422 | 426 |
int _next_arc; |
| 423 | 427 |
|
| 424 | 428 |
public: |
| 425 | 429 |
|
| ... | ... |
@@ -504,25 +508,25 @@ |
| 504 | 508 |
}; //class CandidateListPivotRule |
| 505 | 509 |
|
| 506 | 510 |
|
| 507 | 511 |
// Implementation of the Altering Candidate List pivot rule |
| 508 | 512 |
class AlteringListPivotRule |
| 509 | 513 |
{
|
| 510 | 514 |
private: |
| 511 | 515 |
|
| 512 | 516 |
// References to the NetworkSimplex class |
| 513 | 517 |
const IntVector &_source; |
| 514 | 518 |
const IntVector &_target; |
| 515 | 519 |
const CostVector &_cost; |
| 516 |
const |
|
| 520 |
const StateVector &_state; |
|
| 517 | 521 |
const CostVector &_pi; |
| 518 | 522 |
int &_in_arc; |
| 519 | 523 |
int _search_arc_num; |
| 520 | 524 |
|
| 521 | 525 |
// Pivot rule data |
| 522 | 526 |
int _block_size, _head_length, _curr_length; |
| 523 | 527 |
int _next_arc; |
| 524 | 528 |
IntVector _candidates; |
| 525 | 529 |
CostVector _cand_cost; |
| 526 | 530 |
|
| 527 | 531 |
// Functor class to compare arcs during sort of the candidate list |
| 528 | 532 |
class SortFunc |
0 comments (0 inline)