A predictive controller for controlling a system subject to constraints including equality and inequality constraints on state and control variables of the system , comprising: an estimator to estimate a current state of the system using measurements of outputs of the system ; and a controller to solve, at each control step, a matrix equation of necessary optimality conditions to produce a control solution and to control the system using the control solution to change a state of the system , wherein the matrix equation includes a block-structured matrix having a constraint Jacobian matrix of the equality constraints of the system , wherein the controller is configured to determine the control solution iteratively using two levels of iterations including a first level of iterations and a second level of iterations performed within an iteration of the first level of iterations , wherein the first level of iterations , performed until a first termination condition is met, to select active inequality constraints for each point of time within a control horizon, to update the constraint Jacobian matrix, with a low-rank update for a change in the set of active inequality constraints, to include the equality constraints and the active inequality constraints, and to update a preconditioning matrix, with a low-rank factorization update, in response to the low-rank update of the constraint Jacobian matrix, wherein the second level of iterations , performed until a second termination condition is met, to solve the matrix equation with the updated constraint Jacobian matrix using the updated preconditioning matrix to produce the control solution . an estimator to estimate a current state of the system using measurements of outputs of the system ; and a controller to solve, at each control step, a matrix equation of necessary optimality conditions to produce a control solution and to control the system using the control solution to change a state of the system , wherein the matrix equation includes a block-structured matrix having a constraint Jacobian matrix of the equality constraints of the system , wherein the controller is configured to determine the control solution iteratively using two levels of iterations including a first level of iterations and a second level of iterations performed within an iteration of the first level of iterations , wherein the first level of iterations , performed until a first termination condition is met, to select active inequality constraints for each point of time within a control horizon, to update the constraint Jacobian matrix, with a low-rank update for a change in the set of active inequality constraints, to include the equality constraints and the active inequality constraints, and to update a preconditioning matrix, with a low-rank factorization update, in response to the low-rank update of the constraint Jacobian matrix, to select active inequality constraints for each point of time within a control horizon, to update the constraint Jacobian matrix, with a low-rank update for a change in the set of active inequality constraints, to include the equality constraints and the active inequality constraints, and to update a preconditioning matrix, with a low-rank factorization update, in response to the low-rank update of the constraint Jacobian matrix, wherein the second level of iterations , performed until a second termination condition is met, to solve the matrix equation with the updated constraint Jacobian matrix using the updated preconditioning matrix to produce the control solution . <EOS>