Skip to content

[RFC] add a callback function #65

Description

@jschueller

for scipy integration we should be able to pass an optional callback function to report at least the current best x/f values

subroutine CALLBACK(x, f)
    use consts_mod, only : RP
    implicit none
    real(RP), intent(in) :: bestx(:)
    real(RP), intent(in) :: bestf
    integer(RK), intent(out) :: stop
end subroutine CALLBACK

I propose it could also to cancel the minimization (or via the objective function) according to a "stop" argument (and add a new return code for this):

I dont know if there are other useful stuff we want to track, like the number of evaluations ...

in C it is usual to pass an additional pointer argument to hook back to struct/data:

typedef int (*cbfunc)(unsigned n, const double *bestx, conda double bestf, void *func_data);

see the "callback" argument of minimize:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html

could also be useful for nlopt:
stevengj/nlopt#37

Metadata

Metadata

Assignees

No one assigned

    Labels

    pythonIssues related to the Python interface or implementation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions