Rescale¶
- liftCouplingConstraints(model, BIG, printLevel, equalities)[source]¶
Reformulates badly-scaled coupling constraints C*v <=> d by lifting them to a better scaled problem in a higher dimension by introducing dummy variables.
Assumes C does not contain very small entries and transforms constraints containing very large entries (entries larger than BIG).
Reformulation techniques are described in detail in: Sun, Y., Fleming, R. M., Thiele, I., & Saunders, M. A. (2013). Robust flux balance analysis of multiscale biochemical reaction networks. BMC Bioinformatics, 14(1). https://doi.org/10.1186/1471-2105-14-240 See also tutorial here: https://opencobra.github.io/cobratoolbox/stable/tutorials/tutorial_numCharactWBM.html
- USAGE:
[LPproblem] = reformulate (model, BIG, printLevel)
- INPUTS:
model –
C - k x n Left hand side of C*v <= d
d - k x 1 Right hand side of C*v <= d
ctrs k x 1 Cell Array of Strings giving IDs of the coupling constraints
dsense - k x 1 character array with entries in {L,E,G}
- OPTIONAL INPUTS
‘BIG’ Value consided a large coefficient. BIG should be set between 1000 and 10000 on double precision machines. printLevel 1 or 0 enables/diables printing respectively.
equalities true means also deals with original constraints containing equalities (default false - only deals with original constraints that are inequalities)
- OUTPUTS:
model –
E m x evars Sparse or Full Matrix of Double Matrix of additional, non metabolic variables (e.g. Enzyme capacity variables)
evarlb evars x 1 Column Vector of Doubles Lower bounds of the additional variables
evarub evars x 1 Column Vector of Doubles Upper bounds of the additional variables
evarc evars x 1 Column Vector of Doubles Objective coefficient of the additional variables
evars evars x 1 Column Cell Array of Strings IDs of the additional variables
evarNames evars x 1 Column Cell Array of Strings Names of the additional variables
C ctrs x n Sparse or Full Matrix of Double Matrix of additional Constraints (e.g. Coupling Constraints)
ctrs ctrs x 1 Column Cell Array of Strings IDs of the additional Constraints
ctrNames ctrs x 1 Column Cell Array of Strings Names of the of the additional Constraints
d ctrs x 1 Column Vector of Doubles Right hand side values of the additional Constraints
dsense ctrs x 1 Column Vector of Chars Senses of the additional Constraints
D ctrs x evars Sparse or Full Matrix of Double Matrix to store elements that contain interactions between additional Constraints and additional Variables.
The linear optimisation problem derived from this model is then of the form – [S, E; C, D]*x {L,E,G} [b;d]
- liftModel(model, BIG, printLevel, fileName, directory)[source]¶
Lifts a COBRA model with badly-scaled stoichiometric and coupling constraints of the form: \(max c*v\) subject to: \(Sv = 0, x, Cv <= 0\) Converts it into a COBRA LPproblem structure, which can be used with solveCobraLP. Fluxes for the reactions should stay the same i.e. sol.full(1:nRxns) should yield an optimal flux vector.
- USAGE:
LPproblem = liftModel (model, BIG, printLevel,fileName,directory)
- INPUTS:
model – COBRA LPproblem Structure containing the original LP to be solved. The format of this struct is described in the documentation for solveCobraLP.m
- OPTIONAL INPUTS:
BIG – A parameter the controls the largest entries that appear in the reformulated problem (default = 1000).
printLevel – printLevel = 1 enables printing of problem statistics (default); printLevel = 0 silent
fileName – name of th file to load
directory – file directory (if model is empty, you can load it using fileName and directory)
- OUTPUTS:
LPproblem – COBRA Structure contain the reformulated LP to be solved.
- liftRows(C, cupcon, BIG, logbig, printLevel, ctrs_cuprow, rxns)[source]¶
Helper for liftCouplingConstraints. Implements the lifting
- INPUTS:
C k x n double – Subset of coupling constraints (2-variable rows to be lifted)
cupcon k x 1 char – Senses for rows in C (L/G/E)
BIG double – Threshold for “large” coefficients. TRiggers lifting
logbig double – log(BIG)
printLevel double – 0 or 1. If 1 prints extra information
ctrs_cuprow k x 1 cell array of chr – IDs of the selected constraints. Correspnds to rows in C
rxns nRxns x 1 cell array of chr – model rxn IDs
- OUTPUTS:
Clifted k’ x n’ double – Lifted constraint matrix
newcon ndum x 1 char – Senses of added dummy constraints
ctrs_cuprow k’ x 1 cell array of char – Updated IDs for original coupling constraints.
ctrs_new ndum x 1 cell array of char – IDs for dummy constraints
evars nEvars x 1 cell array of char – IDs of new dummy variables
ndum double – Total number of dummy constraints rows added
cupcon k’ x 1 char – Senses for rows in Clifted (L/G/E)
nEvars double – Total number of dummy variables
- reformulate(LPproblem, BIG, printLevel)[source]¶
Reformulates badly-scaled FBA program Transforms LPproblems with badly-scaled stoichiometric and coupling constraints of the form: \(max c*x\) subject to: math:Ax <= b
Eliminates the need for scaling and hence prevents infeasibilities after unscaling. After using PREFBA to transform a badly-scaled FBA program, please turn off scaling and reduce the aggressiveness of presolve.
Rransforms a badly-scaled LPproblem contained in the struct FBA and returns the transformed program in the structure FBA. reformulate assumes S and C do not contain very small entries and transforms constraints containing very large entries (entries larger than BIG). BIG should be set between 1000 and 10000 on double precision machines. printLevel = 1 or 0 enables/diables printing respectively.
Reformulation techniques are described in detail in: Y. Sun, R. M.T. Fleming, M. A. Saunders, I. Thiele, An Algorithm for Flux Balance Analysis of Multi-scale Biochemical Networks, submitted.
- USAGE:
[LPproblem] = reformulate (LPproblem, BIG, printLevel)
- INPUTS:
LPproblem – Structure contain the original LP to be solved. The format of this struct is described in the documentation for solveCobraLP.m
BIG – A parameter the controls the largest entries that appear in the reformulated problem.
printLevel – 1 enables printing of problem statistics; 0 = silent
- OUTPUTS:
LPproblem – Structure contain the reformulated LP to be solved.
- splitRow(A, ri, evars, evarlb, evarub, evarc, b, dsense, ctrs)[source]¶
Takes row ri of the constraint matrix A (e.g. -1e6*v1 -v2 + v3 < 0), identifies the coefficient with largest absolute value, and replaces the row by:
a constraint containing only that largest coefficient and a new variable z (e.g. -1e6*v1 + z < 0)
an equality constraint defining z as a combination of the remaining variables (e.g. z +v2 - v3 = 0)
- Inputs:
A k x n constraint matrix.
ri Index of the row of A to split
evars Cell array of existing extra variable IDs
evarlb Lower bounds of extra variables
evarub Upper bounds of extra variables
evarc Objective coefficients of extra variables
b Right-hand side vector of constraints
dsense Constraint senses (L,E,G)
ctrs Cell array of constraint IDs
- Outputs:
A Updated constraint matrix with one extra column and one extra row.
evars Updated extra variable IDs including the new z variable
evarlb Updated lower bounds (new z has -Inf)
evarub Updated upper bounds (new z has Inf)
evarc Updated objective coefficients (new z has 0)
b Updated RHS including 0 for the z-definition equality
dsense Updated senses including ‘E’ for the z-definition equality
ctrs Updated constraint IDs with a _splitN suffix for the new row