An apparatus for controlling an operation of a machine subject to state constraints in continuous state space of the system and subject to control input constraints in continuous control input space of the system, comprising: a memory configured to store a constraint admissible invariant set, CAIS, of states of the system satisfying the state constraints and a corresponding control policy mapping a state of the system within the CAIS to a control input satisfying the control input constraints, wherein a control of the system having the state within the CAIS according to the corresponding control policy maintains the state of the system within the CAIS; an input interface to accept data indicative of the state of the system; and a processor configured to jointly control the machine and update the CAIS and the control policy, wherein, for performing the joint control and update, the processor is configured to control the system using the control policy to collect data including a sequence of control inputs generated using the control policy and a sequence of states of the system within the CAIS corresponding to the sequence of control inputs; and perform a constrained policy iteration using the collected data to update the CAIS and the corresponding control policy, wherein, to perform the constrained policy iteration, the processor is configured to perform a constrained policy evaluation to produce an updated CAIS and a corresponding updated value function of state of the system, wherein the updated value function improves a cost function of the operation of the machine and the updated CAIS enforces satisfaction of the state and control input constraints; and perform a constrained policy improvement to produce an updated control policy that improves the cost function of operation according to the updated CAIS and the corresponding updated value function. a memory configured to store a constraint admissible invariant set, CAIS, of states of the system satisfying the state constraints and a corresponding control policy mapping a state of the system within the CAIS to a control input satisfying the control input constraints, wherein a control of the system having the state within the CAIS according to the corresponding control policy maintains the state of the system within the CAIS; an input interface to accept data indicative of the state of the system; and a processor configured to jointly control the machine and update the CAIS and the control policy, wherein, for performing the joint control and update, the processor is configured to control the system using the control policy to collect data including a sequence of control inputs generated using the control policy and a sequence of states of the system within the CAIS corresponding to the sequence of control inputs; and perform a constrained policy iteration using the collected data to update the CAIS and the corresponding control policy, wherein, to perform the constrained policy iteration, control the system using the control policy to collect data including a sequence of control inputs generated using the control policy and a sequence of states of the system within the CAIS corresponding to the sequence of control inputs; and perform a constrained policy iteration using the collected data to update the CAIS and the corresponding control policy, wherein, to perform the constrained policy iteration, the processor is configured to perform a constrained policy evaluation to produce an updated CAIS and a corresponding updated value function of state of the system, wherein the updated value function improves a cost function of the operation of the machine and the updated CAIS enforces satisfaction of the state and control input constraints; and perform a constrained policy improvement to produce an updated control policy that improves the cost function of operation according to the updated CAIS and the corresponding updated value function. perform a constrained policy evaluation to produce an updated CAIS and a corresponding updated value function of state of the system, wherein the updated value function improves a cost function of the operation of the machine and the updated CAIS enforces satisfaction of the state and control input constraints; and perform a constrained policy improvement to produce an updated control policy that improves the cost function of operation according to the updated CAIS and the corresponding updated value function.