Skip to content

Commit

Permalink
fix: swap soplex with scip as solver (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
edkerk authored Feb 12, 2024
1 parent f8ea92c commit 8fe29c6
Show file tree
Hide file tree
Showing 13 changed files with 319 additions and 316 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Temporary Items
#external/kegg/keggRxns.mat
external/kegg/keggModel.mat
#software
software/scip/
!.keep
#doc

# IDE stuff #
Expand Down
4 changes: 2 additions & 2 deletions INIT/scoreComplexModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@
% each genes from its fold change between the tissue/celltype(s) in question
% and all other celltypes, or the threshold if supplied. This is a lower
% quality data than protein abundance, since gene abundance is an indirect
% estimate of protiein level. These scores are therefore only used for genes
% estimate of protein level. These scores are therefore only used for genes
% for which there is no HPA data available. The fold changes are transformed
% as min(5*log(x),10) for x > 1 and max(5*log(x),-5) for x < 1 in order to
% have negative scores for lower expressed genes and to scale the scrores
% have negative scores for lower expressed genes and to scale the scores
% to have somewhat lower weights than the HPA scores
tempArrayLevels = arrayData.levels;
tempArrayLevels(isnan(tempArrayLevels)) = 0;
Expand Down
4 changes: 2 additions & 2 deletions doc/INIT/scoreComplexModel.html
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0218 <span class="comment">% each genes from its fold change between the tissue/celltype(s) in question</span>
0219 <span class="comment">% and all other celltypes, or the threshold if supplied. This is a lower</span>
0220 <span class="comment">% quality data than protein abundance, since gene abundance is an indirect</span>
0221 <span class="comment">% estimate of protiein level. These scores are therefore only used for genes</span>
0221 <span class="comment">% estimate of protein level. These scores are therefore only used for genes</span>
0222 <span class="comment">% for which there is no HPA data available. The fold changes are transformed</span>
0223 <span class="comment">% as min(5*log(x),10) for x &gt; 1 and max(5*log(x),-5) for x &lt; 1 in order to</span>
0224 <span class="comment">% have negative scores for lower expressed genes and to scale the scrores</span>
0224 <span class="comment">% have negative scores for lower expressed genes and to scale the scores</span>
0225 <span class="comment">% to have somewhat lower weights than the HPA scores</span>
0226 tempArrayLevels = arrayData.levels;
0227 tempArrayLevels(isnan(tempArrayLevels)) = 0;
Expand Down
4 changes: 2 additions & 2 deletions doc/installation/checkInstallation.html
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0207 <a href="#_sub4" class="code" title="subfunction printOrange(stringToPrint)">printOrange</a>(<span class="string">'Fail\n'</span>)
0208 <span class="keyword">end</span>
0209
0210 fprintf([<a href="#_sub2" class="code" title="subfunction str = myStr(InputStr,len)">myStr</a>(<span class="string">' &gt; soplex'</span>,40) <span class="string">'%f'</span>])
0210 fprintf([<a href="#_sub2" class="code" title="subfunction str = myStr(InputStr,len)">myStr</a>(<span class="string">' &gt; scip'</span>,40) <span class="string">'%f'</span>])
0211 <span class="keyword">if</span> res(3).Passed == 1
0212 fprintf(<span class="string">'Pass\n'</span>)
0213 <span class="keyword">else</span>
Expand All @@ -285,7 +285,7 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0223 fprintf([<a href="#_sub2" class="code" title="subfunction str = myStr(InputStr,len)">myStr</a>(<span class="string">' &gt; Set RAVEN solver'</span>,40) <span class="string">'%f'</span>])
0224 <span class="keyword">try</span>
0225 oldSolver=getpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0226 solverIdx=find(strcmp(oldSolver,{<span class="string">'glpk'</span>,<span class="string">'gurobi'</span>,<span class="string">'soplex'</span>,<span class="string">'cobra'</span>}));
0226 solverIdx=find(strcmp(oldSolver,{<span class="string">'glpk'</span>,<span class="string">'gurobi'</span>,<span class="string">'scip'</span>,<span class="string">'cobra'</span>}));
0227 <span class="keyword">catch</span>
0228 solverIdx=0;
0229 <span class="keyword">end</span>
Expand Down
252 changes: 96 additions & 156 deletions doc/solver/optimizeProb.html

Large diffs are not rendered by default.

43 changes: 36 additions & 7 deletions doc/solver/setRavenSolver.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,43 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0022 <span class="keyword">end</span>
0023 <span class="keyword">case</span> <span class="string">'mosek'</span>
0024 error(<span class="string">'MOSEK support has been discontinued since RAVEN 2.3.0.'</span>)
0025 <span class="keyword">case</span> {<span class="string">'glpk'</span>,<span class="string">'gurobi'</span>,<span class="string">'soplex'</span>}
0025 <span class="keyword">case</span> {<span class="string">'glpk'</span>,<span class="string">'gurobi'</span>}
0026 setpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>,solver)
0027 <span class="keyword">otherwise</span>
0028 error(<span class="string">'Invalid solver defined'</span>)
0029 <span class="keyword">end</span>
0030 <span class="keyword">global</span> RAVENSOLVER
0031 RAVENSOLVER = solver;
0032 <span class="keyword">end</span></pre></div>
0027 <span class="keyword">case</span> <span class="string">'soplex'</span>
0028 error(<span class="string">'The ''soplex'' solver is replaced by ''scip''.'</span>)
0029 <span class="keyword">case</span> <span class="string">'scip'</span>
0030 <span class="keyword">if</span> ~ispc
0031 <span class="keyword">try</span>
0032 scip; <span class="comment">% The user might have installed SCIP manually</span>
0033 setpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>,<span class="string">'scip'</span>)
0034 <span class="keyword">catch</span>
0035 error(<span class="string">'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'</span>)
0036 <span class="keyword">end</span>
0037 <span class="keyword">else</span>
0038 ravenDir = findRAVENroot();
0039 <span class="keyword">if</span> ~exist(fullfile(ravenDir,<span class="string">'software'</span>,<span class="string">'scip'</span>,<span class="string">'scip.mexw64'</span>),<span class="string">'file'</span>)
0040 <span class="keyword">try</span>
0041 disp(<span class="string">'Downloading and installing RAVEN-provided SCIP MEX binary...'</span>)
0042 websave(fullfile(ravenDir,<span class="string">'software'</span>,<span class="string">'scip_mex_win.zip'</span>),<span class="string">'https://github.com/SysBioChalmers/RAVEN/releases/download/v2.8.6/scip_mex_win.zip'</span>); <span class="comment">% Should be updated to release with SCIP functionality</span>
0043 <span class="keyword">catch</span>
0044 error(<span class="string">'Unable to download SCIP MEX binary from the RAVEN GitHub page.'</span>)
0045 <span class="keyword">end</span>
0046 unzip(fullfile(ravenDir,<span class="string">'software'</span>,<span class="string">'scip_mex_win.zip'</span>),fullfile(ravenDir,<span class="string">'software'</span>,<span class="string">'scip'</span>));
0047 delete(fullfile(ravenDir,<span class="string">'software'</span>,<span class="string">'scip_mex_win.zip'</span>));
0048 <span class="keyword">end</span>
0049 <span class="keyword">try</span>
0050 scip; <span class="comment">% The pre-compiled MEX file might fail</span>
0051 setpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>,<span class="string">'scip'</span>)
0052 <span class="keyword">catch</span>
0053 error(<span class="string">'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'</span>)
0054 <span class="keyword">end</span>
0055 <span class="keyword">end</span>
0056 <span class="keyword">otherwise</span>
0057 error(<span class="string">'Invalid solver defined'</span>)
0058 <span class="keyword">end</span>
0059 <span class="keyword">global</span> RAVENSOLVER
0060 RAVENSOLVER = solver;
0061 <span class="keyword">end</span></pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>
157 changes: 77 additions & 80 deletions doc/testing/unit_tests/solverTests.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^

<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="#_sub1" class="code">function testGlpk(testCase)</a></li><li><a href="#_sub2" class="code">function testGurobi(testCase)</a></li><li><a href="#_sub3" class="code">function testSoplex(testCase)</a></li><li><a href="#_sub4" class="code">function testCobra(testCase)</a></li></ul>
<li><a href="#_sub1" class="code">function testGlpk(testCase)</a></li><li><a href="#_sub2" class="code">function testGurobi(testCase)</a></li><li><a href="#_sub3" class="code">function testSCIP(testCase)</a></li><li><a href="#_sub4" class="code">function testCobra(testCase)</a></li></ul>

<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <span class="comment">%run this test case with the command</span>
Expand Down Expand Up @@ -120,85 +120,82 @@ <h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" sr
0073 verifyEqual(testCase,sol,solOut,<span class="string">'AbsTol'</span>,0.1)
0074 <span class="keyword">end</span>
0075
0076 <a name="_sub3" href="#_subfunctions" class="code">function testSoplex(testCase)</a>
0077 currDir = pwd;
0078 cd(fullfile(findRAVENroot,<span class="string">'software'</span>,<span class="string">'soplex'</span>))
0079 [a,~] = system(<span class="string">'soplex --help'</span>);
0080 cd(currDir)
0081 <span class="keyword">if</span> ~(a == 0)
0082 error(<span class="string">'SoPlex not installed or cannot be found, test skipped'</span>)
0083 <span class="keyword">end</span>
0084 sourceDir = fileparts(which(mfilename));
0085 load([sourceDir,<span class="string">'/test_data/ecoli_textbook.mat'</span>], <span class="string">'model'</span>);
0086 <span class="keyword">try</span>
0087 oldSolver=getpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0088 <span class="keyword">catch</span>
0089 <span class="keyword">end</span>
0090 setRavenSolver(<span class="string">'soplex'</span>);
0091
0092 <span class="keyword">try</span>
0093 <span class="comment">% Try all three types of flux minimization</span>
0094 evalc(<span class="string">'sol=solveLP(model,3);'</span>);
0095 evalc(<span class="string">'sol=solveLP(model,1);'</span>);
0096 evalc(<span class="string">'sol=solveLP(model,0);'</span>);
0097 <span class="keyword">catch</span>
0098 <span class="keyword">try</span>
0099 setRavenSolver(oldSolver);
0100 <span class="keyword">catch</span>
0101 rmpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0102 <span class="keyword">end</span>
0103 error(<span class="string">'Solver not working'</span>)
0104 <span class="keyword">end</span>
0105 <span class="keyword">try</span>
0106 setRavenSolver(oldSolver);
0107 <span class="keyword">catch</span>
0108 rmpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0109 <span class="keyword">end</span>
0110
0111 load([sourceDir,<span class="string">'/test_data/solverTestOutput.mat'</span>], <span class="string">'solOutSoplex'</span>);
0112 <span class="comment">%Check that the actual model is the same as the expected model</span>
0113 verifyEqual(testCase,sol,solOutSoplex,<span class="string">'AbsTol'</span>,0.1)
0114 <span class="keyword">end</span>
0115
0116 <a name="_sub4" href="#_subfunctions" class="code">function testCobra(testCase)</a>
0117 <span class="keyword">if</span> exist(<span class="string">'initCobraToolbox.m'</span>,<span class="string">'file'</span>)~=2
0118 error(<span class="string">'COBRA Toolbox not installed or cannot be found in MATLAB path, test skipped'</span>)
0119 <span class="keyword">end</span>
0120 sourceDir = fileparts(which(mfilename));
0121 load([sourceDir,<span class="string">'/test_data/ecoli_textbook.mat'</span>], <span class="string">'model'</span>);
0122 <span class="keyword">try</span>
0123 oldSolver=getpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0124 <span class="keyword">catch</span>
0125 <span class="keyword">end</span>
0126 <span class="keyword">global</span> CBT_LP_SOLVER
0127 <span class="keyword">global</span> CBT_MILP_SOLVER
0128 CBT_LP_SOLVER = <span class="string">'glpk'</span>;
0129 CBT_MILP_SOLVER = <span class="string">'glpk'</span>;
0130 setRavenSolver(<span class="string">'cobra'</span>);
0131
0132 <span class="keyword">try</span>
0133 <span class="comment">% Try all three types of flux minimization</span>
0134 evalc(<span class="string">'sol=solveLP(model,3);'</span>);
0135 evalc(<span class="string">'sol=solveLP(model,1);'</span>);
0136 evalc(<span class="string">'sol=solveLP(model,0);'</span>);
0137 <span class="keyword">catch</span>
0138 <span class="keyword">try</span>
0139 setRavenSolver(oldSolver);
0140 <span class="keyword">catch</span>
0141 rmpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0142 <span class="keyword">end</span>
0143 error(<span class="string">'Solver not working'</span>)
0144 <span class="keyword">end</span>
0145 <span class="keyword">try</span>
0146 setRavenSolver(oldSolver);
0147 <span class="keyword">catch</span>
0148 rmpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0149 <span class="keyword">end</span>
0150
0151 load([sourceDir,<span class="string">'/test_data/solverTestOutput.mat'</span>], <span class="string">'solOut'</span>);
0152 <span class="comment">%Check that the actual model is the same as the expected model</span>
0153 verifyEqual(testCase,sol,solOut,<span class="string">'AbsTol'</span>,0.1)
0154 <span class="keyword">end</span></pre></div>
0076 <a name="_sub3" href="#_subfunctions" class="code">function testSCIP(testCase)</a>
0077 <span class="keyword">try</span>
0078 scip;
0079 <span class="keyword">catch</span>
0080 error(<span class="string">'SCIP MEX binary not installed or not functional, test skipped'</span>)
0081 <span class="keyword">end</span>
0082 sourceDir = fileparts(which(mfilename));
0083 load([sourceDir,<span class="string">'/test_data/ecoli_textbook.mat'</span>], <span class="string">'model'</span>);
0084 <span class="keyword">try</span>
0085 oldSolver=getpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0086 <span class="keyword">catch</span>
0087 <span class="keyword">end</span>
0088 setRavenSolver(<span class="string">'scip'</span>);
0089 <span class="keyword">try</span>
0090 <span class="comment">% Try all three types of flux minimization</span>
0091 evalc(<span class="string">'sol=solveLP(model,3);'</span>);
0092 evalc(<span class="string">'sol=solveLP(model,1);'</span>);
0093 evalc(<span class="string">'sol=solveLP(model,0);'</span>);
0094 <span class="keyword">catch</span>
0095 <span class="keyword">try</span>
0096 setRavenSolver(oldSolver);
0097 <span class="keyword">catch</span>
0098 rmpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0099 <span class="keyword">end</span>
0100 error(<span class="string">'Solver not working'</span>)
0101 <span class="keyword">end</span>
0102 <span class="keyword">try</span>
0103 setRavenSolver(oldSolver);
0104 <span class="keyword">catch</span>
0105 rmpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0106 <span class="keyword">end</span>
0107
0108 load([sourceDir,<span class="string">'/test_data/solverTestOutput.mat'</span>], <span class="string">'solOutSCIP'</span>);
0109 <span class="comment">%Check that the actual model is the same as the expected model</span>
0110 verifyEqual(testCase,sol,solOutSCIP,<span class="string">'AbsTol'</span>,0.1)
0111 <span class="keyword">end</span>
0112
0113 <a name="_sub4" href="#_subfunctions" class="code">function testCobra(testCase)</a>
0114 <span class="keyword">if</span> exist(<span class="string">'initCobraToolbox.m'</span>,<span class="string">'file'</span>)~=2
0115 error(<span class="string">'COBRA Toolbox not installed or cannot be found in MATLAB path, test skipped'</span>)
0116 <span class="keyword">end</span>
0117 sourceDir = fileparts(which(mfilename));
0118 load([sourceDir,<span class="string">'/test_data/ecoli_textbook.mat'</span>], <span class="string">'model'</span>);
0119 <span class="keyword">try</span>
0120 oldSolver=getpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0121 <span class="keyword">catch</span>
0122 <span class="keyword">end</span>
0123 <span class="keyword">global</span> CBT_LP_SOLVER
0124 <span class="keyword">global</span> CBT_MILP_SOLVER
0125 CBT_LP_SOLVER = <span class="string">'glpk'</span>;
0126 CBT_MILP_SOLVER = <span class="string">'glpk'</span>;
0127 setRavenSolver(<span class="string">'cobra'</span>);
0128
0129 <span class="keyword">try</span>
0130 <span class="comment">% Try all three types of flux minimization</span>
0131 evalc(<span class="string">'sol=solveLP(model,3);'</span>);
0132 evalc(<span class="string">'sol=solveLP(model,1);'</span>);
0133 evalc(<span class="string">'sol=solveLP(model,0);'</span>);
0134 <span class="keyword">catch</span>
0135 <span class="keyword">try</span>
0136 setRavenSolver(oldSolver);
0137 <span class="keyword">catch</span>
0138 rmpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0139 <span class="keyword">end</span>
0140 error(<span class="string">'Solver not working'</span>)
0141 <span class="keyword">end</span>
0142 <span class="keyword">try</span>
0143 setRavenSolver(oldSolver);
0144 <span class="keyword">catch</span>
0145 rmpref(<span class="string">'RAVEN'</span>,<span class="string">'solver'</span>);
0146 <span class="keyword">end</span>
0147
0148 load([sourceDir,<span class="string">'/test_data/solverTestOutput.mat'</span>], <span class="string">'solOut'</span>);
0149 <span class="comment">%Check that the actual model is the same as the expected model</span>
0150 verifyEqual(testCase,sol,solOut,<span class="string">'AbsTol'</span>,0.1)
0151 <span class="keyword">end</span></pre></div>
<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" title="Matlab Documentation in HTML">m2html</a></strong> &copy; 2005</address>
</body>
</html>
4 changes: 2 additions & 2 deletions installation/checkInstallation.m
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
printOrange('Fail\n')
end

fprintf([myStr(' > soplex',40) '%f'])
fprintf([myStr(' > scip',40) '%f'])
if res(3).Passed == 1
fprintf('Pass\n')
else
Expand All @@ -223,7 +223,7 @@
fprintf([myStr(' > Set RAVEN solver',40) '%f'])
try
oldSolver=getpref('RAVEN','solver');
solverIdx=find(strcmp(oldSolver,{'glpk','gurobi','soplex','cobra'}));
solverIdx=find(strcmp(oldSolver,{'glpk','gurobi','scip','cobra'}));
catch
solverIdx=0;
end
Expand Down
Empty file added software/scip/.keep
Empty file.
Loading

0 comments on commit 8fe29c6

Please sign in to comment.