本文整理汇总了C++中Enode::isCostBound方法的典型用法代码示例。如果您正苦于以下问题:C++ Enode::isCostBound方法的具体用法?C++ Enode::isCostBound怎么用?C++ Enode::isCostBound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enode
的用法示例。
在下文中一共展示了Enode::isCostBound方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_status
void CostSolver::check_status()
{
#ifndef NDEBUG
for ( costfuns_t::iterator it = costfuns_.begin();
it != costfuns_.end();
++it )
{
costfun & fun = **it;
codomain slack = 0;
for ( incurnode * n=fun.unassigned.head; n; n=n->next )
{
assert( !n->atom->hasPolarity() );
if ( n->next )
{
assert( n != n->next );
if ( n->cost > n->next->cost )
{
cout << n->cost << " > " << n->next->cost << endl;
}
assert( n->cost <= n->next->cost );
assert( n->next->prev == n );
}
if ( n->prev )
{
assert( n->prev != n );
assert( n->prev->next == n );
}
slack += get_incurred( n->atom );
}
assert( slack == fun.slack );
{
codomain incurred = 0;
for ( costfun::nodes_t::iterator it = fun.assigned.begin();
it != fun.assigned.end();
++it )
{
incurnode * node = *it;
assert( node->atom->hasPolarity() );
if ( node->atom->getPolarity() == l_True )
{
incurred += get_incurred( node->atom );
}
}
if ( fun.incurred != incurred )
{
if ( conflict_ )
{
cout << "conflict = " << conflict_ << endl;
}
cout << "incurred = " << incurred << endl;
print_status( cout, fun );
}
assert( fun.incurred == incurred );
}
}
if ( conflict_ )
{
cout << "ct conflict " << conflict_ << endl;
costfun & fun = *nodemap_.find( conflict_ )->second;
codomain incurred = 0;
Enode * upper_bound = 0;
Enode * lower_bound = 0;
for ( vector<Enode*>::iterator it = explanation.begin();
it != explanation.end();
++it )
{
Enode * atom = *it;
assert( atom->hasPolarity() );
if ( atom->isCostIncur() )
{
if ( atom->getPolarity() == l_True )
{
incurred += get_incurred( atom );
}
}
if ( atom->isCostBound() )
{
if ( atom->getPolarity() == l_True )
{
assert( !upper_bound );
upper_bound = atom;
}
else
{
assert( !lower_bound );
assert( atom->getPolarity() == l_False );
lower_bound = atom;
}
}
}
if ( !fun.lowerbound.empty() && fun.upperbound.empty() )
{
assert( fun.incurred + fun.slack < get_bound( fun.lowerbound.top() ) );
}
if ( fun.lowerbound.empty() && !fun.upperbound.empty() )
{
assert( fun.incurred >= get_bound( fun.upperbound.top() ) );
assert( incurred >= get_bound( upper_bound ) );
}
}
//.........这里部分代码省略.........
示例2: assertLitImpl
//.........这里部分代码省略.........
if ( node->atom->getPolarity() != l_True )
{
continue;
}
if ( incurred - node->cost >= get_bound( fun.upperbound.top() ) )
{
incurred -= node->cost;
continue;
}
#endif
if ( node->atom->getPolarity() == l_True )
{
explanation.push_back( node->atom );
}
}
assert( incurred >= get_bound( fun.upperbound.top() ) );
assert( find( explanation.begin(), explanation.end(), conflict_ ) != explanation.end() );
explanation.push_back( fun.upperbound.top() );
#if DEBUG_CONFLICT
cout << explanation << " : " << fun.slack << endl;
print_status( cout, fun ); cout << endl;
#endif
#if DEBUG
cout << "conflict found " << conflict_ << endl;
print_status( cout, fun );
#endif
#if DEBUG_CHECK_STATUS
check_status();
#endif
return false;
}
}
}
else if ( atom->isCostBound() )
{
#if DEBUG
cout << "ct bound asserted " << atom << endl;
#endif
assert( nodemap_.find( atom ) != nodemap_.end() );
costfun & fun = *nodemap_[ atom ];
Enode * args = atom->getCdr();
Enode * val = args->getCdr()->getCar();
assert( val->isConstant() );
#if DEBUG
cout << atom->get2nd() << endl;
#endif
const codomain & value = atom->get2nd()->getValue();
if ( negated )
{
#if DEBUG
cout << "ct bound asserted negatively " << atom << endl;
#endif
if ( ( !fun.lowerbound.empty() &&
get_bound( fun.lowerbound.top() ) < value ) ||
fun.lowerbound.empty() )
{
#if DEBUG
cout << "ct new lower bound " << atom << endl;
#endif
fun.lowerbound.push( atom );
undo_ops_.push( undo_op( REMOVE_LBOUND, &fun ) );
if ( fun.incurred + fun.slack < get_bound( fun.lowerbound.top() ) )
{
conflict_ = atom;
codomain potential = fun.incurred + fun.slack;
for ( costfun::nodes_t::iterator it = fun.assigned.begin();