Struct openrailwaymap_exporter::simulation::Simulation
source · pub struct Simulation {
pub environment: SimulationEnvironment,
pub object_agents: HashMap<RailwayObjectId, Box<dyn DecisionAgent<A = RailMovableAction>>>,
pub metrics_handlers: Vec<Box<dyn MetricsHandler>>,
pub is_paused: bool,
pub speedup_factor: f64,
/* private fields */
}
Expand description
A Simulation
struct holding a railway graph and a list of moveable railway objects.
Fields§
§environment: SimulationEnvironment
The simulation environment
object_agents: HashMap<RailwayObjectId, Box<dyn DecisionAgent<A = RailMovableAction>>>
A list of agents
metrics_handlers: Vec<Box<dyn MetricsHandler>>
A list of metrics handlers
is_paused: bool
simulation pause state
speedup_factor: f64
Speedup factor of the simulation
Implementations§
source§impl Simulation
impl Simulation
sourcepub fn new(graph: RailwayGraph) -> Self
pub fn new(graph: RailwayGraph) -> Self
sourcepub fn get_observable_environment(
&self
) -> &(dyn ObservableEnvironment + 'static)
pub fn get_observable_environment( &self ) -> &(dyn ObservableEnvironment + 'static)
Returns a reference to the observable environment of the simulation.
The observable environment allows external components to access the state of the simulation without being able to modify it. This is useful for agents to observe the simulation state and make decisions based on it.
Returns
A reference to a trait object implementing the ObservableEnvironment
trait,
which provides read-only access to the simulation environment.
sourcepub fn add_object(
&mut self,
object: Box<dyn SimulationObject>,
agent: Option<Box<dyn DecisionAgent<A = RailMovableAction>>>
) -> bool
pub fn add_object( &mut self, object: Box<dyn SimulationObject>, agent: Option<Box<dyn DecisionAgent<A = RailMovableAction>>> ) -> bool
sourcepub fn remove_object(&mut self, id: i64) -> bool
pub fn remove_object(&mut self, id: i64) -> bool
sourcepub fn add_agent_for_object(
&mut self,
object_id: RailwayObjectId,
agent: Box<dyn DecisionAgent<A = RailMovableAction>>
) -> bool
pub fn add_agent_for_object( &mut self, object_id: RailwayObjectId, agent: Box<dyn DecisionAgent<A = RailMovableAction>> ) -> bool
sourcepub fn register_metrics_handler(&mut self, handler: Box<dyn MetricsHandler>)
pub fn register_metrics_handler(&mut self, handler: Box<dyn MetricsHandler>)
Registers a metrics handler for the simulation.
This function adds a new metrics handler to the simulation. The metrics handler will be used to process events and gather metrics during the simulation run.
Arguments
handler
- A boxed metrics handler that implements theMetricsHandler
trait.
Trait Implementations§
Auto Trait Implementations§
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist.source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
self
to a value of a Properties
struct.§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
self
to a value of a Properties
struct.