0001 function [isFeasible, y, dmu] = cba_feasible_lp(v, network, cba_constraints, cba_options)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 v(abs(v)/max(abs(v))<10^-5)=0;
0029
0030 if sum(v==0),
0031 N_int = network.N(find(network.external==0),:);
0032 Es = -network.N';
0033 [v_act,N_int_act,Es_act,network_act,cba_constraints_act,ind_act,ind_met_act] = cba_reduce_to_active_subnetwork(v,N_int,Es,network,cba_constraints);
0034 [isFeasible, y_act, dmu_act] = cba_feasible_lp(v_act,network_act,cba_constraints_act,cba_options);
0035 [nm,nr] = size(network.N);
0036 y = nan *ones(nr,1);
0037 y(ind_act) = y_act;
0038 dmu = nan *ones(nr,1);
0039 if isFeasible,
0040 dmu(ind_act) = dmu_act;
0041 end
0042 return
0043 end
0044
0045
0046
0047
0048
0049 cba_constraints = cba_update_constraints(cba_constraints,network.N(find(network.external),:));
0050
0051 ind_int = find(network.external==0);
0052 N_int = network.N(ind_int,:);
0053 isFeasible = 1;
0054 y = [];
0055 dmu = [];
0056 zv = cba_constraints.zv;
0057
0058 if ~isfield(cba_options,'test_eba'), cba_options.test_eba = 1; end
0059
0060
0061
0062 epsilon_balance = 10^-4;
0063
0064 if max(abs(N_int*v))>epsilon_balance,
0065 isFeasible = 0; display('Flux mode is not stationary.');
0066 end
0067
0068
0069
0070
0071 v_w = zv'*v;
0072
0073 switch sign(v_w),
0074 case 0, isFeasible = 0; display('No benefit produced.');
0075 case -1, isFeasible = 0; display('Negative benefit produced.');
0076 end
0077
0078
0079
0080
0081 if isFeasible,
0082
0083
0084
0085
0086 nn = network_construct(N_int);
0087 cc = cba_constraints;
0088 cc.z_ext = [];
0089
0090
0091
0092
0093
0094
0095
0096
0097 K = analyse_N(N_int);
0098 nr = size(N_int,2);
0099
0100 epsilon = 10^-4;
0101 c = ones(nr,1);
0102 h = epsilon * ones(nr,1);
0103 G = diag(v);
0104 A = K';
0105 b = K' * cc.zv;
0106
0107
0108
0109 if exist('cplexlp','file'),
0110 opt = optimset('Display','off');
0111 [y, fval, exitflag] = linprog(-c, -G, -h, A, b,[],[], [], opt);
0112 else
0113 opt = cplexoptimset('Display','off');
0114 [y, fval, exitflag] = cplexlp(-c, -G, -h, A, b,[],[], [], opt);
0115 end
0116
0117 if exitflag ~= 1,
0118 exitflag
0119 isFeasible = 0; display('Flux distribution seems to be economically infeasible.');
0120 end
0121
0122 if cba_options.test_eba,
0123 [eba_feas,dmu] = eba_feasible_lp(v,cba_constraints.N_tot);
0124 isFeasible = isFeasible * eba_feas;
0125 end
0126
0127 end