cluster module¶
-
class
cluster.Cluster(shared_cfg, pretrained_cfg, learned_cfg)¶ Bases:
objectComputes optimal process parameters, at each layer, given feedback obtained from the machine sensors.
Parameters: - shared_cfg (dotmap) –
- env.n_parts (int): Total number of parts built under feedback control.
- env.horizon (int): Markov Decision Process horizon (here number of layers).
- env.nS (int): Dimension of the state vector.
- comms (dotmap): Parameters for communication with other classes.
- pretrained_cfg (dotmap) –
- n_parts (dotmap): Number of parts built under this control scheme.
- ctrl_cfg (dotmap): Configuration parameters passed to the MPC class.
- learned_cfg (dotmap) –
- n_parts (dotmap): Number of parts built under this control scheme.
- ctrl_cfg (dotmap): Configuration parameters passed to the MPC class.
-
clearComms()¶
-
computeAction(states)¶ Computes the control actions given the observed system states.
Parameters: states (np.array) – Observed states, shape (n_parts, nS) Returns: Computed actions, with shape (n_parts, nU) Return type: np.array
-
getStates()¶ Load state vectors uploaded to the server by the Machine class.
This function waits for the comms.dir/comms.state.rdy_name folder to be created by the Machine class, before reading the file where the states are located, comms.dir/comms.state.f_name
Returns: State vector with shape (n_parts, nS) Return type: np.array
-
initAction()¶ Returns the initial action vector.
This function is required because an initial layer must be built before any feedback is available.
Returns: Initial action vector with shape (n_parts, nU) Return type: np.array
-
log()¶ Logs the state and action trajectories, as well as the predicted cost, which may be of interest to tune some algorithmic parameters.
-
loop()¶ While within the time horizon, read the states provided by the Machine class, and compute and save the corresponding actions.
Allows the class functionality to be conveniently used as follows:
cluster = Cluster(s_cfg, cp_cfg, cl_cfg) cluster.loop()
-
sendAction(actions)¶ Saves the computed actions.
Signals the Machine class that actions are ready to be downloaded by locally creating the comms.dir/comms.action.rdy_name folder
Parameters: actions (np.array) – Action vector with shape (n_parts, nU)
- shared_cfg (dotmap) –