forked from opencobra/cobratoolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandomObjFBASol.m
30 lines (26 loc) · 876 Bytes
/
randomObjFBASol.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
function x0 = randomObjFBASol(model,initArgs)
%randomObjFBASol Solves an FBA problem with a random objective function
%
% x0 = randomObjSol(model,initArgs)
%
%INPUTS
% model COBRA model structure
% initArgs Cell array containing the following data:
% {1}osenseStr Maximize ('max')/minimize ('min')
% {2}minObjFrac Minimum initial objective fraction
% {3}minObjValue Minimum initial objective value (opt)
% (Default = minObjFrac*sol.f)
%
% Markus Herrgard
osenseStr = initArgs{1};
minObjFrac = initArgs{2};
if (length(initArgs) < 3)
solOpt = optimizeCbModel(model,osenseStr);
model.lb(model.c==1) = minObjFrac*solOpt.f;
else
model.lb(model.c==1) = initArgs{3};
end
nRxns = length(model.rxns);
model.c = rand(nRxns,1)-0.5;
sol = optimizeCbModel(model,osenseStr);
x0 = sol.x;