#[non_exhaustive]pub struct Provided {
pub gradient: bool,
pub inequalities: usize,
pub constraint_jacobian: bool,
}Expand description
What a fitness function gives besides the fitness, for every genome: the answer of
FitnessFunction::provides.
Nothing by default. More extras (equality constraints, residuals) come in later versions, so
the struct is #[non_exhaustive]: build it from Provided::NOTHING or
Provided::GRADIENT and the with_ methods.
use genoxide::engine::Provided;
assert!(Provided::NOTHING.is_empty());
assert!(Provided::NOTHING.with_gradient().gradient);
assert_eq!(Provided::default(), Provided::NOTHING);
// a score with its gradient, 2 inequality constraints g(x) <= 0 and their Jacobian
let all = Provided::GRADIENT.with_inequalities(2).with_constraint_jacobian();
assert_eq!(all.inequalities, 2);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.gradient: boolThe gradient of the score, ∂score / ∂xᵢ, one value per gene: of the score as the fitness
function returns it, whether it’s minimized or maximized.
inequalities: usizeThe number of inequality constraints gᵢ(x) ≤ 0 whose values gᵢ(x) the function gives,
in the same order for every genome; 0 for none. The fitness’s violation should then be
Σ max(0, gᵢ(x)), as constraint::at_most measures it.
constraint_jacobian: boolThe Jacobian of the inequality constraints: ∂gᵢ / ∂xⱼ, a row of one value per gene for
each constraint.
Implementations§
Source§impl Provided
impl Provided
Sourcepub const fn with_gradient(self) -> Self
pub const fn with_gradient(self) -> Self
These extras and the gradient.
Sourcepub const fn with_inequalities(self, count: usize) -> Self
pub const fn with_inequalities(self, count: usize) -> Self
These extras and the values of count inequality constraints.
Sourcepub const fn with_constraint_jacobian(self) -> Self
pub const fn with_constraint_jacobian(self) -> Self
These extras and the Jacobian of the inequality constraints.
Trait Implementations§
impl Copy for Provided
Source§impl<'de> Deserialize<'de> for Provided
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Provided
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Provided
impl StructuralPartialEq for Provided
Auto Trait Implementations§
impl Freeze for Provided
impl RefUnwindSafe for Provided
impl Send for Provided
impl Sync for Provided
impl Unpin for Provided
impl UnsafeUnpin for Provided
impl UnwindSafe for Provided
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> ⓘ
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