Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update extremePools.m #2387

Merged
merged 1 commit into from
Feb 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions src/analysis/topology/extremeRays/lrs/extremePools.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@
end

try
[rankA, p, q] = getRankLUSOL(N, 1);
N=N(:,q(1:rankA));
% [rankA, p, q] = getRankLUSOL(N, 1);
% N=N(:,q(1:rankA));
[rankN, rowPerm, colPerm] = getRankLUSOL(N, 1);
N = N(rowPerm(1:rankN), :); % <-- Removing only rows instead of columns

Check warning on line 65 in src/analysis/topology/extremeRays/lrs/extremePools.m

View check run for this annotation

Codecov / codecov/patch

src/analysis/topology/extremeRays/lrs/extremePools.m#L64-L65

Added lines #L64 - L65 were not covered by tests
disp('extremePools: row reduction with getRankLUSOL worked.')
catch
disp('extremePools: row reduction with getRankLUSOL did not work, check installation of LUSOL. Proceeding without it.')
Expand Down Expand Up @@ -160,13 +162,16 @@
modelName = 'model';
end

b = zeros(size(N, 2),1);

csense(1:size(N, 2),1)='E';
% Set up the zero right-hand side for N*x = 0 (all constraints are equalities)
b = zeros(size(N, 1),1);
csense(1:size(N, 1),1)='E';

Check warning on line 167 in src/analysis/topology/extremeRays/lrs/extremePools.m

View check run for this annotation

Codecov / codecov/patch

src/analysis/topology/extremeRays/lrs/extremePools.m#L166-L167

Added lines #L166 - L167 were not covered by tests

% Output a file for lrs to convert an H-representation (half-space) of a
% polyhedron to a V-representation (vertex / ray) via vertex enumeration
fileNameOut = lrsWriteHalfspace(N', b, csense, modelName, param);
% Write the half-space (H-representation) to file for LRS
% Here, N is an (n x m) matrix representing the transposed stoichiometry (S^T).
% The LRS tool will enumerate all nonnegative solutions x s.t. N*x = 0.
fileNameOut = lrsWriteHalfspace(N, b, csense, modelName, param);

Check warning on line 174 in src/analysis/topology/extremeRays/lrs/extremePools.m

View check run for this annotation

Codecov / codecov/patch

src/analysis/topology/extremeRays/lrs/extremePools.m#L174

Added line #L174 was not covered by tests

%run lrs
param.facetEnumeration = 0;%vertex enumeration
Expand All @@ -179,7 +184,9 @@
V = Q(:,vertexBool);
P = Q(:,~vertexBool)';%extreme rays

if any(any(P*N ~= 0))
% After LRS enumeration, we check that each extreme pool vector P indeed satisfies P*N' = 0,
% ensuring it lies in the left null space of the original stoichiometric matrix (S).
if any(any(P*N' ~= 0))

Check warning on line 189 in src/analysis/topology/extremeRays/lrs/extremePools.m

View check run for this annotation

Codecov / codecov/patch

src/analysis/topology/extremeRays/lrs/extremePools.m#L189

Added line #L189 was not covered by tests
warning('extreme pool not in left nullspace of stoichiometric matrix')
end
end
Expand All @@ -191,5 +198,3 @@
delete('*.sh');
delete('*.time');
end


Loading