pub struct InstantiationResult<C: ComplexScalar> {
pub params: Option<Vec<C::R>>,
pub fun: Option<C::R>,
pub status: usize,
pub message: Option<String>,
}Expand description
Result of an instantiation operation.
This struct encapsulates the outcome of an instantiation attempt. It provides information about the success/failure status, and other relevant information. Very little is standardized between instantiaters, so refer to specific instantiaters for more documentation on how the fields are used.
A successful instantiation is one that was able to run until
§Status Codes
0- Successful termination1- Input cannot be handled by instantiator2+- Instantiator-specific error codes (see relevant documentation)
Fields§
§params: Option<Vec<C::R>>The instantiated solution’s parameters.
fun: Option<C::R>Optional function evaluation at the solution point.
If provided, represents instantiation-specific objective function value at the computed solution. Useful for assessing solution quality. Consult with instantiater documentation.
status: usizeTermination status code.
0: Successful termination1: Input cannot be handled by instantiator; see message2+: Instantiator-specific error codes; see relevant documentation
message: Option<String>Optional diagnostic message, providing additional context.
Implementations§
Source§impl<C: ComplexScalar> InstantiationResult<C>
impl<C: ComplexScalar> InstantiationResult<C>
Sourcepub fn new(
params: Option<Vec<C::R>>,
fun: Option<C::R>,
status: usize,
message: Option<String>,
) -> Self
pub fn new( params: Option<Vec<C::R>>, fun: Option<C::R>, status: usize, message: Option<String>, ) -> Self
Creates a new InstantiationResult with all fields specified.
§Arguments
params- Optional solution parametersfun- Optional function evaluationstatus- Status code (0 for success)message- Optional diagnostic message
§Examples
let result = InstantiationResult::<c64>::new(
Some(vec![1.0, 2.0]),
Some(0.1),
0,
Some("Converged successfully".to_string())
);Sourcepub fn success_with_message(
params: Vec<C::R>,
fun: Option<C::R>,
message: String,
) -> Self
pub fn success_with_message( params: Vec<C::R>, fun: Option<C::R>, message: String, ) -> Self
Creates a successful instantiation result with a message.
§Arguments
params- The computed solution parametersfun- Optional function evaluationmessage- Success message
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Returns true if the instantiation was successful (status == 0).
§Examples
let success = InstantiationResult::<c64>::success(vec![1.0], None);
assert!(success.is_success());Sourcepub fn is_failure(&self) -> bool
pub fn is_failure(&self) -> bool
Returns true if the instantiation failed (status > 0).
Sourcepub fn has_params(&self) -> bool
pub fn has_params(&self) -> bool
Returns true if the result contains solution parameters.
Sourcepub fn has_function_value(&self) -> bool
pub fn has_function_value(&self) -> bool
Returns true if the result contains a function evaluation.
Sourcepub fn num_params(&self) -> Option<usize>
pub fn num_params(&self) -> Option<usize>
Returns the number of parameters if available.
Trait Implementations§
Source§impl<C: Clone + ComplexScalar> Clone for InstantiationResult<C>
impl<C: Clone + ComplexScalar> Clone for InstantiationResult<C>
Source§fn clone(&self) -> InstantiationResult<C>
fn clone(&self) -> InstantiationResult<C>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<C: Debug + ComplexScalar> Debug for InstantiationResult<C>
impl<C: Debug + ComplexScalar> Debug for InstantiationResult<C>
Source§impl<C: ComplexScalar> Display for InstantiationResult<C>
impl<C: ComplexScalar> Display for InstantiationResult<C>
Source§impl<C: PartialEq + ComplexScalar> PartialEq for InstantiationResult<C>
impl<C: PartialEq + ComplexScalar> PartialEq for InstantiationResult<C>
impl<C: ComplexScalar> StructuralPartialEq for InstantiationResult<C>
Auto Trait Implementations§
impl<C> Freeze for InstantiationResult<C>
impl<C> RefUnwindSafe for InstantiationResult<C>
impl<C> Send for InstantiationResult<C>
impl<C> Sync for InstantiationResult<C>
impl<C> Unpin for InstantiationResult<C>
impl<C> UnwindSafe for InstantiationResult<C>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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