Open MaxvdKolk opened 3 years ago
To get a good view let us discuss the different types of enforcing convexity
Agree, would be nice to see if most common methods can be implemented with a simple function or that we might want to think about putting this into more detailed classes etc.
This is a bit tricky to implement for the 2nd-order Taylor expansions with respect to an arbitrary intervening variable y
. The reason being that we must enforce the convexity of \tilde{g}[y[x]]
wrt to x
and not y
. Equations become quite complex, so we might want to leave it out for now. Perhaps we can implement it only on the 1st-order methods and warn the user for the 2nd-order ones or something.
After looking into this and discussing with @artofscience, we concluded that a realistic and viable option would be to implement a method in the Approximation
class that will warn the user when entries of subprob.ddg(x)
and therefore entries of approx.ddg(x)
become negative. That way we are consistent in handling non-convexity throughout the package, cuz enforcing convexity in the case of an arbitrary intervening variable y[x]
in combination with any of our Taylor2
expansion proved to be pretty hard to solve.
Why not add some functions to the "subproblem" object: e.g.
It might be nice to try and implement the convexity enforcement as a separate (wrapper) class. At the moment, it seems that we would need to implement the
if self.force_convex
check, as well as the correspondingenforce_convexity
routines for various instances of theApproximation
classes. Additionally, there might be different approaches possible in which we would like to enforce convexity. For instance, we could consider other thresholds or values to assign to the second derivatives.My proposal would be to implement something as follows
which would sit around an existing
Approximation
instance, so initialised asapproximation = EnforceConvexity(Approximation(...), convexity_enforcer)
, where theconvexity_enforcer
could be any function (or class) that takes the approximation as argumentfor which we could implement a couple different variants. With such a (or similar) scheme, we could potentially then provide a range of such
enforce_convexity
routines that could work on anyApproximation
without requiring to modify theupdate
method of theApproximation
classes directly.There are of course multiple ways to implement behaviour like this and possibly we should consider a PR/issue for this to see what would be the most appropriate way to insert this into the framework.
_Originally posted by @MaxvdKolk in https://github.com/artofscience/sao/pull/62#discussion_r657285997_