Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to solvers #2367

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 18 additions & 35 deletions initCobraToolbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ function initCobraToolbox(updateToolbox)
%
% initCobraToolbox
% -or-
% changeCobraSolver('gurobi');
% changeCobraSolver('gurobi', 'MILP');
% changeCobraSolver('tomlab_cplex', 'QP');
% changeCobraSolver('tomlab_cplex', 'MIQP');
% changeCbMapOutput('svg');
% changeCobraSolver('gurobi','all');
% changeCobraSolver('mosek', 'CLP');
%
% Maintained by Ronan M.T. Fleming

Expand Down Expand Up @@ -362,18 +359,7 @@ function initCobraToolbox(updateToolbox)
% requires the solver compatibility to be re-read at each initialisation
clear isCompatible

%These default tolerances are based on the default values for the Gurobi LP
%solver. Do not change them without first consulting with other developers.
%https://www.gurobi.com/documentation/9.0/refman/parameters.html
% (primal) feasibility tolerance
changeCobraSolverParams('LP', 'feasTol', 1e-6);
% (dual) optimality tolerance
changeCobraSolverParams('LP', 'optTol', 1e-6);

% (primal) feasibility tolerance
changeCobraSolverParams('EP', 'feasTol', 1e-8);
% (dual) optimality tolerance
changeCobraSolverParams('EP', 'optTol', 1e-12);

% Check that SBML toolbox is installed and accessible
if ~exist('TranslateSBML', 'file')
Expand Down Expand Up @@ -409,10 +395,8 @@ function initCobraToolbox(updateToolbox)
%Define a set of "use first" solvers, other supported solvers will also be added to the struct.
%This allows to assign them in any order but keep the most commonly used ones on top of the struct.
SOLVERS = struct('gurobi',struct(),...
'ibm_cplex',struct(),...
'tomlab_cplex',struct(),...
'glpk',struct(),...
'mosek',struct(),...
'glpk',struct(),...
'matlab',struct());

% active support - supported solvers
Expand All @@ -423,25 +407,24 @@ function initCobraToolbox(updateToolbox)
SOLVERS.quadMinos.type = {'LP'};
SOLVERS.dqqMinos.type = {'LP','QP'};
SOLVERS.matlab.type = {'LP', 'NLP'};
% active support of cplex interfaces - supported solvers
SOLVERS.cplex_direct.type = {'LP', 'MILP', 'QP'};
SOLVERS.ibm_cplex.type = {'LP', 'MILP', 'QP', 'MIQP'};
SOLVERS.cplexlp.type = {'LP'};
SOLVERS.tomlab_cplex.type = {'LP', 'MILP', 'QP', 'MIQP'};


% passive support - solver interfaces
SOLVERS.qpng.type = {'QP'};
SOLVERS.tomlab_snopt.type = {'NLP'};

% legacy solvers
SOLVERS.cplex_direct.type = {'LP', 'MILP', 'QP'};
SOLVERS.ibm_cplex.type = {'LP', 'MILP', 'QP', 'MIQP'};
SOLVERS.cplexlp.type = {'LP'};
SOLVERS.tomlab_cplex.type = {'LP', 'MILP', 'QP', 'MIQP'};
%SOLVERS.gurobi_mex.type = {'LP', 'MILP', 'QP', 'MIQP'};
%SOLVERS.lindo_old.type = {'LP'};
%SOLVERS.lindo_legacy.type = {'LP'};
SOLVERS.lp_solve.type = {'LP'};
%SOLVERS.opti.type = {'LP', 'MILP', 'QP', 'MIQP', 'NLP'};

% definition of category of solvers with active support

SOLVERS.dqqMinos.categ = 'active';
SOLVERS.glpk.categ = 'active';
SOLVERS.gurobi.categ = 'active';
Expand All @@ -450,11 +433,6 @@ function initCobraToolbox(updateToolbox)
SOLVERS.pdco.categ = 'active';
SOLVERS.quadMinos.categ = 'active';

SOLVERS.cplex_direct.categ = 'active';
SOLVERS.ibm_cplex.categ = 'active';
SOLVERS.cplexlp.categ = 'active';
SOLVERS.tomlab_cplex.categ = 'active';

% definition of category of solvers with passive support
SOLVERS.qpng.categ = 'passive';
SOLVERS.tomlab_snopt.categ = 'passive';
Expand All @@ -464,6 +442,10 @@ function initCobraToolbox(updateToolbox)
%SOLVERS.lindo_old.categ = 'legacy';
%SOLVERS.lindo_legacy.categ = 'legacy';
SOLVERS.lp_solve.categ = 'legacy';
SOLVERS.cplex_direct.categ = 'legacy';
SOLVERS.ibm_cplex.categ = 'legacy';
SOLVERS.cplexlp.categ = 'legacy';
SOLVERS.tomlab_cplex.categ = 'legacy';
%SOLVERS.opti.categ = 'legacy';

% definition of categories of solvers
Expand All @@ -484,17 +466,19 @@ function initCobraToolbox(updateToolbox)
end
end

% check the installation of the solver
supportedSolversNames = setdiff(supportedSolversNames,{'cplex_direct','ibm_cplex','cplexlp','tomlab_cplex'});

% check the installation of the solver - except cplex
for i = 1:length(supportedSolversNames)
if 0 %set to 1 to debug a new solver
disp(supportedSolversNames{i})
if strcmp(supportedSolversNames{i},'quadMinos')
pause(0.1)
if strcmp(supportedSolversNames{i},'quadMinos')
disp(supportedSolversNames{i})
end
end
%We will validate all solvers in init. After this, all solvers are
%checked, whether they actually work and the SOLVERS field is set.
[solverOK,solverInstalled] = changeCobraSolver(supportedSolversNames{i},SOLVERS.(supportedSolversNames{i}).type{1},0, 2);
[solverOK,solverInstalled] = changeCobraSolver(supportedSolversNames{i},SOLVERS.(supportedSolversNames{i}).type{1},0, 1);
if strcmp(supportedSolversNames{i},'gurobi') && 0%use fordebugging
disp(supportedSolversNames{i});
end
Expand Down Expand Up @@ -667,7 +651,6 @@ function initCobraToolbox(updateToolbox)

% use Gurobi (if installed) as the default solver for LP, QP and MILP problems
changeCobraSolver('gurobi', 'ALL', 0);
%changeCobraSolver('ibm_cplex', 'QP', 0); %until problem with gurobi QP sorted

% check if a new update exists
if installedGit && ENV_VARS.printLevel && status_curl == 0 && contains(result_curl, ' 200') && updateToolbox
Expand Down
Loading
Loading