#[derive(
    Debug,
    Clone,
    conjure_object::serde::Serialize,
    conjure_object::serde::Deserialize,
    conjure_object::private::DeriveWith
)]
#[serde(crate = "conjure_object::serde")]
#[derive_with(PartialEq, Eq, PartialOrd, Ord, Hash)]
#[conjure_object::private::staged_builder::staged_builder]
#[builder(crate = conjure_object::private::staged_builder, update, inline)]
pub struct CustomCurveFit {
    #[builder(custom(type = super::StringConstant, convert = Box::new))]
    #[serde(rename = "formula")]
    formula: Box<super::StringConstant>,
    #[builder(
        default,
        map(key(type = super::LocalVariableName), value(type = super::CurveFitVariable))
    )]
    #[serde(
        rename = "variables",
        skip_serializing_if = "std::collections::BTreeMap::is_empty",
        default
    )]
    variables: std::collections::BTreeMap<
        super::LocalVariableName,
        super::CurveFitVariable,
    >,
    #[builder(
        default,
        map(key(type = String, into), value(type = super::DoubleConstant))
    )]
    #[serde(
        rename = "parameters",
        skip_serializing_if = "std::collections::BTreeMap::is_empty",
        default
    )]
    parameters: std::collections::BTreeMap<String, super::DoubleConstant>,
}
impl CustomCurveFit {
    /// Constructs a new instance of the type.
    #[inline]
    pub fn new(formula: super::StringConstant) -> Self {
        Self::builder().formula(formula).build()
    }
    /// A mathematical expression in terms of variable and parameter names, e.g. `a * x + b * sin(x)`.
    /// Variable names must match keys in the `variables` map; parameter names must match keys in the
    /// `parameters` map.
    #[inline]
    pub fn formula(&self) -> &super::StringConstant {
        &*self.formula
    }
    /// Named input series referenced in the formula. Keys must match the variable names used in the formula expression.
    #[inline]
    pub fn variables(
        &self,
    ) -> &std::collections::BTreeMap<super::LocalVariableName, super::CurveFitVariable> {
        &self.variables
    }
    /// Named fitting parameters and their initial guesses. Keys must match the parameter names used in
    /// the formula expression; values are the starting points passed to the optimizer. The target the
    /// curve is fit against is the `y` of the enclosing curve fit (the timeSeries series values, or the
    /// scatter `y` series).
    #[inline]
    pub fn parameters(
        &self,
    ) -> &std::collections::BTreeMap<String, super::DoubleConstant> {
        &self.parameters
    }
}
