- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 * Ted Ralphs, Lehigh University *
11 * *
12 * Conceptual Design: *
13 * *
14 * Yan Xu, Lehigh University *
15 * Ted Ralphs, Lehigh University *
16 * Laszlo Ladanyi, IBM T.J. Watson Research Center *
17 * Matthew Saltzman, Clemson University *
18 * *
19 * *
20 * Copyright (C) 2001-2013, Lehigh University, Yan Xu, and Ted Ralphs. *
21 *===========================================================================*/
22
23 #ifndef AlpsHelperFunctions_h_
24 #define AlpsHelperFunctions_h_
25
26 #if defined(NF_DEBGU)
27 #include <iostream>
28 #endif
29 #include <cmath>
30
31 #include "CoinTime.hpp"
32
33 #include "AlpsTreeNode.h"
34
35 //#############################################################################
36
38 class TotalWorkload : public std::unary_function<AlpsTreeNode*, void> {
39
40 private:
41 double totalLoad_;
42 double incVal_;
43 double rho_;
44
45 public:
46 TotalWorkload(const double incVal, const double rho)
47 :
48 totalLoad_(0.0),
49 incVal_(incVal),
50 rho_(rho)
51 {}
52
53 void operator()(AlpsTreeNode*& node) {
54 totalLoad_ += pow(fabs(incVal_ - node->getQuality()), rho_);
55 }
56
57 double result() const { return totalLoad_; }
58 };
59
60 //#############################################################################
62 struct DeletePtrObject
63 {
64 template<class T>
65 void operator()(const T* ptr) const
66 {
67 delete ptr;
68 }
69 };
70
71 //#############################################################################
73 inline void AlpsSleep(double sec)
74 {
75 double start = CoinCpuTime();
76 while ( (CoinCpuTime() - start) < sec) { };
77 }
78 #endif
TotalWorkload::TotalWorkload
TotalWorkload(const double incVal, const double rho)
Definition: AlpsHelperFunctions.h:46
TotalWorkload::result
double result() const
Definition: AlpsHelperFunctions.h:57
TotalWorkload
A functor class used in calulating total workload in a node pool.
Definition: AlpsHelperFunctions.h:38
DeletePtrObject::operator()
void operator()(const T *ptr) const
Definition: AlpsHelperFunctions.h:65
TotalWorkload::operator()
void operator()(AlpsTreeNode *&node)
Definition: AlpsHelperFunctions.h:53
AlpsSleep
void AlpsSleep(double sec)
Delay for the specified seconds.
Definition: AlpsHelperFunctions.h:73
TotalWorkload::incVal_
double incVal_
Definition: AlpsHelperFunctions.h:42
AlpsTreeNode
This class holds one node of the search tree.
Definition: AlpsTreeNode.h:50
CoinCpuTime
static double CoinCpuTime()
Definition: CoinTime.hpp:106
DeletePtrObject
Definition: AlpsHelperFunctions.h:62
TotalWorkload::rho_
double rho_
Definition: AlpsHelperFunctions.h:43
TotalWorkload::totalLoad_
double totalLoad_
Definition: AlpsHelperFunctions.h:41
AlpsTreeNode.h
CoinTime.hpp
AlpsTreeNode::getQuality
double getQuality() const
Query/set the quality of the node.
Definition: AlpsTreeNode.h:222