void FileAllocator::allocateAsap( const string &name, unsigned long long &size ) { scoped_lock lk( _pendingMutex ); long oldSize = prevSize( name ); if ( oldSize != -1 ) { size = oldSize; if ( !inProgress( name ) ) return; } checkFailure(); _pendingSize[ name ] = size; if ( _pending.size() == 0 ) _pending.push_back( name ); else if ( _pending.front() != name ) { _pending.remove( name ); list< string >::iterator i = _pending.begin(); ++i; _pending.insert( i, name ); } _pendingUpdated.notify_all(); while( inProgress( name ) ) { checkFailure(); _pendingUpdated.wait( lk.boost() ); } }
// check only modifications on the objective variable void whenRange() { checkFailure(); wcsp->enforceUb(); // fail if lower bound >= upper bound and enforce NC* if (obj.getMax() + 1 < wcsp->getUb()) { wcsp->decreaseUb(obj.getMax() + 1); } push(); // global propagation done after local propagation }
// global propagation using WCSP propagation queues void propagate() { checkFailure(); if (synchronized) { synchronized.setValue(getSolver(), IlcFalse); synchronize(); } if (ToulBar2::verbose >= 2) cout << "ILOG: propagate wcsp index " << wcsp->getIndex() << endl; wcsp->decreaseUb(obj.getMax() + 1); wcsp->propagate(); }
// variable varIndex has its domain reduced void whenDomain(const IlcInt varIndex) { checkFailure(); if (!vars[varIndex].isBound()) { for (IlcIntVarDeltaIterator iter(vars[varIndex]); iter.ok(); ++iter) { IlcInt val = *iter; if (ToulBar2::verbose >= 2) cout << "ILOG: " << vars[varIndex].getName() << " != " << val << endl; wcsp->remove(varIndex, val); } push(); // global propagation done after local propagation } }
// variable varIndex has been assigned void whenValue(const IlcInt varIndex) { checkFailure(); if (ToulBar2::verbose >= 2) cout << "ILOG: " << vars[varIndex].getName() << " = " << vars[varIndex].getValue() << endl; wcsp->assign(varIndex, vars[varIndex].getValue()); if (unassignedVars->canbe(varIndex)) { unassignedVars->erase(varIndex); if (unassignedVars->empty()) { assert(wcsp->verify()); obj.setValue(wcsp->getLb()); } } push(); // global propagation done after local propagation }
bool PlannerThread::planning_cycle() { checkPause(); if (!updateState()) { return false; } checkPause(); if (!completePlannerState()) { return false; } checkPause(); if (!loadState()) { return false; } checkPause(); if (compareState()) { checkPause(); if (!adaptRules()) { return false; } checkPause(); } checkPause(); if (!goalUpdate()) { return false; } checkPause(); if (!loadGoal()) { return false; } checkPause(); if (!planCompletion()) { return true; } checkPause(); if (!checkHoldingSymbols()) { checkPause(); jumpBack(); checkPause(); if (!resetConfig()) { return false; } checkPause(); } else { checkPause(); if (checkGoalCompletion()) { checkPause(); if (!resetRules()) { return false; } checkPause(); if (!resetConfig()) { return false; } checkPause(); if (!loadRules()) { return false; } checkPause(); if (!jumpForward()) { return false; } checkPause(); return true; } checkPause(); int flag_prada = PRADA(); checkPause(); if (flag_prada == 0) { return false; } else if (flag_prada == 2) { if (!increaseHorizon()) { return false; } checkPause(); return true; } if (!loadUsedObjs()) { return false; } checkPause(); if (!codeAction()) { return false; } checkPause(); if (!execAction()) { return false; } checkPause(); if (!preserveState()) { return false; } checkPause(); if (!checkFailure()) { return false; } checkPause(); } checkPause(); return true; }
void TestCaseTest::testNoFailure() { checkFailure( false, false, false ); }
void TestCaseTest::testFailAll() { checkFailure( true, true, true ); }
void TestCaseTest::testTearDownFailure() { checkFailure( false, false, true ); }
void TestCaseTest::testRunTestFailure() { checkFailure( false, true, false ); }
void TestCaseTest::testSetUpFailure() { checkFailure( true, false, false ); }