Struct MCTS

Source
pub struct MCTS<D: Domain> { /* private fields */ }
Expand description

The state of a running planner instance.

Implementations§

Source§

impl<D: Domain> MCTS<D>

Source

pub fn new( initial_state: D::State, root_agent: AgentId, config: MCTSConfiguration, ) -> Self

Instantiates a new search tree for the given state, with idle tasks for all agents and starting at tick 0.

Source

pub fn new_with_tasks( initial_state: D::State, root_agent: AgentId, start_tick: u64, tasks: ActiveTasks<D>, config: MCTSConfiguration, state_value_estimator: Box<dyn StateValueEstimator<D> + Send>, early_stop_condition: Option<Box<EarlyStopCondition>>, ) -> Self

Instantiates a new search tree for the given state, with active tasks for all agents and starting at a given tick.

Source

pub fn best_task_at_root(&mut self) -> Option<Box<dyn Task<D>>>

Returns the best task, using exploration value of 0.

Source

pub fn best_task_with_history( &self, task_history: &HashMap<AgentId, ActiveTask<D>>, ) -> Box<dyn Task<D>>

Returns the best task, following a given recent task history, in case planning tasks are used.

Source

pub fn q_value_at_root(&self, agent: AgentId) -> f32

Returns the q-value at root.

Source

pub fn run(&mut self) -> Option<Box<dyn Task<D>>>

Executes the MCTS search.

Returns the current best task, if there is at least one task for the root node.

Source

pub fn initial_state(&self) -> &D::State

Returns the initial state at the root of the planning tree.

Source

pub fn start_tick(&self) -> u64

Returns the tick at the root of the planning tree.

Source

pub fn agent(&self) -> AgentId

Returns the agent the tree searches for.

Source

pub fn min_max_range(&self, agent: AgentId) -> Range<AgentValue>

Returns the range of minimum and maximum global values.

Source

pub fn nodes(&self) -> impl Iterator<Item = (&Node<D>, &Edges<D>)>

Returns an iterator over all nodes and edges in the tree.

Source

pub fn root_node(&self) -> Node<D>

Returns the root node of the search tree.

Source

pub fn get_edges(&self, node: &Node<D>) -> Option<&Edges<D>>

Returns the edges associated to a given node.

Source

pub fn seed(&self) -> u64

Returns the seed of the tree.

Source

pub fn node_count(&self) -> usize

Returns the number of nodes.

Source

pub fn edge_count(&self) -> usize

Returns the number of nodes.

Source

pub fn time(&self) -> Duration

Returns the duration of the last run.

Source

pub fn size(&self, task_size: fn(&dyn Task<D>) -> usize) -> usize

Returns an estimation of the memory footprint of the MCTS struct.

Auto Trait Implementations§

§

impl<D> Freeze for MCTS<D>
where <D as Domain>::State: Freeze,

§

impl<D> !RefUnwindSafe for MCTS<D>

§

impl<D> Send for MCTS<D>
where <D as Domain>::State: Send, <D as Domain>::Diff: Sync + Send,

§

impl<D> !Sync for MCTS<D>

§

impl<D> Unpin for MCTS<D>
where <D as Domain>::State: Unpin,

§

impl<D> !UnwindSafe for MCTS<D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V