Objective_function.objective_function module

Description

This module defines the ParaMol.Objective_function.objective_function.ObjectiveFunction class, which is a ParaMol representation of the objective function.

class ParaMol.Objective_function.objective_function.ObjectiveFunction(restart_settings, parameter_space, properties, systems, platform_name, parallel=False, weighting_method='uniform', weighting_temperature=Quantity(value=300, unit=kelvin), checkpoint_freq=1000)

Bases: object

ParaMol representation of the objective function.

Parameters
  • restart_settings (dict) – Dictionary containing restart ParaMol settings.

  • parameter_space (ParaMol.Parameter_space.parameter_space.ParameterSpace) – ParaMol representation of ParameterSpace.

  • properties (list of ParaMol.ObjectiveFunction.Properties) – List of property object instances.

  • systems (list of ParaMol.System.system.ParaMolSystem) – List containing instances of ParaMol systems.

  • platform_name – Name of the OpenMM platform. Only options are ‘Reference’, ‘CPU’ and ‘OpenCL’.

  • parallel (bool, default=`False`) – Flag that signals if the objective function calculation is to be performed in parallel.

  • weighting_method (str, default="uniform") – Method used to weight the conformations. Available methods are “uniform, “boltzmann” and “non-boltzmann”.

  • weighting_temperature (unit.simtk.Quantity, default=300.0*unit.kelvin) – Temperature used in the weighting. Only relevant if weighting_method is “boltzmann” or “non_boltzmann”.

  • checkpoint_freq (int) – Frequency at which checkpoint files are saved.

Variables
calculate_objective_function(parameters_values, fmm, emm, esp)

Method that performs the necessary steps to calculate the objective function.

Notes

This is a shared function of both parallel and serial version since performance-speaking it does not compensate to parallelize this function. The conformations weights for the current force field parameters are calculated inside this method.

Parameters
  • parameters_values (list of floats) – Lists containing the optimizable values of the parameters.

  • fmm (np.array) – Forces array.

  • emm (np.array) – Energies array.

  • esp (np.array) – Electrostatic potential array.

Returns

objective_function (float) – Value of the objective function.

f(parameters_values, opt_mode=True)

Method that calculates the objective function for a given set of parameters.

Parameters
  • parameters_values (list of floats) – Lists containing the optimizable values of the parameters.

  • opt_mode (bool) – Flag that signal whether this objective function . If it is not, there is more verbose.

Returns

objective_function (float) – Value of the objective function.

get_f_count()

Method that retrieves the objective function evaluation counter.

Returns

int – Number of times that the objective function has been evaluated.

init_parallel()

Method that initializes the variables and calls the functions necessary to perform parallel objective function evaluation.

Returns

int – Number of parallel calculation batches.

reset_f_count()

Method that resets the objective function evaluation counter.

Returns

int – Number of times that the objective function has been evaluated (should be equal to 0).