config_dmbrl module¶
Low level configuration for modeling and optimisation.
ctrl_cfg: Configuration parameters for the control algorithm.
-dO: dimensionality of observations -dU: dimensionality of control inputs - per: How often the action sequence will be optimized, i.e, for per=1 it is reoptimized at every call to MPC.act(). - constrains: [[np.array([min v, min q]), np.array([max v, max q])], [min q/v, max q/v], [min q/sqrt(v), max q/sqrt(v)]] - prop_cfg: Configuration parameters for modeling and uncertainty propagation.
model_pretrained: True if model used for MPC has been trained on previous data, False otherwise.
model_init_cfg: Configuration parameters for model initialisation.
- ensemble_size: Number of models within the ensemble.
- load_model: True for a pretrained model to be loaded upon initialisation.
- model_dir: Directory in which the model files (.mat, .nns) are located.
- model_name: Name of the model files (model_dir/model_name.mat or model_dir/model_name.nns)
- model_train_cfg: Configuration parameters for model training optimisation
- batch_size: Batch size.
- epochs: Number of training epochs.
- hide_progress: If ‘True’, additional information regarding model training is printed.
npart: Number of particles used for uncertainty propagation.
model_in: Number of inputs to the model.
model_out: Number of outputs to the model.
n_layers: Number of hidden layers.
n_neurons: Number of neurons per hidden layer.
learning_rate: Learning rate.
wd_in: Weight decay for the input layer neurons.
wd_hid: Weight decay for the hidden layer neurons.
wd_out: Weight decay for the output layer neurons.
opt_cfg: Configuration parameters for optimisation.
mode: Uncertainty propagation method.
plan_hor: Planning horizon for the model predictive control algorithm.
cfg
- popsize: Number of cost evaluations per iteration.
- max_iters: Maximum number of optimisation iterations.
- num_elites: Number of elites.
- alpha: Alpha parametero of the CEM optimisation algorithm.
- eps: Epsilon parameter of the CEM optimisation algorithm.
prop_cfg
- mode: Uncertainty propagation method, ie “TSinf”
change_target: True if multiple setpoints used, i.e. 980 and 1010
n_parts_targets: Number of parts to be built for each target
targets: Different temperature setpoints to be used (must be of same length as n_parts_targets)
force: Configuration parameters to periodically overwrite (“force”) predefined build parameters
- on: Force functionality enabled if True
- start_part: First part where functionality is enabled (disregarding the first few ignored parts)
- n_parts: Number of parts for which the functionality is enabled
- n_repeats: Number of consecutive layers for which inputs are forced. For [1,2], n_parts will be forced only once (periodically), while a further n_parts will be forced two times consecutively (periodically)
- init_buffer: Initial number of layers for which parameters are not forced
- upper_init: Upper bound is initialised to this.
- upper_delta: Upper bound increases by this. For instance, for upper_init=105 and upper_delta=5, the upper bound sequence will be 105, 110, 115…
- lower_init: Lower bound is initialised to this.
- lower_delta: Lower bound is increased by this. For instance, for lower_init=65 and lower_delta=-5, the lower bound sequence will be 60, 55, 50…
- fixed_speed: For the forced parameters, power will be adjusted but mark speed will be kept fixed to this value.
-
config_dmbrl.ac_cost_fn(acs)¶ Cost function (action-dependent) used in the optimisation problem.
Should process both np.arrays and tf.Tensor inputs.
Parameters: acs (np.array or tf.Tensor) – Array of actions with shape (n, dU). Returns: float
-
config_dmbrl.bnn_constructor(model_init_cfg)¶ Constructs the Bayesian Neural Network model.
- Moodel_init_cfg is a dotmap object containing:
- model_in (int): Number of inputs to the model.
- model_out (int): Number of outputs to the model.
- n_layers (int): Number of hidden layers.
- n_neurons (int): Number of neurons per hidden layer.
- learning_rate (float): Learning rate.
- wd_in (float): Weight decay for the input layer neurons.
- wd_hid (float): Weight decay for the hidden layer neurons.
- wd_out (float): Weight decay for the output layer neurons.
Returns: BNN class object
-
config_dmbrl.create_dmbrl_config()¶ Returns the low-level modeling and optimisation configuration parameters.
-
config_dmbrl.obs_cost_fn(obs, target)¶ Cost function (state-dependent) used in the optimisation problem.
Should process both np.arrays and tf.Tensor inputs.
Parameters: - obs (np.array or tf.Tensor) – Array of observations with shape (n, dO).
- target (float) –
Returns: float
-
config_dmbrl.obs_postproc(obs, pred)¶ Modifies observations and model p redictions before being passed to cost function.
Parameters: - obs (np.array or tf.Tensor) – Array of observations with shape (n, dO).
- pred (np.array or tf.Tensor) – Array of predictions (model outputs) with shape (n, model_output).
Returns: np.array or tf.Tensor with shape (n, dO)
-
config_dmbrl.obs_preproc(obs)¶ Modifies observations (in a 2D matrix) before they are passed into the model.
Parameters: obs (np.array or tf.Tensor) – Array of observations with shape (n, dO). Returns: np.array or tf.Tensor with shape (n, model_in)
-
config_dmbrl.targ_proc(obs, next_obs)¶ Takes current observations and next observations and returns the array of targets (so that the model learns the mapping obs -> targ_proc(obs, next_obs))
Parameters: - obs (np.array or tf.Tensor) – Array of observations at time t with shape (n, dO).
- next_obs (np.array or tf.Tensor) – Array of observations at time t+1 with shape (n, dO).
Returns: np.array or tf.Tensor with shape (n, model_out)