From 1480aa9bb54a7391fe13de73f045533b52d8c0b1 Mon Sep 17 00:00:00 2001 From: Junaid Rasheed Date: Fri, 2 Oct 2026 11:35:01 +0100 Subject: [PATCH 1/2] refactor(simplex): remove unused pivot bindings --- src/Linear/Simplex/Solver/TwoPhase.hs | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/Linear/Simplex/Solver/TwoPhase.hs b/src/Linear/Simplex/Solver/TwoPhase.hs index ca148f0..8824e65 100644 --- a/src/Linear/Simplex/Solver/TwoPhase.hs +++ b/src/Linear/Simplex/Solver/TwoPhase.hs @@ -838,30 +838,15 @@ simplexPivot objective@(PivotObjective {variable = objectiveVar, function = obje & #constant %~ divideByNegatedEnteringVariableCoeff where - newEnteringVarTerm = (leavingVariable, -1) divideByNegatedEnteringVariableCoeff = (/ negate enteringVariableCoeff) -- Substitute pivot equation into other rows updatedRows :: Dict updatedRows = - M.fromList $ map (uncurry f2) $ M.toList dict + M.fromList $ map (uncurry updateRow) $ M.toList dict where - f entryVar entryVal = - if leavingVariable == entryVar - then pivotEnteringRow - else case M.lookup enteringVariable (entryVal.varMapSum) of - Just subsCoeff -> - entryVal - & #varMapSum - .~ combineVarLitMapSums - (pivotEnteringRow.varMapSum <&> (subsCoeff *)) - (filterOutEnteringVarTerm (entryVal.varMapSum)) - & #constant - .~ ((subsCoeff * (pivotEnteringRow.constant)) + entryVal.constant) - Nothing -> entryVal - - f2 :: Var -> DictValue -> (Var, DictValue) - f2 entryVar entryVal = + updateRow :: Var -> DictValue -> (Var, DictValue) + updateRow entryVar entryVal = if leavingVariable == entryVar then (enteringVariable, pivotEnteringRow) else case M.lookup enteringVariable (entryVal.varMapSum) of From bea050f0007ecc7711cf44ad6faf1b4dac77cfe4 Mon Sep 17 00:00:00 2001 From: Junaid Rasheed Date: Fri, 2 Oct 2026 11:46:33 +0100 Subject: [PATCH 2/2] docs(changelog): document changes in PR #21 --- ChangeLog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.md b/ChangeLog.md index d47e0a4..415eca9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,7 @@ ## Unreleased changes +- Remove unused pivot bindings and give the active row-update helper a descriptive name. ([#21](https://github.com/rasheedja/simplex-method/pull/21)) - `twoPhaseSimplex` now takes a `VarDomainMap` as its first argument - Specify each variable's domain using smart constructors: `nonNegative`, `unbounded`, `lowerBoundOnly`, `upperBoundOnly`, or `boundedRange` - Variables not in the `VarDomainMap` are assumed to be `unbounded`