[Desire-commits] r22 - in packages/mco: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 29 22:39:45 CEST 2008


Author: olafm
Date: 2008-05-29 22:39:45 +0200 (Thu, 29 May 2008)
New Revision: 22

Modified:
   packages/mco/R/nsga2.R
   packages/mco/man/nsga2.Rd
Log:
* Add examples to documentation
* Change default parameters for nsga2


Modified: packages/mco/R/nsga2.R
===================================================================
--- packages/mco/R/nsga2.R	2008-05-27 22:26:43 UTC (rev 21)
+++ packages/mco/R/nsga2.R	2008-05-29 20:39:45 UTC (rev 22)
@@ -12,8 +12,8 @@
                   lower.bounds=rep(-Inf, idim),
                   upper.bounds=rep(Inf, idim),
                   popsize=100, generations=100,
-                  cprob=0.5, cdist=5,
-                  mprob=0.9, mdist=10) {
+                  cprob=0.7, cdist=5,
+                  mprob=0.2, mdist=10) {
   ff <- function(x)
     fn(x, ...)
   cf <- function(x)

Modified: packages/mco/man/nsga2.Rd
===================================================================
--- packages/mco/man/nsga2.Rd	2008-05-27 22:26:43 UTC (rev 21)
+++ packages/mco/man/nsga2.Rd	2008-05-29 20:39:45 UTC (rev 22)
@@ -5,7 +5,7 @@
   Multicriterion optimization algorithm
 }
 \usage{
-nsga2(fn, idim, odim, ..., constraints = NULL, cdim = 0, lower.bounds = rep(-Inf, idim), upper.bounds = rep(Inf, idim), popsize = 100, generations = 100, cprob = 0.5, cdist = 5, mprob = 0.9, mdist = 10)
+nsga2(fn, idim, odim, ..., constraints = NULL, cdim = 0, lower.bounds = rep(-Inf, idim), upper.bounds = rep(Inf, idim), popsize = 100, generations = 100, cprob = 0.7, cdist = 5, mprob = 0.2, mdist = 10)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
@@ -28,7 +28,8 @@
   TBD
 }
 \value{
-  TBD
+  A list describing the final population with components \code{par},
+  \code{value} and \code{pareto.optimal}.
 }
 \references{}
 \author{
@@ -36,4 +37,36 @@
   Detlef Steuer \email{steuer at hsu-hamburg.de} and
   Olaf Mersmann \email{olafm at statistik.uni-dortmund.de}
 }
+\examples{
+## Binh 1 problem:
+binh1 <- function(x) {
+  y <- numeric(2)
+  y[1] <- crossprod(x, x)
+  y[2] <- crossprod(x - 5, x - 5)
+  return (y)
+}
+r1 <- nsga2(binh1, 2, 2,
+           generations=150, popsize=100,
+           cprob=0.7, cdist=20,
+           mprob=0.2, mdist=20,
+           lower.bounds=rep(-5, 2),
+           upper.bounds=rep(10, 2))
+plot(r1)
+
+## VNT problem:
+vnt <- function(x) {  
+  y <- numeric(3)
+  xn <- crossprod(x, x)
+  y[1] <- xn/2 + sin(xn);
+  y[2] <- (crossprod(c(3, -2), x) + 4)^2/8 + (crossprod(c(1, -1), x) + 1)^2/27 + 15
+  y[3] <- 1/(xn + 1) - 1.1*exp(-xn)
+  return (y)
+}
+
+r2 <- nsga2(vnt, 2, 3,
+           generations=150, popsize=100,
+           lower.bounds=rep(-3, 2),
+           upper.bounds=rep(3, 2))
+plot(r2)
+}
 \keyword{optimize}



More information about the Desire-commits mailing list