Skip to content

Latest commit

 

History

History
219 lines (152 loc) · 7.93 KB

utils_grid.md

File metadata and controls

219 lines (152 loc) · 7.93 KB

Convex Hull (Pareto-Optimal) MLP Search

Note: Requires version 0.19.1 or later.

The accuracy and computational efficiency of the polynomial MLP strongly depend on the input parameters, which include:

  1. The cutoff radius
  2. The type of polynomial function
  3. The order of the polynomial function
  4. The number of radial Gaussian functions
  5. The truncation of the polynomial invariants, i.e., the maximum angular numbers of spherical harmonics and the maximum polynomial order of invariants

To determine the optimal values, a systematic grid search for each system can be employed.

In general, accuracy and computational efficiency are conflicting properties, and their trade-off should be optimized. However, there is no single optimal solution to this multi-objective optimization problem, which involves several conflicting objectives. In such cases, the convex-hull (Pareto-optimal) points represent optimal solutions with different trade-offs between accuracy and computational efficiency. No other points can simultaneously improve both the accuracy and computational efficiency compared to the convex-hull (Pareto-optimal) points.

1. Systematic Generation of Input Files for Polynomial MLP Development

pypolymlp-utils supports the systematic generation of input files for candidate polynomial MLP models. Given a set of elements or a system, candidate values for the cutoff radius and the number of Gaussians are automatically determined. For other parameters, such as the truncation of polynomial invariants, candidate values are systematically enumerated.

Using Command-Line Interface

# For elemental systems
pypolymlp-utils --generate_models --elements Be

# Enumeration with hybrid models for elemental systems
pypolymlp-utils --generate_models --elements Si --enable_hybrid

# For binary alloy systems
pypolymlp-utils --generate_models --elements Ag Au
pypolymlp-utils --generate_models --generate_models_system Ag-Au

# For ternary alloy systems
pypolymlp-utils --generate_models --elements Cu Ag Au
pypolymlp-utils --generate_models --generate_models_system Cu-Ag-Au

Input files for the enumerated models can be found in the polymlps directory. To include hybrid models, which are represented by the sum of two or more polynomial MLP models, use the --enable_hybrid option.

Using Python API

Input files for candidate models can also be generated using the Python API.

from pypolymlp.api.pypolymlp_utils import PypolymlpUtils

elements = ["Ag", "Au"]
utils = PypolymlpUtils(verbose=True)
utils.enumerate_models(path="polymlps")

When including hybrid models, set hybrid=True in the enumerate_models function. Input files for the enumerated models can be found in the polymlps directory.

from pypolymlp.api.pypolymlp_utils import PypolymlpUtils

elements = ["Ag", "Au"]
utils = PypolymlpUtils(verbose=True)
utils.enumerate_models(path="polymlps", hybrid=True)

When changing the upper bound values that control the number of candidate models, the following options can be used to specify model parameters. See Notes on Polymlp Parameters for details on the input parameters.

from pypolymlp.api.pypolymlp_utils import PypolymlpUtils

elements = ["Ag", "Au"]
utils = PypolymlpUtils(verbose=True)
utils.enumerate_models(
    model_types=(2, 3, 4),
    maxps=(2,),
    gtinv=True,
    gtinv_order_ub=3,
    gtinv_maxl_ub=(16, 12),
    gtinv_maxl_int=(8, 4),
    include_force=True,
    include_stress=True,
    regression_alpha=(-4, 1, 6),
    path="polymlps",
    hybrid=True,
)

2. Systematic MLP development

Using the generated input files, MLPs are then systematically evaluated. For details on developing each MLP, see MLP development (Command-line).

Note that the input files generated by pypolymlp-utils do not include dataset locations and atomic energy values. Before running the MLP development, these must be specified for each model.

3. Computational Cost Estimation of MLPs

Once MLPs with various models have been systematically evaluated, the computational cost of calculating the properties must also be assessed in order to evaluate the trade-off between computational cost and accuracy.

The calc_cost option in pypolymlp-utils calculates the properties of a structure multiple times and estimates the computational time per atom required for a single run of energy, force, or virial stress tensor calculations. For each MLP, a file named polymlp_cost.yaml is generated, containing the computational costs necessary for identifying convex-hull (Pareto-optimal) MLPs.

Single polynomial MLP

To estimate the computational cost for a single MLP or a hybrid MLP, specify the polymlp file using the --pot option as follows:

> pypolymlp-utils --calc_cost --pot polymlp.yaml

# hybrid polynomial MLP
> pypolymlp-utils --calc_cost --pot polymlp.yaml*

Multiple polynomial MLPs

When the computational costs of multiple MLPs, which have been systematically developed, are evaluated simultaneously, the -d option can be used to specify the directory paths containing the MLP files.

Consider the following file and directory structures, which can be found in examples/utils/mlp_opt/.

> ls Ag-Au
polymlp-00001/  polymlp-00003/  polymlp-00005/  polymlp-00007/  polymlp-00009/
polymlp-00002/  polymlp-00004/  polymlp-00006/  polymlp-00008/

> ls Ag-Au/polymlp-00*
Ag-Au/polymlp-00001:
polymlp.yaml

Ag-Au/polymlp-00002:
polymlp.yaml

Ag-Au/polymlp-00003:
polymlp.yaml

Ag-Au/polymlp-00004:
polymlp.yaml

Ag-Au/polymlp-00005:
polymlp.yaml

Ag-Au/polymlp-00006:
polymlp.yaml

Ag-Au/polymlp-00007:
polymlp.yaml

Ag-Au/polymlp-00008:
polymlp.yaml

Ag-Au/polymlp-00009:
polymlp.yaml

To obtain the computational costs for all MLPs in this example, the directory paths can be specified as follows:

> pypolymlp-utils --calc_cost -d Ag-Au/polymlp-00*

Once the estimation is complete, polymlp_cost.yaml files are generated for all MLPs in each directory.

4. Convex Hull MLP Search

Consider the following file and directory structures, which can be found in examples/utils/mlp_opt/.

> ls Ag-Au
polymlp-00001/  polymlp-00003/  polymlp-00005/  polymlp-00007/  polymlp-00009/
polymlp-00002/  polymlp-00004/  polymlp-00006/  polymlp-00008/

> ls Ag-Au/polymlp-00*

Ag-Au/polymlp-00001:
polymlp.yaml  polymlp_cost.yaml  polymlp_error.yaml

Ag-Au/polymlp-00002:
polymlp.yaml  polymlp_cost.yaml  polymlp_error.yaml

Ag-Au/polymlp-00003:
polymlp.yaml  polymlp_cost.yaml  polymlp_error.yaml

Ag-Au/polymlp-00004:
polymlp.yaml  polymlp_cost.yaml  polymlp_error.yaml

Ag-Au/polymlp-00005:
polymlp.yaml  polymlp_cost.yaml  polymlp_error.yaml

Ag-Au/polymlp-00006:
polymlp.yaml  polymlp_cost.yaml  polymlp_error.yaml

Ag-Au/polymlp-00007:
polymlp.yaml  polymlp_cost.yaml  polymlp_error.yaml

Ag-Au/polymlp-00008:
polymlp.yaml  polymlp_cost.yaml  polymlp_error.yaml

Ag-Au/polymlp-00009:
polymlp.yaml  polymlp_cost.yaml  polymlp_error.yaml

In each directory corresponding to an MLP, there are two files: polymlp_error.yaml, generated during MLP development, and polymlp_cost.yaml, generated from the computational cost estimation described above.

Using these files, a set of convex-hull MLPs can be identified with the --find_optimal option in pypolymlp-utils. In this example, the optimal MLPs on the convex hull can be identified as follows:

> pypolymlp-utils --find_optimal Ag-Au/* --key test-disp1

The --key option defines the prediction error used in this search and specifies which dataset is used to estimate that error. In this example, a dataset whose name includes "test-disp1" is used to define the prediction error. This option must be specified according to the dataset names provided by the user.

Once the search is complete, polymlp_summary_all.yaml, containing the attributes of all MLPs, and polymlp_summary_convex.yaml, containing the attributes of the MLPs on the convex hull of computational cost versus prediction error, are generated.