pub struct SimplexSolver {
pub num_vars: usize,
pub num_constraints: usize,
pub obj: Vec<f64>,
pub a_matrix: Vec<Vec<f64>>,
pub rhs: Vec<f64>,
}Expand description
A tableau-based simplex solver for LP: minimize cᵀx subject to Ax ≤ b, x ≥ 0.
Uses the standard two-phase / big-M approach in the augmented tableau form. For simplicity this implementation handles only the bounded feasible case.
Fields§
§num_vars: usizeNumber of decision variables.
num_constraints: usizeNumber of constraints (rows in A).
obj: Vec<f64>Objective coefficients c (length = num_vars).
a_matrix: Vec<Vec<f64>>Constraint matrix A (num_constraints × num_vars).
rhs: Vec<f64>Right-hand side b (length = num_constraints).
Implementations§
Source§impl SimplexSolver
impl SimplexSolver
Sourcepub fn new(obj: Vec<f64>, a_matrix: Vec<Vec<f64>>, rhs: Vec<f64>) -> Self
pub fn new(obj: Vec<f64>, a_matrix: Vec<Vec<f64>>, rhs: Vec<f64>) -> Self
Create a new simplex solver instance.
Sourcepub fn solve(&self) -> Option<f64>
pub fn solve(&self) -> Option<f64>
Solve the LP using the simplex method (minimization).
Uses the standard full-tableau form. The objective row stores the current reduced costs; a negative reduced cost means the variable can improve the objective.
Returns Some(optimal_value) if an optimal solution is found,
or None if the problem is unbounded or infeasible.
Trait Implementations§
Source§impl Clone for SimplexSolver
impl Clone for SimplexSolver
Source§fn clone(&self) -> SimplexSolver
fn clone(&self) -> SimplexSolver
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more