A standard pattern is used for maximum calculation:
double maxValue = Double.MIN_VALUE;
for (int nextAction : actionsFromState) {
double value = Q[nextState][nextAction];
if (value > maxValue)
maxValue = value;
}
But Double.MIN_VALUE in Java is not minimal double but minimal positive value. See https://stackoverflow.com/questions/3884793/why-is-double-min-value-in-not-negative for details.
Especially, if each value considered in for-loop is 0, calculated maximum is Double.MIN_VALUE, because Double.MIN_VALUE > 0.
However, replacing Double.MIN_VALUE with Double.NEGATIVE_INFINITY cause wrong calculation. In such case maxQ(8) is Double.NEGATIVE_INFINITY and whole calculation fails.
Summary: maximum calculation is implemented wrong or at least misleading. It hard to me to propose a solution because it is not clear to me what is expected to be maxQ(8)
A standard pattern is used for maximum calculation:
But
Double.MIN_VALUEin Java is not minimal double but minimal positive value. See https://stackoverflow.com/questions/3884793/why-is-double-min-value-in-not-negative for details.Especially, if each
valueconsidered in for-loop is 0, calculated maximum isDouble.MIN_VALUE, becauseDouble.MIN_VALUE> 0.However, replacing
Double.MIN_VALUEwithDouble.NEGATIVE_INFINITYcause wrong calculation. In such casemaxQ(8)isDouble.NEGATIVE_INFINITYand whole calculation fails.Summary: maximum calculation is implemented wrong or at least misleading. It hard to me to propose a solution because it is not clear to me what is expected to be
maxQ(8)