use crate::user_parameter_state::MnUserParameterState;
#[derive(Debug, Clone)]
pub struct MnCross {
value: f64,
state: MnUserParameterState,
nfcn: usize,
valid: bool,
is_at_limit: bool,
is_at_max_fcn: bool,
new_minimum: bool,
}
impl MnCross {
pub fn valid(value: f64, state: MnUserParameterState, nfcn: usize) -> Self {
Self {
value,
state,
nfcn,
valid: true,
is_at_limit: false,
is_at_max_fcn: false,
new_minimum: false,
}
}
pub fn limit_reached(nfcn: usize) -> Self {
Self {
value: 0.0,
state: MnUserParameterState::new(crate::user_parameters::MnUserParameters::new()),
nfcn,
valid: false,
is_at_limit: true,
is_at_max_fcn: false,
new_minimum: false,
}
}
pub fn call_limit_reached(nfcn: usize) -> Self {
Self {
value: 0.0,
state: MnUserParameterState::new(crate::user_parameters::MnUserParameters::new()),
nfcn,
valid: false,
is_at_limit: false,
is_at_max_fcn: true,
new_minimum: false,
}
}
pub fn new_minimum_found(state: MnUserParameterState, nfcn: usize) -> Self {
Self {
value: 0.0,
state,
nfcn,
valid: false,
is_at_limit: false,
is_at_max_fcn: false,
new_minimum: true,
}
}
pub fn invalid(nfcn: usize) -> Self {
Self {
value: 0.0,
state: MnUserParameterState::new(crate::user_parameters::MnUserParameters::new()),
nfcn,
valid: false,
is_at_limit: false,
is_at_max_fcn: false,
new_minimum: false,
}
}
pub fn value(&self) -> f64 {
self.value
}
pub fn state(&self) -> &MnUserParameterState {
&self.state
}
pub fn nfcn(&self) -> usize {
self.nfcn
}
pub fn is_valid(&self) -> bool {
self.valid
}
pub fn at_limit(&self) -> bool {
self.is_at_limit
}
pub fn at_max_fcn(&self) -> bool {
self.is_at_max_fcn
}
pub fn new_minimum(&self) -> bool {
self.new_minimum
}
}