Optimization in R with arbitrary constraints

孤街醉人 提交于 2019-12-03 22:47:39

The problem you are referring to is (presumably) a non-linear optimization with non-linear constraints. This is one of the most general optimization problems.

The package I have used for these purposes is called nloptr: see here. From my experience, it is both versatile and fast. You can specify both equality and inequality constaints by setting eval_g_eq and eval_g_ineq, correspondingly. If the jacobians are known explicitly (can be derived analytically), specify them for faster convergence; otherwise, a numerical approximation is used.

Use this list as a general reference to optimization problems.

Write the set of equations using the Lagrange multiplier, then solve using the R command nlm.

You can do this in the OpenMx Package (currently host at the site listed below. Aiming for 2.0 relase on cran this year)

It is a general purpose package mostly used for Structural Equation Modelling, but handling nonlinear constraints.

FOr your case, make an mxModel() with your algebras expressed in mxAlgebras() and the constraints in mxConstraints()

When you mxRun() the model, the algebras will be solved within the constraints, if possible.

http://openmx.psyc.virginia.edu/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!