-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathinfo.rs
More file actions
72 lines (65 loc) · 2.02 KB
/
info.rs
File metadata and controls
72 lines (65 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#![allow(non_snake_case)]
use clarabel::{algebra::FloatT, solver::DefaultInfo};
use clarabel::solver::LinearSolverInfo;
use crate::solver::implementations::default::solver::ClarabelSolverStatus;
use super::settings::ClarabelDirectSolveMethods;
#[repr(C)]
pub struct ClarabelLinearSolverInfo {
pub name: ClarabelDirectSolveMethods,
pub threads: u32,
pub direct: bool,
pub nnzA: u32,
pub nnzL: u32,
}
impl From<&LinearSolverInfo> for ClarabelLinearSolverInfo {
fn from(linsolver: &LinearSolverInfo) -> Self {
Self {
name: (&linsolver.name).into(),
threads: linsolver.threads as u32,
direct: linsolver.direct,
nnzA: linsolver.nnzA as u32,
nnzL: linsolver.nnzL as u32,
}
}
}
#[repr(C)]
pub struct ClarabelDefaultInfo<T> {
pub μ: T,
pub sigma: T,
pub step_length: T,
pub iterations: u32,
pub cost_primal: T,
pub cost_dual: T,
pub res_primal: T,
pub res_dual: T,
pub res_primal_inf: T,
pub res_dual_inf: T,
pub gap_abs: T,
pub gap_rel: T,
pub ktratio: T,
pub solve_time: f64,
pub status: ClarabelSolverStatus,
pub linsolver: ClarabelLinearSolverInfo,
}
impl<T: FloatT> From<&DefaultInfo<T>> for ClarabelDefaultInfo<T> {
fn from(info: &DefaultInfo<T>) -> Self {
Self {
μ: info.μ,
sigma: info.sigma,
step_length: info.step_length,
iterations: info.iterations,
cost_primal: info.cost_primal,
cost_dual: info.cost_dual,
res_primal: info.res_primal,
res_dual: info.res_dual,
res_primal_inf: info.res_primal_inf,
res_dual_inf: info.res_dual_inf,
gap_abs: info.gap_abs,
gap_rel: info.gap_rel,
ktratio: info.ktratio,
solve_time: info.solve_time,
status: ClarabelSolverStatus::from(&info.status),
linsolver: ClarabelLinearSolverInfo::from(&info.linsolver),
}
}
}