fragile.optimize.env
Contents
fragile.optimize.env
#
Module Contents#
Classes#
Apply |
|
Wrapper that applies a local minimization process to the observations returned by a |
|
Environment that represents an arbitrary mathematical function bounded in a given interval. |
- class fragile.optimize.env.Minimizer(function, bounds=None, **kwargs)[source]#
Apply
scipy.optimize.minimize
to aFunction
.- Parameters
function (fragile.core.env.Function) –
- minimize(x)[source]#
Apply
scipy.optimize.minimize
to a single point.- Parameters
x (judo.typing.Tensor) – Array representing a single point of the function to be minimized.
- Returns
Optimization result object returned by
scipy.optimize.minimize
.
- minimize_point(x)[source]#
Minimize the target function passing one starting point.
- Parameters
x (judo.typing.Tensor) – Array representing a single point of the function to be minimized.
- Returns
Tuple containing a numpy array representing the best solution found, and the numerical value of the function at that point.
- Return type
Tuple[judo.typing.Tensor, judo.typing.Scalar]
- minimize_batch(x)[source]#
Minimize a batch of points.
- Parameters
x (judo.typing.Tensor) – Array representing a batch of points to be optimized, stacked across the first dimension.
- Returns
Tuple of arrays containing the local optimum found for each point, and an array with the values assigned to each of the points found.
- Return type
Tuple[judo.typing.Tensor, judo.typing.Tensor]
- class fragile.optimize.env.MinimizerWrapper(function, **kwargs)[source]#
Bases:
fragile.core.env.Function
Wrapper that applies a local minimization process to the observations returned by a
Function
.- Parameters
function (fragile.core.env.Function) –
- property function#
Return the function of the wrapped environment.
- Return type
Callable
- property bounds#
Return the bounds of the wrapped environment.
- Return type
judo.Bounds
- property custom_domain_check#
Return the custom_domain_check of the wrapped environment.
- Return type
Callable
- class fragile.optimize.env.ParticleSimulation(step_size=1.0, steps=10, **kwargs)[source]#
Bases:
fragile.core.env.Function
Environment that represents an arbitrary mathematical function bounded in a given interval.
- default_inputs#
- default_outputs = ['observs', 'rewards', 'oobs', 'velocities']#
- classmethod from_instance(function, step_size=1, steps=1, x0=None, start_same_pos=False)[source]#
- Parameters
function (fragile.core.env.Function) –
step_size (float) –
start_same_pos (bool) –
- property param_dict#
Return the dictionary defining all the data attributes that the component requires.
- Return type
fragile.core.typing.StateDict
- fai_leapfrog(init_pos, init_momentum, grad, step_size, function, force=None)[source]#
Perfom a leapfrog jump in the Hamiltonian space INPUTS —— init_pos: ndarray[float, ndim=1]
initial parameter position
- init_momentum: ndarray[float, ndim=1]
initial momentum
- grad: float
initial gradient value
- step_size: float
step size
- function: callable
it should return the log probability and gradient evaluated at theta logp, grad = function(theta)
- new_position: ndarray[float, ndim=1]
new parameter position
- new_momentum: ndarray[float, ndim=1]
new momentum
- gradprime: float
new gradient
- new_potential: float
new lnp
- step(actions, observs, velocities, **kwargs)[source]#
Sum the target action to the observations to obtain the new points, and evaluate the reward and boundary conditions.
- Returns
Dictionary containing the information of the new points evaluated.
{"states": new_points, "observs": new_points, "rewards": typing.Scalar array, "oobs": boolean array}
- Return type
fragile.core.typing.StateData