Mosek

inspectMosekNumerics(prob)[source]

Inspect numerical properties of a MOSEK problem structure.

USAGE:

report = inspectMosekNumerics (prob)

INPUTS:

prob – MOSEK problem structure. Typical fields include: .a - linear constraint matrix .blc - lower linear constraint bounds .buc - upper linear constraint bounds .c - objective vector .blx - lower variable bounds .bux - upper variable bounds .f - affine conic constraint matrix .g - affine conic constraint offset

OUTPUTS:

report – Structure containing numerical diagnostics for the problem data. Depending on which fields are present in prob, this may include: .A_size .A_nnz .A_density .A_abs_min_nonzero .A_abs_max .A_dynamic_range .A_row_norm_inf_min .A_row_norm_inf_max .A_col_norm_inf_min .A_col_norm_inf_max .blc_abs_min, .blc_abs_max, .blc_dynamic_range .buc_abs_min, .buc_abs_max, .buc_dynamic_range .c_abs_min, .c_abs_max, .c_dynamic_range .blx_abs_min, .blx_abs_max, .blx_dynamic_range .bux_abs_min, .bux_abs_max, .bux_dynamic_range .f_abs_min, .f_abs_max, .f_dynamic_range .g_abs_min, .g_abs_max, .g_dynamic_range .nBadVarBounds .nBadConBounds

This routine is written to reduce unnecessary full-array calls to isfinite, which can dominate runtime on very large problem instances. It uses a fast path that assumes data are finite and only falls back to explicit finite filtering if non-finite values are detected.

Example

report = inspectMosekNumerics(prob);

Note

Intended for diagnostic inspection of MOSEK-style problem data.

inspectMosekProb(prob)[source]

Numerical and structural inspection of a MOSEK problem struct

USAGE:

report = inspectMosekProb (prob)

INPUTS:

prob – MOSEK problem structure with fields:

  • .a - linear constraint matrix

  • .blc - lower linear constraint bounds

  • .buc - upper linear constraint bounds

  • .c - objective vector

  • .blx - lower variable bounds

  • .bux - upper variable bounds

  • .f - affine conic constraint matrix

  • .g - affine conic constraint offset

OUTPUTS:

report – Structure with fields:

  • .fieldStats - table of per-field numerical statistics

  • .sizeStats - table of shape/sparsity information for the matrix fields a and f

  • .problemChecks - struct of higher-level consistency checks

Example

report = inspectMosekProb(prob);

mosekParamStrip(solverParams)[source]

Remove non-MOSEK parameters to avoid crashing the MOSEK solver interface

USAGE:

solverParams = mosekParamStrip (solverParams)

INPUTS:

solverParams – Solver parameter structure with fields:

  • .timelimit - (optional) COBRA-style time limit in seconds; copied to .MSK_DPAR_OPTIMIZER_MAX_TIME before non-MOSEK fields are stripped

  • .MSK_DPAR_OPTIMIZER_MAX_TIME - (optional) MOSEK native time-limit parameter, set from .timelimit when the latter is present

OUTPUTS:

solverParams – Copy of the input structure retaining only fields whose name contains the substring MSK_, i.e. only recognised MOSEK-native parameters remain

parseMskResult(res)[source]

Parse the res structure returned by mosekopt into a COBRA-style solver status and primal/dual solution vectors

For conic problems with affine conic constraints, the interior-point solution res.sol.itr is preferred whenever it is available and has an optimal or near-optimal solution status. The basis solution, res.sol.bas, is mainly relevant for linear problems and does not override a valid interior-point solution for conic subproblems.

This parser deliberately maps NEAR_OPTIMAL to stat = 3, not stat = 1. The caller can decide whether a near-optimal solution is acceptable, but solveSCLP should not silently accept it as a fully accurate inner solve.

USAGE:

[stat, origStat, x, y, yl, yu, z, zl, zu, s, basis, pobjval, dobjval] = parseMskResult (res)

INPUTS:

res – Result structure returned by mosekopt, with fields:

  • .sol - structure of MOSEK sub-solutions, expected to contain an interior-point sub-solution .itr and/or a basis sub-solution .bas, each in turn carrying solsta, xx, slc, suc, slx, sux, doty, s, skc, skx, xc, pobjval, and dobjval

  • .rcodestr - MOSEK response-code string, appended to origStat for traceability when present

OUTPUTS:
  • stat – COBRA-style solver status flag:

    • 0 - primal infeasible certificate

    • 1 - strict optimal solution

    • 2 - dual infeasible certificate, interpreted upstream as unbounded

    • 3 - near optimal / almost optimal solution

    • -1 - unknown, numerical issue, time limit, or unrecognised status

  • origStat – Original MOSEK solution-status string (solsta), with res.rcodestr appended after ‘ & ‘ when present

  • x – Primal solution vector

  • y – Linear-row dual vector, computed as yl - yu

  • yl – Lower linear-row multiplier

  • yu – Upper linear-row multiplier

  • z – Variable-bound dual vector, computed as zu - zl

  • zl – Lower variable-bound multiplier

  • zu – Upper variable-bound multiplier

  • s – Dual variables to the affine conic constraints

  • basis – Structure of basis-status fields for hot-starting linear problems, populated only when the basis solution is used, with fields:

    • .skc - constraint status keys

    • .skx - variable status keys

    • .xc - constraint activity levels

    • .xx - primal variable values

  • pobjval – Primal objective value

  • dobjval – Dual objective value

Note

With the dual sign convention above, stationarity is naturally checked as c - A’*y + z - F’*s = 0, equivalently c - A’*(yl - yu) + (zu - zl) - F’*s = 0.

setMosekParam(param)[source]

Single-file source of truth for MOSEK parameter materialisation

This function deliberately does not call external helper files to set, strip, normalise, or otherwise manipulate MOSEK parameters. All helper functions used below are local functions in this same file.

Supported profiles (param.mosekParam):

‘default’

True MOSEK default profile. No MSK_* parameters are passed except those needed to enforce the requested print policy.

‘manual’

Pass caller-supplied MSK_* fields through, after applying the print policy and stripping non-MOSEK fields.

‘cobra’ ‘cobraNoPresolve’ ‘cobraVerbose’ ‘cobraNoPresolveVerbose’

Backward-compatible COBRA-style profiles.

‘SCLP_default’

True MOSEK default profile for solveSCLP inner solves.

‘SCLP_normalPresolve’ ‘SCLP_noPresolve’ ‘SCLP_verbose’ ‘SCLP_noPresolveVerbose’

solveSCLP-specific ordinary conic profiles.

‘SCLP_startTight’ ‘SCLP_startTightNoPresolve’

solveSCLP-specific tight profiles for initial centring and centred-start raw repair. These inherit the ordinary SCLP profile first, then override only accuracy-related parameters.

Print policy:

The line param.printLevel = param.printLevel - 1; is intentional. It prevents inner MOSEK solve traces from appearing during ordinary use of solveSCLP inside higher-level algorithms.

Effective behaviour:

solveSCLP printLevel = 0 -> MOSEK silent solveSCLP printLevel = 1 -> MOSEK silent solveSCLP printLevel = 2 -> MOSEK default printing solveSCLP printLevel > 2 -> verbose-profile MOSEK logs may print

USAGE:

[cmd, mosekParam] = setMosekParam (param)

INPUTS:

param – Structure of COBRA/solveSCLP-style solver parameters. All fields are optional; absent fields fall back to the defaults noted below. Fields read or written:

  • .printLevel - COBRA print level (default 0); reduced by 1 before it drives the MOSEK print policy

  • .debug - debug flag (default 0); when 1, requests MOSEK infeasibility reporting in the cobra* profiles

  • .problemType - COBRA problem type, e.g. ‘LP’, ‘QP’, ‘CLP’, ‘EP’, ‘VK’ (default ‘CLP’); selects the optimizer choice below

  • .mosekParam - name of the requested profile listed above (default ‘cobra’)

  • .timelimit - COBRA-style solve time limit in seconds; copied to .MSK_DPAR_OPTIMIZER_MAX_TIME when the latter is not already supplied (SCLP profiles default it to 600 when absent)

  • .mosekInnerTol - overrides the MOSEK primal interior-point tolerance directly (and the dual tolerance too, unless .mosekInnerMuTol is given)

  • .feasTol - COBRA feasibility tolerance, used as the MOSEK primal tolerance default when .mosekInnerTol is absent (also scales the solveSCLP inner tolerances)

  • .optTol - COBRA optimality tolerance, used as the MOSEK dual tolerance default when .mosekInnerTol is absent

  • .mosekInnerMuTol - overrides the MOSEK complementarity (mu) tolerance directly

  • .mosekSolveForm - overrides the default MSK_IPAR_INTPNT_SOLVE_FORM value (‘MSK_SOLVE_PRIMAL’)

  • .mosekPresolveUse - overrides the default MSK_IPAR_PRESOLVE_USE value (‘MSK_PRESOLVE_MODE_FREE’)

  • .mosekPrimalInfeasPerturbationTol - overrides the default MSK_DPAR_PRESOLVE_TOL_PRIMAL_INFEAS_PERTURBATION value (0)

  • .mosekPresolveTolX - overrides the default MSK_DPAR_PRESOLVE_TOL_X value

  • .mosekPresolveTolS - overrides the default MSK_DPAR_PRESOLVE_TOL_S value

  • .mosekDataTolX - overrides the default MSK_DPAR_DATA_TOL_X value

  • .numTol - COBRA numerical tolerance, the basis (times 100 or 1) for the presolve/data tolerance defaults above

  • .mosekNearRel - overrides the default MSK_DPAR_INTPNT_CO_TOL_NEAR_REL value (1.0)

  • .lifted - when 1, disables the MOSEK eliminator retry (MSK_IPAR_PRESOLVE_ELIMINATOR_MAX_NUM_TRIES set to 0) unless already supplied

  • .multiscale - when 1 and .lifted is 0/absent, turns off MOSEK’s own scaling (MSK_IPAR_PRESOLVE_LINDEP_NEW, MSK_IPAR_INTPNT_SCALING, MSK_IPAR_SIM_SCALING) unless already supplied

  • .strict - when non-empty, requests a stricter solve: disables the basis-identification iteration limit, forces a free solve form, and tightens the infeasibility tolerance, unless the corresponding MSK_* fields are already supplied

  • .repairInfeasibility - when non-empty, copied to MSK_IPAR_LOG_FEAS_REPAIR unless already supplied

  • .lpmethod, .qpmethod, .clpmethod, .epmethod - COBRA solver-method selectors, normalised and copied to MSK_IPAR_OPTIMIZER when .problemType is respectively ‘LP’, ‘QP’, ‘CLP’, or ‘EP’

  • .innerMosekTolFactor, .innerMosekTolFloorFactor, .innerMosekMuTolFactor, .innerMosekMuTolFloorFactor - factors (defaults 1e-3, 10, 1e-5, 1) that scale .feasTol/.numTol into the solveSCLP inner interior-point/complementarity tolerances

  • .mosekPresolveTolXFactor, .mosekPresolveTolSFactor, .mosekDataTolXFactor - factors (defaults 100, 100, 1) that scale .numTol into the solveSCLP presolve and data tolerances

  • caller-supplied MSK_* fields, honoured as-is wherever the profile logic above checks for them first, rather than being overridden: .MSK_DPAR_OPTIMIZER_MAX_TIME, .MSK_DPAR_INTPNT_TOL_PFEAS, .MSK_DPAR_INTPNT_QO_TOL_PFEAS, .MSK_DPAR_INTPNT_CO_TOL_PFEAS, .MSK_DPAR_INTPNT_TOL_DFEAS, .MSK_DPAR_INTPNT_QO_TOL_DFEAS, .MSK_DPAR_INTPNT_CO_TOL_DFEAS, .MSK_DPAR_INTPNT_CO_TOL_REL_GAP, .MSK_DPAR_INTPNT_CO_TOL_MU_RED, .MSK_IPAR_INTPNT_SOLVE_FORM, .MSK_IPAR_PRESOLVE_USE, .MSK_DPAR_PRESOLVE_TOL_PRIMAL_INFEAS_PERTURBATION, .MSK_DPAR_PRESOLVE_TOL_X, .MSK_DPAR_PRESOLVE_TOL_S, .MSK_DPAR_DATA_TOL_X, .MSK_DPAR_INTPNT_CO_TOL_NEAR_REL, .MSK_IPAR_PRESOLVE_ELIMINATOR_MAX_NUM_TRIES, .MSK_IPAR_PRESOLVE_LINDEP_NEW, .MSK_IPAR_INTPNT_SCALING, .MSK_IPAR_SIM_SCALING, .MSK_IPAR_BI_IGNORE_MAX_ITER, .MSK_DPAR_INTPNT_TOL_INFEAS, .MSK_IPAR_LOG_FEAS_REPAIR, .MSK_IPAR_LOG, .MSK_IPAR_LOG_INTPNT, .MSK_IPAR_LOG_SIM, .MSK_IPAR_LOG_PRESOLVE, .MSK_IPAR_INFEAS_REPORT_AUTO, .MSK_IPAR_INFEAS_REPORT_LEVEL, .MSK_IPAR_INTPNT_REGULARIZATION_USE, and .MSK_IPAR_OPTIMIZER; .MSK_IPAR_INTPNT_MAX_ITERATIONS is additionally set to 400 for the EP problem type unless already supplied

OUTPUTS:
  • cmd – MOSEK command string, usually ‘minimize echo(0)’ or ‘minimize’

  • mosekParam – Structure containing only MSK_* fields, ready to be passed to mosekopt