pub struct Thompson { /* private fields */ }Expand description
Thompson Sampling 選択
Beta(successes + 1, failures + 1) の期待値 + 学習ボーナス でスコアリング。
本来の Thompson Sampling は Beta 分布からサンプリングするが、 決定論的にするため期待値を使用。
Implementations§
Source§impl Thompson
impl Thompson
pub fn new() -> Self
Sourcepub fn with_learning_weight(learning_weight: f64) -> Self
pub fn with_learning_weight(learning_weight: f64) -> Self
学習ボーナス係数を指定して生成
Sourcepub fn learning_weight(&self) -> f64
pub fn learning_weight(&self) -> f64
学習ボーナス係数を取得
Sourcepub fn compute_score(
&self,
stats: &SwarmStats,
action: &str,
target: Option<&str>,
provider: &dyn LearnedProvider,
) -> f64
pub fn compute_score( &self, stats: &SwarmStats, action: &str, target: Option<&str>, provider: &dyn LearnedProvider, ) -> f64
Thompson スコアを計算(コンテキストなし、後方互換用)
Sourcepub fn compute_score_with_context(
&self,
stats: &SwarmStats,
action: &str,
target: Option<&str>,
provider: &dyn LearnedProvider,
prev_action: Option<&str>,
prev_prev_action: Option<&str>,
) -> f64
pub fn compute_score_with_context( &self, stats: &SwarmStats, action: &str, target: Option<&str>, provider: &dyn LearnedProvider, prev_action: Option<&str>, prev_prev_action: Option<&str>, ) -> f64
Thompson スコアを計算(コンテキスト付き)
Provider に confidence_with_context クエリを投げて学習ボーナスを取得。
Trait Implementations§
Source§impl<N, E, S> SelectionLogic<N, E, S> for Thompson
impl<N, E, S> SelectionLogic<N, E, S> for Thompson
Source§fn next(
&self,
map: &GraphMap<N, E, S>,
stats: &SwarmStats,
provider: &dyn LearnedProvider,
) -> Option<MapNodeId>
fn next( &self, map: &GraphMap<N, E, S>, stats: &SwarmStats, provider: &dyn LearnedProvider, ) -> Option<MapNodeId>
次のノードを1つ選択
Source§fn select(
&self,
map: &GraphMap<N, E, S>,
count: usize,
stats: &SwarmStats,
provider: &dyn LearnedProvider,
) -> Vec<MapNodeId>
fn select( &self, map: &GraphMap<N, E, S>, count: usize, stats: &SwarmStats, provider: &dyn LearnedProvider, ) -> Vec<MapNodeId>
次のノードを複数選択
Source§fn score(
&self,
action: &str,
target: Option<&str>,
stats: &SwarmStats,
provider: &dyn LearnedProvider,
) -> f64
fn score( &self, action: &str, target: Option<&str>, stats: &SwarmStats, provider: &dyn LearnedProvider, ) -> f64
ノードのスコアを計算
Auto Trait Implementations§
impl Freeze for Thompson
impl RefUnwindSafe for Thompson
impl Send for Thompson
impl Sync for Thompson
impl Unpin for Thompson
impl UnwindSafe for Thompson
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more