simsopt.solve package

Submodules

simsopt.solve.mpi_solve module

This module provides two main functions, fd_jac_mpi and least_squares_mpi_solve. Also included are some functions that help in the operation of these main functions.

simsopt.solve.mpi_solve.fd_jac_mpi(dofs, mpi, x=None, eps=1e-07, centered=False)

Compute the finite-difference Jacobian of the functions in dofs with respect to all non-fixed degrees of freedom. Parallel function evaluations will be used.

If the argument x is not supplied, the Jacobian will be evaluated for the present state vector. If x is supplied, then first get_dofs() will be called for each object to set the global state vector to x.

The mpi argument should be an MpiPartition.

There are 2 ways to call this function. In method 1, all procs (including workers) call this function (so mpi.is_apart is False). In this case, the worker loop will be started automatically. In method 2, the worker loop has already been started before this function is called, as would be the case in least_squares_mpi_solve(). Then only the group leaders call this function.

This function returns a 3-tuple. The first entry is the Jacobian. The second entry is a matrix, the columns of which give all the values of x at which the functions were evaluated. The third entry is a matrix, the colums of which give the corresponding values of the functions.

simsopt.solve.mpi_solve.least_squares_mpi_solve(prob, mpi, grad=None, **kwargs)

Solve a nonlinear-least-squares minimization problem using MPI. All MPI processes (including group leaders and workers) should call this function.

prob should be an instance of LeastSquaresProblem.

mpi should be an instance of MpiPartition.

kwargs allows you to pass any arguments to scipy.optimize.minimize.

simsopt.solve.mpi_solve.mpi_leaders_task(mpi, dofs, data)

This function is called by group leaders when MpiPartition.leaders_loop() receives a signal to do something.

We have to take a “data” argument, but there is only 1 task we would do, so we don’t use it.

simsopt.solve.mpi_solve.mpi_workers_task(mpi, dofs, data)

This function is called by worker processes when MpiPartition.workers_loop() receives a signal to do something.

simsopt.solve.serial_solve module

This module provides the least_squares_serial_solve function. Eventually I can also put a serial_solve function here for general optimization problems.

simsopt.solve.serial_solve.least_squares_serial_solve(prob, grad=None, **kwargs)

Solve a nonlinear-least-squares minimization problem using scipy.optimize, and without using any parallelization.

prob should be a LeastSquaresProblem object.

kwargs allows you to pass any arguments to scipy.optimize.least_squares.

simsopt.solve.serial_solve.serial_solve(prob, grad=None, **kwargs)

Solve a general minimization problem (i.e. one that need not be of least-squares form) using scipy.optimize.minimize, and without using any parallelization.

prob should be a simsopt problem.

kwargs allows you to pass any arguments to scipy.optimize.minimize.

Module contents