uqfoundation / mystic

constrained nonlinear optimization for scientific machine learning, UQ, and AI
http://mystic.rtfd.io
Other
467 stars 50 forks source link

add solver one-liner for building solver #51

Open mmckerns opened 9 years ago

mmckerns commented 9 years ago

It would be very useful to be able to have a solver "one-liner" that configures a solver but doesn't run it. For example: diffev could be run with:

>>> solver = diffev_solver(…)
>>> solver.Solve()

Similarly for Step. Solve should not require a cost or ExtraArgs, but should allow them.

Additionally, all inputs to Solve and Step should be able to be given through different methods so that Solve and Step can be called with no arguments/keywords in all cases.

mmckerns commented 9 years ago

Probably a natural place for this "one-liner" is to augment the constructor (i.e __init__) for each solver. Then there's no management of a new "stand-alone" function.

mmckerns commented 9 years ago

A natural place to add callbackis SetObjective. It should the same sticky/non-sticky behavior as cost. callback, I believe, is the last of the settings that need to be handled before Step and Solve are consistent when no settings are passed in.

As a side note, it needs to be decided whether to treat sigint_callback like callback or to have it only accessible when Solve is called.

mmckerns commented 9 years ago

Apparently when cost is changed… it's ignored. That's not good. To fix this (bug), the thing to do might be to store both the "raw" and "wrapped" cost in self._cost. I'll create a new issue for this.

The self._cost tuple may also be a good place to stash callback. However, what does callback=None mean (i.e. "turn off" callback, or reuse the existing callback)? It might be necessary to introduce callback=null, where null is a "null callback".

mmckerns commented 9 years ago

It would probably be cleaner to add callback with SetStepCallback, and also likely better to store the callback separately from the objective since it's never bound to the objective.

mmckerns commented 2 years ago

This could be super useful, but will keep bumping this for now.