本文整理汇总了C++中Propagator类的典型用法代码示例。如果您正苦于以下问题:C++ Propagator类的具体用法?C++ Propagator怎么用?C++ Propagator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Propagator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkDestination
void TraineeWalker::computeWalkerPath()
{
_maxNeed = 0; // need of this trainee in buildings
Propagator pathPropagator;
pathPropagator.init(*_originBuilding);
pathPropagator.propagate(_maxDistance);
for (std::list<BuildingType>::iterator itType = _buildingNeed.begin(); itType != _buildingNeed.end(); ++itType)
{
BuildingType buildingType = *itType;
checkDestination(buildingType, pathPropagator);
}
if (_destinationBuilding != NULL)
{
// some building needs that trainee!
// std::cout << "trainee sent!" << std::endl;
PathWay pathWay;
pathPropagator.getPath(*_destinationBuilding, pathWay);
setPathWay(pathWay);
setIJ(_pathWay.getOrigin().getI(), _pathWay.getOrigin().getJ());
Scenario::instance().getCity().getWalkerList().push_back(this);
_destinationBuilding->reserveTrainee(_traineeType);
}
else
{
// nobody needs him...
// std::cout << "trainee suicide!" << std::endl;
_isDeleted = true;
}
}
示例2: assert
bool Engine::propagate() {
if (async_fail) {
async_fail = false;
assert(!so.lazy || sat.confl);
return false;
}
last_prop = NULL;
WakeUp:
if (!sat.consistent() && !sat.propagate()) return false;
for (int i = 0; i < v_queue.size(); i++) {
v_queue[i]->wakePropagators();
}
v_queue.clear();
if (sat.confl) return false;
last_prop = NULL;
for (int i = 0; i < num_queues; i++) {
if (p_queue[i].size()) {
Propagator *p = p_queue[i].last(); p_queue[i].pop();
propagations++;
bool ok = p->propagate();
p->clearPropState();
if (!ok) return false;
goto WakeUp;
}
}
return true;
}
示例3: checkDestination
void TraineeWalker::computeWalkerPath()
{
_maxNeed = 0; // need of this trainee in buildings
Propagator pathPropagator;
pathPropagator.init( *_originBuilding.object() );
pathPropagator.propagate(_maxDistance);
for (std::list<BuildingType>::iterator itType = _buildingNeed.begin(); itType != _buildingNeed.end(); ++itType)
{
BuildingType buildingType = *itType;
checkDestination(buildingType, pathPropagator);
}
if( _destinationBuilding != NULL )
{
// some building needs that trainee!
// std::cout << "trainee sent!" << std::endl;
PathWay pathWay;
pathPropagator.getPath( _destinationBuilding, pathWay);
setPathWay( pathWay );
setIJ( _pathWay.getOrigin().getIJ() );
}
else
{
// nobody needs him...
// std::cout << "trainee suicide!" << std::endl;
deleteLater();
}
}
示例4: assignPath
void Emigrant::assignPath( const Road& startPoint )
{
std::list<PathWay> pathWayList;
std::list<LandOverlay*> houses = Scenario::instance().getCity().getBuildingList(B_HOUSE);
House* blankHouse = 0;
for( std::list<LandOverlay*>::iterator itHouse = houses.begin(); itHouse != houses.end(); ++itHouse )
{
if( House* house = dynamic_cast<House*>(*itHouse) )
{
if( house->getNbHabitants() < house->getMaxHabitants() )
{
blankHouse = house;
_d->destination = house->getTile().getIJ();
break;
}
}
}
Propagator pathfinder;
PathWay pathWay;
pathfinder.init( const_cast< Road& >( startPoint ) );
bool findPath = pathfinder.getPath( *blankHouse, pathWay );
if( findPath )
{
setPathWay( pathWay );
setIJ(_pathWay.getOrigin().getI(), _pathWay.getOrigin().getJ());
}
}
示例5: computeWalkerPath
void ServiceWalker::computeWalkerPath()
{
std::list<PathWay> pathWayList;
Propagator pathPropagator;
pathPropagator.init(*_building);
pathPropagator.getAllPaths(_maxDistance, pathWayList);
float maxPathValue = 0.0;
PathWay* bestPath = NULL;
for (std::list<PathWay>::iterator itPath = pathWayList.begin(); itPath != pathWayList.end(); ++itPath)
{
PathWay &path = *itPath;
float pathValue = evaluatePath(path);
if (pathValue > maxPathValue)
{
bestPath = &path;
maxPathValue = pathValue;
}
}
if (bestPath == NULL)
{
// no good path
_isDeleted = true;
return;
}
reservePath(*bestPath);
setPathWay(*bestPath);
setIJ(_pathWay.getOrigin().getI(), _pathWay.getOrigin().getJ());
Scenario::instance().getCity().getWalkerList().push_back(this);
}
示例6:
void Roads::Impl::updateRoadsAround( Propagator& propagator, UpdateInfo info )
{
propagator.init( info.first );
PathwayList pathWayList = propagator.getWays( info.second );
for( auto& path : pathWayList )
{
RoadList roads = path->allTiles().overlays<Road>();
for( auto road : roads )
road->appendPaved( paved.increase );
}
}
示例7: getWalkerDestination_factory
BuildingPtr CartPusher::getWalkerDestination_factory(Propagator &pathPropagator, PathWay &oPathWay)
{
BuildingPtr res;
GoodType goodType = _d->stock._goodType;
BuildingType buildingType = BuildingDataHolder::instance().getBuildingTypeByInGood(goodType);
if (buildingType == B_NONE)
{
// no factory can use this good
return NULL;
}
Propagator::ReachedBuldings pathWayList;
pathPropagator.getReachedBuildings(buildingType, pathWayList);
for( Propagator::ReachedBuldings::iterator pathWayIt= pathWayList.begin(); pathWayIt != pathWayList.end(); ++pathWayIt)
{
// for every factory within range
BuildingPtr building= pathWayIt->first;
PathWay& pathWay= pathWayIt->second;
SmartPtr<Factory> factory = building.as<Factory>();
_d->reservationID = factory->getGoodStore().reserveStorage(_d->stock);
if (_d->reservationID != 0)
{
res = factory.as<Building>();
oPathWay = pathWay;
break;
}
}
return res;
}
示例8: Compute
double Kernel::
Compute(Propagator & propagator) const
{
if(0 == propagator.GetNUpwindNeighbors())
return infinity;
return DoCompute(propagator);
}
示例9: getWarehouse4Buys
Propagator::DirectRoute getWarehouse4Buys( Propagator &pathPropagator,
SimpleGoodStore& basket )
{
Propagator::Routes pathWayList = pathPropagator.getRoutes( building::warehouse );
std::map< int, Propagator::DirectRoute > warehouseRating;
// select the warehouse with the max quantity of requested goods
Propagator::Routes::iterator pathWayIt = pathWayList.begin();
while( pathWayIt != pathWayList.end() )
{
// for every warehouse within range
WarehousePtr warehouse= pathWayIt->first.as< Warehouse >();
int rating = 0;
for( int i=Good::wheat; i<Good::goodCount; i++ )
{
Good::Type gtype = Good::Type(i);
int qty = warehouse->getGoodStore().getMaxRetrieve( gtype );
int need = basket.getFreeQty( gtype );
rating = need > 0 ? ( qty ) : 0;
}
rating = math::clamp( rating - pathWayIt->second.getLength(), 0, 999 );
warehouseRating[ rating ] = *pathWayIt;
pathWayIt++;
}
//have only available warehouses, find nearest of it
return warehouseRating.size() > 0 ? warehouseRating.rbegin()->second : Propagator::DirectRoute();
}
示例10: getWalkerDestination_granary
BuildingPtr CartPusher::getWalkerDestination_granary(Propagator &pathPropagator, PathWay &oPathWay)
{
BuildingPtr res;
GoodType goodType = _d->stock._goodType;
if (!(goodType == G_WHEAT || goodType == G_FISH || goodType == G_MEAT || goodType == G_FRUIT || goodType == G_VEGETABLE))
{
// this good cannot be stored in a granary
return NULL;
}
Propagator::ReachedBuldings pathWayList;
pathPropagator.getReachedBuildings( B_GRANARY, pathWayList);
// find a granary with enough storage
for( Propagator::ReachedBuldings::iterator pathWayIt= pathWayList.begin(); pathWayIt != pathWayList.end(); ++pathWayIt)
{
// for every granary within range
BuildingPtr building= pathWayIt->first;
PathWay& pathWay= pathWayIt->second;
SmartPtr<Granary> granary= building.as<Granary>();
_d->reservationID = granary->getGoodStore().reserveStorage(_d->stock);
if (_d->reservationID != 0)
{
res = granary.as<Building>();
oPathWay = pathWay;
break;
}
}
return res;
}
示例11: getWalkerDestination_warehouse
BuildingPtr CartPusher::getWalkerDestination_warehouse(Propagator &pathPropagator, PathWay &oPathWay)
{
BuildingPtr res;
Propagator::ReachedBuldings pathWayList;
pathPropagator.getReachedBuildings(B_WAREHOUSE, pathWayList);
for( Propagator::ReachedBuldings::iterator pathWayIt= pathWayList.begin(); pathWayIt != pathWayList.end(); ++pathWayIt)
{
// for every warehouse within range
BuildingPtr building= pathWayIt->first;
PathWay& pathWay= pathWayIt->second;
SmartPtr<Warehouse> warehouse= building.as<Warehouse>();
_d->reservationID = warehouse->getGoodStore().reserveStorage(_d->stock);
if (_d->reservationID != 0)
{
res = warehouse.as<Building>();
oPathWay = pathWay;
break;
}
}
return res;
}
示例12: runGPU0
void runGPU0(Int_t nthreads = 4, Bool_t graphics = false,
// const char *geomfile="gexam1.root")
const char *geomfile = "http://root.cern.ch/files/cms.root")
{
TFile::SetCacheFileDir("./files");
gSystem->Load("libPhysics");
gSystem->Load("libHist");
gSystem->Load("libThread");
gSystem->Load("libGeom");
gSystem->Load("libVMC");
gSystem->Load("libGeant_v");
gSystem->Load("libXsec");
// gSystem->Load("libGeantCuda");
Int_t ntotal = 20; // Number of events to be transported
Int_t nbuffered = 10; // Number of buffered events
Propagator *prop = Propagator::Instance(ntotal, nbuffered);
WorkloadManager *wmgr = WorkloadManager::Instance(nthreads);
wmgr->SetNminThreshold(5 * nthreads);
// CoprocessorBroker *gpuBroker = new CoprocessorBroker();
// gpuBroker->CudaSetup(32,128,1);
// wmgr->SetTaskBroker(gpuBroker);
prop->fNaverage = 500; // Average number of tracks per event
prop->fNperBasket = 32;
prop->fEmin = 1.E-5; // [10KeV] energy cut
prop->fEmax = 0.03; // [30MeV] used for now to select particle gun energy
// prop->fEmax = 1.;
// Create the tab. phys process.
prop->fProcess = new TTabPhysProcess("tab_phys", "xsec_FTFP_BERT.root", "fstate_FTFP_BERT.root");
prop->fApplication = new MyApplication();
// gROOT->ProcessLine(".x factory.C+");
// prop->fUseDebug = true;
// prop->fDebugTrk = 1;
// prop->PropagatorGeom(geomfile, nthreads, graphics);
// This sets gGeomManager and hence superseeds the filename.
VP_SimpleECal();
prop->PropagatorGeom("", nthreads /* + 3 */, graphics);
delete gGeoManager;
}
示例13:
void Roads::Impl::updateRoadsAround( Propagator& propagator, UpdateInfo info )
{
propagator.init( info.first );
PathwayList pathWayList = propagator.getWays( info.second );
for( auto&& path : pathWayList )
{
const TilesArray& tiles = path->allTiles();
for( auto tile : tiles )
{
RoadPtr road = tile->overlay().as<Road>();
if( road.isValid() )
{
road->appendPaved( defaultIncreasePaved );
}
}
}
}
示例14: reserveShortestPath
BuildingPtr reserveShortestPath( const BuildingType buildingType,
GoodStock& stock, long& reservationID,
Propagator &pathPropagator, PathWay &oPathWay )
{
BuildingPtr res;
Propagator::Routes pathWayList;
pathPropagator.getRoutes(buildingType, pathWayList);
//remove factories with improrer storage
Propagator::Routes::iterator pathWayIt= pathWayList.begin();
while( pathWayIt != pathWayList.end() )
{
// for every factory within range
SmartPtr<T> building = pathWayIt->first.as<T>();
if( stock._currentQty > building->getGoodStore().getMaxStore( stock.type() ) )
{
pathWayList.erase( pathWayIt++ );
}
else
{
pathWayIt++;
}
}
//find shortest path
int maxLength = 999;
PathWay* shortestPath = 0;
for( Propagator::Routes::iterator pathIt = pathWayList.begin();
pathIt != pathWayList.end(); pathIt++ )
{
if( pathIt->second.getLength() < maxLength )
{
shortestPath = &pathIt->second;
maxLength = pathIt->second.getLength();
res = pathIt->first;
}
}
if( res.isValid() )
{
reservationID = res.as<T>()->getGoodStore().reserveStorage( stock );
if (reservationID != 0)
{
oPathWay = *shortestPath;
}
else
{
res = BuildingPtr();
}
}
return res;
}
示例15: DiagramBase
//------------------------------------------------------------------------------
DiagramTwoLoop::DiagramTwoLoop(std::vector<Line> lines, LabelMap<Vertex, VertexType> vertextypes, LabelMap<Vertex, KernelType> kerneltypes) : DiagramBase(lines, vertextypes, kerneltypes), _qmax(std::numeric_limits<double>::infinity())
{
_order = Order::kTwoLoop;
// check to ensure that the diagram is really two loop
bool is2Loop = false;
// find the nontrivial poles
for (auto line : _lines) {
// check if the line has the loop momentum in it
// if so, it has an IR pole that must be regulated if it is away from 0
if (line.propagator.hasLabel(Momentum::q)) {
is2Loop = true;
_order = Order::kOneLoop;
Propagator pole = line.propagator.IRpole(Momentum::q);
if (!pole.isNull()) {
_IRpoles.push_back(pole);
}
}
}
assert(is2Loop);
}