Param

changeCobraSolverParams(solverType, paramName, paramValue)[source]

Sets global parameters for all Cobra Toolbox optimization solvers

USAGE

changeOK = changeCobraSolverParams (solverType, paramName, paramValue)

INPUTS
  • solverType – Solver type, ‘LP’ or ‘MILP’ (opt, default, ‘LP’)

  • paramName – Parameter name

  • paramValue – Parameter value

OUTPUT

changeOK – Logical inicator that supplied parameter is allowed (= 1)

Explanation on parameters:

  • printLevel: Printing level

    • 0 - Silent

    • 1 - Warnings and Errors

    • 2 - Summary information (Default)

    • 3 - More detailed information

    • > 10 - Pause statements, and maximal printing (debug mode)

  • primalOnly: {(0), 1}; 1 = only return the primal vector (lindo solvers)

  • saveInput: Saves LPproblem to filename specified in field.

    i.e. parameters.saveInput = ‘LPproblem.mat’;

  • minNorm: {(0), scalar , n x 1 vector}, where [m, n] = size(S);

    If not zero then, minimise the Euclidean length of the solution to the LP problem. minNorm ~1e-6 should be high enough for regularisation yet maintain the same value for the linear part of the objective. However, this should be checked on a case by case basis, by optimization with and without regularisation.

  • optTol Optimality tolerance

  • feasTol Feasibility tolerance

  • timeLimit: Global solver time limit

  • intTol: Integrality tolerance

  • relMipGapTol: Relative MIP gap tolerance

  • logFile: Log file (for CPLEX)

Note

The available solver Parameters can be obtained by calling getSolverParamsOptionsForType(). If input argument minNorm is not zero, then minimise the Euclidean length of the solution to the LP problem. minNorm ~1e-6 should be high enough for regularisation yet maintain the same value for the linear part of the objective. However, this should be checked on a case by case basis, by optimization with and without regularisation.

getCobraSolverParams(problemType, paramNames, paramStructure)[source]

This function gets the specified paramStructure in paramNames from paramStructure, the global cobra parameters variable or default values set within this script.

It will use values with the following priority paramStructure > solver type paramStructure > default paramStructure

The specified paramStructure will be delt to the specified output arguements. See examples below.

USAGE

varargout = getCobraSolverParams (problemType, paramNames, paramStructure)

INPUTS
  • problemType – Type of problem solved: ‘LP’, ‘MILP’, ‘QP’, ‘MIQP’, ‘EP’, ‘CLP’

  • paramNames – Cell array of strings containing parameter names OR one parameter name as string

OPTIONAL INPUTS

paramStructure – Structure with fields pertaining to parameter values that should be used in place of global or default paramStructure. paramStructure can be set to ‘default’ to use the default values set within this script.

OUTPUTS

varargout – Variables which each value corresponding to paramNames is output to. In addition, if paramStructure is passed as an input, then the final output argument is paramStructureOut, with fields removed corresponding to paramNames

Example

paramStructure.saveInput = ‘LPproblem.mat’; paramStructure.printLevel = 1; [printLevel, saveInput] = getCobraSolverParams(‘LP’, {‘printLevel’, ‘saveInput’}, paramStructure);

%Example using default values [printLevel, saveInput] = getCobraSolverParams(‘LP’, {‘printLevel’,’saveInput’}, ‘default’);

getCobraSolverParamsOptionsForType(problemType)[source]

This function returns the parameters that are supported for each specified problem type.

USAGE

paramNames = getCobraSolverParamsOptionsForType (problemType)

INPUT

problemType – One of the problem types available in the COBRA Toolbox (‘LP’,’QP’,’EP’,’CLP’,’MILP’,’MIQP’,’NLP’)

OUPTUT:
paramNames: Cell array of names of parameters that can be set

for each problem type, independent of the specific solver being used.

mergeCobraParams(param1, param2)[source]

Merge the structures with preference to param1 fields over param2 fields

parseSolverParameters(problemType, varargin)[source]

Gets default cobra solver parameters for a problem of type problemType, unless overridden by cobra solver parameters provided by varagin either as parameter struct, or as parameter/value pairs.

USAGE

[param, solverOnlyParams] = parseSolverParameters (problemType,varargin)

INPUT

problemType – The type of the problem to get parameters for (‘LP’,’MILP’,’QP’,’MIQP’,’NLP’,’EP’,’CLP’)

OPTIONAL INPUTS

varargin – Additional parameters either as parameter struct, or as parameter/value pairs. A combination is possible, if the parameter struct is either at the beginning or the end of the optional input. All fields of the struct which are not COBRA parameters (see getCobraParamsOptionsForType) for this problem type will be passed on to the solver in a solver specific manner.

OUTPUTS
  • param – The COBRA Toolbox specific parameters for this problem type given the provided parameters, plus any additional parameters

  • solverOnlyParams – Structure of parameters that only contains fields that can be passed to a specific solver, e.g., gurobi or mosek. For some solvers, it is essential to NOT include any extraneous fields that are outside the solver interface specification, otherwise an error will result.