25 StateSpace::StateSpace(
size_t N,
size_t Nprio, std::vector<StateSpaceDimension *> dims, std::vector<PriorityState *> prio)
27 , nbOfPriorityStates(Nprio)
29 , priorityStates(prio)
30 , internalState(std::vector<int>(dimensions.size()))
48 assert(dim !=
nullptr);
84 static std::vector<size_t> vect(size);
86 static bool init =
false;
88 static std::vector<int> multVect(size);
92 for (
size_t i = 0;
i < size-1;
i++)
94 multVect[
i+1] = multVect[
i]*
dimensions[
i]->getNumberOfPositions();
98 for (ssize_t
i = size-1;
i >= 0;
i--)
100 vect[
i] = state/multVect[
i];
101 state %= multVect[
i];
104 unsigned int multiplicator = 1;
105 for (
size_t i = 0;
i <
size;
i++)
107 multiplicator *=
dimensions[
i]->getNumberOfPositions();
109 for (ssize_t
i = size-1;
i >= 0;
i--)
111 multiplicator /=
dimensions[
i]->getNumberOfPositions();
112 vect[
i] = state / multiplicator;
113 state = state % multiplicator;
135 unsigned int multiplicator = 1;
138 for (
size_t i = 0;
i <
size;
i++)
141 state += added * multiplicator;
142 multiplicator *=
dimensions[
i]->getNumberOfPositions();
143 if (multiplicator <= 0)
144 throw std::runtime_error(
"The number of positions of one of the dimensions is not positive");
virtual statePosition_t getPosition()=0
gets the position of the state along that dimension
std::shared_ptr< DomainModel > domainModel
StateInternal internalState
virtual std::vector< size_t > * factorize(state_t state)
std::vector< StateSpaceDimension * > dimensions
virtual state_t getState()
size_t nbOfPriorityStates
state_t currentExternalState
state_t convertState(StateInternal)
virtual std::vector< size_t > getDimensionSizes()
void updateInternalState()
virtual double getReward()
virtual size_t getNbOfDimensions()
std::vector< PriorityState * > priorityStates
virtual void updateCurrentState()
int getPriorityStateInternal()
this models a dimension in the state space.
std::vector< statePosition_t > StateInternal