ometah-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[oMetah-devel] ometah/problem/CEC05 itsCEC05_SSRPO_Base.cpp it...


From: NoJhan
Subject: [oMetah-devel] ometah/problem/CEC05 itsCEC05_SSRPO_Base.cpp it...
Date: Fri, 03 Jun 2005 09:01:08 -0400

CVSROOT:        /cvsroot/ometah
Module name:    ometah
Branch:         
Changes by:     NoJhan <address@hidden> 05/06/03 13:01:08

Modified files:
        problem/CEC05  : itsCEC05_SSRPO_Base.cpp itsCEC05_SSRPO_Base.hpp 

Log message:
        * weierstrass's function

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/problem/CEC05/itsCEC05_SSRPO_Base.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/ometah/ometah/problem/CEC05/itsCEC05_SSRPO_Base.hpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text

Patches:
Index: ometah/problem/CEC05/itsCEC05_SSRPO_Base.cpp
diff -u ometah/problem/CEC05/itsCEC05_SSRPO_Base.cpp:1.2 
ometah/problem/CEC05/itsCEC05_SSRPO_Base.cpp:1.3
--- ometah/problem/CEC05/itsCEC05_SSRPO_Base.cpp:1.2    Fri Jun  3 12:47:12 2005
+++ ometah/problem/CEC05/itsCEC05_SSRPO_Base.cpp        Fri Jun  3 13:01:07 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- * $Id: itsCEC05_SSRPO_Base.cpp,v 1.2 2005/06/03 12:47:12 nojhan Exp $
+ * $Id: itsCEC05_SSRPO_Base.cpp,v 1.3 2005/06/03 13:01:07 nojhan Exp $
  * Author: Johann Dréo <address@hidden>
  ****************************************************************************/
 
@@ -47,7 +47,7 @@
     setKey("Ackley");
     setDescription("");
     setCitation("Unknown");
-    setFormula("$-20e^{\\left(-0.2\\sqrt{\\frac{1}{D}{\\displaystyle 
\\sum_{i=1}^{D}z_{i}^{2}}}\\right)}-e^{\\left(\\frac{1}{D}{\\displaystyle 
\\sum_{i=1}^{D}\\cos\\left(2\\pi z_{i}\\right)}\\right)}+20+e$");
+    setFormula("$-20e^{\\left(-0.2\\sqrt{\\frac{1}{D}{\\displaystyle 
\\sum_{i=1}^{D}x_{i}^{2}}}\\right)}-e^{\\left(\\frac{1}{D}{\\displaystyle 
\\sum_{i=1}^{D}\\cos\\left(2\\pi x_{i}\\right)}\\right)}+20+e$");
     
     setDimension(1); // one dimension is the default, but one may change it 
after instanciation
     
@@ -107,7 +107,7 @@
     setKey("Rastrigin");
     setDescription("");
     setCitation("Unknown");
-    setFormula("${\\displaystyle 
\\sum_{i=1}^{D}\\left(z_{i}^{2}-10\\cos\\left(2\\pi 
z_{i}\\right)+10\\right)}$");
+    setFormula("${\\displaystyle 
\\sum_{i=1}^{D}\\left(x_{i}^{2}-10\\cos\\left(2\\pi 
x_{i}\\right)+10\\right)}$");
     
     setDimension(1); // one dimension is the default, but one may change it 
after instanciation
     
@@ -129,12 +129,11 @@
 
 itsPoint itsRastrigin::objectiveFunction(itsPoint point)
 {
-    long double res = 0.0;
+    double res = 0.0;
     unsigned int dim = getDimension();
     vector<double> x=point.getSolution();
 
-    for (unsigned int i=0; i<dim; i++)
-    {
+    for (unsigned int i=0; i<dim; i++) {
         res += (x[i]*x[i] - 10.0*cos(2.0*PI*x[i]) + 10.0);
     }
 
@@ -148,3 +147,68 @@
 {
     return new itsRastrigin();
 }
+
+
+
+/*******************************************************************************
+ * Weierstrass
+ 
******************************************************************************/
+
+
+itsWeierstrass::itsWeierstrass()
+{
+    // informations 
+    setName("Weierstrass");
+    setKey("Weierstrass");
+    setDescription("");
+    setCitation("Unknown");
+    setFormula("${\\displaystyle \\sum_{i=1}^{D}\\left({\\displaystyle 
\\sum_{k=0}^{k_{max}}\\left(a^{k}\\cos\\left(2\\pi 
b^{k}\\left(x_{i}+0.5\\right)\\right)\\right)}\\right)-D\\sum_{k=0}^{k_{max}}\\left(a^{k}\\cos\\left(2\\pi
 b^{k}\\cdot0.5\\right)\\right)},a=0.5, b=3, k_{max}=20$");
+    
+    setDimension(1); // one dimension is the default, but one may change it 
after instanciation
+    
+    setBoundsMinimaAll(-0.5);
+    setBoundsMaximaAll(0.5);
+    
+    vector<itsPoint> optim;
+    itsPoint pt;
+
+    vector<double> sol(getDimension(),0);
+    pt.setSolution(sol); // a vector of 0
+
+    vector<double> val(1,0);
+    pt.setValues(val); // a value of 0
+
+    optim.push_back(pt);
+    setOptima(optim);
+}
+
+itsPoint itsWeierstrass::objectiveFunction(itsPoint point)
+{
+    unsigned int dim = getDimension();
+    vector<double> x=point.getSolution();
+
+    double res, sum, a, b;
+    unsigned int k_max;
+    a = 0.5;
+    b = 3.0;
+    k_max = 20;
+    res = 0.0;
+
+    for (unsigned int i=0; i<dim; i++) {
+        sum = 0.0;
+        for (unsigned int j=0; j<=k_max; j++) {
+            sum += pow( a, (double)j ) * cos( 2.0 * PI * pow( b, (double)j ) * 
( x[i] + 0.5 ) );
+        }
+        res += sum;
+    }
+
+    vector<double> val(1,res);
+    point.setValues(val);
+    
+    return point;
+}
+
+itsProblem * itsWeierstrassFactory::create()
+{
+    return new itsWeierstrass();
+}
Index: ometah/problem/CEC05/itsCEC05_SSRPO_Base.hpp
diff -u ometah/problem/CEC05/itsCEC05_SSRPO_Base.hpp:1.2 
ometah/problem/CEC05/itsCEC05_SSRPO_Base.hpp:1.3
--- ometah/problem/CEC05/itsCEC05_SSRPO_Base.hpp:1.2    Fri Jun  3 12:47:12 2005
+++ ometah/problem/CEC05/itsCEC05_SSRPO_Base.hpp        Fri Jun  3 13:01:07 2005
@@ -1,5 +1,5 @@
 /***************************************************************************
- * $Id: itsCEC05_SSRPO_Base.hpp,v 1.2 2005/06/03 12:47:12 nojhan Exp $
+ * $Id: itsCEC05_SSRPO_Base.hpp,v 1.3 2005/06/03 13:01:07 nojhan Exp $
  * Author: Johann Dréo <address@hidden>
  ****************************************************************************/
 
@@ -67,4 +67,20 @@
 };
 
 
+/***** Weierstrass *****/
+
+class itsWeierstrass : public itsProblem
+{
+public:
+    itsWeierstrass();
+    itsPoint objectiveFunction(itsPoint point);
+};
+
+class itsWeierstrassFactory : public itsProblemFactory
+{
+public:
+    itsProblem * create();
+};
+
+
 #endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]