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
impl Workspace
Sourcepub fn problem(&self) -> &QpProblem
pub fn problem(&self) -> &QpProblem
Returns the problem data currently held by the workspace (original, unscaled space, including any updates applied so far).
Sourcepub const fn settings(&self) -> &SolverSettings
pub const fn settings(&self) -> &SolverSettings
Returns the settings this workspace iterates with.
Sourcepub const fn factorizations(&self) -> usize
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.
Sourcepub fn update_linear(&mut self, linear: &[f64]) -> Result<(), SolverError>
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.
Sourcepub fn update_l1_anchor(&mut self, anchor: &[f64]) -> Result<(), SolverError>
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.
Sourcepub fn update_equality_rhs(&mut self, rhs: &[f64]) -> Result<(), SolverError>
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.
Sourcepub fn update_inequality_rhs(&mut self, rhs: &[f64]) -> Result<(), SolverError>
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.
Sourcepub fn solve(
&mut self,
warm_start: Option<&WarmStart>,
) -> Result<Solution, SolverError>
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.