Skip to main content

Problem

Struct Problem 

Source
pub struct Problem {
    pub configs: Vec<System>,
    pub vars: Vec<Var>,
    pub terms: Vec<Term>,
    pub jac: JacMode,
    pub fd_rel: f64,
    pub fd_rel_noisy: f64,
    pub analytic_min: usize,
    pub stopped_as_vignetted: bool,
}
Expand description

最適化の問題

Fields§

§configs: Vec<System>

構成(多重構成・ズームの各状態)。1 つなら単一の系

§vars: Vec<Var>§terms: Vec<Term>§jac: JacMode§fd_rel: f64

差分の刻みの相対値(刻み = rel × max(|値|, 種類ごとの目安))

§fd_rel_noisy: f64

回転対称でない系の波面の項の差分の刻みの相対値。射出瞳を実光線の外挿で求める(OpticStudio と同じ)ので 評価関数に 1e-8 程度の揺れがあり、小さい刻みでは差分が揺れに負ける

§analytic_min: usize

JacMode::Auto で解析的に求める列の最少の数(項ごと。これより少なければ中心差分)。 既定 16 は、11 面の系のスポットで解析的と中心差分の時間が並ぶ列の数。0 なら常に解析的

§stopped_as_vignetted: bool

瞳の光線を並べる項(スポット・波面・重心)で、追跡が止まった光線(全反射・面に届かない)を、けられた光線と 同じく除く(既定 false: 項が評価できない誤り)。除いた数は Problem::ray_counts

Implementations§

Source§

impl Problem

Source

pub fn ray_counts(&self, x: &[f64]) -> Result<Vec<Option<RayCounts>>>

瞳の光線を並べる項(スポット・波面・重心)の光線の数(けられた・止まった光線。ほかの項は None)。 評価関数は光線がけられる・戻るたびに跳ぶので、開口の縁で最適化が振れるときの目安に

Source§

impl Problem

Source

pub fn new(configs: Vec<System>) -> Problem

Source

pub fn with_configs(&self, configs: Vec<System>) -> Problem

構成だけ configs に替えた問題(今の構成は写さない)

Source

pub fn single(s: System) -> Problem

単一の系

Source

pub fn add_var(&mut self, spec: &str) -> Result<&mut Var>

文字列で変数を足す(System::param の書き方。最初の構成で解釈する)

Source

pub fn add_default( &mut self, kind: DefaultMerit, rings: usize, reference: RmsRef, )

既定の評価関数: 構成ごと・定義済みの視野ごとに、重みのある全波長の RMS の項を足す(重みは視野の重み、 重み 0 の視野は除く)

Source

pub fn check(&self) -> Result<()>

問題の確かめ(構成・変数・項の番号と値)

Source

pub fn x0(&self) -> Result<Vec<f64>>

変数の初期値(効く最初の構成の値)

Source

pub fn systems(&self, x: &[f64]) -> Result<Vec<System>>

変数の値 x での各構成の系

Source

pub fn term_rows(&self) -> Vec<usize>

項ごとの残差の行数(系の形と項で決まり、変数の値によらない)

Source

pub fn n_residuals(&self) -> usize

残差の数

Source

pub fn residuals(&self, x: &[f64]) -> Result<Vec<f64>>

残差(重みの平方根を掛けたもの、項の順に並べる)

Source

pub fn merit(&self, x: &[f64]) -> Result<f64>

評価関数の値 √(Σ r² / Σ 重み)

Source

pub fn merit_of(&self, r: &[f64]) -> f64

残差から評価関数の値

Source

pub fn term_values(&self, x: &[f64]) -> Result<Vec<TermValue>>

項ごとの値: 目標のある項は量そのもの(TermValue::Quantity)、ない項は残差の √Σr²(TermValue::Rms。 スポット・波面の項では RMS そのもの)

Source

pub fn merit_and_terms(&self, x: &[f64]) -> Result<(f64, Vec<TermValue>)>

Self::merit と Self::term_values(系を 1 回作り、項を 1 回ずつ評価する。値はそれぞれと同じ)

Source

pub fn term_values_contrib( &self, x: &[f64], ) -> Result<(Vec<TermValue>, Vec<f64>)>

Self::term_values と、項ごとの評価関数への寄与 [%](重みを掛けた残差の 2 乗の和の、全体に対する割合。 OpticStudio の評価関数エディタの % Contrib と同じ。全体が 0 なら 0)

Source

pub fn jacobian(&self, x: &[f64]) -> Result<(Vec<f64>, Vec<f64>)>

残差とヤコビアン(行優先 [残差][変数])

Trait Implementations§

Source§

impl Clone for Problem

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Problem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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
§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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,