GroupSelector contains parent classes for all group selectors. A GroupSelector is used at the stochastic engine’s runtime to select groups upon which a move will be applied. Therefore it has become possible to fully customize the selection of groups of atoms and to choose when and how frequently a group can be chosen to perform a move upon.

Bases: object
Group selector is the parent class that selects groups to perform moves at stochastic engine’s runtime.
engine (None, fullrmc.Engine): Selector’s stochastic engine instance.
Create a selector instance given instantiation parameters.
params (dict): Instantiation parameters as returned by the
parameters property.
engine (None, fullrmc.Engine): The stochastic engine to attach to the created selector instance.
obj (GroupSelector): The created instance.
Get current state and instantiation parameters.
parameters (dict): A dictionary holding the class definition
name and the constructor keyword arguments. This is the
exact dictionary consumed by create to rebuild an
identical selector instance.
Design pattern implementation, must be overloaded by every GroupSelector sub-class that needs a way to update its state.
params (dict): The update parameters, sub-class specific.
Stochastic engine’s instance.
engine (None, fullrmc.Engine): The selector’s stochastic engine instance.
Get refine flag value. It will always return False because refine is a property of RecursiveGroupSelector instances only.
refine (bool): Always False on a plain GroupSelector.
Get explore flag value. It will always return False because explore is a property of RecursiveGroupSelector instances only.
explore (bool): Always False on a plain GroupSelector.
Get whether next step a new selection is occur or still the same group is going to be selected again. It will always return True because recurrence is a property of RecursiveGroupSelector instances only.
willSelect (bool): Always True on a plain GroupSelector.
Get whether next step the same group will be returned. It will always return False because this is a property of RecursiveGroupSelector instances only.
willRecur (bool): Always False on a plain GroupSelector.
Get whether selection is recurring and refine flag is True. It will always return False because recurrence is a property of RecursiveGroupSelector instances only.
willRefine (bool): Always False on a plain GroupSelector.
Get whether selection is recurring and explore flag is True. It will always return False because recurrence is a property of RecursiveGroupSelector instances only.
willExplore (bool): Always False on a plain GroupSelector.
Get whether the last step a new selection was made. It will always return True because recurrence is a property of RecursiveGroupSelector instances only.
isNewSelection (bool): Always True on a plain GroupSelector.
Get whether the last step the same group was returned. It will always return False because this is a property of RecursiveGroupSelector instances only.
isRecurring (bool): Always False on a plain GroupSelector.
Get whether selection is recurring and refine flag is True. It will always return False because recurrence is a property of RecursiveGroupSelector instances only.
isRefining (bool): Always False on a plain GroupSelector.
Get whether selection is recurring and explore flag is True. It will always return False because recurrence is a property of RecursiveGroupSelector instances only.
isExploring (bool): Always False on a plain GroupSelector.
Set selector’s stochastic engine instance.
engine (None, fullrmc.Engine): Selector’s stochastic engine.
This method must be overloaded in every GroupSelector sub-class
index (integer): the selected group index in engine groups list.
This method is called by the stochastic engine when a move generated on a group is accepted. This method is empty must be overloaded when needed.
index (integer): the selected group index in engine groups list.
This method is called by the stochastic engine when a move generated on a group is rejected. This method is empty must be overloaded when needed.
index (integer): the selected group index in engine groups list.
Bases: GroupSelector
Recursive selector is the only selector that can use the recursive property on a selection. It is used as a wrapper around a GroupSelector instance.
selector (fullrmc.Core.GroupSelector.GroupSelector): The selector instance to wrap.
recur (integer): Set number of times to recur. It must be a positive integer.
override (boolean): Override temporary recur value. recur value will be overridden only when selected group move generator is a PathGenerator instance. In this particular case, recur value will be temporary changed to the number of moves stored in the PathGenerator. If selected group move generator is not a PathGenerator instance, recur value will take back its original value.
refine (boolean): Its an engine flag that is used to refine the position of a group until recurrence expires and a new group is selected. Refinement is done by applying moves upon the selected group always from its initial position at the time it was selected until recurrence expires, then the best position is kept.
explore (boolean): Its an engine flag that is used to make a group explore the space around it until recurrence expires and a new group is selected. Exploring is done by applying moves upon the selected group starting from its initial position and evolving in a trajectory like way until recurrence expires, then the best position is kept.
NB: refine and explore flags can’t both be set to True at the same time. When this happens refine flag gets automatically switched to False. The usage of those flags is very important because they allow groups of atoms to go out of local minima in the energy surface. The way traditional reverse mote carlo works is by minimizing the total energy of the system (error) using gradient descent method. Using of those flags allows the system to go up hill in the energy surface searching for other lower minimas, while always conserving the lowest energy state found and not changing the system structure until a better structure with smaller error is found.
The following video compares the Reverse Monte Carlo traditional fitting mode with fullrmc's recursive selection one with explore flag set to True. From a potential point of view, exploring allows to cross forbidden unlikely energy barriers and going out of local minimas.
The following video is an example of refining the position of a molecule using RecursiveGroupSelector and setting refine flag to True. The molecule is always refined from its original position towards a new one generated by the move generator.
The following video is an example of exploring the space of a molecule using RecursiveGroupSelector and setting explore flag to True. The molecule explores the allowed space by wandering via its move generator and only moves enhancing the structure are stored.
# import fullrmc modules
from fullrmc.Engine import Engine
from fullrmc.Core.GroupSelector import RecursiveGroupSelector
# create engine
ENGINE = Engine(path='my_engine.stc')
# set pdb file
ENGINE.set_pdb('system.pdb')
# Add constraints ...
# Re-define groups if needed ...
# Re-define groups selector if needed ...
##### Wrap engine group selector with a recursive group selector. #####
# create recursive group selector. Recurrence is set to 20 with explore flag set to True.
RGS = RecursiveGroupSelector(ENGINE.groupSelector, recur=20, refine=False, explore=True)
ENGINE.set_group_selector(RGS)
Create a selector instance given instantiation parameters.
params (dict): Instantiation parameters as returned by the
parameters property.
engine (None, fullrmc.Engine): The stochastic engine to attach to the created wrapped selector instance.
obj (RecursiveGroupSelector): The created instance.
Get current state and instantiation parameters.
parameters (dict): A dictionary holding the class definition name, the wrapped selector’s own parameters, and the recur, override, refine and explore constructor keyword arguments.
The wrapped selector instance.
selector (GroupSelector): The wrapped selector instance.
The last selected group index.
lastSelectedIndex (None, integer): The last selected group index in the engine’s groups list, or None if no selection has been made yet.
Get whether next step a new selection is occur or still the same group is going to be selected again.
willSelect (bool): Whether next step a new selection will be made.
Get whether next step the same group will be returned.
willRecur (bool): Whether next step the same group is returned.
Get whether next step the same group will be returned and refine flag is True.
willRefine (bool): Whether next step will refine.
Get whether next step the same group will be returned and explore flag is True.
willExplore (bool): Whether next step will explore.
Get whether this last step a new selection was made.
isNewSelection (bool): Whether the last step made a new selection.
Get whether this last step the same group was returned.
isRecurring (bool): Whether the last step recurred on the same group.
Get whether this last step the same group was returned and refine flag is True.
isRefining (bool): Whether the last step was a refining recurrence.
Get whether this last step the same group was returned and explore flag is True.
isExploring (bool): Whether the last step was an exploring recurrence.
Override flag value.
override (bool): The override flag value.
Refine flag value.
refine (bool): The refine flag value.
Explore flag value.
explore (bool): The explore flag value.
The current recur value which is selected group dependant when override flag is True.
currentRecur (integer): The current, possibly overridden, recur value.
The current recur value. The set recur value can change during engine runtime if override flag is True. To get the recur value as set by set_recur method recurAsSet must be used.
recur (integer): The current recur value.
Get recur value as set but set_recur method.
recurAsSet (integer): The recur value as originally set via set_recur, unaffected by runtime overriding.
Get the position of the selector in the path.
position (integer): The current position counter, i.e. the number of recurring steps already taken since the last new selection.
Get the wrapped selector engine instance.
engine (None, fullrmc.Engine): The wrapped selector’s stochastic engine instance.
Sets the wrapped selector stochastic engine instance.
engine (None, fullrmc.Engine): The selector stochastic engine.
Sets the recur value.
recur (integer): Set the recur value. It must be a positive integer.
Select override value.
override (boolean): Override selector recur value only when selected group move generator is a PathGenerator instance. Overridden recur value is temporary and totally selected group dependant. If selected group move generator is not a PathGenerator instance, recur value will take back selector’s recur value.
Set the refine flag value.
refine (boolean): Its an engine flag that is used to refine the position of a group until recurrence expires and a new group is selected. Refinement is done by applying moves upon the selected group always from its initial position at the time it was selected until recurrence expires, then the best position is kept.
Set the explore flag value.
explore (boolean): Its an engine flag that is used to make a group explore the space around it until recurrence expires and a new group is selected. Exploring is done by applying moves upon the selected group starting from its initial position and evolving in a trajectory like way until recurrence expires, then the best position is kept.
Select new index.
index (integer): the selected group index in engine groups list.
OrderedSelectors contains GroupSelector classes that select groups in a user-defined or automatically computed order.

Bases: GroupSelector
DefinedOrderSelector is a group selector with a user-defined order of selection.
engine (None, fullrmc.Engine): The engine instance used by the selector.
order (None, list, set, tuple, numpy.ndarray): The order in which groups are selected. If None, the order is automatically set to the full list of group indexes.
# import external libraries
import numpy as np
# import fullrmc modules
from fullrmc.Engine import Engine
from fullrmc.Selectors.OrderedSelectors import DefinedOrderSelector
# create engine
ENGINE = Engine(path='my_engine.stc')
# set pdb file
ENGINE.set_pdb('system.pdb')
# Add constraints ...
# Re-define groups if needed ...
# Re-define groups generators as needed ...
##### set the order of selection from closest to the origin to the further. #####
# compute groups centers
centers = [np.sum(ENGINE.realCoordinates[g.indexes], axis=0)/len(g) for g in ENGINE.groups]
# compute distances to origin
distances = [np.sqrt(np.add.reduce(c**2)) for c in centers]
# compute increasing order
order = np.argsort(distances)
# set group selector
ENGINE.set_group_selector( DefinedOrderSelector(engine=ENGINE, order=order) )
Get current state and instantiation parameters.
parameters (dict): The current state and instantiation parameters dictionary.
Update instance using parameters
params (dict): instantiation parameters. Can be pure (key,value) dictionary or as returned from parameters instance property
A copy of the group-selection order, as a list of group indexes, or None if no order has been set yet.
The current pointer position within order. This is not a group index; the next group index is order[index % len(order)].
Set the selector’s group order.
order (None, list, set, tuple, numpy.ndarray): The order in which groups are selected.
Select a group index.
index (integer): The selected group’s index in the engine’s groups list.
Bases: DefinedOrderSelector
DirectionalOrderSelector is a group selector whose order of selection is computed automatically at engine runtime. Each group’s distance to a center is computed, and the order is set from the farthest to the closest group if expand is True, or from the closest to the farthest if expand is False.
engine (None, fullrmc.Engine): The engine instance used by the selector.
center (None, string, list, tuple, numpy.ndarray): The center of expansion. If None, the center is automatically set to the origin (0,0,0). If a list, tuple, or numpy.ndarray, it must be the center position as (x,y,z). If a string, the center is calculated at runtime upon calling the run method. It must be a valid element weighting scheme defined in the pdbparser database, in addition to ‘geometric’, ‘x’, ‘xrays’, ‘x-rays’, ‘xray’, ‘x-ray’, ‘neutron’, ‘neutrons’.
expand (bool): Whether to set the order from the farthest to the closest group, or from the closest to the farthest if set to False.
adjustMoveGenerators (bool): If set to True, all groups’ move generator instances will be automatically replaced at engine runtime by a MoveGeneratorCollector combining a TranslationTowardsCenterGenerator and a RotationGenerator (the latter only for groups of more than one atom). Generator parameters can be given through generatorsParams. It is advisable to set this flag to True to take advantage of automatic, intelligent directional moves.
generatorsParams (None, dict): Parameters for the automatically created move generators. If None, default parameters are used. If a dictionary is given, only two keys are allowed. ‘TG’ is for TranslationTowardsCenterGenerator parameters and ‘RG’ is for RotationGenerator parameters. The TranslationTowardsCenterGenerator amplitude is not the same for every group; groups closer to the center are intelligently allowed to move less than groups farther away, according to the damping parameter.
Parameters are the following:
TG_amp = generatorsParams[‘TG’][‘amplitude’]: TranslationTowardsCenterGenerator’s amplitude parameter.
TG_ang = generatorsParams[‘TG’][‘angle’]: TranslationTowardsCenterGenerator’s angle parameter.
TG_dam = generatorsParams[‘TG’][‘damping’]: Fractional damping applied to TG_amp based on distance from the center.
RG_ang = generatorsParams[‘RG’][‘amplitude’]: RotationGenerator’s amplitude parameter.
Parameters are used as the following:
TG = TranslationTowardsCenterGenerator(center={“fixed”:center}, amplitude=AMPLITUDE, angle=TG_ang)
Where TG_amp*TG_dam <= AMPLITUDE <= TG_amp, groups closer to the center getting the smaller amplitude.
RG = RotationGenerator(amplitude=RG_ang)
MoveGeneratorCollector(collection=[TG,RG], randomize=True)
NB: These parameters are not checked for errors until engine runtime.
# import fullrmc modules
from fullrmc.Engine import Engine
from fullrmc.Selectors.OrderedSelectors import DirectionalOrderSelector
# create engine
ENGINE = Engine(path='my_engine.stc')
# set pdb file
ENGINE.set_pdb('system.pdb')
# Add constraints ...
# Re-define groups if needed ...
# Re-define groups generators as needed ...
# Set the order of selection from the farthest to the closest to (1,1,1).
# Automatically adjust the groups' move generators, allowing modulation of amplitudes.
ENGINE.set_group_selector( DirectionalOrderSelector(engine = ENGINE,
center = (1,1,1),
adjustMoveGenerators = True) )
Get current state and instantiation parameters.
parameters (dict): The current state and instantiation parameters dictionary.
Update instance using parameters
params (dict): instantiation parameters. Can be pure (key,value) dictionary or as returned from parameters instance property
The expand flag.
The center of expansion: (X,Y,Z) coordinates once resolved, or still the original weighting-scheme string if runtime resolution hasn’t happened yet.
The adjustMoveGenerators flag.
The automatic move generators’ parameters.
Set the move generators’ parameters.
generatorsParams (None, dict): Parameters for the automatically created move generators. If None, default parameters are used. If a dictionary is given, only two keys are allowed. ‘TG’ is for TranslationTowardsCenterGenerator parameters and ‘RG’ is for RotationGenerator parameters. The TranslationTowardsCenterGenerator amplitude is not the same for every group; groups closer to the center are intelligently allowed to move less than groups farther away, according to the damping parameter.
Parameters are the following:
TG_amp = generatorsParams[‘TG’][‘amplitude’]: TranslationTowardsCenterGenerator’s amplitude parameter.
TG_ang = generatorsParams[‘TG’][‘angle’]: TranslationTowardsCenterGenerator’s angle parameter.
TG_dam = generatorsParams[‘TG’][‘damping’]: Fractional damping applied to TG_amp based on distance from the center.
RG_ang = generatorsParams[‘RG’][‘amplitude’]: RotationGenerator’s amplitude parameter.
Parameters are used as the following:
TG = TranslationTowardsCenterGenerator(center={“fixed”:center}, amplitude=AMPLITUDE, angle=TG_ang)
Where TG_amp*TG_dam <= AMPLITUDE <= TG_amp, groups closer to the center getting the smaller amplitude.
RG = RotationGenerator(amplitude=RG_ang)
MoveGeneratorCollector(collection=[TG,RG], randomize=True)
NB: These parameters are not checked for errors until engine runtime.
Set the center.
center (None, string, list, tuple, numpy.ndarray): The center of expansion. If None, the center is automatically set to the origin (0,0,0). If a list, tuple, or numpy.ndarray, it must be the center position as (x,y,z). If a string, the center is calculated at runtime upon calling the run method. It must be a valid element weighting scheme defined in the pdbparser database, in addition to ‘geometric’, ‘x’, ‘xrays’, ‘x-rays’, ‘xray’, ‘x-ray’, ‘neutron’, ‘neutrons’.
Set the expand flag.
expand (bool): Whether to set the order from the farthest to the closest group, or from the closest to the farthest if set to False.
Set the adjustMoveGenerators flag.
adjustMoveGenerators (bool): If set to True, all groups’ move generator instances will be automatically replaced at engine runtime by a MoveGeneratorCollector combining a TranslationTowardsCenterGenerator and a RotationGenerator (the latter only for groups of more than one atom). Generator parameters can be given through generatorsParams. It is advisable to set this flag to True to take advantage of automatic, intelligent directional moves.
RandomSelectors contains GroupSelector classes that select groups in random order.

The example below demonstrates machine learning applied to group selection.
Each group is set to a single atom and assigned a random translation move
generator, with two different amplitudes used so that moves are accepted at
different ratios. SmartRandomSelector is used to enable machine
learning on top of this group selection. No experimental constraints are
used; only inter-molecular distance, intra-molecular bond, angle, and
improper angle constraints are applied to preserve the integrity of the
system and its molecules. As shown below, machine learning on group
selection is highly effective at improving the ratio of accepted moves.
Still, how fast the system converges, and how high the acceptance ratio
gets, remains strongly correlated with the move generator assigned to each
group.
25% of the assigned move generators have their amplitude set to \(10 \AA\), so very few of their moves are accepted; the remaining 75% have their amplitude set to \(0.3 \AA\).¶ |
25% of the assigned move generators have their amplitude set to \(10 \AA\), so very few of their moves are accepted; the remaining 75% have their amplitude set to \(0.25 \AA\).¶ |
random() -> x in the interval [0, 1).
Bases: GroupSelector
RandomSelector generates group indexes randomly for engine group selection.
engine (None, fullrmc.Engine): The engine instance used by the selector.
# import external libraries
import numpy as np
# import fullrmc modules
from fullrmc.Engine import Engine
from fullrmc.Selectors.RandomSelectors import RandomSelector
# create engine
ENGINE = Engine(path='my_engine.stc')
# set pdb file
ENGINE.set_pdb('system.pdb')
# Add constraints ...
# Re-define groups if needed ...
# Re-define groups generators as needed ...
# set group selector as random selection from all defined groups.
ENGINE.set_group_selector( RandomSelector(engine=ENGINE) )
Get current state and instantiation parameters.
parameters (dict): The current state and instantiation parameters dictionary.
Select a group index.
index (integer): The selected group’s index in the engine’s groups list.
Bases: RandomSelector
WeightedRandomSelector generates group indexes randomly, following a per-group weighting scheme.
engine (fullrmc.Engine): The engine instance used by the selector.
weights (None, list): Weights list. It must be None for equivalent weighting, or a list of (groupIndex, weight) tuples.
# import fullrmc modules
from fullrmc.Engine import Engine
from fullrmc.Selectors.RandomSelectors import WeightedRandomSelector
# create engine
ENGINE = Engine(path='my_engine.stc')
# set pdb file
ENGINE.set_pdb('system.pdb')
# Add constraints ...
# Re-define groups if needed ...
# Re-define groups generators as needed ...
# set group selector as random selection but with double likelihood to
# selecting the first and the last group.
WEIGHTS = [[idx,1] for idx in range(len(ENGINE.groups))]
WEIGHTS[0][1] = WEIGHTS[-1][1] = 2
ENGINE.set_group_selector( WeightedRandomSelector(engine=ENGINE, weights=WEIGHTS) )
Get current state and instantiation parameters.
parameters (dict): The current state and instantiation parameters dictionary.
Update instance using parameters
params (dict): instantiation parameters. Can be pure (key,value) dictionary or as returned from parameters instance property
Groups’ weights, as set upon initialization or via set_weights.
Groups’ normalized selection weight at the current state, derived from selectionScheme.
Cumulative selection scheme (normalized cumulative sum of groups’ weights) used to pick a group index upon selection.
Set the groups’ selection weighting scheme.
weights (None, list): Weights list. It must be None for equivalent weighting, or a list of (groupIndex, weight) tuples.
Set a single group’s weight.
groupWeight (list, set, tuple): Group weight tuple composed of the group index as first element and the group’s weight as second.
Select a group index.
index (integer): The selected group’s index in the engine’s groups list.
Bases: WeightedRandomSelector
SmartRandomSelector is a random group selector fed by a machine learning algorithm. Group index generation is biased and evolves throughout the simulation towards selecting groups with a more successful history of accepted moves.
engine (fullrmc.Engine): The engine instance used by the selector.
weights (None, list): Weights list fed as the initial biasing scheme. It must be None for equivalent weighting, or a list of (groupIndex, weight) tuples.
biasFactor (Number): The biasing factor added to a group’s weight when one of its moves is accepted. Must be a positive number.
unbiasFactor(None, Number): Whether to unbias a group’s weight when one of its moves is rejected. If None, unbiasing is turned off. Unbiasing is only performed while the group’s weight remains positive.
# import fullrmc modules
from fullrmc.Engine import Engine
from fullrmc.Selectors.RandomSelectors import SmartRandomSelector
# create engine
ENGINE = Engine(path='my_engine.stc')
# set pdb file
ENGINE.set_pdb('system.pdb')
# Add constraints ...
# Re-define groups if needed ...
# Re-define groups generators as needed ...
# set group selector as random smart selection that will adjust its
# weighting scheme to improve the chances of moves getting accepted.
ENGINE.set_group_selector( SmartRandomSelector(engine=ENGINE) )
Get current state and instantiation parameters.
parameters (dict): The current state and instantiation parameters dictionary.
Update instance using parameters
params (dict): instantiation parameters. Can be pure (key,value) dictionary or as returned from parameters instance property
The biasing factor.
The unbiasing factor.
Set the biasing factor.
biasFactor (Number): The biasing factor added to a group’s weight when one of its moves is accepted. Must be a positive number.
Set the unbiasing factor.
unbiasFactor(None, Number): Whether to unbias a group’s weight when one of its moves is rejected. If None, unbiasing is turned off. Unbiasing is only performed while the group’s weight remains positive.
Called by the engine when a move generated on a group is accepted. Increases the selection weight of the accepted group (and all groups after it in the cumulative scheme) by biasFactor.
index (integer): the selected group index in engine groups list
Called by the engine when a move generated on a group is rejected. If unbiasFactor is not None, decreases the selection weight of the rejected group (and all groups after it in the cumulative scheme) by unbiasFactor, as long as its weight stays positive.
index (integer): the selected group index in engine groups list
Select a group index.
index (integer): The selected group’s index in the engine’s groups list.