Skip to main content

Workspace

Struct Workspace 

Source
pub struct Workspace { /* private fields */ }
Expand description

Reusable solve state for a fixed problem structure.

Constructed by crate::Solver::workspace. Holds the equilibrated problem copy and a penalty-keyed cache of SMW-reduced factorizations, so repeated solves skip both setup costs. See the module documentation for what is cached and when it is rebuilt.

Implementations§

Source§

impl Workspace

Source

pub fn problem(&self) -> &QpProblem

Returns the problem data currently held by the workspace (original, unscaled space, including any updates applied so far).

Source

pub const fn settings(&self) -> &SolverSettings

Returns the settings this workspace iterates with.

Source

pub const fn factorizations(&self) -> usize

Number of reduced factorizations built since construction (including the initial one). Stable counts across rolling solves demonstrate factorization reuse.

Source

pub fn update_linear(&mut self, linear: &[f64]) -> Result<(), SolverError>

Replaces the linear objective coefficient (for portfolios: new expected returns and/or previous weights folded into q).

The cached factorizations stay valid; the equilibration computed at construction is reapplied to the new vector as an exact transform.

§Errors

Returns SolverError::InvalidProblem when the vector has the wrong length or contains a non-finite value.

Source

pub fn update_l1_anchor(&mut self, anchor: &[f64]) -> Result<(), SolverError>

Replaces the anchor of the L1 term (for portfolios: the previous weights the proportional turnover cost is measured from).

The anchor enters neither the quadratic nor the constraint matrices, so the cached factorizations stay valid; the frozen variable scaling is reapplied as an exact transform. The costs themselves are part of the problem structure held by this workspace and stay fixed.

§Errors

Returns SolverError::InvalidProblem when the problem has no L1 term, or the vector has the wrong length or a non-finite value.

Source

pub fn update_equality_rhs(&mut self, rhs: &[f64]) -> Result<(), SolverError>

Replaces the equality right-hand side (for portfolios: a new budget).

The cached factorizations stay valid.

§Errors

Returns SolverError::InvalidProblem when the vector has the wrong length or contains a non-finite value.

Source

pub fn update_inequality_rhs(&mut self, rhs: &[f64]) -> Result<(), SolverError>

Replaces the inequality right-hand side (for portfolios: new exposure caps with unchanged constraint rows).

The cached factorizations stay valid.

§Errors

Returns SolverError::InvalidProblem when the vector has the wrong length or contains a non-finite value.

Source

pub fn solve( &mut self, warm_start: Option<&WarmStart>, ) -> Result<Solution, SolverError>

Solves the current problem data, reusing the cached equilibration and factorizations.

The iterate path is identical to a fresh Solver::solve of the same data: the penalty policy restarts from SolverSettings::rho and adapts as usual, but every penalty already visited by this workspace reuses its cached factorization instead of rebuilding it.

Unlike crate::Solver::solve, the reported Solution::solve_time covers only this call: one-time setup was paid at construction.

§Errors

Returns SolverError when the warm start is invalid or a rebuilt reduced system cannot be factored.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.