コード例 #1
0
    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() );
        }

    }
コード例 #2
0
 // 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
 }
コード例 #3
0
 // 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();
 }
コード例 #4
0
 // 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
     }
 }
コード例 #5
0
 // 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
 }
コード例 #6
0
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;
}    
コード例 #7
0
ファイル: TestCaseTest.cpp プロジェクト: asir6/Colt
void 
TestCaseTest::testNoFailure()
{
  checkFailure( false, false, false );
}
コード例 #8
0
ファイル: TestCaseTest.cpp プロジェクト: asir6/Colt
void 
TestCaseTest::testFailAll()
{
  checkFailure( true, true, true );
}
コード例 #9
0
ファイル: TestCaseTest.cpp プロジェクト: asir6/Colt
void 
TestCaseTest::testTearDownFailure()
{
  checkFailure( false, false, true );
}
コード例 #10
0
ファイル: TestCaseTest.cpp プロジェクト: asir6/Colt
void 
TestCaseTest::testRunTestFailure()
{
  checkFailure( false, true, false );
}
コード例 #11
0
ファイル: TestCaseTest.cpp プロジェクト: asir6/Colt
void 
TestCaseTest::testSetUpFailure()
{
  checkFailure( true, false, false );
}