#[derive(Debug, Clone)]
pub struct OptimalCertificate {
stationarity_rel: f64,
primal_residual_rel: f64,
bound_violation: f64,
complementarity_rel: f64,
dual_sign_violation: f64,
duality_gap_rel: f64,
tol: f64,
}
impl OptimalCertificate {
pub(crate) fn new(
stationarity_rel: f64,
primal_residual_rel: f64,
bound_violation: f64,
complementarity_rel: f64,
dual_sign_violation: f64,
duality_gap_rel: f64,
tol: f64,
) -> Self {
Self {
stationarity_rel,
primal_residual_rel,
bound_violation,
complementarity_rel,
dual_sign_violation,
duality_gap_rel,
tol,
}
}
pub fn stationarity_rel(&self) -> f64 { self.stationarity_rel }
pub fn primal_residual_rel(&self) -> f64 { self.primal_residual_rel }
pub fn bound_violation(&self) -> f64 { self.bound_violation }
pub fn complementarity_rel(&self) -> f64 { self.complementarity_rel }
pub fn dual_sign_violation(&self) -> f64 { self.dual_sign_violation }
pub fn duality_gap_rel(&self) -> f64 { self.duality_gap_rel }
pub fn tol(&self) -> f64 { self.tol }
}
#[derive(Debug, Clone)]
pub struct NotProven {
pub stationarity_rel: f64,
pub primal_residual_rel: f64,
pub bound_violation: f64,
pub complementarity_rel: f64,
pub dual_sign_violation: f64,
pub duality_gap_rel: f64,
pub tol: f64,
pub failing_conditions: Vec<&'static str>,
}
#[derive(Debug, Clone)]
pub struct BoundGapCertificate {
incumbent_obj: f64,
lower_bound: f64,
gap_rel: f64,
gap_tol: f64,
}
impl BoundGapCertificate {
pub(crate) fn new(incumbent_obj: f64, lower_bound: f64, gap_rel: f64, gap_tol: f64) -> Self {
Self { incumbent_obj, lower_bound, gap_rel, gap_tol }
}
pub fn incumbent_obj(&self) -> f64 { self.incumbent_obj }
pub fn lower_bound(&self) -> f64 { self.lower_bound }
pub fn gap_rel(&self) -> f64 { self.gap_rel }
pub fn gap_tol(&self) -> f64 { self.gap_tol }
}
#[derive(Debug, Clone)]
pub struct FarkasCertificate;
#[derive(Debug, Clone)]
pub struct UnboundedRayCertificate;
#[derive(Debug)]
pub enum SolveOutcome {
Optimal {
x: Vec<f64>,
y: Vec<f64>,
z: Vec<f64>,
objective: f64,
cert: OptimalCertificate,
},
LocalOptimal {
x: Vec<f64>,
y: Vec<f64>,
z: Vec<f64>,
objective: f64,
kkt_cert: OptimalCertificate,
},
Infeasible { cert: FarkasCertificate },
Unbounded { cert: UnboundedRayCertificate },
Incomplete {
incumbent: Option<Vec<f64>>,
reason: IncompleteReason,
},
}
#[derive(Debug, Clone)]
pub enum IncompleteReason {
MaxIterations,
Timeout,
NumericalError,
SuboptimalSolution,
NonConvex(String),
NotSupported(String),
}