Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization with state #83

Open
f0uriest opened this issue Sep 18, 2024 · 1 comment
Open

Optimization with state #83

f0uriest opened this issue Sep 18, 2024 · 1 comment
Labels
question User queries

Comments

@f0uriest
Copy link

Suppose I have an optimization problem where the function to be optimized requires solving some expensive iterative sub-problem. It would be efficient if I could re-use the solution from the last step of the optimizer to warm start the next step. Something like

def myfun(x, y0):
    y = expensive_subproblem(x, initial_guess=y0)
    return some_other_func(x,y), y

And a sketch of what I'm doing now:

for _ in range(maxiter):
    ((f, y), df) = jax.value_and_grad(myfun, argnums=0, has_aux=True)(x, y)
    x = optimizer_step(x, f, df)

Is something like this possible in optimistix?

@patrick-kidger
Copy link
Owner

This can be done by defining a custom solver, which wraps your current solver of choice. Solvers are the API level at which we pass state between steps.

For an example take a look at the best-so-far solvers, which do something very similar -- they wrap an existing solver, call that on every step, but additionally pass around some additional state.

@patrick-kidger patrick-kidger added the question User queries label Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question User queries
Projects
None yet
Development

No branches or pull requests

2 participants