|
59 | 59 | end
|
60 | 60 |
|
61 | 61 | try
|
62 |
| - [rankA, p, q] = getRankLUSOL(N, 1); |
63 |
| - N=N(:,q(1:rankA)); |
| 62 | + % [rankA, p, q] = getRankLUSOL(N, 1); |
| 63 | + % N=N(:,q(1:rankA)); |
| 64 | + [rankN, rowPerm, colPerm] = getRankLUSOL(N, 1); |
| 65 | + N = N(rowPerm(1:rankN), :); % <-- Removing only rows instead of columns |
64 | 66 | disp('extremePools: row reduction with getRankLUSOL worked.')
|
65 | 67 | catch
|
66 | 68 | disp('extremePools: row reduction with getRankLUSOL did not work, check installation of LUSOL. Proceeding without it.')
|
|
160 | 162 | modelName = 'model';
|
161 | 163 | end
|
162 | 164 |
|
163 |
| - b = zeros(size(N, 2),1); |
164 |
| - |
165 |
| - csense(1:size(N, 2),1)='E'; |
| 165 | + % Set up the zero right-hand side for N*x = 0 (all constraints are equalities) |
| 166 | + b = zeros(size(N, 1),1); |
| 167 | + csense(1:size(N, 1),1)='E'; |
166 | 168 |
|
167 | 169 | % Output a file for lrs to convert an H-representation (half-space) of a
|
168 | 170 | % polyhedron to a V-representation (vertex / ray) via vertex enumeration
|
169 |
| - fileNameOut = lrsWriteHalfspace(N', b, csense, modelName, param); |
| 171 | + % Write the half-space (H-representation) to file for LRS |
| 172 | + % Here, N is an (n x m) matrix representing the transposed stoichiometry (S^T). |
| 173 | + % The LRS tool will enumerate all nonnegative solutions x s.t. N*x = 0. |
| 174 | + fileNameOut = lrsWriteHalfspace(N, b, csense, modelName, param); |
170 | 175 |
|
171 | 176 | %run lrs
|
172 | 177 | param.facetEnumeration = 0;%vertex enumeration
|
|
179 | 184 | V = Q(:,vertexBool);
|
180 | 185 | P = Q(:,~vertexBool)';%extreme rays
|
181 | 186 |
|
182 |
| - if any(any(P*N ~= 0)) |
| 187 | + % After LRS enumeration, we check that each extreme pool vector P indeed satisfies P*N' = 0, |
| 188 | + % ensuring it lies in the left null space of the original stoichiometric matrix (S). |
| 189 | + if any(any(P*N' ~= 0)) |
183 | 190 | warning('extreme pool not in left nullspace of stoichiometric matrix')
|
184 | 191 | end
|
185 | 192 | end
|
|
191 | 198 | delete('*.sh');
|
192 | 199 | delete('*.time');
|
193 | 200 | end
|
194 |
| - |
195 |
| - |
|
0 commit comments