diff --git a/doc/testing/unit_tests/solverTests.html b/doc/testing/unit_tests/solverTests.html index c7aacfad..22563d35 100644 --- a/doc/testing/unit_tests/solverTests.html +++ b/doc/testing/unit_tests/solverTests.html @@ -121,81 +121,84 @@

SOURCE CODE ^end 0075 0076 function testSoplex(testCase) -0077 [a,~] = system('soplex --help'); -0078 if ~(a == 0) -0079 error('SoPlex not installed or cannot be found, test skipped') -0080 end -0081 sourceDir = fileparts(which(mfilename)); -0082 load([sourceDir,'/test_data/ecoli_textbook.mat'], 'model'); -0083 try -0084 oldSolver=getpref('RAVEN','solver'); -0085 catch -0086 end -0087 setRavenSolver('soplex'); -0088 -0089 try -0090 % Try all three types of flux minimization -0091 evalc('sol=solveLP(model,3);'); -0092 evalc('sol=solveLP(model,1);'); -0093 evalc('sol=solveLP(model,0);'); -0094 catch -0095 try -0096 setRavenSolver(oldSolver); -0097 catch -0098 rmpref('RAVEN','solver'); -0099 end -0100 error('Solver not working') -0101 end -0102 try -0103 setRavenSolver(oldSolver); -0104 catch -0105 rmpref('RAVEN','solver'); -0106 end -0107 -0108 load([sourceDir,'/test_data/solverTestOutput.mat'], 'solOutSoplex'); -0109 %Check that the actual model is the same as the expected model -0110 verifyEqual(testCase,sol,solOutSoplex,'AbsTol',0.1) -0111 end -0112 -0113 function testCobra(testCase) -0114 if exist('initCobraToolbox.m','file')~=2 -0115 error('COBRA Toolbox not installed or cannot be found in MATLAB path, test skipped') -0116 end -0117 sourceDir = fileparts(which(mfilename)); -0118 load([sourceDir,'/test_data/ecoli_textbook.mat'], 'model'); -0119 try -0120 oldSolver=getpref('RAVEN','solver'); -0121 catch -0122 end -0123 global CBT_LP_SOLVER -0124 global CBT_MILP_SOLVER -0125 CBT_LP_SOLVER = 'glpk'; -0126 CBT_MILP_SOLVER = 'glpk'; -0127 setRavenSolver('cobra'); -0128 -0129 try -0130 % Try all three types of flux minimization -0131 evalc('sol=solveLP(model,3);'); -0132 evalc('sol=solveLP(model,1);'); -0133 evalc('sol=solveLP(model,0);'); -0134 catch -0135 try -0136 setRavenSolver(oldSolver); -0137 catch -0138 rmpref('RAVEN','solver'); -0139 end -0140 error('Solver not working') -0141 end -0142 try -0143 setRavenSolver(oldSolver); -0144 catch -0145 rmpref('RAVEN','solver'); -0146 end -0147 -0148 load([sourceDir,'/test_data/solverTestOutput.mat'], 'solOut'); -0149 %Check that the actual model is the same as the expected model -0150 verifyEqual(testCase,sol,solOut,'AbsTol',0.1) -0151 end +0077 currDir = pwd; +0078 cd(fullfile(findRAVENroot,'software','soplex')) +0079 [a,~] = system('soplex --help'); +0080 cd(currDir) +0081 if ~(a == 0) +0082 error('SoPlex not installed or cannot be found, test skipped') +0083 end +0084 sourceDir = fileparts(which(mfilename)); +0085 load([sourceDir,'/test_data/ecoli_textbook.mat'], 'model'); +0086 try +0087 oldSolver=getpref('RAVEN','solver'); +0088 catch +0089 end +0090 setRavenSolver('soplex'); +0091 +0092 try +0093 % Try all three types of flux minimization +0094 evalc('sol=solveLP(model,3);'); +0095 evalc('sol=solveLP(model,1);'); +0096 evalc('sol=solveLP(model,0);'); +0097 catch +0098 try +0099 setRavenSolver(oldSolver); +0100 catch +0101 rmpref('RAVEN','solver'); +0102 end +0103 error('Solver not working') +0104 end +0105 try +0106 setRavenSolver(oldSolver); +0107 catch +0108 rmpref('RAVEN','solver'); +0109 end +0110 +0111 load([sourceDir,'/test_data/solverTestOutput.mat'], 'solOutSoplex'); +0112 %Check that the actual model is the same as the expected model +0113 verifyEqual(testCase,sol,solOutSoplex,'AbsTol',0.1) +0114 end +0115 +0116 function testCobra(testCase) +0117 if exist('initCobraToolbox.m','file')~=2 +0118 error('COBRA Toolbox not installed or cannot be found in MATLAB path, test skipped') +0119 end +0120 sourceDir = fileparts(which(mfilename)); +0121 load([sourceDir,'/test_data/ecoli_textbook.mat'], 'model'); +0122 try +0123 oldSolver=getpref('RAVEN','solver'); +0124 catch +0125 end +0126 global CBT_LP_SOLVER +0127 global CBT_MILP_SOLVER +0128 CBT_LP_SOLVER = 'glpk'; +0129 CBT_MILP_SOLVER = 'glpk'; +0130 setRavenSolver('cobra'); +0131 +0132 try +0133 % Try all three types of flux minimization +0134 evalc('sol=solveLP(model,3);'); +0135 evalc('sol=solveLP(model,1);'); +0136 evalc('sol=solveLP(model,0);'); +0137 catch +0138 try +0139 setRavenSolver(oldSolver); +0140 catch +0141 rmpref('RAVEN','solver'); +0142 end +0143 error('Solver not working') +0144 end +0145 try +0146 setRavenSolver(oldSolver); +0147 catch +0148 rmpref('RAVEN','solver'); +0149 end +0150 +0151 load([sourceDir,'/test_data/solverTestOutput.mat'], 'solOut'); +0152 %Check that the actual model is the same as the expected model +0153 verifyEqual(testCase,sol,solOut,'AbsTol',0.1) +0154 end
Generated by m2html © 2005
\ No newline at end of file diff --git a/testing/unit_tests/solverTests.m b/testing/unit_tests/solverTests.m index 86b21111..63978ee9 100644 --- a/testing/unit_tests/solverTests.m +++ b/testing/unit_tests/solverTests.m @@ -74,7 +74,10 @@ function testGurobi(testCase) end function testSoplex(testCase) +currDir = pwd; +cd(fullfile(findRAVENroot,'software','soplex')) [a,~] = system('soplex --help'); +cd(currDir) if ~(a == 0) error('SoPlex not installed or cannot be found, test skipped') end