Skip to content

Newton

Newton(HP=NewtonParameters(), verbose=NewtonVerboseOptions(), **kwargs)

Bases: Logger

Newton's algorithm to find the minimum of a function knowing its gradient and hessian.

References

[1] https://won-j.github.io/M1399_000200-2021fall/lectures/22-newton/newton_constr.html

optimize(x_init)

Alias of the 'run' method.

Parameters:

Name Type Description Default
x_init ndarray

initial values for the variables.

required

Returns:

Name Type Description
float float

final value of the energy

register_constraints(A, l=None, u=None)

Adds linear constraints to the optimization problem :

min_X F(X) s.t. l <= AX <= u

Parameters:

Name Type Description Default
cstMat spmatrix

constraint matrix, either dense or sparse

required
cstL ndarray

vector l. Defaults to None.

required
cstR ndarray

vector u. Defaults to None.

required

register_function(fun, fun_noG=None)

Adds a function to minimize.

Parameters:

Name Type Description Default
fun python callable

A function taking a single argument X (np.array) returning a real value F, a gradient G and a hessian matrix H

required
fun_noG python callable

The same function that avoids the computation of the gradient and the hessian for speed purposes. If not provided, will use the function provided above and ignore the other arguments.

None

run(x_init)

Runs the optimizer

Parameters:

Name Type Description Default
x_init ndarray

initial values for the variables.

required

Returns:

Name Type Description
float

final value of the energy

NewtonParameters(N_ITER_MAX=1000, MIN_STEP_NORM=1e-06, MIN_DELTA_F=1e-08, MIN_GRAD_NORM=1e-08, alpha_init=1.0, c1=0.0001, rho=0.5) dataclass

Hyper parameters for Newton's algorithm