Skip to main content

LearnableSwarmBuilder

Struct LearnableSwarmBuilder 

Source
pub struct LearnableSwarmBuilder { /* private fields */ }
Expand description

学習機能付き Swarm のビルダー

Orchestrator + LearningDaemon + Subscriber を統合構築する。

Implementations§

Source§

impl LearnableSwarmBuilder

Source

pub fn new(runtime: Handle) -> Self

新しいビルダーを作成

Source

pub fn scenario(self, name: impl Into<String>) -> Self

シナリオ名を設定

Source

pub fn with_learning(self, enabled: bool) -> Self

学習機能を有効化

Note: LearningEventChannel の有効化は build() 時に行われる。

Source

pub fn data_dir(self, path: impl Into<PathBuf>) -> Self

データディレクトリを設定

Source

pub fn swarm_config(self, config: SwarmConfig) -> Self

Swarm 設定を追加

Source

pub fn add_worker(self, worker: Box<dyn WorkerAgent>) -> Self

Worker を追加

Source

pub fn workers(self, workers: Vec<Box<dyn WorkerAgent>>) -> Self

複数の Workers を追加

Source

pub fn add_manager(self, manager: Box<dyn ManagerAgent>) -> Self

Manager を追加

Source

pub fn managers(self, managers: Vec<Box<dyn ManagerAgent>>) -> Self

複数の Managers を追加

Source

pub fn batch_invoker(self, invoker: Box<dyn BatchInvoker>) -> Self

BatchInvoker を設定

Source

pub fn dependency_provider( self, provider: Box<dyn DependencyGraphProvider>, ) -> Self

DependencyGraphProvider を設定

Source

pub fn operator_provider( self, provider: Box<dyn OperatorProvider<NodeRules>>, ) -> Self

OperatorProvider を設定

Source

pub fn extensions(self, extensions: Extensions) -> Self

Extensions を設定

Source

pub fn dependency_graph(self, graph: DependencyGraph) -> Self

DependencyGraph を設定

Source

pub fn offline_model(self, model: OfflineModel) -> Self

Offline model を設定

Source

pub fn with_scenario_profile(self, profile: &ScenarioProfile) -> Self

ScenarioProfile から OfflineModel を生成して設定

ScenarioProfile の各コンポーネント(LearnedExploration, LearnedStrategy, LearnedDepGraph) を OfflineModel に変換し、Orchestrator に適用する。

§Example
use swarm_engine_core::learn::{LearnableSwarmBuilder, ScenarioProfile};

let profile = load_profile("troubleshooting")?;
let swarm = LearnableSwarmBuilder::new(runtime.handle().clone())
    .with_scenario_profile(&profile)
    .build()?;
Source

pub fn offline_model_ref(&self) -> Option<&OfflineModel>

Offline model への参照を取得(build 前に参照する場合)

Source

pub fn prior_snapshot(self, snapshot: LearningSnapshot) -> Self

Prior snapshot を設定

Source

pub fn learning_store(self, store: LearningStore) -> Self

LearningStore を設定(ロードなし、store のみ設定)

Source

pub fn with_learning_store(self, store: LearningStore) -> Self

既存の LearningStore からシナリオデータを自動ロード

prior_snapshot, offline_model, data_dir を自動設定し、learning を有効化する。 EvalRunner など、store を保持し続ける必要がある場合に使用。

§Note

ロード時のクリティカルエラー(permission denied 等)は build() 時に返される。 NotFound(初回実行)は正常として扱われる。

Source

pub fn train_trigger(self, trigger: Arc<dyn TrainTrigger>) -> Self

Train trigger を設定

Source

pub fn lifecycle_hook(self, hook: Box<dyn LifecycleHook>) -> Self

LifecycleHook を設定

Source

pub fn enable_exploration(self, enabled: bool) -> Self

Exploration を有効化

Source

pub fn with_trace_subscriber(self, subscriber: Arc<dyn TraceSubscriber>) -> Self

TraceSubscriber を設定(ActionEvent のトレース出力)

§Example
use swarm_engine_core::events::{InMemoryTraceSubscriber, JsonlTraceSubscriber};

// InMemory: 最後にまとめて出力
let trace = Arc::new(InMemoryTraceSubscriber::new());
builder.with_trace_subscriber(trace.clone());

// Jsonl: リアルタイム出力
let trace = Arc::new(JsonlTraceSubscriber::new("trace.jsonl")?);
builder.with_trace_subscriber(trace);
Source

pub fn with_learning_store_path(self, path: impl AsRef<Path>) -> Self

LearningStore からシナリオデータを自動ロード(パス指定)

prior_snapshot と offline_model を自動設定する。

§Note

Store 作成失敗やロード時のクリティカルエラーは build() 時に返される。

Source

pub fn build(self) -> Result<LearnableSwarm, SwarmError>

LearnableSwarm を構築

Auto Trait Implementations§

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more