From 36cefd8bd81c488cc40ac9af6e27f91ed7e4fa8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20F=C3=A4ssler?= Date: Thu, 23 Oct 2025 14:43:33 +0200 Subject: [PATCH 1/3] resolving QPold method of optimizeWBModel --- .../wholeBody/PSCMToolbox/optimizeWBModel.m | 30 +++++++++---------- src/base/solvers/buildOptProblemFromModel.m | 2 ++ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m b/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m index b8e8383ab1..d3cf4110c4 100644 --- a/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m +++ b/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m @@ -181,7 +181,7 @@ case 'ibm_cplex' % https://www.ibm.com/docs/en/icos/12.10.0?topic=infeasibility-coping-ill-conditioned-problem-handling-unscaled-infeasibilities - param.minNorm = 0; + % param.minNorm = 0; % Decides how to scale the problem matrix. % Value Meaning @@ -189,7 +189,7 @@ % 0 Equilibration scaling; default % 1 More aggressive scaling % https://www.ibm.com/docs/en/icos/12.10.0?topic=parameters-scale-parameter - param.scaind = -1; + % param.scaind = -1; % Emphasizes precision in numerically unstable or difficult problems. % This parameter lets you specify to CPLEX that it should emphasize precision in @@ -198,7 +198,7 @@ % 0 Do not emphasize numerical precision; default % 1 Exercise extreme caution in computation % https://www.ibm.com/docs/en/icos/12.10.0?topic=parameters-numerical-precision-emphasis - param.emphasis_numerical=1; + % param.emphasis_numerical=1; case 'mosek' param.MSK_DPAR_OPTIMIZER_MAX_TIME=param.secondsTimeLimit; param.MSK_IPAR_WRITE_DATA_PARAM='MSK_ON'; @@ -258,26 +258,26 @@ noLinearObjective = all(model.c==0); if noLinearObjective - [tmp, solverOK] = getCobraSolver('QP'); - solverName{1,1} = tmp; - solverName{1,2} = 'QP'; + [tmp, solverOK] = getCobraSolver('QP', 1); + solverNameQP{1,1} = tmp; + solverNameQP{1,2} = 'QP'; else - [solverName{1,1}, solverOK] = getCobraSolver('LP'); - solverName{1,2} = 'QP'; - [solverName{2,1}, solverOK] = getCobraSolver('QP'); - solverName{2,2} = 'QP'; + [solverNameQP{1,1}, solverOK] = getCobraSolver('LP', 1); + solverNameQP{1,2} = 'QP'; + [solverNameQP{2,1}, solverOK] = getCobraSolver('QP', 1); + solverNameQP{2,2} = 'QP'; end - for i = 1:size(solverName,1) - if ~any(strcmp(solverName{i,1},validatedSolvers)) + for i = 1:size(solverNameQP,1) + if ~any(strcmp(solverNameQP{i,1},validatedSolvers)) fprintf('%s\n','Note that the solvers validated for use with the PSCM toolbox are:') disp(validatedSolvers) %switch over to a validated solver - [solverOK, solverInstalled] = changeCobraSolver('tomlab_cplex', solverName{i,2},1,1); + [solverOK, solverInstalled] = changeCobraSolver('tomlab_cplex', solverNameQP{i,2},1,1); if solverOK - fprintf('%s\n',[solverName{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) + fprintf('%s\n',[solverNameQP{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) else - error([solverName{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) + error([solverNameQP{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) end end end diff --git a/src/base/solvers/buildOptProblemFromModel.m b/src/base/solvers/buildOptProblemFromModel.m index 4ec8f19b31..4889998389 100644 --- a/src/base/solvers/buildOptProblemFromModel.m +++ b/src/base/solvers/buildOptProblemFromModel.m @@ -207,6 +207,8 @@ %nothing to do - done above already case 'QP' %nothing to do - done above already + case 'QPold' + %nothing to do - done above already case 'QRLP' [m,n]=size(optProblem.A); optProblem.A = [... From 1be02f5630fec0b917362edec5292e81d1071ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20F=C3=A4ssler?= Date: Thu, 23 Oct 2025 16:52:10 +0200 Subject: [PATCH 2/3] Keep param.scand=-1 and param.emphasis_numerical=1 --- src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m b/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m index d3cf4110c4..3f77e3a2ba 100644 --- a/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m +++ b/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m @@ -189,7 +189,7 @@ % 0 Equilibration scaling; default % 1 More aggressive scaling % https://www.ibm.com/docs/en/icos/12.10.0?topic=parameters-scale-parameter - % param.scaind = -1; + param.scaind = -1; % Emphasizes precision in numerically unstable or difficult problems. % This parameter lets you specify to CPLEX that it should emphasize precision in @@ -198,7 +198,7 @@ % 0 Do not emphasize numerical precision; default % 1 Exercise extreme caution in computation % https://www.ibm.com/docs/en/icos/12.10.0?topic=parameters-numerical-precision-emphasis - % param.emphasis_numerical=1; + param.emphasis_numerical=1; case 'mosek' param.MSK_DPAR_OPTIMIZER_MAX_TIME=param.secondsTimeLimit; param.MSK_IPAR_WRITE_DATA_PARAM='MSK_ON'; @@ -275,9 +275,9 @@ %switch over to a validated solver [solverOK, solverInstalled] = changeCobraSolver('tomlab_cplex', solverNameQP{i,2},1,1); if solverOK - fprintf('%s\n',[solverNameQP{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) + fprintf('%s\n',[solverName{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) else - error([solverNameQP{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) + error([solverName{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) end end end From a203746d11e16ada2259a1d3c860c83128c8e2e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20F=C3=A4ssler?= Date: Thu, 23 Oct 2025 17:43:58 +0200 Subject: [PATCH 3/3] change solverName to solverNameQP in QPold --- src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m b/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m index 3f77e3a2ba..fc3af0f129 100644 --- a/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m +++ b/src/analysis/wholeBody/PSCMToolbox/optimizeWBModel.m @@ -275,9 +275,9 @@ %switch over to a validated solver [solverOK, solverInstalled] = changeCobraSolver('tomlab_cplex', solverNameQP{i,2},1,1); if solverOK - fprintf('%s\n',[solverName{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) + fprintf('%s\n',[solverNameQP{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) else - error([solverName{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) + error([solverNameQP{i,1} ' has not been validated for use with the PSCM toolbox. Tried to change to tomlab_cplex, but it failed.']) end end end