Skip to content

Commit 868cb60

Browse files
committed
refactored parameters gurobi and mosek
1 parent 27d920b commit 868cb60

28 files changed

+1445
-962
lines changed

initCobraToolbox.m

+18-35
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,8 @@ function initCobraToolbox(updateToolbox)
1616
%
1717
% initCobraToolbox
1818
% -or-
19-
% changeCobraSolver('gurobi');
20-
% changeCobraSolver('gurobi', 'MILP');
21-
% changeCobraSolver('tomlab_cplex', 'QP');
22-
% changeCobraSolver('tomlab_cplex', 'MIQP');
23-
% changeCbMapOutput('svg');
19+
% changeCobraSolver('gurobi','all');
20+
% changeCobraSolver('mosek', 'CLP');
2421
%
2522
% Maintained by Ronan M.T. Fleming
2623

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

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

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

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

418402
% active support - supported solvers
@@ -423,25 +407,24 @@ function initCobraToolbox(updateToolbox)
423407
SOLVERS.quadMinos.type = {'LP'};
424408
SOLVERS.dqqMinos.type = {'LP','QP'};
425409
SOLVERS.matlab.type = {'LP', 'NLP'};
426-
% active support of cplex interfaces - supported solvers
427-
SOLVERS.cplex_direct.type = {'LP', 'MILP', 'QP'};
428-
SOLVERS.ibm_cplex.type = {'LP', 'MILP', 'QP', 'MIQP'};
429-
SOLVERS.cplexlp.type = {'LP'};
430-
SOLVERS.tomlab_cplex.type = {'LP', 'MILP', 'QP', 'MIQP'};
410+
431411

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

436416
% legacy solvers
417+
SOLVERS.cplex_direct.type = {'LP', 'MILP', 'QP'};
418+
SOLVERS.ibm_cplex.type = {'LP', 'MILP', 'QP', 'MIQP'};
419+
SOLVERS.cplexlp.type = {'LP'};
420+
SOLVERS.tomlab_cplex.type = {'LP', 'MILP', 'QP', 'MIQP'};
437421
%SOLVERS.gurobi_mex.type = {'LP', 'MILP', 'QP', 'MIQP'};
438422
%SOLVERS.lindo_old.type = {'LP'};
439423
%SOLVERS.lindo_legacy.type = {'LP'};
440424
SOLVERS.lp_solve.type = {'LP'};
441425
%SOLVERS.opti.type = {'LP', 'MILP', 'QP', 'MIQP', 'NLP'};
442426

443427
% definition of category of solvers with active support
444-
445428
SOLVERS.dqqMinos.categ = 'active';
446429
SOLVERS.glpk.categ = 'active';
447430
SOLVERS.gurobi.categ = 'active';
@@ -450,11 +433,6 @@ function initCobraToolbox(updateToolbox)
450433
SOLVERS.pdco.categ = 'active';
451434
SOLVERS.quadMinos.categ = 'active';
452435

453-
SOLVERS.cplex_direct.categ = 'active';
454-
SOLVERS.ibm_cplex.categ = 'active';
455-
SOLVERS.cplexlp.categ = 'active';
456-
SOLVERS.tomlab_cplex.categ = 'active';
457-
458436
% definition of category of solvers with passive support
459437
SOLVERS.qpng.categ = 'passive';
460438
SOLVERS.tomlab_snopt.categ = 'passive';
@@ -464,6 +442,10 @@ function initCobraToolbox(updateToolbox)
464442
%SOLVERS.lindo_old.categ = 'legacy';
465443
%SOLVERS.lindo_legacy.categ = 'legacy';
466444
SOLVERS.lp_solve.categ = 'legacy';
445+
SOLVERS.cplex_direct.categ = 'legacy';
446+
SOLVERS.ibm_cplex.categ = 'legacy';
447+
SOLVERS.cplexlp.categ = 'legacy';
448+
SOLVERS.tomlab_cplex.categ = 'legacy';
467449
%SOLVERS.opti.categ = 'legacy';
468450

469451
% definition of categories of solvers
@@ -484,17 +466,19 @@ function initCobraToolbox(updateToolbox)
484466
end
485467
end
486468

487-
% check the installation of the solver
469+
supportedSolversNames = setdiff(supportedSolversNames,{'cplex_direct','ibm_cplex','cplexlp','tomlab_cplex'});
470+
471+
% check the installation of the solver - except cplex
488472
for i = 1:length(supportedSolversNames)
489473
if 0 %set to 1 to debug a new solver
490474
disp(supportedSolversNames{i})
491-
if strcmp(supportedSolversNames{i},'quadMinos')
492-
pause(0.1)
475+
if strcmp(supportedSolversNames{i},'quadMinos')
476+
disp(supportedSolversNames{i})
493477
end
494478
end
495479
%We will validate all solvers in init. After this, all solvers are
496480
%checked, whether they actually work and the SOLVERS field is set.
497-
[solverOK,solverInstalled] = changeCobraSolver(supportedSolversNames{i},SOLVERS.(supportedSolversNames{i}).type{1},0, 2);
481+
[solverOK,solverInstalled] = changeCobraSolver(supportedSolversNames{i},SOLVERS.(supportedSolversNames{i}).type{1},0, 1);
498482
if strcmp(supportedSolversNames{i},'gurobi') && 0%use fordebugging
499483
disp(supportedSolversNames{i});
500484
end
@@ -667,7 +651,6 @@ function initCobraToolbox(updateToolbox)
667651

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

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

0 commit comments

Comments
 (0)