perturb method

num perturb(
  1. List<num> position,
  2. List<num> deltaPosition
)

Returns the energy at a point selected randomly from the region (position - deltaPosition, position + deltaPosition).

  • The quantity deltaPosition represents a vector. Each component specifies the max. perturbation magnitude along the corrsponding dimension.
  • The new position can be accessed via the getter this.position. The return value of perturb() can also be accessed via this.value.

Implementation

num perturb(List<num> position, List<num> deltaPosition) {
  _position = space.perturb(
    position,
    deltaPosition,
  );
  _value = energy(_position);
  if (_value < _minValue) {
    _minValue = _value;
    _minPosition = _position;
  }
  return _value;
}