esa / pagmo_plugins_nonfree

A pagmo affiliated package (https://github.com/esa/pagmo2) adding commercial solvers to the list of solvers/algorithms: SNOPT7, WORHP
GNU General Public License v3.0
10 stars 9 forks source link

Feature/zen update #23

Open mlooz opened 3 years ago

mlooz commented 3 years ago

This is the structure I want to use for #22 .

While a prototype of the functions is there, I haven't tested them yet. There are a couple of open questions:

@bluescarni , @darioizzo and @gabor-varga: Comments on this are very welcome!

Next steps for me:

Edit: Switching to "Ready for Review" to trigger the CI, but please don't merge it yet.

gabor-varga commented 3 years ago

To do sensitivity updates, a user must call zen_init first, which runs the same worhp optimization as evolution, but saves the resulting state. Then, zen_update can be called to get new optimal values for changed constraints.

Do you mean doing an entire new optimisation? It's fine for now, but it would be enough to verify feasibility and optimality conditions are met (I guess running the optimisation is the simplest way).

The perturbation model in Worhp Zen includes a nonlinear perturbation p as a second argument to the fitness function: f(x,p). Should this be included? If so, how?

I think this can be omitted from the interface for now. It could be added without the interface to provide the partials, in which case they would be computed numerically by WORHP.

mlooz commented 3 years ago

Do you mean doing an entire new optimisation? It's fine for now, but it would be enough to verify feasibility and optimality conditions are met (I guess running the optimisation is the simplest way).

I mean that if a user knows they want to look at the sensitivity afterwards, they would call zen_init instead of evolve. It does the same but saves the state. I would like to keep the original evolve unchanged if possible.

I think this can be omitted from the interface for now. It could be added without the interface to provide the partials, in which case they would be computed numerically by WORHP.

Maybe I misunderstood what you mean, but I think that the perturbations are unrelated to partial derivatives. Instead this particular perturbation p targets a fitness function that accepts additional arguments. Which we can add if needed, no problem, it just moves a bit further away from the pygmo problem.

Extracting the derivatives from the problem is an internal matter that should not affect the interface.

darioizzo commented 3 years ago

@mlooz Note that this solution you are trying to go for is not going to work with pagmo.

It is a solution to wrap in python some worhp functionality independently from pagmo.

darioizzo commented 3 years ago

ALso you are basically rewriting evolve with a different name and adding the state management right? It seems to me this structure is a work around rather than a solution ... :(

mlooz commented 3 years ago

ALso you are basically rewriting evolve with a different name and adding the state management right? It seems to me this structure is a work around rather than a solution ... :(

Exactly. Based on the requirements that 1) the zen_update needs state and 2) the pagmo algorithm class should have as little state as possible, I separated them as much as I could without duplicating code.

If this doesn't fit into pagmo, though, I'll try something else.

gabor-varga commented 3 years ago

ALso you are basically rewriting evolve with a different name and adding the state management right? It seems to me this structure is a work around rather than a solution ... :(

We could also pursue a solution outside of pagmo. The idea was that most of the infrastructure is already there for WORHP (loading binary, binding functions).

mlooz commented 3 years ago

Restructured the code as discussed. As of now, the zen update sometimes works and sometimes segfaults, currently hunting down why.

mlooz commented 3 years ago

I think this is getting close to finished. Two small questions:

mlooz commented 3 years ago

This is now ready for review. I realize that I could also have used the m_bool_opts dict instead of WorhpGetBoolParam, I don't mind either way.