1#' Function to compute diversification as a constraint2#'3#' Diversification is defined as 1 minus the sum of the squared weights4#' \deqn{diversification = 1 - sum(w^2)}5#'6#' @param weights vector of asset weights7#' @author Ross Bennett8#' @export9diversification <- function(weights){10div <- 1 - sum(weights^2)11return(div)12}131415###############################################################################16# R (https://r-project.org/) Numeric Methods for Optimization of Portfolios17#18# Copyright (c) 2004-2021 Brian G. Peterson, Peter Carl, Ross Bennett, Kris Boudt19#20# This library is distributed under the terms of the GNU Public License (GPL)21# for full details see the file COPYING22#23# $Id$24#25###############################################################################262728