6.10 Solver Parameters

The MOSEK API provides many parameters to tune and customize the solver behaviour. Parameters are grouped depending on their type: integer, double or string. In general, it should not be necessary to change any of the parameters but if required, it is easily done. A complete list of all parameters is found in Sec. 17.4 (Parameters (alphabetical list sorted by type)).

We will show how to access and set the integer parameter that define the logging verbosity of the solver, i.e. MSK_IPAR_LOG, and the algorithm used by MOSEK, i.e. MSK_IPAR_OPTIMIZER.

Note

The very same concepts and procedures apply to string and double valued parameters.

To inspect the current value of a parameter, we can use the mosekopt command param:

[r,resp]=mosekopt('param'); 

To set a parameter we only need to make a structure with fields that corresponds to the parameters we want to set:

param.MSK_IPAR_LOG = 1
param.MSK_IPAR_LOG = -1

The values for integer parameters are either simple integer values or enum values. Enumerations are provided mainly to improve readability and ensure compatibility.

In the next lines we show how to set the algorithm used by MOSEK to solve linear optimization problem. To that purpose we set the MSK_IPAR_OPTIMIZER parameter using a value from the optimizertype enumeration: for instance we may decide to use the dual simplex algorithm, and thus

param.MSK_IPAR_OPTIMIZER = 'MSK_OPTIMIZER_DUAL_SIMPLEX'

For more information about other parameter related functions, please browse the API reference in Sec. 17.1 (Command Reference).

The complete code for this tutorial follows in Listing 19.

Listing 19 Parameter setting example. Click here to download.
function r = parameters()


fprintf('Test MOSEK parameter get/set functions');

[r,resp]=mosekopt('param'); 

fprintf('Default value for parameter MSK_IPAR_LOG= %d\n', resp.param.MSK_IPAR_LOG)
    
fprintf(' setting to 1...');
param.MSK_IPAR_LOG = 1

    
fprintf(' setting to -1 ...');
param.MSK_IPAR_LOG = -1


fprintf(' selecting the dual simplex algorithm...');
param.MSK_IPAR_OPTIMIZER = 'MSK_OPTIMIZER_DUAL_SIMPLEX'

try
    % Perform the optimization, but it should fail
    [r,resp] = mosekopt('minimize', [] , param); 
catch 
    fprintf('The value -1 for parameter MSK_IPAR_LOG has been correctly detected as wrong!')
    r = 0
    return 
end

fprintf('The value -1 for parameter MSK_IPAR_LOG has NOT been correctly detected as wrong!')

r = 1

end