Alps
2.0.2
Alps
src
AlpsHelperFunctions.h
Go to the documentation of this file.
1
/*===========================================================================*
2
* This file is part of the Abstract Library for Parallel Search (ALPS). *
3
* *
4
* ALPS is distributed under the Eclipse Public License as part of the *
5
* COIN-OR repository (http://www.coin-or.org). *
6
* *
7
* Authors: *
8
* *
9
* Yan Xu, Lehigh University *
10
* Aykut Bulut, Lehigh University *
11
* Ted Ralphs, Lehigh University *
12
* *
13
* Conceptual Design: *
14
* *
15
* Yan Xu, Lehigh University *
16
* Ted Ralphs, Lehigh University *
17
* Laszlo Ladanyi, IBM T.J. Watson Research Center *
18
* Matthew Saltzman, Clemson University *
19
* *
20
* *
21
* Copyright (C) 2001-2023, Lehigh University, Yan Xu, Aykut Bulut, and *
22
* Ted Ralphs. *
23
* All Rights Reserved. *
24
*===========================================================================*/
25
26
27
#ifndef AlpsHelperFunctions_h_
28
#define AlpsHelperFunctions_h_
29
30
#if defined(NF_DEBUG)
31
#include <iostream>
32
#endif
33
#include <cmath>
34
35
#include "CoinTime.hpp"
36
37
#include "
AlpsTreeNode.h
"
38
39
//#############################################################################
40
42
class
TotalWorkload
:
public
std::unary_function<AlpsTreeNode*, void> {
43
44
private
:
45
double
totalLoad_
;
46
double
incVal_
;
47
double
rho_
;
48
49
public
:
50
TotalWorkload
(
const
double
incVal,
const
double
rho)
51
:
52
totalLoad_
(0.0),
53
incVal_
(incVal),
54
rho_
(rho)
55
{}
56
57
void
operator()
(
AlpsTreeNode
*& node) {
58
totalLoad_
+= pow(fabs(
incVal_
- node->
getQuality
()),
rho_
);
59
}
60
61
double
result
()
const
{
return
totalLoad_
; }
62
};
63
64
//#############################################################################
66
struct
DeletePtrObject
67
{
68
template
<
class
T>
69
void
operator()
(
const
T* ptr)
const
70
{
71
delete
ptr;
72
}
73
};
74
75
//#############################################################################
77
inline
void
AlpsSleep
(
double
sec)
78
{
79
double
start = CoinCpuTime();
80
while
( (CoinCpuTime() - start) < sec) { };
81
}
82
#endif
TotalWorkload::TotalWorkload
TotalWorkload(const double incVal, const double rho)
Definition:
AlpsHelperFunctions.h:50
DeletePtrObject
Definition:
AlpsHelperFunctions.h:66
AlpsSleep
void AlpsSleep(double sec)
Delay for the specified seconds.
Definition:
AlpsHelperFunctions.h:77
TotalWorkload::operator()
void operator()(AlpsTreeNode *&node)
Definition:
AlpsHelperFunctions.h:57
AlpsTreeNode.h
AlpsTreeNode
This class holds one node of the search tree.
Definition:
AlpsTreeNode.h:52
DeletePtrObject::operator()
void operator()(const T *ptr) const
Definition:
AlpsHelperFunctions.h:69
AlpsTreeNode::getQuality
double getQuality() const
Query/set the quality of the node.
Definition:
AlpsTreeNode.h:207
TotalWorkload::totalLoad_
double totalLoad_
Definition:
AlpsHelperFunctions.h:45
TotalWorkload::result
double result() const
Definition:
AlpsHelperFunctions.h:61
TotalWorkload::rho_
double rho_
Definition:
AlpsHelperFunctions.h:47
TotalWorkload
A functor class used in calulating total workload in a node pool.
Definition:
AlpsHelperFunctions.h:42
TotalWorkload::incVal_
double incVal_
Definition:
AlpsHelperFunctions.h:46
Generated by
1.8.17