How to put mathematical constraints with GenSA function in R

前端 未结 2 986
遥遥无期
遥遥无期 2020-12-21 08:34

I am currently trying to use Simulated Annealing package GenSA in order to minimize the function below :

efficientFunction <- function(v) {
  t(v)  %*% Co         


        
2条回答
  •  清酒与你
    2020-12-21 09:32

    A possible approach would be to make use of so-called Lagrange multipliers (cf., http://en.wikipedia.org/wiki/Lagrange_multiplier). For example, set

    efficientFunction <- function(v) {
      lambda <- 100
      t(v)  %*% Cov_Mat   %*%  v + lambda * abs( sum(v) - 1 )
    }
    

    , so that in order to minimize the objective function efficientFunction the resulting parameter also minimize the penalty term lambda * abs( sum(v) - 1 ). The Lagrange multiplier lambda is set to an arbitrary but sufficiently high level.

提交回复
热议问题