rcognita.actors.Actor

class rcognita.actors.Actor(dim_output: int = 5, dim_input: int = 2, prediction_horizon: int = 1, action_bounds: Optional[Union[list, numpy.ndarray]] = None, action_init: Optional[list] = None, predictor: Optional[rcognita.predictors.Predictor] = None, optimizer: Optional[rcognita.optimizers.Optimizer] = None, critic: Optional[rcognita.critics.Critic] = None, running_objective=None, model: Optional[rcognita.models.Model] = None, discount_factor=1)

Class of actors. These are to be passed to a controller. An objective (a loss) as well as an optimizer are passed to an actor externally.

__init__(dim_output: int = 5, dim_input: int = 2, prediction_horizon: int = 1, action_bounds: Optional[Union[list, numpy.ndarray]] = None, action_init: Optional[list] = None, predictor: Optional[rcognita.predictors.Predictor] = None, optimizer: Optional[rcognita.optimizers.Optimizer] = None, critic: Optional[rcognita.critics.Critic] = None, running_objective=None, model: Optional[rcognita.models.Model] = None, discount_factor=1)

Initialize an actor.

Parameters
  • prediction_horizon (int) – Number of time steps to look into the future.

  • dim_input (int) – Dimension of the observation.

  • dim_output (int) – Dimension of the action.

  • action_bounds (list or ndarray, optional) – Bounds on the action.

  • action_init (list, optional) – Initial action.

  • predictor (Predictor, optional) – Predictor object for generating predictions.

  • optimizer (Optimizer, optional) – Optimizer object for optimizing the action.

  • critic (Critic, optional) – Critic object for evaluating actions.

  • running_objective (RunningObjective, optional) – Running objective object for recording the running objective.

  • model (Model, optional) – Model object to be used as reference by the Predictor and the Critic.

  • discount_factor (float, optional) – discount factor to be used in conjunction with the critic.

Methods

__init__([dim_output, dim_input, …])

Initialize an actor.

accept_or_reject_weights(weights[, …])

Determines whether the given weights should be accepted or rejected based on the specified constraints.

cache_weights([weights])

Cache the current weights of the model of the actor.

create_observation_constraints(…)

Method to create observation (or state) related constraints using a predictor over a prediction_horizon.

optimize_weights([constraint_functions, time])

Method to optimize the current actor weights.

receive_observation(observation)

Update the current observation of the actor.

reset()

Reset the actor to its initial state.

restore_weights()

Restore the previously cached weights of the model of the actor.

set_action(action)

Set the current action of the actor.

update_action([observation])

Update the current action of the actor.

update_and_cache_weights([weights])

Update and cache the weights of the model of the actor.

update_weights([weights])

Update the weights of the model of the actor.