initCobraToolbox

PURPOSE ^

initCobraToolbox Initialize COnstraint-Based Reconstruction and Analysis Toolbox

SYNOPSIS ^

function initCobraToolbox

DESCRIPTION ^

initCobraToolbox Initialize COnstraint-Based Reconstruction and Analysis Toolbox

 Define default solvers and paths
 Function only needs to be called once. Save paths afer script terminates.

 In addition add either of the following into startup.m (generally in MATLAB_DIRECTORY/toolbox/local/startup.m)
     initCobraToolbox 
           -or- 
     changeCobraSolver('gurobi');
     changeCobraSolver('gurobi', 'MILP');
     changeCobraSolver('tomlab_cplex', 'QP');
     changeCobraSolver('tomlab_cplex', 'MIQP');
     changeCbMapOutput('svg');

 Markus Herrgard 8/30/06

 Rewritten to utilize addpath_recurse. Richard Que (11/19/09)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function initCobraToolbox
0002 %initCobraToolbox Initialize COnstraint-Based Reconstruction and Analysis Toolbox
0003 %
0004 % Define default solvers and paths
0005 % Function only needs to be called once. Save paths afer script terminates.
0006 %
0007 % In addition add either of the following into startup.m (generally in MATLAB_DIRECTORY/toolbox/local/startup.m)
0008 %     initCobraToolbox
0009 %           -or-
0010 %     changeCobraSolver('gurobi');
0011 %     changeCobraSolver('gurobi', 'MILP');
0012 %     changeCobraSolver('tomlab_cplex', 'QP');
0013 %     changeCobraSolver('tomlab_cplex', 'MIQP');
0014 %     changeCbMapOutput('svg');
0015 %
0016 % Markus Herrgard 8/30/06
0017 %
0018 % Rewritten to utilize addpath_recurse. Richard Que (11/19/09)
0019 
0020 %% add cobra toolbox paths
0021 pth=which('initCobraToolbox.m');
0022 CBTDIR = pth(1:end-(length('initCobraToolbox.m')+1));
0023 path(path,[CBTDIR, filesep, 'external']);
0024 addpath_recurse(CBTDIR,{'.svn','obsolete','m2html','docs','src','stow'});
0025 
0026 %% Define Solvers
0027 % Define the default linear programming solver to be used by the toolbox
0028 % Available solver options:
0029 % 'lindo_new','lindo_old','glpk','lp_solve','mosek','tomlab_cplex',
0030 % 'cplex_direct','gurobi'
0031 % Note that you must install the solver separately and make sure Matlab can
0032 % access the solver
0033 CobraLPSolver = 'tomlab_cplex';
0034 % CobraLPSolver = 'glpk';
0035  %CobraLPSolver = 'mosek';
0036 % CobraLPSolver = 'cplx';
0037 if isunix
0038   addpath('/usr/local/lib/');
0039 end
0040 CobraLPSolvers = { 'gurobi5', 'gurobi', 'tomlab_cplex', 'glpk', 'mosek', 'cplx' };
0041 for CobraLPSolver = CobraLPSolvers
0042     LPsolverOK = changeCobraSolver(char(CobraLPSolver));
0043     if LPsolverOK
0044         fprintf('LP solver set to %s successful\n',char(CobraLPSolver));
0045         break;
0046     end
0047 end
0048 if ~LPsolverOK
0049     fprintf('LP solver set failed\n');
0050 end
0051 % Define default MILP solver
0052 %CobraMILPSolver = 'tomlab_cplex';
0053 %CobraMILPSolver = 'glpk';
0054 for CobraMILPSolver = { 'gurobi5', 'gurobi', 'tomlab_cplex', 'glpk' }
0055     MILPsolverOK = changeCobraSolver(char(CobraMILPSolver),'MILP');
0056     if MILPsolverOK
0057         fprintf('MILP solver set to %s successful\n',char(CobraMILPSolver));
0058         break;
0059    end 
0060 end
0061 if ~MILPsolverOK
0062     fprintf('MILP solver set failed\n');
0063 end
0064 % Define default QP solver
0065 %CobraQPSolver = 'tomlab_cplex';
0066 for CobraQPSolver = {'gurobi5', 'gurobi', 'tomlab_cplex', 'qpng' }
0067     QPsolverOK = changeCobraSolver(char(CobraQPSolver),'QP');
0068     if QPsolverOK
0069         fprintf('QP solver set to %s successful\n',char(CobraQPSolver));
0070         break;
0071     end
0072 end
0073 if ~QPsolverOK
0074     fprintf('QP solver set failed\n');
0075 end
0076 % Define default MIQP solver
0077 for CobraMIQPSolver = {'gurobi5', 'gurobi' 'tomlab_cplex'}
0078     MIQPsolverOK = changeCobraSolver(char(CobraMIQPSolver),'MIQP');
0079     if MIQPsolverOK
0080         fprintf('MIQP solver set to %s successful\n',char(CobraMIQPSolver));
0081         break;
0082     end
0083 end
0084 if ~MIQPsolverOK
0085     fprintf('MIQP solver set failed\n');
0086 end
0087 
0088 
0089 % Define default CB map output
0090 % CbMapOutput = 'matlab';
0091 CbMapOutput = 'svg';
0092 CbMapOutputOK = changeCbMapOutput(CbMapOutput);
0093 if CbMapOutputOK
0094     fprintf('CB map output set to %s successful\n',CbMapOutput);
0095 else    
0096     fprintf('Cb map output set failed\n');
0097 end
0098 
0099 
0100 % Set global LP solution accuracy tolerance
0101 changeOK = changeCobraSolverParams('LP','objTol',1e-6);
0102 
0103 % Check that SBML toolbox is installed and accessible
0104 if (~exist('TranslateSBML'))
0105     warning('SBML Toolbox not in Matlab path: COBRA Toolbox will be unable to read SBML files');
0106 end

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003