1. A method for controlling an operation of a machine according to a model of the machine dynamics, wherein the method uses a processor coupled with stored instructions implementing the method, wherein the instructions, when executed by the processor carry out at least some steps of the method, comprising: controlling iteratively the operation of the machine with control inputs determined using the model based on an optimization of a cost function subject to constraints on the control inputs, and constraints on the state of the machine, wherein the operation is controlled online over a plurality of iterations, each iteration comprises: determining a current state of the machine using measurements of outputs of the machine controlled with a previous control input determined for a previous iteration; updating a parameter of a model of the machine dynamics to reduce a prediction error between the current state and a state estimated using the model of the machine dynamics, and wherein the parameter of the model of the machine dynamics represents a physical quantity of the machine; optimizing the cost function to produce a control input, wherein the cost function includes a first term related to a performance of the machine and a second term related to improving estimation of the parameter of the model of the machine dynamics, wherein the second term is weighted by a function of the prediction error, and wherein the second term includes an information functional of a predicted error covariance of the parameter of the model of the machine dynamics; and controlling the machine using the control input.