pub struct IncrementalParallelSolver { /* private fields */ }Expand description
Multi-threaded incremental constraint solver.
Re-solves after constraint addition/removal without a full restart when possible:
- On constraint addition: if the current solution is already feasible for the new constraint, no work is needed. Otherwise, only project onto the new constraint (warm start) before running full alternating projections.
- On constraint removal: the solution remains feasible for remaining constraints,
so no re-solve is needed;
solution_validis kepttrue.
Implementations§
Source§impl IncrementalParallelSolver
impl IncrementalParallelSolver
Sourcepub fn new(config: ParallelConfig) -> Self
pub fn new(config: ParallelConfig) -> Self
Create a new solver with the given configuration.
Sourcepub fn add_constraint(&mut self, constraint: Box<dyn FastConstraint>)
pub fn add_constraint(&mut self, constraint: Box<dyn FastConstraint>)
Add a constraint. If a valid solution already exists and it satisfies the new
constraint, solution_valid remains true — avoiding a full re-solve.
Sourcepub fn remove_constraint(&mut self, idx: usize) -> bool
pub fn remove_constraint(&mut self, idx: usize) -> bool
Remove a constraint by index. Returns false if idx is out of range.
After removal the cached solution (if any) is still feasible for the remaining
constraints, so solution_valid is preserved.
Sourcepub fn invalidate(&mut self)
pub fn invalidate(&mut self)
Force a full re-solve on the next call to solve.
Sourcepub fn current_solution(&self) -> Option<&Array1<f32>>
pub fn current_solution(&self) -> Option<&Array1<f32>>
Return a reference to the cached solution, if any.
Sourcepub fn num_constraints(&self) -> usize
pub fn num_constraints(&self) -> usize
Number of registered constraints.
Sourcepub fn solve(&mut self, init: Array1<f32>, max_iter: usize) -> SolverResult
pub fn solve(&mut self, init: Array1<f32>, max_iter: usize) -> SolverResult
Solve incrementally.
- If
solution_valid, warm-starts from the cached solution (fewer iterations). - Otherwise, starts from
init.
Uses Dykstra’s alternating projections in parallel (via ParallelFeasibilityChecker).
Auto Trait Implementations§
impl Freeze for IncrementalParallelSolver
impl !RefUnwindSafe for IncrementalParallelSolver
impl Send for IncrementalParallelSolver
impl Sync for IncrementalParallelSolver
impl Unpin for IncrementalParallelSolver
impl UnsafeUnpin for IncrementalParallelSolver
impl !UnwindSafe for IncrementalParallelSolver
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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