Latin Hypercube Sampling

Samples points using a Latin Hypercube. The bounds are determined from min and max of each parameter.

For a mesh scan if the final code of the job chain is serial Python and if an objective function is not provided (see below) then the return value of the Python function must be either None or float. If the final code of the job chain is serial Python and the function returns a float the value will be recorded in the f field of the history file.

Configuration

Requirements and optional keys for setting up the configuration file to use Latin Hypercube Sampling are given below.

Codes Blocks

No special configuration is needed in any portion of the codes blocks to use Latin Hypercube Sampling.

Options

The following required and optional keys can be used within the options: block:

  • software [str (required)]: lh_scan

  • batch_size [int (required)]: The number of sample points to evaluate.

  • seed [int or None or str (optional)]: Sets the seed to initialize the pseudo-random number generator used by the sampler. Behavior depends on the setting:

  • '': default If an empty string is given, or seed is not explicitly included then a fixed seed is set.

    Repeated runs with this setting will always evaluate the same point.

  • None: If seed is set to :code: None then a random seed will be used. IMPORTANT: To set a field to be None-type in YAML the field must be empty. So the options block should look like:

    options:
     software: lh_scan
     seed:
     batch_size: 42
    
    • int: If set be any integer between 0 and 2**32 - 1 inclusive then the integer is used as the seed initialize the pseudo-random number generator.

Objective Function

An objective function is not required for a sampling run, but may be provided. If an objective function is provided the returned value will be recorded in the f field of the history file. The objective function must return a single value of type float.

 1   # As passed to options.objective_function:
 2   def obj_f(J):
 3       # Objective function is always passed
 4       # to the rsopt job dictionary `J`
 5
 6       # ... Code to calculate objective value `f`
 7
 8       return f
 9
10   # Example if using code block type `python`
11   # without options.objective_function:
12   def my_function(x, y):
13       # Assuming user defined `parameters` (x, y)
14       # in the configuration file
15
16       f = x**2 + y**2 + x * y
17
18       return f