use crate::DType;
use numr::runtime::Runtime;
use numr::tensor::Tensor;
use crate::optimize::error::OptimizeResult;
#[derive(Debug, Clone)]
pub struct SocConstraint<R: Runtime<DType = DType>> {
pub a: Tensor<R>,
pub b: Tensor<R>,
pub c: Tensor<R>,
pub d: f64,
}
#[derive(Debug, Clone)]
pub struct SocpOptions {
pub max_iter: usize,
pub tol: f64,
}
impl Default for SocpOptions {
fn default() -> Self {
Self {
max_iter: 200,
tol: 1e-8,
}
}
}
#[derive(Debug, Clone)]
pub struct SocpResult<R: Runtime<DType = DType>> {
pub x: Tensor<R>,
pub fun: f64,
pub iterations: usize,
pub converged: bool,
}
pub trait SocpAlgorithms<R: Runtime<DType = DType>> {
fn solve_socp(
&self,
c: &Tensor<R>,
constraints: &[SocConstraint<R>],
options: &SocpOptions,
) -> OptimizeResult<SocpResult<R>>;
}