Home > solver > setRavenSolver.m

setRavenSolver

PURPOSE ^

setRavenSolver

SYNOPSIS ^

function setRavenSolver(solver)

DESCRIPTION ^

 setRavenSolver
   Sets the solver for RAVEN and optionally saves a default value
    to MATLAB startup.

   solver  string with solver name. The following options are available:
           glpk    uses RAVEN-provided binaries
           gurobi  requires a working Gurobi installation
           cobra   requires a working COBRA Toolbox installation. RAVEN
                   parses the problem to COBRA and uses the solver that is
                   set by changeCobraSolver.

 Usage: setRavenSolver(solver)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function setRavenSolver(solver)
0002 % setRavenSolver
0003 %   Sets the solver for RAVEN and optionally saves a default value
0004 %    to MATLAB startup.
0005 %
0006 %   solver  string with solver name. The following options are available:
0007 %           glpk    uses RAVEN-provided binaries
0008 %           gurobi  requires a working Gurobi installation
0009 %           cobra   requires a working COBRA Toolbox installation. RAVEN
0010 %                   parses the problem to COBRA and uses the solver that is
0011 %                   set by changeCobraSolver.
0012 %
0013 % Usage: setRavenSolver(solver)
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; % The user might have installed SCIP manually
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'); % Should be updated to release with SCIP functionality
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; % The pre-compiled MEX file might fail
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

Generated by m2html © 2005