Skip to content

Commit

Permalink
Merge pull request #2387 from farid-zare/extremePools
Browse files Browse the repository at this point in the history
Update extremePools.m
  • Loading branch information
farid-zare authored Feb 1, 2025
2 parents a6af2d8 + f883bab commit 2f5c6ab
Showing 1 changed file with 14 additions and 9 deletions.
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
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';

% 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);

%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))
warning('extreme pool not in left nullspace of stoichiometric matrix')
end
end
Expand All @@ -191,5 +198,3 @@
delete('*.sh');
delete('*.time');
end


0 comments on commit 2f5c6ab

Please sign in to comment.