Changed the sense of the < operator for heap: it is reversed according to the stl where highest score elements must float in the heap
Completed TimeBudget Termination condition. Parametrized the ClearHeap procedure now there is a HeapSimplexRatio param. Removed dirty printf.
This commit is contained in:
parent
2ef5b676b5
commit
a7b6938a1e
|
@ -22,6 +22,9 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
$Log: not supported by cvs2svn $
|
$Log: not supported by cvs2svn $
|
||||||
|
Revision 1.14 2005/04/14 11:34:33 ponchio
|
||||||
|
*** empty log message ***
|
||||||
|
|
||||||
Revision 1.13 2005/01/19 10:33:50 cignoni
|
Revision 1.13 2005/01/19 10:33:50 cignoni
|
||||||
Improved ClearHeap management
|
Improved ClearHeap management
|
||||||
|
|
||||||
|
@ -132,7 +135,7 @@ template<class MeshType>
|
||||||
class LocalOptimization
|
class LocalOptimization
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LocalOptimization(MeshType &mm): m(mm){ ClearTermination();e=0.0;}
|
LocalOptimization(MeshType &mm): m(mm){ ClearTermination();e=0.0;HeapSimplexRatio=5;}
|
||||||
|
|
||||||
struct HeapElem;
|
struct HeapElem;
|
||||||
// scalar type
|
// scalar type
|
||||||
|
@ -162,12 +165,16 @@ public:
|
||||||
nTargetSimplices,
|
nTargetSimplices,
|
||||||
nTargetVertices;
|
nTargetVertices;
|
||||||
|
|
||||||
int timeBudget,
|
float timeBudget;
|
||||||
start;
|
int start;
|
||||||
float
|
float currMetric,
|
||||||
currMetric,
|
|
||||||
targetMetric;
|
targetMetric;
|
||||||
|
|
||||||
|
// The ratio between Heap size and the number of simplices in the current mesh
|
||||||
|
// When this value is exceeded a ClearHeap Start;
|
||||||
|
|
||||||
|
float HeapSimplexRatio;
|
||||||
|
|
||||||
void SetTerminationFlag (int v){tf |= v;}
|
void SetTerminationFlag (int v){tf |= v;}
|
||||||
void ClearTerminationFlag (int v){tf &= ~v;}
|
void ClearTerminationFlag (int v){tf &= ~v;}
|
||||||
bool IsTerminationFlag (int v){return ((tf & v)!=0);}
|
bool IsTerminationFlag (int v){return ((tf & v)!=0);}
|
||||||
|
@ -221,7 +228,7 @@ public:
|
||||||
/// usually we mean priority as an error so we should invert the comparison
|
/// usually we mean priority as an error so we should invert the comparison
|
||||||
inline const bool operator <(const HeapElem & h) const
|
inline const bool operator <(const HeapElem & h) const
|
||||||
{
|
{
|
||||||
return (pri < h.pri);
|
return (pri > h.pri);
|
||||||
//return (locModPtr->Priority() < h.locModPtr->Priority());
|
//return (locModPtr->Priority() < h.locModPtr->Priority());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,10 +256,11 @@ public:
|
||||||
nPerfmormedOps =0;
|
nPerfmormedOps =0;
|
||||||
while( !GoalReached() && !h.empty())
|
while( !GoalReached() && !h.empty())
|
||||||
{
|
{
|
||||||
if(h.size()> m.fn*5 ) ClearHeap();
|
if(h.size()> m.SimplexNumber()*HeapSimplexRatio ) ClearHeap();
|
||||||
std::pop_heap(h.begin(),h.end());
|
std::pop_heap(h.begin(),h.end());
|
||||||
LocModPtrType locMod = h.back().locModPtr;
|
LocModPtrType locMod = h.back().locModPtr;
|
||||||
h.pop_back();
|
currMetric=h.back().pri;
|
||||||
|
h.pop_back();
|
||||||
|
|
||||||
if( locMod->IsUpToDate() )
|
if( locMod->IsUpToDate() )
|
||||||
{
|
{
|
||||||
|
@ -288,7 +296,7 @@ void ClearHeap()
|
||||||
--hi;
|
--hi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("\nReduced heap from %7i to %7i (fn %7i) ",sz,h.size(),m.fn);
|
//printf("\nReduced heap from %7i to %7i (fn %7i) ",sz,h.size(),m.fn);
|
||||||
make_heap(h.begin(),h.end());
|
make_heap(h.begin(),h.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue