Skip to main content

SwapSearch

Struct SwapSearch 

Source
pub struct SwapSearch<'a> {
    pub picks: Vec<Vec<Pick>>,
    /* private fields */
}
Expand description

差し替え探索

Fields§

§picks: Vec<Vec<Pick>>

所ごとの選び方

Implementations§

Source§

impl SwapSearch<'_>

Source

pub fn uses_beam(&self) -> bool

ビーム探索か(SwapSpec::beam)

Source

pub fn beam_run( &self, threads: Option<usize>, ) -> (Vec<SwapResult>, usize, bool, Option<String>)

ビーム探索(SwapSpec::beam がなければ全組の総当たり Self::run): (すべての所を選んだ組の結果(評価関数の小さい順), 最適化した選び方の数, 止めたか, 結果が空のときの理由)。 進み具合は文脈の受け手(par::with_progress)へ段 "main" の par::Event::Count で知らせ、total は評価する数の 見込みの上限(Self::beam_estimate)。文脈の中断の印(par::with_cancel)が倒れたら新しい評価を始めない

Source§

impl<'a> SwapSearch<'a>

Source

pub fn new( p: &Project, env: &Env<'_>, cat: &'a LensCatalog, spec: SwapSpec, ) -> Result<SwapSearch<'a>>

プロジェクト p(状態は spec.state)の玉を差し替える探索を作る。env.base・glass_dirs を使い、 レンズは cat から引く(env.catalog は使わない)

Source

pub fn count(&self) -> usize

組の数

Source

pub fn combo(&self, i: usize) -> Vec<usize>

組 i の所ごとの選び方の番号(混合基数、最後の所が最も速く回る)

Source

pub fn project(&self, i: usize) -> Result<Project>

組 i で差し替えたプロジェクト

Source

pub fn problem(&self, i: usize) -> Result<(System, Problem)>

組 i の系と、最適化の問題

Source

pub fn eval(&self, i: usize) -> SwapResult

組 i を評価した結果(組 i だけから決まる)。評価できなければ error に理由

Source

pub fn distinct_count(&self) -> usize

同じ形の組の数(代表の選び方の組の数。Self::count 以下)

Source

pub fn screened(&self, threads: Option<usize>) -> Vec<usize>

二段目(今の評価)に回す組の番号(小さい順)。粗いふるいがなければ全組。threads は Self::run と同じ

Source

pub fn screen(&self, o: &RunOpts<'_>) -> Result<(Vec<usize>, bool)>

Self::screened を一括実行(lensbench_runs::run)で回す: (二段目に回す組の番号, 止めたか)。 o.out があれば一段目の粗い評価関数を組ごとにそのファイルへ書き、o.resume なら同じ頭のファイルの続きから回す (o.header・o.stage は使わず、一段目の頭を書く)。進み具合は段 "screen" で文脈の受け手へ知らせ、文脈の中断の印で止める。 止めたら番号は空

Source

pub fn header(&self) -> String

一括実行の結果のファイルの頭: 版・設定・元のプロジェクトの hash・所ごとの候補。 候補(カタログ)・設定・プロジェクトが変われば違う頭になり、再開できない

Source

pub fn run_to( &self, out: Option<&Path>, resume: bool, threads: Option<usize>, ) -> Result<Vec<SwapResult>>

run と同じ。out があれば一括実行(lensbench_runs::run)で結果を 1 組ずつ JSONL に書き出し、resume なら同じ頭のファイルの続きから回す(書いた組は飛ばす)。返り値はファイルの全部の組。 粗いふるいがあれば、一段目の値は screen_path(out) に書いて同じく続きから回す。 進み具合は文脈の受け手(par::with_progress)へ、段(SwapStage::name)を付けて知らせる

Source

pub fn run(&self, threads: Option<usize>) -> Vec<SwapResult>

すべての組(ビーム探索なら Self::beam_run で評価した組)を並列に評価し、評価関数の小さい順に並べる(評価できなかった組は後ろ、番号の順)。 threads は par::with_threads と同じ(None は外の指定を引き継ぐ)

Source§

impl SwapSearch<'_>

Source

pub fn slots(&self) -> Vec<Vec<SwapCand>>

所ごとの候補(SwapReply::slots)

Auto Trait Implementations§

§

impl<'a> !Freeze for SwapSearch<'a>

§

impl<'a> RefUnwindSafe for SwapSearch<'a>

§

impl<'a> Send for SwapSearch<'a>

§

impl<'a> Sync for SwapSearch<'a>

§

impl<'a> Unpin for SwapSearch<'a>

§

impl<'a> UnsafeUnpin for SwapSearch<'a>

§

impl<'a> UnwindSafe for SwapSearch<'a>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,