I am an economics/stat guy who uses quite a bit of optimization (maximum likelihood, simulated maximum likelihood), constrained optimization (mathematical programming w/ equilibrium conditions), dynamic programming, etc.

I am wondering how Python compares to R for optimization. In my opinion (feel free to argue this and show me if I am wrong), R is not great for optimization in that it does not have automatic differentiation nor great solvers for higher dimensional problems. Programs like AMPL (can hook up to any world class solver) or even Matlab with KNITRO solver won't make you explicitly enter a horribly complex jacobian, hessian, nor sparsity pattern, but R (even IPOPTR) makes you do this. As such, I find R poor for optimization.

Is Python any better? Does it have the automatic differentiation feature? Can it link up to world-class solvers? Any information on this would be great. Otherwise, I fear I will have to do my work in AMPL or CPLEX, which I do not know, and learning yet another language isn't my highest priority unless I need to.

  • 1
    $\begingroup$ I found ampl very easy to use and learn. But its weird when I run a code with R is way faster than AMPL and I do not know why?! $\endgroup$
    – sherek_66
    Aug 5, 2019 at 16:21
  • 1
    $\begingroup$ @Sherek Because this does not answer the question, but perhaps might be a relevant comment, I am converting it to a comment. Please visit our help center for information about the distinction. $\endgroup$
    – whuber
    Aug 5, 2019 at 16:26


Browse other questions tagged or ask your own question.