#[derive(Debug, Clone)]
pub enum SetDescription {
HalfSpace { normal: Vec<f64>, offset: f64 },
Polytope { inequalities: Vec<(Vec<f64>, f64)> },
Ball { center: Vec<f64>, radius: f64 },
Simplex { vertices: Vec<Vec<f64>> },
Intersection(Vec<Box<SetDescription>>),
}
#[derive(Debug, Clone)]
pub struct ConvexSet {
pub dimension: usize,
pub description: SetDescription,
}
impl ConvexSet {
pub fn new(dimension: usize, description: SetDescription) -> Self {
Self {
dimension,
description,
}
}
}
#[derive(Debug, Clone)]
pub enum FunctionKind {
Quadratic {
q: Vec<Vec<f64>>,
b: Vec<f64>,
c: f64,
},
Linear { a: Vec<f64>, b: f64 },
Norm { p: f64 },
Indicator,
MaxAffine { pieces: Vec<(Vec<f64>, f64)> },
}
#[derive(Debug, Clone)]
pub struct ConvexFunction {
pub domain: ConvexSet,
pub kind: FunctionKind,
}
impl ConvexFunction {
pub fn new(domain: ConvexSet, kind: FunctionKind) -> Self {
Self { domain, kind }
}
}
#[derive(Debug, Clone)]
pub struct SubgradientResult {
pub point: Vec<f64>,
pub subgradient: Vec<f64>,
pub value: f64,
}
#[derive(Debug, Clone)]
pub struct ProjectionResult {
pub projected: Vec<f64>,
pub distance: f64,
}
#[derive(Debug, Clone)]
pub struct SeparatingHyperplane {
pub normal: Vec<f64>,
pub offset: f64,
}
#[derive(Debug, Clone)]
pub struct ConjugateFunction {
pub original_kind: FunctionKind,
}
#[derive(Debug, Clone)]
pub struct ProximalOperator {
pub function: ConvexFunction,
pub step_size: f64,
}
impl ProximalOperator {
pub fn new(function: ConvexFunction, step_size: f64) -> Self {
Self {
function,
step_size,
}
}
}
#[derive(Debug, Clone)]
pub struct OptimizationResult {
pub optimal_point: Vec<f64>,
pub optimal_value: f64,
pub iterations: usize,
pub converged: bool,
}