pub struct SwapSearch<'a> {
pub picks: Vec<Vec<Pick>>,
/* private fields */
}Expand description
差し替え探索
Fields§
§picks: Vec<Vec<Pick>>所ごとの選び方
Implementations§
Source§impl SwapSearch<'_>
impl SwapSearch<'_>
Sourcepub fn uses_beam(&self) -> bool
pub fn uses_beam(&self) -> bool
ビーム探索か(SwapSpec::beam)
Sourcepub fn beam_run(
&self,
threads: Option<usize>,
) -> (Vec<SwapResult>, usize, bool, Option<String>)
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>
impl<'a> SwapSearch<'a>
Sourcepub fn new(
p: &Project,
env: &Env<'_>,
cat: &'a LensCatalog,
spec: SwapSpec,
) -> Result<SwapSearch<'a>>
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 は使わない)
Sourcepub fn eval(&self, i: usize) -> SwapResult
pub fn eval(&self, i: usize) -> SwapResult
組 i を評価した結果(組 i だけから決まる)。評価できなければ error に理由
Sourcepub fn distinct_count(&self) -> usize
pub fn distinct_count(&self) -> usize
同じ形の組の数(代表の選び方の組の数。Self::count 以下)
Sourcepub fn screened(&self, threads: Option<usize>) -> Vec<usize>
pub fn screened(&self, threads: Option<usize>) -> Vec<usize>
二段目(今の評価)に回す組の番号(小さい順)。粗いふるいがなければ全組。threads は Self::run と同じ
Sourcepub fn screen(&self, o: &RunOpts<'_>) -> Result<(Vec<usize>, bool)>
pub fn screen(&self, o: &RunOpts<'_>) -> Result<(Vec<usize>, bool)>
Self::screened を一括実行(lensbench_runs::run)で回す: (二段目に回す組の番号, 止めたか)。
o.out があれば一段目の粗い評価関数を組ごとにそのファイルへ書き、o.resume なら同じ頭のファイルの続きから回す
(o.header・o.stage は使わず、一段目の頭を書く)。進み具合は段 "screen" で文脈の受け手へ知らせ、文脈の中断の印で止める。
止めたら番号は空
Sourcepub fn header(&self) -> String
pub fn header(&self) -> String
一括実行の結果のファイルの頭: 版・設定・元のプロジェクトの hash・所ごとの候補。 候補(カタログ)・設定・プロジェクトが変われば違う頭になり、再開できない
Sourcepub fn run_to(
&self,
out: Option<&Path>,
resume: bool,
threads: Option<usize>,
) -> Result<Vec<SwapResult>>
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)を付けて知らせる
Sourcepub fn run(&self, threads: Option<usize>) -> Vec<SwapResult>
pub fn run(&self, threads: Option<usize>) -> Vec<SwapResult>
すべての組(ビーム探索なら Self::beam_run で評価した組)を並列に評価し、評価関数の小さい順に並べる(評価できなかった組は後ろ、番号の順)。
threads は par::with_threads と同じ(None は外の指定を引き継ぐ)
Source§impl SwapSearch<'_>
impl SwapSearch<'_>
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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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