This study introduces a student model and control algorithm, optimizing mathematics learning in children. The adaptive system is integrated into a computer-based training system for enhancing numerical cognition aimed at children with developmental dyscalculia or difficulties in learning mathematics. The student model consists of a dynamic Bayesian network which incorporates domain knowledge and enables the operation of an online system of automatic control. The system identifies appropriate tasks and exercise interventions on the basis of estimated levels of accumulated knowledge. Student actions are evaluated and monitored to extract statistical patterns which are useful for predictive control. The training system is adaptive and personalizes the learning experience, which improves both success and motivation. Comprehensive testing of input data validates the quality of the obtained results and confirms the advantage of the optimized training. Pilot results of training effects are included and discussed.