[Returnanalytics-commits] r2784 - pkg/PortfolioAnalytics/sandbox
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Aug 14 19:22:28 CEST 2013
Author: rossbennett34
Date: 2013-08-14 19:22:28 +0200 (Wed, 14 Aug 2013)
New Revision: 2784
Modified:
pkg/PortfolioAnalytics/sandbox/testing_factor_exposure.R
Log:
adding DEoptim and random optimization methods to factor exposure testing
Modified: pkg/PortfolioAnalytics/sandbox/testing_factor_exposure.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/testing_factor_exposure.R 2013-08-14 16:24:03 UTC (rev 2783)
+++ pkg/PortfolioAnalytics/sandbox/testing_factor_exposure.R 2013-08-14 17:22:28 UTC (rev 2784)
@@ -3,6 +3,7 @@
require(ROI.plugin.quadprog)
require(ROI.plugin.glpk)
library(Rglpk)
+library(DEoptim)
data(edhec)
ret <- edhec[, 1:4]
@@ -87,3 +88,43 @@
optf
all.equal(opte$weights, optf$weights)
+
+##### maximize return objective with DEoptim #####
+set.seed(123)
+optde1 <- optimize.portfolio(R=ret, portfolio=pspec,
+ constraints=list(lev_constr, lo_constr, grp_constr),
+ objectives=list(ret_obj),
+ optimize_method="DEoptim",
+ search_size=2000,
+ trace=TRUE)
+optde1
+
+set.seed(123)
+optde2 <- optimize.portfolio(R=ret, portfolio=pspec,
+ constraints=list(lev_constr, lo_constr, exp_constr),
+ objectives=list(ret_obj),
+ optimize_method="DEoptim",
+ search_size=2000,
+ trace=TRUE)
+optde2
+
+all.equal(optde1$weights, optde2$weights)
+
+##### maximize return objective with random #####
+optrp1 <- optimize.portfolio(R=ret, portfolio=pspec,
+ constraints=list(lev_constr, lo_constr, grp_constr),
+ objectives=list(ret_obj),
+ optimize_method="random",
+ search_size=2000,
+ trace=TRUE)
+optrp1
+
+optrp2 <- optimize.portfolio(R=ret, portfolio=pspec,
+ constraints=list(lev_constr, lo_constr, exp_constr),
+ objectives=list(ret_obj),
+ optimize_method="random",
+ search_size=2000,
+ trace=TRUE)
+optrp2
+
+all.equal(optrp1$weights, optrp2$weights)
\ No newline at end of file
More information about the Returnanalytics-commits
mailing list