-
Notifications
You must be signed in to change notification settings - Fork 10
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
symbolify models cause BoundsError #140
Comments
This particular example is fixed in the latest release JuliaRegistries/General#62556. However, a bigger problem remains. The problem is that sometimes the initial Hessian has structural non-zeros that have the value of 0. The way I get Hessians is using ForwardDiff over Zygote. ForwardDiff causes a loss in sparsity in the Hessian in the process. So I workaround this issue by using The reason why we can't use the sparsity pattern returned by Symbolics here is that it is hidden in the Lagrangian function which calls the constraint/objective functions which call the symbolified functions. So the There are 2 ways to workaround this:
I might have to go with the third option. For now, you can just make sure the initial Hessian is non-zero for any structural non-zeros at the initial solution. I worked around the individual example in the issue reported by ensuring the diagonal of the Hessian is always treated as structural non-zeros. The 0 value in that example happened to be on the diagonal so that solved the problem in this case. |
How would one do this? |
By using a random initial solution that's unlikely to lead to term cancellation. |
I am not sure I follow what this means, but I will remark that the starting point for your NLP solver is quite important to convergence and solution quality, users will need the ability to set specific starting points that are connected to domain knowledge about the problem that is being solved. |
Based on my testing for lanl-ansi/rosetta-opf#23 I do believe that the selected starting point impacts the correctness of the symbolic AD system. I would recommend that this behavior be avoided if possible as it will be quite unexpected to users of Nonconvex, who have experience using other NLP modeling frameworks. |
NonconvexIpopt 0.4 should have fixed this issue. |
I will go ahead and close this issue since I don't think the issue exists anymore with NonconvexIpopt 0.4. If you think otherwise, please report with a new MWE. |
For the record, this is the new, simpler working code with import Nonconvex
import NonconvexUtils
Nonconvex.@load Ipopt
model = Nonconvex.Model(x -> x[1] * x[4] * (x[1] + x[2] + x[3]) + x[3]);
addvar!(model, fill(1.0, 4), fill(5.0, 4));
add_ineq_constraint!(model, x -> 25.0 - x[1] * x[2] * x[3] * x[4]);
add_eq_constraint!(model, x -> 40.0 - x[1]^2 + x[2]^2 + x[3]^2 + x[4]^2);
result = Nonconvex.optimize(
model,
IpoptAlg(),
[1.0, 5.0, 5.0, 1.0];
options = IpoptOptions(; first_order = false, symbolic = true, sparse = true),
); |
Ok, I'll open a new issue for this point, with an example on how to reproduce. |
You might want to re-open this issue. This appears to happen when testing the nonconvex model in rosetta-opf on the |
Presumably Nonconvex could do this internally? Why do you need to use the user's primal starting point? Even then, it's still a probabilistic approach. It wouldn't work for something like |
Symbolic differentiation will not work for any function that's not |
The |
The text was updated successfully, but these errors were encountered: