本文整理汇总了C++中CState::getContinuousState方法的典型用法代码示例。如果您正苦于以下问题:C++ CState::getContinuousState方法的具体用法?C++ CState::getContinuousState怎么用?C++ CState::getContinuousState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CState
的用法示例。
在下文中一共展示了CState::getContinuousState方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getInputDerivation
void CCAGradientPolicyNumericInputDerivationCalculator::getInputDerivation(CStateCollection *inputStateCol, Matrix *targetVector)
{
CStateProperties *modelState = policy->getStateProperties();
CState *inputState = stateBuffer->getState(modelState);
inputState->setState(inputStateCol->getState(modelState));
double stepSize = getParameter("NumericInputDerivationStepSize");
DebugPrint('p', "Calculating Numeric Policy Input Derivation\n");;
for (unsigned int col = 0; col < modelState->getNumContinuousStates(); col++)
{
double stepSize_i = (modelState->getMaxValue(col) - modelState->getMinValue(col)) * stepSize;
inputState->setContinuousState(col, inputState->getContinuousState(col) + stepSize_i);
stateBuffer->newModelState();
policy->getNextContinuousAction(stateBuffer, contDataPlus);
if (DebugIsEnabled('p'))
{
DebugPrint('p', "State : ");
inputState->saveASCII(DebugGetFileHandle('p'));
DebugPrint('p', "Action : ");
contDataPlus->saveASCII(DebugGetFileHandle('p'));
}
inputState->setContinuousState(col, inputState->getContinuousState(col) - 2 * stepSize_i);
stateBuffer->newModelState();
policy->getNextContinuousAction(stateBuffer, contDataMinus);
if (DebugIsEnabled('p'))
{
DebugPrint('p', "State : ");
inputState->saveASCII(DebugGetFileHandle('p'));
DebugPrint('p', "Action : ");
contDataMinus->saveASCII(DebugGetFileHandle('p'));
}
inputState->setContinuousState(col, inputState->getContinuousState(col) + stepSize_i);
for (int row = 0; row < policy->getNumOutputs(); row ++)
{
targetVector->element(row, col) = (contDataPlus->getActionValue(row) - contDataMinus->getActionValue(row)) / (2 * stepSize_i);
}
}
}
示例2: nextStep
void CEpisodeMatlabOutput::nextStep(CStateCollection *oldState, CAction *action, double reward, CStateCollection *nextState)
{
CActionData *actionData = action->getActionData();
fprintf(stream, "%d %d ", nEpisodes, nSteps);
CState *state = oldState->getState(properties);
unsigned int i = 0;
for (i = 0; i < properties->getNumContinuousStates(); i++)
{
fprintf(stream, "%lf ", state->getContinuousState(i));
}
for (i = 0; i < properties->getNumDiscreteStates(); i++)
{
fprintf(stream, "%d ", (int)state->getDiscreteState(i));
}
state = nextState->getState(properties);
for (i = 0; i < properties->getNumContinuousStates(); i++)
{
fprintf(stream, "%lf ", state->getContinuousState(i));
}
for (i = 0; i < properties->getNumDiscreteStates(); i++)
{
fprintf(stream, "%d ", (int)state->getDiscreteState(i));
}
fprintf(stream,"%d ", actions->getIndex(action));
if (actionData != NULL)
{
CContinuousActionData *contData = dynamic_cast<CContinuousActionData *>(actionData);
for (int j = 0; j < contData->nrows(); j++)
{
fprintf(stream, "%lf ", contData->element(j));
}
}
fprintf(stream, "%lf ", reward);
fprintf(stream, "\n");
nSteps++;
fflush(stream);
}
示例3: getModifiedState
void CStateVariablesChooser::getModifiedState(CStateCollection *originalStateCol, CState *modifiedState)
{
CState *origState = originalStateCol->getState(originalState);
for (unsigned int i = 0; i < getNumContinuousStates(); i ++)
{
modifiedState->setContinuousState(i, origState->getContinuousState(contStatesInd[i]));
}
for (unsigned int i = 0; i < getNumDiscreteStates(); i ++)
{
modifiedState->setDiscreteState(i, origState->getDiscreteState(discStatesInd[i]));
}
}
示例4: nextStep
void CFeatureStateRewardModel::nextStep(CStateCollection *, CAction *, double reward, CStateCollection *newStateCol)
{
CState *newState = newStateCol->getState(discretizer);
if (newState->getStateProperties()->isType(FEATURESTATE))
{
for (unsigned int i = 0; i < newState->getNumContinuousStates(); i++)
{
rewards[newState->getDiscreteState(i)] += reward * newState->getContinuousState(i);
visits[newState->getDiscreteState(i)] += newState->getContinuousState(i);
}
}
else
{
if (newState->getStateProperties()->isType(DISCRETESTATE))
{
rewards[newState->getDiscreteState(0)] += reward ;
visits[newState->getDiscreteState(0)] += 1.0;
}
}
}
示例5: getModifiedState
void CFeatureOperatorAnd::getModifiedState(CStateCollection *stateCol, CState *featState)
{
int featureOffset = 1;
std::list<CStateModifier *>::iterator it = getStateModifiers()->begin();
std::list<CState *>::iterator stateIt = states->begin();
CState *stateBuf;
for (unsigned int i = 0; i < getNumDiscreteStates();i ++)
{
featState->setDiscreteState(i, 0);
featState->setContinuousState(i, 1.0);
}
int repetitions = getNumDiscreteStates();
for (int j = 0; it != getStateModifiers()->end(); it ++, stateIt ++, j ++)
{
repetitions /= (*it)->getNumDiscreteStates();
stateBuf = NULL;
if (stateCol->isMember(*it))
{
stateBuf = stateCol->getState(*it);
}
else
{
stateBuf = *stateIt;
(*it)->getModifiedState(stateCol, stateBuf);
}
if (stateBuf->getStateProperties()->isType(FEATURESTATE))
{
for (unsigned int i = 0; i < getNumDiscreteStates(); i++)
{
unsigned int singleStateFeatureNum = (i / repetitions) % stateBuf->getNumDiscreteStates();
featState->setDiscreteState(i, featState->getDiscreteState(i) + featureOffset * stateBuf->getDiscreteState(singleStateFeatureNum));
featState->setContinuousState(i, featState->getContinuousState(i) * stateBuf->getContinuousState(singleStateFeatureNum));
}
}
else
{
for (unsigned int i = 0; i < getNumDiscreteStates(); i++)
{
featState->setDiscreteState(i, featState->getDiscreteState(i) + featureOffset * stateBuf->getDiscreteState(0));
}
}
featureOffset = featureOffset * (*it)->getDiscreteStateSize();
}
normalizeFeatures(featState);
}
示例6: receiveError
void CQAverageTDErrorLearner::receiveError(double error, CStateCollection *state, CAction *action, CActionData *)
{
CState *featureState = state->getState(averageErrorFunction->getFeatureCalculator());
for (unsigned int i = 0; i < featureState->getNumDiscreteStates(); i++)
{
int index = featureState->getDiscreteState(i);
double featureFac = featureState->getContinuousState(i);
double featureVal = averageErrorFunction->getValue(index, action);
featureVal = featureVal * (updateRate + (1 - featureFac) * (1 - updateRate)) + error * (1 - updateRate) * featureFac;
averageErrorFunction->setValue(index, action, featureVal);
}
}
示例7: getGradient
void CContinuousActionPolicyFromGradientFunction::getGradient(CStateCollection *inputState, int outputDimension, CFeatureList *gradientFeatures)
{
*outputError = 0;
outputError->element(outputDimension) = 1.0;
ColumnVector input(getNumInputs());
CState *state = inputState->getState(modelState);
for (int i = 0; i < getNumInputs(); i++)
{
input.element(i) = state->getContinuousState(i);
}
gradientFunction->getGradient(&input, outputError, gradientFeatures);
}
示例8: getFunctionValuePre
void CContinuousActionGradientPolicy::getFunctionValuePre(ColumnVector *input, ColumnVector *output)
{
CState *state = new CState(modelState);
CContinuousActionData *data = dynamic_cast<CContinuousActionData *>(contAction->getNewActionData());
for (int i = 0; i < getNumInputs(); i ++)
{
state->setContinuousState(i, input->element(i));
}
getNextContinuousAction(state, data);
for (int i = 0; i < getNumOutputs(); i ++)
{
output->element(i) = state->getContinuousState(i);
}
delete state;
delete data;
}