rlmesh::Policy
A model's declarations, predict operations and lifecycle hooks. Write the corners the model has and list them in CORNERS; a corner that reads the per-episode context is listed in CONTEXT too and written as its <corner>_with_context twin. Build the model with Model::new or Model::from_config.
trait Policy: Send + 'staticRust cannot see which methods an impl wrote, so the consts are the
declaration: a corner listed but not written fails its first call with
the RuntimeError class naming the entry, and a corner written but not
listed is never called.
Associated constants
Provided methods
- spec()The model's adapter spec.
- workflow_edition()The workflow edition the policy was authored against.
- load()Load weights from
config, once, in the constructor. - allow_fusion()Whether a grouped predict may fuse lanes from different envs into one batched-corner call; read once, after
load. - native_chunk()The native chunk length K after
load(a checkpoint may decide it); read once, afterload. - predict()One observation to one action.
- predict_with_context()
predictreading the context. - predict_batch()One action per observation, in one call.
- predict_batch_with_context()
predict_batchreading one context per row. - predict_chunk()One observation to a chunk of actions (leading axis = frames).
- predict_chunk_with_context()
predict_chunkreading the context. - predict_chunk_batch()One chunk per observation, in one call.
- predict_chunk_batch_with_context()
predict_chunk_batchreading one context per row. - on_episode_end()An episode ended (after its context entry is dropped).
- close()Release the model's resources: runs at most once.
CORNERS
associated constant[source]const CORNERS: CornersThe corners this policy implements.
CONTEXT
associated constant[source]const CONTEXT: CornersThe corners that read the context; each is called through its
_with_context twin. Must be a subset of CORNERS.
NATIVE_CHUNK
associated constant[source]const NATIVE_CHUNK: Option<u32>The static native chunk length K (describe reads this one).
LOAD_KEYS
associated constant[source]const LOAD_KEYS: Option<&'static [LoadKey]>The parameter keys load accepts; None forwards every key.
spec
provided method[source]fn spec() -> Option<SpecArg> where Self: SizedThe model’s adapter spec.
workflow_edition
provided method[source]fn workflow_edition() -> Option<String> where Self: SizedThe workflow edition the policy was authored against.
load
provided method[source]fn load(&mut self, kwargs: &Kwargs) -> Result<()>Load weights from config, once, in the constructor. The default
accepts only an empty config.
allow_fusion
provided method[source]fn allow_fusion(&self) -> boolWhether a grouped predict may fuse lanes from different envs into one
batched-corner call; read once, after load.
native_chunk
provided method[source]fn native_chunk(&self) -> Option<u32>The native chunk length K after load (a checkpoint may decide it);
read once, after load.
predict
provided method[source]fn predict(&mut self, observation: Value) -> Result<Value>One observation to one action.
predict_with_context
provided method[source]fn predict_with_context(
&mut self,
observation: Value,
context: &mut PredictContext<'_>,
) -> Result<Value>predict reading the context.
predict_batch
provided method[source]fn predict_batch(
&mut self,
observations: Vec<Value>,
) -> Result<Vec<Value>>One action per observation, in one call.
predict_batch_with_context
provided method[source]fn predict_batch_with_context(
&mut self,
observations: Vec<Value>,
context: &mut BatchPredictContext<'_>,
) -> Result<Vec<Value>>predict_batch reading one context per row.
predict_chunk
provided method[source]fn predict_chunk(
&mut self,
observation: Value,
execution_horizon: u32,
) -> Result<Value>One observation to a chunk of actions (leading axis = frames).
predict_chunk_with_context
provided method[source]fn predict_chunk_with_context(
&mut self,
observation: Value,
execution_horizon: u32,
context: &mut PredictContext<'_>,
) -> Result<Value>predict_chunk reading the context.
predict_chunk_batch
provided method[source]fn predict_chunk_batch(
&mut self,
observations: Vec<Value>,
execution_horizon: u32,
) -> Result<Vec<Value>>One chunk per observation, in one call.
predict_chunk_batch_with_context
provided method[source]fn predict_chunk_batch_with_context(
&mut self,
observations: Vec<Value>,
execution_horizon: u32,
context: &mut BatchPredictContext<'_>,
) -> Result<Vec<Value>>predict_chunk_batch reading one
context per row.
on_episode_end
provided method[source]fn on_episode_end(&mut self, episode_id: &str) -> Result<()>An episode ended (after its context entry is dropped).
close
provided method[source]fn close(&mut self) -> Result<()>Release the model’s resources: runs at most once.