Go to the documentation of this file.
32 return std::all_of(requestStrategies.begin(),
33 requestStrategies.end(),
34 [](ComputingPowerRequestStrategyBasePtr&
s)
35 { return s->shouldAllocateComputingPower(); });
47 allocatedLastTime += std::chrono::seconds{timeDeltaInSeconds};
56 allocateNextTime = nodeCount + nodeCountDelta;
60 allocateNextTime += nodeCountDelta;
67 for (
auto& strat : strategyPerTaskStatus)
69 strat.second->updateNodeCount(count);
76 const auto it = strategyPerTaskStatus.find(newStatus);
77 current = (it == strategyPerTaskStatus.end()) ?
nullptr : it->second.get();
79 for (
auto& strat : strategyPerTaskStatus)
81 strat.second->updateTaskStatus(newStatus);
88 for (
auto& strat : strategyPerTaskStatus)
90 strat.second->allocatedComputingPower();
99 for (
auto& strat : strategyPerTaskStatus)
101 strat.second->updateNodeCreations(nodesCreated, tries);
110 for (std::size_t i = 0; i < static_cast<std::size_t>(tries); ++i)
112 backlog.at((currentBacklogIndex + i) % backlogSize) =
113 i <
static_cast<std::size_t
>(nodesCreated) ? 0 : 1;
116 currentBacklogIndex = (currentBacklogIndex + tries) % backlogSize;
122 const auto perc = std::accumulate(backlog.begin(), backlog.end(), 1.f) / backlog.size();
123 const auto usedTimeDelta = timeDeltaInSeconds / (1.f + sigma * perc);
132 allocatedLastTime += std::chrono::seconds{
static_cast<std::size_t
>(usedTimeDelta)};
139 for (
auto&
s : requestStrategies)
141 s->setCurrentStateAsInitialState();
148 for (
auto&
s : requestStrategies)
150 s->updateNodeCount(count);
158 for (
auto&
s : requestStrategies)
160 s->updateTaskStatus(newStatus);
167 for (
auto&
s : requestStrategies)
169 s->allocatedComputingPower();
178 for (
auto&
s : requestStrategies)
180 s->updateNodeCreations(nodesCreated, tries);
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
bool shouldAllocateComputingPower(const ::Ice::Current &=Ice::emptyCurrent) override
Returns true if all compounded strategies return true.
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void updateNodeCount(Ice::Long count, const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
void setCurrentStateAsInitialState(const ::Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next time to allocate depending on the flag skipping.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Passes this call to all sub strategies.
void updateTaskStatus(armarx::TaskStatus::Status newStatus, const Ice::Current &=Ice::emptyCurrent) override
Switches the current strategy and passes this call to all sub strategies.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Calls this function for all compounded strategies.
void allocatedComputingPower(const Ice::Current &=Ice::emptyCurrent) override
Sets the next creation count to allocate depending on the flag skipping.
double s(double t, double s0, double v0, double a0, double j)
This file offers overloads of toIce() and fromIce() functions for STL container types.
void updateNodeCreations(Ice::Long nodesCreated, Ice::Long tries, const Ice::Current &=Ice::emptyCurrent) override
Updates the number of failed node creations.
DateTime now() const
Current date/time of the clock.