gemseo / wrappers / matlab

Definition of the Matlab license manager.

## Overview¶

This module contains the LicenseManager which enables to check the presence of any toolbox licenses of the Matlab installation.

Classes:

 LicenseManager(engine) Manage Matlab License.

Bases: object

The licenseManager was created to enables de-synchronised launch of optimization using matlab_discipline. The goal is to wait until all licenses that are needed are available in Matlab workspace. Parallel computing launch can be used with this tool.

engine

The MatlabEngine instance.

The list of license toolbox that must be used.

Examples

>>> # Build a new matlab engine
>>> eng = get_matlab_engine()
>>> # add a toolbox to the engine
>>> # build a license manager from the previous engine
>>> # check licenses of the engine until all are available

Parameters

engine (__MatlabEngine) – The MatlabEngine instance.

Return type

None

Attributes:

 CURVE_FIT_TOOL DISTRIB_COMP_TOOL SIGNAL_TOOL licenses Get and set all licences.

Methods:

 check_licenses([licenses, pause_frac, ...]) Check that the Matlab licenses exist. Stop parallel computing in matlab engine. Start parallel computing in MatlabEngine.
CURVE_FIT_TOOL = 'Curve_Fitting_Toolbox'
DISTRIB_COMP_TOOL = 'distrib_computing_toolbox'
SIGNAL_TOOL = 'signal_toolbox'

Check that the Matlab licenses exist.

The method fetches all the needed licenses thanks to the matlab function licenseControl and the class Logger. Note that the MATLAB function will be looping until the given toolboxes are available.

Parameters

The list of matlab toolboxes. If None, use the already existing engine licenses.

By default it is set to None.

• pause_frac (float) –

The time used between each try to get licenses.

By default it is set to 60.

• pause_const (float) –

The time added in order to estimate the waiting time. The waiting time is estimated at each try with the following formula: Wt = pause_const + random([0,1])*pause_frac.

By default it is set to 20.

Return type

None

end_parallel_computing()[source]

Stop parallel computing in matlab engine.

Return type

bool

Get and set all licences.

start_parallel_computing(n_parallel_workers=4, cluster_name='local')[source]

Start parallel computing in MatlabEngine.

Parameters
• n_parallel_workers (int) –

The number of “workers” to the parallel pool. Maximum number allowed is 12

By default it is set to 4.

• cluster_name (str) –

The matlab parallel pool cluster name. If None, the given name is the same as the engine.

By default it is set to local.

Return type

bool