Client

Warning

This interface documentation describes a deprecated version of the Analysis and Optimization Toolkit in JCMsuite. It has been superseded by JCMoptimizer and is retained solely for reference in legacy projects.

For all new simulation and optimization projects, use JCMOptimizer instead. The corresponding documentation is available here.

Note

A client object can be created by calling jcmwave.optimizer.client().

class jcmwave.client.Client(host, verbose=True, check=True)

This class provides methods for creating new optimization studies. Example:

 domain = [
   {'name': 'x1', 'type': 'continuous', 'domain': (-1.5,1.5)}, 
   {'name': 'x2', 'type': 'continuous', 'domain': (-1.5,1.5)},
]
study = client.create_study(domain=domain, name='example')
check_server()

Checks if the optimization server is running. Example:

>>> client.check_server()
Optimization server is running
create_benchmark(benchmark_id=None, num_average=None)

Creates a new Benchmark object for benchmarking different optimization studies against each other. Example:

benchmark = client.create_benchmark(num_average=6);
Parameters:
  • benchmark_id (str) – A unique identifier of the benchmark.
  • num_average (int) – Number of study runs to determine average study performance
create_study(domain=None, name=None, study_id=None, constraints=None, driver='BayesOptimization', save_dir=None, output_precision=1e-10, dashboard=True, open_browser=True)

Creates a new Study instance. Example:

study = client.create_study(domain=domain, name='example')
Parameters:
  • domain (list) –

    List of domain definitions for each parameter. A domain definition consists of a dictionary with the entries

    name:Name of the parameter. E.g. ‘x1’. The name should contain no spaces and must not be equal to function names like ‘sin’, ‘cos’, ‘exp’ etc.
    type:Type of the parameter. Either ‘continuous’, ‘discrete’, ‘categorial’, or ‘fixed’. Fixed parameters are not optimized, but can be used in the constraint functions.
    domain:The domain of the parameter. For continuous parameters this is a tuple (min, max). For discrete parameters this is a list of values, e.g. [1.0,2.5,3.0]. For categorial inputs it is a list of strings, e.g. [‘cat1’,’cat2’,’cat3’]. Note, that categorial values are internally mapped to integer representations, which are allowed to have a correlation. The categorial values should therefore be ordered according to their similarity. For fixed parameters the domain is a single parameter value.

    Example:

    domain = [{'name': 'x1', 'type': 'continuous', 'domain': (-2.0,2.0)}, 
              {'name': 'x2', 'type': 'continuous', 'domain': (-2.0,2.0)},
              {'name': 'x3', 'type': 'discrete', 'domain': [-1.0,0.0,1.0]},
              {'name': 'x4', 'type': 'categorial', 'domain': ['a','b']}
              {'name': 'x5', 'type': 'fixed', 'domain': 2.0}]
    
  • constraints (list) –

    List of constraints on the domain. Each list element is a dictionary with the entries

    name:Name of the constraint.
    constraint:A string defining a function that is smaller zero if and only if the constraint is met. The following operations and functions may be used: +,-,*,/,^,sqrt,sin,cos,tan,abs,round, sgn, tunc. E.g. 'x1^2 + x2^2 + sin(x1+x2)'

    Example:

    constraints = [
        {'name': 'circle', 'constraint': 'x1^2+x2^2-4'},
        {'name': 'triangle', 'constraint': 'x1-x2'},
    ]
    
  • study_id (str) – A unique identifier of the study. All relevant information on the study are saved in a file named study_id+’.jcmo’ If the study already exists, the domain and constraints do not need to be provided. If not set, the study_id is set to a random unique string.
  • name (str) – The name of the study that will be shown in the dashboard.
  • save_dir (str) – The path to a directory, where the study file (jcmo-file) is saved. If False, no study file is saved.
  • driver (str) – Driver used for the study (default: ‘BayesOptimization’). For a list of drivers, see the Analysis and Optimization Toolkit (deprecated)/Driver Reference.
  • output_precision (float) –

    Precision level for output of parameters. (Default: 1e-10)

    Note

    Rounding the output can potentially lead to a slight breaking of constraints.

  • dashboard (bool) – If true, a dashboard server will be started for the study. (Default: True)
  • open_browser (bool) – If true, a browser window with the dashboard is started. (Default: True)
shutdown_server(force=False)

Shuts down the optimization server. Example:

client.shutdown_server()
Parameters:force (bool) – If True the optimization server is closed even if a study is not yet finished.