Use of neural network for optimization of energy cost in moving limb