pub struct ClarabelOptionsBuilder {
pub clarabel_settings: DefaultSettings<f64>,
pub allow_almost_solved: bool,
pub allow_max_iterations: bool,
pub allow_max_time: bool,
pub allow_callback_terminated: bool,
pub allow_insufficient_progress: bool,
pub verbosity: Verbosity,
}Expand description
Builder for ClarabelOptions.
Usage policy:
- Keep default path minimal for common users (
new); - Allow expert tuning with raw Clarabel settings (
with_clarabel_setting); - By default,
SolverStatus::SolvedandSolverStatus::AlmostSolvedare accepted; all otherallow_*switches default tofalse; - Normalize output behavior in
buildby applying verbosity-vs-clarabel logging precedence.
Fields§
§clarabel_settings: DefaultSettings<f64>Raw Clarabel settings that will be embedded into built options.
allow_almost_solved: boolWhether to accept SolverStatus::AlmostSolved as usable.
allow_max_iterations: boolWhether to accept SolverStatus::MaxIterations as usable.
allow_max_time: boolWhether to accept SolverStatus::MaxTime as usable.
allow_callback_terminated: boolWhether to accept SolverStatus::CallbackTerminated as usable.
allow_insufficient_progress: boolWhether to accept SolverStatus::InsufficientProgress as usable.
verbosity: VerbosityVerbosity level for diagnostics during reachability analysis.
Implementations§
Source§impl ClarabelOptionsBuilder
impl ClarabelOptionsBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a builder with crate default Clarabel settings. Defaults:
verbosity = Verbosity::Silent;clarabel_settings = default_clarabel_settings();allow_almost_solved = true, all otherallow_*switches arefalse.
Sourcepub fn with_clarabel_setting(clarabel_settings: DefaultSettings<f64>) -> Self
pub fn with_clarabel_setting(clarabel_settings: DefaultSettings<f64>) -> Self
Create a builder from caller-provided Clarabel settings. This is intended for users who need direct control over Clarabel tolerances, limits, or linear-solver behavior.
§Example
The example below starts from raw Clarabel settings and then lets the shared builder normalize verbosity policy.
use copp::diag::Verbosity;
use copp::solver::copp2_socp::ClarabelOptionsBuilder;
use clarabel::solver::DefaultSettings;
let custom = DefaultSettings::<f64> {
tol_gap_rel: 1e-7,
max_iter: 300,
verbose: true,
..Default::default()
};
let options = ClarabelOptionsBuilder::with_clarabel_setting(custom)
.verbosity(Verbosity::Debug)
.build()
.expect("valid options");
assert!(options.clarabel_settings().tol_gap_rel <= 1.01e-7);Sourcepub fn verbosity(self, verbosity: Verbosity) -> Self
pub fn verbosity(self, verbosity: Verbosity) -> Self
Set crate-level verbosity used by solver wrappers and algorithm diagnostics.
Sourcepub fn clarabel_setting(self, clarabel_settings: DefaultSettings<f64>) -> Self
pub fn clarabel_setting(self, clarabel_settings: DefaultSettings<f64>) -> Self
Replace Clarabel settings in the builder.
Sourcepub fn allow_almost_solved(self, allow: bool) -> Self
pub fn allow_almost_solved(self, allow: bool) -> Self
Allow SolverStatus::AlmostSolved.
This is enabled by default; pass false for a strict solved-only policy.
Rationale: AlmostSolved usually means the solver is very close to strict tolerances and the returned primal vector is often practically usable.
Integration contract used by wrapper APIs:
- if status is
SolverStatus::Solvedor enabled byallow_*, wrapper returnsSome(a); - otherwise wrapper returns
None; - in both branches, full Clarabel
solutionshould still be returned to support expert post-analysis.
Sourcepub fn allow_max_iterations(self, allow: bool) -> Self
pub fn allow_max_iterations(self, allow: bool) -> Self
Allow SolverStatus::MaxIterations.
Meaning: solver stopped because iteration cap was reached.
Sourcepub fn allow_max_time(self, allow: bool) -> Self
pub fn allow_max_time(self, allow: bool) -> Self
Allow SolverStatus::MaxTime.
Meaning: solver stopped because time budget was reached.
Sourcepub fn allow_callback_terminated(self, allow: bool) -> Self
pub fn allow_callback_terminated(self, allow: bool) -> Self
Allow SolverStatus::CallbackTerminated.
Meaning: solver was terminated by user callback logic.
Sourcepub fn allow_insufficient_progress(self, allow: bool) -> Self
pub fn allow_insufficient_progress(self, allow: bool) -> Self
Allow SolverStatus::InsufficientProgress.
Meaning: solver progress was judged insufficient before full convergence.
Sourcepub fn build(self) -> Result<ClarabelOptions, CoppError>
pub fn build(self) -> Result<ClarabelOptions, CoppError>
Build finalized ClarabelOptions.
Normalization rule: if verbosity <= Verbosity::Summary,
clarabel_settings.verbose is forcibly set to false.
This keeps output ownership at crate level and avoids interleaved duplicate logs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ClarabelOptionsBuilder
impl RefUnwindSafe for ClarabelOptionsBuilder
impl Send for ClarabelOptionsBuilder
impl Sync for ClarabelOptionsBuilder
impl Unpin for ClarabelOptionsBuilder
impl UnwindSafe for ClarabelOptionsBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.