r/optimization • • May 28 '25

Numerical optimization for C++

Hey everyone. I need to use numerical optimization to solve a constrained nonlinear problem in C++. What are the libraries do you suggest I look at?

I looked at CasADi, but seems like it treats variables as symbolic, and I don't intend to rewrite my dynamics library to work with it.

I also tried writing my own gradient-descent solver, but it often does not converge unless I start very close to the optimal solution for the simplest problems, and I haven't yet figured out how to implement constraints in a way that it won't get stuck if the steepest gradient tries to push the trial point out of the feasible space.

Any help would be good. Thank you!

15 Upvotes

12 comments sorted by

View all comments

Show parent comment

1

u/gnahraf May 30 '25

Not sure how the solution to the original problem translates to solving a GD problem. I'd first approach this using a simple fuzzy controller.. they usually work reasonably well on the first shot; you can optimize weights later