-
Notifications
You must be signed in to change notification settings - Fork 42
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
input variables scaling #95
Comments
Scaling can be done automatically for fully bounded variables. Using a non-linear transform (like arcsine or tanh) may not be a good idea for the convergence. The main reason to scale variables is to have similar magnitude for the changes of all variables of the problem and, for example, avoid that the convergence depends on the units of the variables. This is ususal trick when applying a numerical method to a problem with heterogeneous variables. |
Hi @jschueller and @emmt , Apologies for the late reply. First of all, I totally agree that scaling is important. Thank you for raising this point. However, I do not think a trivial and good scaling strategy exists.
Note that the above strategy does not work well in the following case, where the problem probably needs a nonlinear transformation (taking logarithm) before any scaling (recall point 1 above). Thanks. |
I totally agree with these 2 points, this is why I would add the scaling as an optional argument (e.g. a keyword in Julia interface) whose values (the scaling factors for each variables of the problem) are chosen by the caller. If the optional scaling is specified as a single value, we could assume that it is the parameter |
The scaling scheme involving The MATLAB interface does the following:
We do not accept a In other words, we only handle two cases:
Thanks. |
OK but then this means that, internaly, the Powell's algorithms are capable of dealing with non-unit scaling of variables (in particular for the |
OK. I agree. What about the following? Define two options,
If the user inputs The problem with |
Since, in Julia, we have access to the type of the arguments/keywords, we can combine your suggested logic in a single keyword, say
I agree that scaling factors must be checked for validity but I would rather throw an exception (i.e. raise an error rather than a warning) if they are invalid because it means that the caller has made a wrong choice and must fix that. |
This is an excellent idea! I agree that
I tend to disagree with this point. The reason is as follows. When developing a solver (be it optimization, linear algebra, PDE, ...), we should keep an important fact in mind: the "caller" is not necessarily a human. It is very likely another piece of code that calls the solver. The invocation of the solver is probably a quite small part of a bigger project. Moreover, the invocation of the solver may be done repeatedly in a loop. For example, consider the following pseudo-code.
Suppose that, in theory, it is guaranteed that In my opinion, a user-friendly package should tolerate any erroneous options as long as the problem being solved is still well-defined. If an option is invalid, then raise a warning and reset it to a correct one. (Of course, exceptions exist.) Indeed, this happens quite often for linear solvers. Consider a problem where the coefficient matrix is theoretically nonsingular. In practice, the matrix may become numerically singular due to ill-conditioning. If this happens, should we abort the computation and raise an error, or should we raise a warning and solve the problem in the best way we can? I would prefer the latter. (In this case, the problem being solved is even not well-defined in the classical sense). What do you think? Thanks. |
Well, for me, such an error indicates an erroneous use of the program which I would not left pass through. My experience is it's usually a bad idea to sweep this kind of mistake under the carpet because it delays the moment when one realizes the error and correctly fixes it. In the case of your example, a possible explicit fix of
assuming We don't have to make a decision right now, especially not until we've defined a rescue strategy. I would propose to cope with this in several steps:
At least implementing step 1 is a prerequisite. |
I agree that some errors likely indicate an erroneous use of the program, which should not be left pass through. This is what I mean by the exceptions when saying the following.
However, I am not sure whether an invalid
I agree with this idea in general. That is why users should always be informed when some inputs are erroneous, eitherby a warning (in most cases) or by an error (in exceptional cases).
I agree. Anyway, the particular question of "how to deal with an invalid Thanks. |
it turns out i'm not so much interested in that anymore |
the matlab interface scales the problem only if all variables are bound on each side
however it still possible to transform unbounded variables with arcsine (or tanh), for example:
https://lmfit.github.io/lmfit-py/bounds.html
what do you think ?
in the julia interface we were wondering if this should be done in the fortran or C layer
https://github.com/emmt/PRIMA.jl/issues/4#issuecomment-1740971230
a concern by @emmt was that iprint would print scaled variables
The text was updated successfully, but these errors were encountered: