gemseo_matlab

Hide inherited members

license_manager module

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.

class gemseo_matlab.license_manager.LicenseManager(engine)[source]

Bases: object

Manage Matlab License.

The licenseManager was created to enable 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.

Examples

>>> # Build a new matlab engine
>>> eng = get_matlab_engine()
>>> # add a toolbox to the engine
>>> eng.add_toolbox("signal_toolbox")
>>> # build a license manager from the previous engine
>>> lm = LicenseManager(eng)
>>> # check licenses of the engine until all are available
>>> lm.check_licenses()
Parameters:

engine (MatlabEngine) – The MatlabEngine instance.

check_licenses(licenses=(), pause_frac=60, pause_const=20)[source]

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:
  • licenses (Iterable[str]) –

    The matlab toolboxes. If empty, use the already existing engine licenses.

    By default it is set to ().

  • 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:

None

start_parallel_computing(n_parallel_workers=4, cluster_name=ParallelType.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 (ParallelType) –

    The matlab parallel pool cluster name.

    By default it is set to “local”.

Return type:

None

CURVE_FIT_TOOL: ClassVar[str] = 'Curve_Fitting_Toolbox'
DISTRIB_COMP_TOOL: ClassVar[str] = 'distrib_computing_toolbox'
SIGNAL_TOOL: ClassVar[str] = 'signal_toolbox'
engine: MatlabEngine

The MatlabEngine instance.