Go to the documentation of this file.
31 return std::all_of(requestStrategies.begin(), requestStrategies.end(),
32 [](ComputingPowerRequestStrategyBasePtr &
s)
34 return s->shouldAllocateComputingPower();
47 allocatedLastTime += std::chrono::seconds {timeDeltaInSeconds};
55 allocateNextTime = nodeCount + nodeCountDelta;
59 allocateNextTime += nodeCountDelta;
65 for (
auto& strat : strategyPerTaskStatus)
67 strat.second->updateNodeCount(count);
73 const auto it = strategyPerTaskStatus.find(newStatus);
74 current = (it == strategyPerTaskStatus.end()) ?
nullptr : it->second.get();
76 for (
auto& strat : strategyPerTaskStatus)
78 strat.second->updateTaskStatus(newStatus);
84 for (
auto& strat : strategyPerTaskStatus)
86 strat.second->allocatedComputingPower();
92 for (
auto& strat : strategyPerTaskStatus)
94 strat.second->updateNodeCreations(nodesCreated, tries);
100 for (std::size_t i = 0; i < static_cast<std::size_t>(tries); ++i)
102 backlog.at((currentBacklogIndex + i) % backlogSize) = i <
static_cast<std::size_t
>(nodesCreated) ? 0 : 1;
105 currentBacklogIndex = (currentBacklogIndex + tries) % backlogSize;
110 const auto perc = std::accumulate(backlog.begin(), backlog.end(), 1.f) / backlog.size();
111 const auto usedTimeDelta = timeDeltaInSeconds / (1.f + sigma * perc);
120 allocatedLastTime += std::chrono::seconds {
static_cast<std::size_t
>(usedTimeDelta)};
126 for (
auto&
s : requestStrategies)
128 s->setCurrentStateAsInitialState();
134 for (
auto&
s : requestStrategies)
136 s->updateNodeCount(count);
142 for (
auto&
s : requestStrategies)
144 s->updateTaskStatus(newStatus);
150 for (
auto&
s : requestStrategies)
152 s->allocatedComputingPower();
158 for (
auto&
s : requestStrategies)
160 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.