0001 function setRavenSolver(solver)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 solver=char(solver);
0015 switch solver
0016 case 'cobra'
0017 global CBT_LP_SOLVER;
0018 if isempty(CBT_LP_SOLVER)
0019 error('COBRA toolbox is not initialized, run ''initCobraToolbox()''')
0020 else
0021 setpref('RAVEN','solver','cobra');
0022 end
0023 case 'mosek'
0024 error('MOSEK support has been discontinued since RAVEN 2.3.0.')
0025 case {'glpk','gurobi'}
0026 setpref('RAVEN','solver',solver)
0027 case 'soplex'
0028 error('The ''soplex'' solver is replaced by ''scip''.')
0029 case 'scip'
0030 if ~ispc
0031 try
0032 scip;
0033 setpref('RAVEN','solver','scip')
0034 catch
0035 error('SCIP not found. RAVEN only provides the precompiled SCIP MEX binary for Windows. Instructions on how to compile the SCIP MEX file are found at https://github.com/scipopt/MatlabSCIPInterface')
0036 end
0037 else
0038 ravenDir = findRAVENroot();
0039 if ~exist(fullfile(ravenDir,'software','scip','scip.mexw64'),'file')
0040 try
0041 disp('Downloading and installing RAVEN-provided SCIP MEX binary...')
0042 websave(fullfile(ravenDir,'software','scip_mex_win.zip'),'https://github.com/SysBioChalmers/RAVEN/releases/download/v2.8.6/scip_mex_win.zip');
0043 catch
0044 error('Unable to download SCIP MEX binary from the RAVEN GitHub page.')
0045 end
0046 unzip(fullfile(ravenDir,'software','scip_mex_win.zip'),fullfile(ravenDir,'software','scip'));
0047 delete(fullfile(ravenDir,'software','scip_mex_win.zip'));
0048 end
0049 try
0050 scip;
0051 setpref('RAVEN','solver','scip')
0052 catch
0053 error('Unable to use the RAVEN-provided precompiled SCIP MEX binary. Instructions on how to compile the SCIP MEX file are found at https://github.com/scipopt/MatlabSCIPInterface')
0054 end
0055 end
0056 otherwise
0057 error('Invalid solver defined')
0058 end
0059 global RAVENSOLVER
0060 RAVENSOLVER = solver;
0061 end