diff --git a/README.md b/README.md
index 50ab96149b5fb1789abe7838046f84eb3754830e..466338eb6feefaf3792ed286e09d21edf71d7b9d 100644
--- a/README.md
+++ b/README.md
@@ -32,11 +32,52 @@ Search methods used: nelder mead, gradient descent, EM and CMAES.
 
 All target Images are 100*100
 
-<img src="img/circle_target.png" alt="drawing" width="200"/>
-<img src="img/rectange_target.png" alt="drawing" width="200"/>
-<img src="img/gear_target.png" alt="drawing" width="200"/>
-<img src="img/blob_target.png" alt="drawing" width="200"/>
-<img src="img/hole_target.png" alt="drawing" width="200"/>
+<img src="img/circle_target.png" width="200">
+<img src="img/rectange_target.png" width="200">
+<img src="img/gear_target.png" width="200">
+<img src="img/blob_target.png" width="200">
+<img src="img/hole_target.png" width="200">
+
+----
+
+### Example Best Results
+
+- parametric frep (~ 5 parameters)
+- frep trees (~ 10 parameters)
+- dft (~ 20 parameters) 
+- DNN/DMN (~ 300 parameters)
+  - cmaes
+
+<img src="img/dnn_cmaes/1.png" width="200">
+<img src="img/dnn_cmaes/2.png" width="200">
+<img src="img/dnn_cmaes/3.png" width="200">
+<img src="img/dnn_cmaes/4.png" width="200">
+<img src="img/dnn_cmaes/5.png" width="200">
+
+  - sgd
+
+<img src="img/dnn_sgd/1.png" width="200">
+<img src="img/dnn_sgd/2.png" width="200">
+<img src="img/dnn_sgd/3.png" width="200">
+<img src="img/dnn_sgd/4.png" width="200">
+<img src="img/dnn_sgd/5.png" width="200">
+
+- distance fields (~ 400 parameters) 
+
+<img src="img/df/1.png" width="200">
+<img src="img/df/2.png" width="200">
+<img src="img/df/3.png" width="200">
+<img src="img/df/4.png" width="200">
+<img src="img/df/5.png" width="200">
+
+- point cloud/mesh (~ 1,000 parameters)
+- voxel search (~ 10,000 parameters)
+  
+<img src="img/voxel/1.png" width="200">
+<img src="img/voxel/2.png" width="200">
+<img src="img/voxel/3.png" width="200">
+<img src="img/voxel/4.png" width="200">
+<img src="img/voxel/5.png" width="200">
 
 ---
 ### dft progress
diff --git a/Representation Comparison.xlsx b/Representation Comparison.xlsx
index 893ab9689f6dc18cab4344f1d6192955040ee9b0..2484358bc85a05b62badb7c6a58cb9da4bd0232a 100644
Binary files a/Representation Comparison.xlsx and b/Representation Comparison.xlsx differ
diff --git a/cpp_dft/main.cpp b/cpp_dft/main.cpp
index 76f8361b9aabc6d65883138124faff06bd99d6fc..d6a7939fcc609f51f7fa984b16f3137c9a06820d 100644
--- a/cpp_dft/main.cpp
+++ b/cpp_dft/main.cpp
@@ -81,7 +81,7 @@ cv::Mat drawFrep(Frep* frep,scalar minX,scalar maxX,scalar minY,scalar maxY,scal
     //         cv::Scalar(0,0,0), // BGR Color
     //         1); // Line Thickness (Optional)
 
-    std::string fileName="img/"+name+".png";
+    std::string fileName="img_dft/"+name+".png";
     cv::imwrite( fileName, image );
     if(preview){
         cv::namedWindow("Display Image", cv::WINDOW_AUTOSIZE );
@@ -310,7 +310,7 @@ cv::Mat dft(int w, int h, const int resolution, std::vector<scalar> mag,std::vec
                 cv::Scalar( 0, 0, 0 ),
                 lineType );
     
-    std::string fileName="img/"+name+".png";
+    std::string fileName="img_dft/"+name+".png";
     cv::cvtColor(img, img, cv::COLOR_BGR2GRAY);
     if(save){
         cv::imwrite ( fileName, img );
@@ -368,97 +368,84 @@ scalar compareToTarget(int width,int height,const int resolution,Vector v, cv::M
 
 int main(int const, char const**) {
    
-    scalar res=0.01f;
-    scalar bound =3.0f;
 
 
     float precision = 0.001f;
 
     
+    scalar res=0.05f;
+    scalar bound =2.5f;
+
+
+    
     scalar minX=-bound;
     scalar maxX=bound;
     scalar minY=-bound;
     scalar maxY=bound;
     scalar dx=res;
     scalar dy=res;
-
     int height=(int)((maxX-minX)/dx);
     int width=(int)((maxY-minY)/dy);
 
-    // defines the complex number: (10 + 2i) 
-    // std::complex<scalar> mycomplex(10.0f, 2.0f); 
-    // std::complex<scalar> mycomplex =polar (1.0f, 0.927295f) ;
-    // std::complex<scalar> j;
-    // j=-1.0f;
-    // j=sqrt(j);
+    cout<<"width: "<<width<<", height: "<<height <<std::endl;
 
-    // std::complex<scalar> trial = mycomplex * exp (-1.0f*PI_F*j*1.0f);
-    // std::complex<scalar> trial = exp (-1.0f*PI_F*j*1.0f);
-    
-    // // prints the real part using the real function 
-    // cout << "Real part: " << real(trial) << endl; 
-    // cout << "Imaginary part: " << imag(trial) << endl;
 
-    // cout << "The complex whose magnitude is " << 5.0; 
-    // cout << " and phase angle is " << 0.927295; 
-        
-    // // use of polar() 
-    // cout << " is " << polar (5.0, 0.927295) << endl; 
+    const int resolution=19;
 
-    // // defines the complex number: (3.0+4.0i) 
-    // std::complex<double> mycomplex (3.0, 4.0); 
-    
-    // // prints the absolute value of the complex number 
-    // cout << "The absolute value of " << mycomplex << " is: "; 
-    // cout << abs(mycomplex) << endl; //magnitude
-        
-    // // prints the argument of the complex number 
-    // cout << "The argument of " << mycomplex << " is: "; 
-    // cout << arg(mycomplex) << endl; //phase
+    cpp_frep::Circle c(1.5f,0.0f,0.0f);
+    // std::vector<unsigned char> targ1 =drawFrep(&c,minX, maxX, minY, maxY, dx, dy,"circle_target",false);
+    cv::Mat targ1 =drawFrep(&c,minX, maxX, minY, maxY, dx, dy,"dft_circle",false);
 
+    cpp_frep::Rectangle r(-1.5f,1.5f,-1.0f,1.0f);
+    cpp_frep::Rotate rot1 (&r,0.0f,0.0f,90.0f);
+    // std::vector<unsigned char> targ2 =drawFrep(&rot1,minX, maxX, minY, maxY, dx, dy,"rectange_target",false);
+    cv::Mat targ2 =drawFrep(&rot1,minX, maxX, minY, maxY, dx, dy,"dft_reactangle",false);
 
-    
+    cpp_frep::InvoluteGear gear( 1.0f,  1.0f, 1.1f, 20.0f, 8.0f) ;
+    cpp_frep::Rotate rot (&gear,0.0f,0.0f,15.0f);
+    cpp_frep::Scale sc1(&rot,0.0f,0.0f,0.5f,0.5f);
+    cpp_frep::Add target(&sc1,&c);
+    // std::vector<unsigned char> targ3 =drawFrep(&target,minX, maxX, minY, maxY, dx, dy,"gear_target",false);
+    cv::Mat targ3 =drawFrep(&target,minX, maxX, minY, maxY, dx, dy,"dft_gear",false);
 
-    // std::vector<scalar> mag ={0.0f,0.5f,    0.25f,0.1f,0.05f};
-    // std::vector<scalar> ampl={0.0f,0.0f,PI_F/2.0f,0.0f,0.0f};
 
-    const int resolution=19;
+    cpp_frep::Circle c1(0.9f,-0.5f,0.8f);
+    cpp_frep::Circle c2(0.8f,0.2f,-0.2f);
+    cpp_frep::Circle c3(0.9f,1.5f,0.0f);
+    cpp_frep::Circle c4(0.9f,1.7f,-1.1f);
+    // Subtract ss(&rot1,&c1);
+    
+    // Subtract sss(&ss,&c2);
+    cpp_frep::Add aa(&c1,&c3);
+    cpp_frep::Add aaa(&aa,&c2);
+    cpp_frep::Add a(&aaa,&c4);
+    cpp_frep::Morph m (&a,&target,0.6f);
+    cpp_frep::Rotate rot2 (&m,0.3f,0.0f,-90.0f);
+    // Scale scc (&m,0.0f,0.0f,1.0,1.0);
+    // std::vector<unsigned char> targ4 =drawFrep(&rot2,minX, maxX, minY, maxY, dx, dy,"blob_target",false);
+    cv::Mat targ4 =drawFrep(&rot2,minX, maxX, minY, maxY, dx, dy,"dft_blob",false);
 
-    // std::vector<scalar> mag ={0.0f, 1.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f, 0.05f};
-    // std::vector<scalar> ampl={0.0f, 0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f,0.0f, 0.0f};
-    // cv::Mat d = dft(width, height, resolution, mag , ampl,"dft",true,true);
+    cpp_frep::Circle c5(0.5f,0.0f,0.0f);
+    cpp_frep::Subtract ss(&c,&c5);
+    // std::vector<unsigned char> targ5 =drawFrep(&ss,minX, maxX, minY, maxY, dx, dy,"hole_target",false);
+    cv::Mat targ5 =drawFrep(&ss,minX, maxX, minY, maxY, dx, dy,"dft_hole",false);
 
-    // mag=getRandomMag(resolution);
-    // ampl=getRandomAmpl(resolution);
-    // cv::Mat d = dft(width, height, resolution, mag,ampl,"dft",true);
-    // cv::cvtColor(d, d, cv::COLOR_BGR2GRAY);
-    // cv::cvtColor(targ, targ, cv::COLOR_BGR2GRAY);
-    // cv::Mat diff= d-targ;
-    // cout<< "nonzero: "<<countNonZero(diff)<<endl;
-    // cout<< "size: "<<width*height<<endl;
-    // cout<< "norm l2: "<<cv::norm(d, targ,  cv::NORM_L2)<<endl;
-    // cout<< "norm l1: "<<cv::norm(d, targ,  cv::NORM_L1)<<endl;
-    // cout<< "norm NORM_HAMMING: "<<cv::norm(d, targ,cv::NORM_HAMMING )<<endl;
-    // cout<< "norm NORM_HAMMING2: "<<cv::norm(d, targ,cv::NORM_HAMMING2 )<<endl;
-    // cout<< "norm NORM_L2SQR: "<<cv::norm(d, targ,cv::NORM_L2SQR )<<endl;
-    // cout<< "norm: "<<cv::norm(d, targ)<<endl;
-    
 
 
-    // cv::namedWindow("Display Image", cv::WINDOW_AUTOSIZE );
-    // cv::imshow("Display Image", diff);
-    // cv::waitKey(0);
 
-    Circle c(1.2f,0.0f,0.0f);
-    InvoluteGear gear( 1.0f,  1.0f, 1.1f, 20.0f, 8.0f) ;
-    Rotate rot (&gear,0.0f,0.0f,15.0f);
-    Scale sc1(&rot,0.0f,0.0f,0.3f,0.3f);
-    Add target(&sc1,&c);
-    cv::Mat targ =drawFrep(&target,minX, maxX, minY, maxY, dx, dy,"dft_target",false);
+    // Circle c(1.2f,0.0f,0.0f);
+    // InvoluteGear gear( 1.0f,  1.0f, 1.1f, 20.0f, 8.0f) ;
+    // Rotate rot (&gear,0.0f,0.0f,15.0f);
+    // Scale sc1(&rot,0.0f,0.0f,0.3f,0.3f);
+    // Add target(&sc1,&c);
+    cv::Mat targ;
 
     // Circle c(1.0f,0.0f,0.0f);
     // cv::Mat targ =drawFrep(&c,minX, maxX, minY, maxY, dx, dy,"dft_target",false);
-    cv::cvtColor(targ, targ, cv::COLOR_BGR2GRAY);
+    cv::cvtColor(targ3, targ, cv::COLOR_BGR2GRAY);
+
+
+
 
     ///neldermead
 
@@ -484,7 +471,7 @@ int main(int const, char const**) {
     int count2=0;
     int maxSteps=10000;
     int maxSteps1=10000;
-    int saveEvery=10;
+    int saveEvery=25;
     scalar score=0.0f;
 
     std::string name1 = "ii";
@@ -503,6 +490,7 @@ int main(int const, char const**) {
         if(count2>=saveEvery){
             //save
             score=compareToTarget( width, height,resolution,v, targ ,name,true,false);
+            std::cout<<"Step:"<<count<<", total:"<< count1<<", score:"<<-score<<"\n";
             count2=0;
 
         }else{
@@ -511,7 +499,7 @@ int main(int const, char const**) {
 
         }
             
-        std::cout<<"Step:"<<count<<", total:"<< count1<<", score:"<<-score<<"\n";
+        
         v = o.step(v, score);
         count++;
         count1++;
@@ -538,3 +526,170 @@ int main(int const, char const**) {
 }
 
 
+///target1
+    // Step:25, total:25, score:44004
+    // Step:51, total:51, score:40950
+    // Step:77, total:77, score:26444
+    // Step:103, total:103, score:23756
+    // Step:129, total:129, score:16948
+    // Step:155, total:155, score:14380
+    // Step:181, total:181, score:13500
+    // Step:207, total:207, score:12524
+    // Step:233, total:233, score:13532
+    // Step:259, total:259, score:12020
+    // Step:285, total:285, score:12356
+    // Step:311, total:311, score:11908
+    // Step:337, total:337, score:11772
+    // Step:363, total:363, score:12788
+    // Step:389, total:389, score:11564
+    // Step:415, total:415, score:12196
+    // Step:441, total:441, score:11636
+    // Step:467, total:467, score:12268
+    // Step:493, total:493, score:11724
+    // Step:519, total:519, score:11796
+    // Step:545, total:545, score:11932
+    // Step:571, total:571, score:12180
+    // Step:597, total:597, score:11740
+    // Step:623, total:623, score:11812
+    // Step:649, total:649, score:12172
+    // Step:675, total:675, score:11764
+    // Step:701, total:701, score:11972
+    // Step:727, total:727, score:11836
+    // Step:753, total:753, score:11740
+    // Step:779, total:779, score:11716
+    // Step:805, total:805, score:11732
+    // Step:831, total:831, score:11812
+    // Step:857, total:857, score:11788
+    // Step:883, total:883, score:11740
+    // Step:909, total:909, score:11860
+    // Step:935, total:935, score:11908
+    // Step:961, total:961, score:11748
+    // Step:987, total:987, score:11948
+    // Step:1013, total:1013, score:11676
+    // Step:1039, total:1039, score:12260
+    // Step:1065, total:1065, score:11764
+    // Step:1091, total:1091, score:11772
+    // Step:1117, total:1117, score:11764
+    // Step:1143, total:1143, score:11788
+    // Step:1169, total:1169, score:11972
+    // Step:1195, total:1195, score:11804
+    // Step:1221, total:1221, score:11884
+    // Step:1247, total:1247, score:11900
+    // Step:1273, total:1273, score:11868
+    // Step:1299, total:1299, score:12260
+    // Step:1325, total:1325, score:11732
+    // Step:1351, total:1351, score:11740
+    // Step:1377, total:1377, score:11900
+    // Step:1403, total:1403, score:11796
+    // Step:1429, total:1429, score:11740
+    // Step:1455, total:1455, score:11788
+    // Step:1481, total:1481, score:12236
+
+//target 2
+
+    // Step:25, total:25, score:28356
+    // Step:51, total:51, score:23300
+    // Step:77, total:77, score:24778
+    // Step:103, total:103, score:18426
+    // Step:129, total:129, score:16386
+    // Step:155, total:155, score:14418
+    // Step:181, total:181, score:13234
+    // Step:207, total:207, score:12794
+    // Step:233, total:233, score:12426
+    // Step:259, total:259, score:12746
+    // Step:285, total:285, score:11562
+    // Step:311, total:311, score:11978
+    // Step:337, total:337, score:11786
+    // Step:363, total:363, score:11282
+    // Step:389, total:389, score:12162
+    // Step:415, total:415, score:12074
+    // Step:441, total:441, score:12218
+    // Step:467, total:467, score:11530
+    // Step:493, total:493, score:11754
+    // Step:519, total:519, score:11994
+    // Step:545, total:545, score:11810
+    // Step:571, total:571, score:11658
+    // Step:597, total:597, score:11218
+    // Step:623, total:623, score:11898
+    // Step:649, total:649, score:11506
+    // Step:675, total:675, score:11442
+    // Step:701, total:701, score:11474
+    // Step:727, total:727, score:11970
+    // Step:753, total:753, score:12042
+    // Step:779, total:779, score:11594
+    // Step:805, total:805, score:11986
+    // Step:831, total:831, score:11450
+    // Step:857, total:857, score:11762
+    // Step:883, total:883, score:11522
+    // Step:909, total:909, score:11442
+    // Step:935, total:935, score:11890
+    // Step:961, total:961, score:11490
+    // Step:987, total:987, score:11986
+    // Step:1013, total:1013, score:11706
+    // Step:1039, total:1039, score:12186
+    // Step:1065, total:1065, score:11610
+    // Step:1091, total:1091, score:11866
+    // Step:1117, total:1117, score:11626
+    // Step:1143, total:1143, score:12106
+    // Step:1169, total:1169, score:11386
+    // Step:1195, total:1195, score:11450
+    // Step:1221, total:1221, score:11586
+    // Step:1247, total:1247, score:11418
+    // Step:1273, total:1273, score:11450
+    // Step:1299, total:1299, score:11610
+    // Step:1325, total:1325, score:11898
+    // Step:1351, total:1351, score:11658
+    // Step:1377, total:1377, score:11658
+    // Step:1403, total:1403, score:11746
+    // Step:1429, total:1429, score:11818
+    // Step:1455, total:1455, score:11730
+    // Step:1481, total:1481, score:11442
+    // Step:1507, total:1507, score:11786
+    // Step:1533, total:1533, score:11442
+    // Step:1559, total:1559, score:11874
+    // Step:1585, total:1585, score:11714
+    // Step:1611, total:1611, score:11626
+    // Step:1637, total:1637, score:11458
+    // Step:1663, total:1663, score:11178
+    // Step:1689, total:1689, score:12146
+    // Step:1715, total:1715, score:11634
+    // Step:1741, total:1741, score:12178
+    // Step:1767, total:1767, score:11850
+    // Step:1793, total:1793, score:11698
+    // Step:1819, total:1819, score:11634
+    // Step:1845, total:1845, score:11570
+    // Step:1871, total:1871, score:12026
+    // Step:1897, total:1897, score:11610
+    // Step:1923, total:1923, score:11490
+    // Step:1949, total:1949, score:12122
+    // Step:1975, total:1975, score:11914
+    // Step:2001, total:2001, score:11522
+    // Step:2027, total:2027, score:12314
+    // Step:2053, total:2053, score:11594
+    // Step:2079, total:2079, score:11866
+    // Step:2105, total:2105, score:11538
+    // Step:2131, total:2131, score:11362
+    // Step:2157, total:2157, score:11514
+    // Step:2183, total:2183, score:11650
+    // Step:2209, total:2209, score:11514
+    // Step:2235, total:2235, score:11554
+    // Step:2261, total:2261, score:11474
+    // Step:2287, total:2287, score:11954
+    // Step:2313, total:2313, score:11594
+    // Step:2339, total:2339, score:12098
+    // Step:2365, total:2365, score:11930
+    // Step:2391, total:2391, score:11746
+    // Step:2417, total:2417, score:11226
+    // Step:2443, total:2443, score:11506
+    // Step:2469, total:2469, score:11714
+    // Step:2495, total:2495, score:11786
+    // Step:2521, total:2521, score:12338
+    // Step:2547, total:2547, score:11618
+
+// target3
+
+// target4
+
+
+// target5
+
diff --git a/cpp_dnn/cmaes_initials.par b/cpp_dnn/cmaes_initials.par
new file mode 100644
index 0000000000000000000000000000000000000000..c3609a9827a8d565890bbe46864153385917a7d4
--- /dev/null
+++ b/cpp_dnn/cmaes_initials.par
@@ -0,0 +1,116 @@
+function number 1 2 5 6 8 23  # the first number is read by example_restarts.c, see there.
+restarts 0                    # read by example_restarts.c, remark that restarts
+                              # with the same initialX might be sub-optimal
+#
+# Input parameter file for cmaes_t.
+# Comments start with '#' or '%' until end of line.
+# Actual recent parameter setting is written to file actparcmaes.par.
+#
+
+## --- OBLIGATORY SETTINGS
+# these settings, if read, overwrite the input values to cmaes_init
+
+ N 3        # Problem dimension, overwrites parameter in cmaes_init
+ initialX 10:   # Initial search point. Syntax: 1==read one number, see also end of file.
+    0.5
+    1.1
+    1.1
+#    0.1
+#    0.9
+#    0.1
+#    0.1
+#    0.4
+#    0.15
+#    0.1
+#    0.6
+#    2.8
+ typicalX 1:   # Typical search point (useful for restarts, cave: boundaries), overwritten by initialX
+    0.0        #    these are the read value(s)
+ initialStandardDeviations  1:   #  1==read only one number for all coordinates
+   0.1                           #  numbers should not differ by orders of magnitude
+                                 #  should be roughly 1/4 of the search interval
+                                 #  this number essentially influences the global
+                                 #  search ability (ie. the horizon where to search
+                                 #  at all) on multimodal functions
+
+## --- OPTIONAL SETTINGS
+
+# stop-Parameters can be changed online via cmaes_signals.par
+
+stopMaxFunEvals   1e4     # max number of f-evaluations, 900*(N+3)*(N+3) is default
+# fac*maxFunEvals   1e0     # multiplies stopMaxFunEvals by read number, default is 1
+# stopMaxIter       1e3     # max number of iterations (generations), inf is default
+stopMaxIter       3     # max number of iterations (generations), inf is default
+
+
+stopFitness -500   # stop if function value is smaller than stopFitness
+                     # commented == never stop on function value (default)
+stopTolFun 1e-1     # stop if function value differences are
+                     # smaller than stopTolFun, default=1e-12
+stopTolFunHist 1e-1 # stop if function value differences of best values are
+                     # smaller than stopTolFunHist, default was 0
+stopTolX 1e-2   # stop if step sizes/steps in x-space are
+                 # smaller than TolX, default=0
+stopTolUpXFactor 1e3 # stop if std dev increases more than by TolUpXFactor, default 1e3
+
+seed 0            # 0 == by time, also regard maxTimeFractionForEigendecomposition
+                  #   below, as for values smaller than one the outcome might not be
+                  #   exactly reproducible even with the same seed
+
+# diffMinChange 1 # Minimal coordinate wise standard deviation. Syntax see below.
+#        1e-299   # Interferes with stopTolX termination criterion! default=0
+
+
+## --- internal CPU-time related settings
+
+maxTimeFractionForEigendecompostion 1  # maximal CPU-time fraction for eigensystem
+                     # decomposition. Large values (up to one) are better
+                     # w.r.t. the number of function evaluations to reach a
+                     # certain function value. Only >=1 yields exactly
+                     # reproducible results.
+                     # 0.2==20% should often be faster than larger values
+                     # w.r.t. the CPU-time to reach a certain function value.
+
+# updatecov      1   # default is updating the eigensystem after
+                     # every 1/ccov/N/10-th generation.
+# fac*updatecov  3   # multiplier for updatecov
+
+# resume allcmaes.dat   # reads restart distribution from given file
+
+
+## --- Strategy internal parameter ---
+##     default values are set in cmaes_readpara_SupplementDefaults()
+## -- Selection related parameters
+lambda 5        # number of offspring == samplesize was 12
+# mu
+# weights      log # possible values: log (==default),
+                   #   lin (==linearely decreasing), or equal
+
+## -- Adaptation (distribution estimation) related parameters
+# diagonalCovarianceMatrix -1   # number of iterations, 1<==>always, -1<==>2+100*N/sqrt(lambda)
+# fac*damp      1  # increase or decrease damping for step size control.
+# ccumcov       1  # default is 4/(N+4), 1 means no cumulation for p_c.
+# mucov         1  # 1 means only rank 1 update of C
+# fac*ccov      1  # multiplier for default learning rate for cov. matrix
+
+
+## --- Syntax for input vectors xstart, sigma, mincoorstddev
+#
+#    N 7              # dimension must be defined before
+#    xstart 3 :       # read 3 numbers from next lines, the colon is superfluous
+#      0.2 0.3
+#      0.4 0.5 0.6
+#      0.7
+#
+# reads the first three numbers starting from the
+# line following the keyword "xstart" and recycles
+# these numbers (or cut them) to length N, resulting in
+#   xstart=[0.2 0.3 0.4 0.2 0.3 0.4 0.2]
+# No comments are allowed between the numbers. I.e.
+#
+#    xstart 3      22 anything here is ok, 22 is disregarded  # still ok
+#      0.2 0.3     # this comment fails, if >2 numbers to be read
+#      0.4 0.5 0.6
+#
+# would fail due to the comment between second and third number to
+# be read.
diff --git a/cpp_dnn/cmaes_signals.par b/cpp_dnn/cmaes_signals.par
new file mode 100644
index 0000000000000000000000000000000000000000..e6536fb8fa89a6636f63ab548383179ae596c156
--- /dev/null
+++ b/cpp_dnn/cmaes_signals.par
@@ -0,0 +1,77 @@
+#
+# Comment characters are '%' and '#' to end of line.
+# Uncomment one or more rows (and/or add an uncommented line)
+# and save this file to induce an action.
+#
+# Function cmaes_ReadSignals reads and interprets the syntax
+#   as given in this file
+#
+
+## --- modify termination condition, see also initials.par for more docu
+# stop now                # manual stop as soon as signals.par is parsed
+# stopMaxFunEvals  4.5e6  # stop after given number of function evaluations
+# stopMaxIter 3e3         # stop after given number of iterations (generations)
+# stopFitness 1e-6     # stop if function value is smaller than stopFitness
+# stopTolFun 1e-12     # stop if function value differences are small
+# stopTolFunHist 1e-12 # stop if f-value differences between best values are small
+# stopTolX 1e-1        # stop if step-sizes/steps in x-space are small
+# stopTolUpXFactor 1e3 # stop if std dev increases more than by TolUpXFactor
+
+# checkeigen  1        # number > 0 switches checking on, Check_Eigen() is O(n^3)!
+# maxTimeFractionForEigendecompostion 0.2
+
+# write resume allcmaes.dat  # write data for restart
+
+## --- print data to stdout
+##   syntax (in one row):
+##   print <keyword for cmaes_WriteToFilePtr()>[+<another keyword>]
+##         [<seconds>]
+##   After the first iteration ONLY the action with the smallest
+##     seconds value will take place.
+##   For more info see write data below.
+
+#  print gen+fitness    5
+## "few" prints Fevals Fval Sigma Max&MinCoorDev AxisRatio MinOfD
+#  print fewinfo     30 # print every n seconds
+#  print few+clock     2 # clock: used processor time since start
+  print few          2
+#  print fitness+xmean 3
+#  print gen+few  20
+#  print gen+few+few(diag(D)) 0
+#  print few(diag(D))
+#  print all 100
+
+## --- write data to file (example2.c can also write into data file)
+##  syntax (in one row):
+##  write <keyword for cmaes_WriteToFilePtr()>[+<another keyword>]
+##        [<filename>] [<seconds>]
+##   After the first iteration ONLY the action with the smallest
+##     seconds value will take place.
+
+##  Default filename is tmpcmaes.dat. Default is seconds=1,
+##  and during the first second or so it is 0 with a smooth
+##  writing gap transition until up to one second. For
+##  seconds=0 writing takes place every generation. For seconds < 0
+##  writing is blocked after the first key where seconds < 0 was
+##  written. Blocking lasts until all values for seconds are >=0
+##  again. For keywords compare cmaes_interface.h and function
+##  cmaes_WriteToFilePtr in cmaes.c.
+
+##        KEYWORD(s)                                  FILE          SECONDS to wait until next writing
+# write with default format for plotting
+write iter+eval+sigma+axisratio+fbestever+fitness+fmedian+fworst+mindii+idxmaxSD+maxSD+idxminSD+minSD   outcmaesfit.dat
+write iter+eval+sigma+axisratio+stddevratio+diag(D)       outcmaesaxlen.dat
+write iter+eval+sigma+idxmaxSD+idxminSD+stddev            outcmaesstddev.dat
+write iter+eval+sigma+0+0+xmean                           outcmaesxmean.dat
+write iter+eval+sigma+0+fitness+xbest                     outcmaesxrecentbest.dat
+
+##        KEYWORD(s)        FILE       SECONDS to wait until next writing
+
+# write few+few(diag(D)) rescmaes.dat     0    # writes every generation
+# write few+diag(D)      tmp.dat          0    # writes every generation
+# write few+few(diag(D)) rescmaes.dat          # writes once per second
+# write few+few(diag(D)) rescmaes.dat    -1    # writes once, blocks further writing
+# write gen+xbest          xcmaes.dat     2
+# write B                allcmaes.dat   100    # writes every 100 seconds
+# write all              allcmaes.dat   100
+# write gen+arfitness    tmpcmaes.dat     0
diff --git a/cpp_dnn/dnn.cpp b/cpp_dnn/dnn.cpp
index bd396fb3bf788423a566a574ac1bf925f506d374..2f62ff2b0de7dc6fad139cd8b41aec80ac37f752 100644
--- a/cpp_dnn/dnn.cpp
+++ b/cpp_dnn/dnn.cpp
@@ -474,30 +474,9 @@ namespace cpp_dnn {
                     this->sgd_step(lrate); 
                     
                 }
-                std::cout<<"Loss: "<< sum_loss<<std::endl;
+                // std::cout<<"Loss: "<< sum_loss<<std::endl;
                 
-                // for(var i=0; i < iters; i++){
-                //     var j= getRandomInt(N);
-                //     var Xt = X.slice([0,j], [D,1]);
-                //     var Yt = Y.slice([0,j], [D,1]);
-                //     var Ypred = this.forward(Xt);
-                //     sum_loss.add(sum_loss, this.loss.forward(Ypred, Yt));
-                //     var err = this.loss.backward();
-                //     this.backward(err);
-                //     this.sgd_step(lrate);
-                
-                // }
-                // D, N = X.shape
-                // for it in range(iters):
-                //     j = np.random.randint(N)
-                //     Xt = X[:,j:j+1]; Yt = Y[:,j:j+1]
-                //     print(Xt)
-                //     Ypred=self.forward( Xt)
-                //     l=self.loss.forward(Ypred, Yt)
-                //     delta=self.loss.backward()
-                //     b=self.backward( delta)
-                //     s=self.sgd_step( lrate)
-                //     }
+           
             }
             
         // private:
diff --git a/cpp_dnn/image.cpp b/cpp_dnn/image.cpp
index 0bb6dbe4fa564b4086ae98d7ad15e34eaa21b718..21d060ce27722093cbb35adcf33752706afbacc7 100644
--- a/cpp_dnn/image.cpp
+++ b/cpp_dnn/image.cpp
@@ -18,8 +18,8 @@ namespace cpp_dnn {
 
     class Image { 
         public:
-            scalar res=0.01;
-            scalar bound =3.0;
+            scalar res=0.05;
+            scalar bound =2.5;
             scalar minX;
             scalar maxX;
             scalar minY;
@@ -31,7 +31,7 @@ namespace cpp_dnn {
             int height;
             int width;
 
-            Image():res(0.01),bound(3.0){
+            Image():res(0.05),bound(2.5){
                 minX=-bound;
                 maxX=bound;
                 minY=-bound;
@@ -99,11 +99,23 @@ namespace cpp_dnn {
                 saveImage(predict(target.t()) ,"Target_"+ name);
                 return target.t();
             }
+            
+            int getHamming(const MatrixXI& Ypred,const MatrixXI& YY){
+                int d=0;
+                for(unsigned i=0;i<Ypred.size();i++){
+                    if((Ypred(i)>0.0 && YY(i)>0.0 )||(Ypred(i)<=0.0 && YY(i)<=0.0)){
+                    }else{
+                        d++;
+                    }
+                }
+                return d;
+            }
 
             void saveImage(const MatrixXI& Ypred,std::string name){
                 const int size=height*width*4;
                 int stride=0;
                 unsigned char pix[size];
+
     
                 for(unsigned i=0;i<Ypred.size();i++){
                     if(Ypred(i)>0.0){
@@ -123,7 +135,7 @@ namespace cpp_dnn {
 
                 ////////////////create image and save it//////////////////////////
                 cv::Mat image = cv::Mat(width, height, CV_8UC4, pix);
-                std::string fileName="img/"+name+".jpg";
+                std::string fileName="img_dnn/"+name+".png";
                 cv::imwrite( fileName, image );
                 bool preview=false;
                 if(preview){
diff --git a/cpp_dnn/main.cpp b/cpp_dnn/main.cpp
index badd39b62d5a573d2037f7af31e1b8dc94856608..f2c6ac044497ba14a985f6aab42d869e52ccf41c 100644
--- a/cpp_dnn/main.cpp
+++ b/cpp_dnn/main.cpp
@@ -13,6 +13,8 @@
 using namespace cpp_dnn;
 using scalar=double;
 
+int COUNT=0;
+
 scalar getRandom(){//between 0 and 1
     return ((scalar) rand() / (RAND_MAX));
 }
@@ -45,333 +47,1235 @@ std::vector<scalar>  pointerToVector(double const *x, int N){
 
 // /* the objective (fitness) function to be minimized */
 double fitfun(double const *x, int N,MatrixX X,MatrixX Y,Sequential seq) { /* function "cigtab" */
+  Image Im;
+  MatrixX XX=Im.getLocMatrix();
   seq.setWeights( pointerToVector(x, N));
-  seq.step(X,Y);
-  return seq.sumLoss();
+  auto Ypred=seq.step(X,Y);
+  auto YY=Im.predict(Y);
+  double res=(double) Im.getHamming(Ypred,YY);
+  if(COUNT%100==0){
+    Im.saveImage(Ypred,std::to_string(COUNT)); //test
+    cout<<"iter:"<<COUNT<<" score:"<<res<<endl;
+
+  }
+  COUNT++;
+  
+  
+  return res;
 }
 
 //--------------------------------------------------------------------------------------------------
 int main(int const, char const**) {
 
-  // //Create network
-    // std::vector<Node*> network;
-
-    // Linear l1(2, 12);
-    // Tanh a1;
-
-    // Linear l2(12, 12);
-    // Tanh a2;
-
-    // Linear l3(12, 6);
-    // Tanh a3;
-
-    // Linear l4(6, 6);
-    // Tanh a4;
-
-    // Linear l5(6, 2);
-    // SoftMax a5;
-
-    // NLL l;
-    // network.push_back( &l1);
-    // network.push_back( &a1);
-    // network.push_back( &l2);
-    // network.push_back( &a2);
-    // network.push_back( &l3);
-    // network.push_back( &a3);
-    // network.push_back( &l4);
-    // network.push_back( &a4);
-    // network.push_back( &l5);
-    // network.push_back( &a5);
-
-    // Sequential seq(network, &l);
-
-    // Linear linear_1(2,3);
-    // scalar lrate = 0.005;
-    // // arma::Mat<double> a=arma::randu(2,2);
-
-    
-    // arma::Mat<scalar> X;
-    // arma::Mat<scalar> Y;
-    // X<< 2<<  3<< 9<< 12<<arma::endr
-    //  << 5<<  2<< 6<<  5<<arma::endr;
-    // Y<<0<< 1<< 0<< 1<<arma::endr
-    //  <<1<< 0<< 1<< 0<<arma::endr;
-    // // arma::Mat<scalar> dL_dz1;
-    // // dL_dz1<< 1.69467553e-09<<-1.33530535e-06<<  0.00000000e+00<<-0.00000000e+00<<arma::endr
-    // //       <<-5.24547376e-07<< 5.82459519e-04<< -3.84805202e-10<< 1.47943038e-09<<arma::endr
-    // //       <<-3.47063705e-02<< 2.55611604e-01<< -1.83538094e-02<< 1.11838432e-04<<arma::endr;
-
-    // // std::cout << linear_1.forward(X) << '\n';
-    // // std::cout << linear_1.backward(dL_dz1) << '\n';
-    // // linear_1.sgd_step(lrate);
-    // // std::cout << linear_1._W << '\n';
-    // // std::cout << linear_1._W0 << '\n';
+  scalar res=0.05f;
+    scalar bound =2.5f;
 
 
-
-    // std::cout << arma::index_max(Y,0) << '\n';
-    // std::vector<Node*> network;
-    // Linear l1(2, 3);
-    // ReLU t;
-    // Linear l2(3, 2);
-    // SoftMax s;
-    // NLL l;
-    // network.push_back( &l1);
-    // network.push_back( &t);
-    // network.push_back( &l2);
-    // network.push_back( &s);
-
-    // arma::Mat<scalar> z_1 = l1.forward(X);
-
-    // std::cout << z_1 << '\n';
-
-    // arma::Mat<scalar> a_1 = t.forward(z_1);
-
-    // std::cout << a_1 << '\n';
-
-    // arma::Mat<scalar> z_2;
-
-    // // z_2 <<0.40837833<<0.53900088<< 0.56956001<< 0.57209377<<arma::endr
-    // //      << -0.66368766<< 0.65353931<< 0.96361427<< 0.98919526<<arma::endr;
-
-
-    // z_2<<5.28714248<< 3.64078533<< 10.92235599<< 12.36410102<<arma::endr
-    //    <<  0.78906625<< 0.80620366<< 2.41861097<<4.44170662<<arma::endr;
     
-    // // arma::Mat<scalar> z_2 = l2.forward(a_1);
+    scalar minX=-bound;
+    scalar maxX=bound;
+    scalar minY=-bound;
+    scalar maxY=bound;
+    scalar dx=res;
+    scalar dy=res;
+    int height=(int)((maxX-minX)/dx);
+    int width=(int)((maxY-minY)/dy);
 
-    // // std::cout << z_2 << '\n';
+    cout<<"width: "<<width<<", height: "<<height <<std::endl;
 
     
-    // arma::Mat<scalar> a_2 = s.forward(z_2);
+    //Create Image
+    Image Im;
+    MatrixX X=Im.getLocMatrix();
 
-    // std::cout << a_2 << '\n';
     
     
-
-    // arma::Mat<scalar> loss = l.forward(a_2, Y);
-
-    // std::cout << loss<< '\n';
-
-    // arma::Mat<scalar> dloss = l.backward();
-
-    // std::cout << dloss<< '\n';
-
-    // arma::Mat<scalar>  dL_dz2 = s.backward(dloss);
-
-    // std::cout << dL_dz2<< '\n';
-  
-    // arma::Mat<scalar> dL_da1;
-
-    // // dL_da1<<0.47375374<< -0.3361494<< 0.25611147<<-0.38332583<<arma::endr
-    // // <<-0.2210031<< 0.15681155<< -0.11947437<< 0.17881905<<arma::endr
-    // // <<-0.56355604<< 0.39986813<< -0.30465863<< 0.45598708<<arma::endr;
-
-    // dL_da1<< 6.28919807e-01<< -3.52832568e-02<<  6.35791049e-01<< -2.30458563e-04<<arma::endr
-    // <<-2.93387075e-01<<  1.64594141e-02<< -2.96592466e-01<<  1.07507449e-04<<arma::endr
-    // <<-7.48134578e-01<<  4.19713676e-02<< -7.56308297e-01<<  2.74143091e-04<<arma::endr;
-
-    // std::cout << dL_da1<< '\n';
-
-    // // dL_da1 = linear_2.backward(dL_dz2)
+    cpp_frep::Circle c(1.5f,0.0f,0.0f);
+    // std::vector<unsigned char> targ1 =drawFrep(&c,minX, maxX, minY, maxY, dx, dy,"circle_target",false);
+    MatrixX targ1=Im.getTarget( &c,"circle");
+
+    cpp_frep::Rectangle r(-1.5f,1.5f,-1.0f,1.0f);
+    cpp_frep::Rotate rot1 (&r,0.0f,0.0f,90.0f);
+    // std::vector<unsigned char> targ2 =drawFrep(&rot1,minX, maxX, minY, maxY, dx, dy,"rectange_target",false);
+    MatrixX targ2=Im.getTarget( &rot1,"rectange");
+
+    cpp_frep::InvoluteGear gear( 1.0f,  1.0f, 1.1f, 20.0f, 8.0f) ;
+    cpp_frep::Rotate rot (&gear,0.0f,0.0f,15.0f);
+    cpp_frep::Scale sc1(&rot,0.0f,0.0f,0.5f,0.5f);
+    cpp_frep::Add target(&sc1,&c);
+    // std::vector<unsigned char> targ3 =drawFrep(&target,minX, maxX, minY, maxY, dx, dy,"gear_target",false);
+    MatrixX targ3=Im.getTarget( &target,"gear");
+
+
+    cpp_frep::Circle c1(0.9f,-0.5f,0.8f);
+    cpp_frep::Circle c2(0.8f,0.2f,-0.2f);
+    cpp_frep::Circle c3(0.9f,1.5f,0.0f);
+    cpp_frep::Circle c4(0.9f,1.7f,-1.1f);
+    // Subtract ss(&rot1,&c1);
     
+    // Subtract sss(&ss,&c2);
+    cpp_frep::Add aa(&c1,&c3);
+    cpp_frep::Add aaa(&aa,&c2);
+    cpp_frep::Add a(&aaa,&c4);
+    cpp_frep::Morph m (&a,&target,0.6f);
+    cpp_frep::Rotate rot2 (&m,0.3f,0.0f,-90.0f);
+    // Scale scc (&m,0.0f,0.0f,1.0,1.0);
+    // std::vector<unsigned char> targ4 =drawFrep(&rot2,minX, maxX, minY, maxY, dx, dy,"blob_target",false);
+    MatrixX targ4=Im.getTarget( &rot2,"blob");
+
+    cpp_frep::Circle c5(0.5f,0.0f,0.0f);
+    cpp_frep::Subtract ss(&c,&c5);
+    // std::vector<unsigned char> targ5 =drawFrep(&ss,minX, maxX, minY, maxY, dx, dy,"hole_target",false);
+    MatrixX targ5=Im.getTarget( &ss,"hole");
+
+    ////////////////////////////////////////////////////
+
+    //Create network
+    std::vector<Node*> network;
 
-    // arma::Mat<scalar> dL_dz1 = t.backward(dL_da1);
-
-    // std::cout << dL_dz1<< '\n';
-
-    // arma::Mat<scalar> dL_dX = l1.backward(dL_dz1);
-
-    // std::cout << dL_dX<< '\n';
-
-    // l1.sgd_step(lrate);
-    // std::cout << l1._W << '\n';
-    // std::cout << l1._W0 << '\n';
-
-    // l1.sgd_step(lrate);
-    // std::cout << l1._W << '\n';
-    // std::cout << l1._W0 << '\n';
-
-    // dL_dX = linear_1.backward(dL_dz1)
-    // unit_test('dL_dX', test_values['dL_dX'], dL_dX)
-
-    // Sequential seq(network, &l);
-    // std::cout <<seq.getWeightsNum()<<'\n';
-    // std::cout <<seq.step(X,Y)<< '\n';
-
+    Linear l1(2, 12);
+    Tanh a1;
 
-    // std::vector<Node*> network;
-    // Linear l1(2, 3);
-    // Sigmoid r;
-    // Linear l2(3, 3);
-    // Tanh t;
-    // Tanh t1;
-    // Linear l3(3, 2);
-    // SoftMax s;
-    // NLL l;
-    // network.push_back( &l1);
-    // network.push_back( &r);
-    // // network.push_back( &l2);
-    // // network.push_back( &t1);
-    // network.push_back( &l3);
-    // network.push_back( &s);
+    Linear l2(12, 12);
+    ReLU a2;
 
-    // Sequential seq(network, &l);
-    // std::cout <<seq.getWeightsNum()<<'\n';
-    // std::cout <<seq.step(X,Y)<< '\n';
-    arma::Mat<scalar> X;
-    arma::Mat<scalar> Y;
+    Linear l3(12, 6);
+    ReLU a3;
 
-    X <<-0.23390341<< 1.18151883<< -2.46493986<< 1.55322202<< 1.27621763<< 2.39710997<< -1.3440304<< -0.46903436<< -0.64673502<< -1.44029872<<
-        -1.37537243<< 1.05994811<< -0.93311512<< 1.02735575<< -0.84138778<<-2.22585412<< -0.42591102<< 1.03561105<< 0.91125595<< -2.26550369<<arma::endr <<
-        -0.92254932<< -1.1030963<< -2.41956036<< -1.15509002<< -1.04805327<< 0.08717325<< 0.8184725<< -0.75171045<< 0.60664705<< 0.80410947<<
-        -0.11600488<< 1.03747218<< -0.67210575<< 0.99944446<< -0.65559838<<-0.40744784<< -0.58367642<< 1.0597278<< -0.95991874<< -1.41720255<<arma::endr;
+    Linear l4(6, 6);
+    Tanh a4;
 
-    Y <<1.<< 1.<< 0.<< 1.<< 1.<< 1.<< 0.<< 0.<< 0.<< 0.<< 0.<< 1.<< 1.<< 1.<< 0.<< 0.<< 0.<< 1.<< 1.<< 0.<<arma::endr
-      <<0.<< 0.<< 1.<< 0.<< 0.<< 0.<< 1.<< 1.<< 1.<< 1.<< 1.<< 0.<< 0.<< 0.<< 1.<< 1.<< 1.<< 0.<< 0.<< 1.<<arma::endr;
+    Linear l5(6, 2);
+    SoftMax a5;
 
-    std::vector<Node*> network;
-    Linear l1(2, 10);
-    ReLU r1;
-    Linear l2(10, 10);
-    ReLU r2;
-    Linear l3(10, 2);
-    SoftMax s;
     NLL l;
     network.push_back( &l1);
-    network.push_back( &r1);
+    network.push_back( &a1);
     network.push_back( &l2);
-    network.push_back( &r2);
+    network.push_back( &a2);
     network.push_back( &l3);
-    network.push_back( &s);
+    network.push_back( &a3);
+    network.push_back( &l4);
+    network.push_back( &a4);
+    network.push_back( &l5);
+    network.push_back( &a5);
 
-    Sequential nn(network, &l);
+    Sequential seq(network, &l);
 
-    // Sequential([Linear(2, 10), ReLU(), Linear(10, 10), ReLU(), Linear(10,2), SoftMax()], NLL())
+    ///////TARGET/////
+    MatrixX Y=targ5; /////////////////////////////////////////////target
+    Im.saveImage(seq.step(X,Y),"trial"); //test
 
+    std::cout<<"Number of Weights:"<<(int)seq.getWeightsNum()<<std::endl;
+
+    // ///////////////////////////// //Optimize neldermead
+    // unsigned numWeights=seq.getWeightsNum();
+    auto YY=Im.predict(Y);
+
+
+    ///////SGD/////
+
+    // unsigned epoch=2500;
+    // unsigned it=1000;//10000
+    // scalar lrate = 0.005;
+    // for (unsigned i=0;i<epoch;i++){
+    //   if(i%25==0){
+    //     auto Ypred=seq.step(X,Y);
+    //     Im.saveImage(Ypred,std::to_string(i)); //test
+    //     std::cout<<"iter:"<<i<<" score:"<<Im.getHamming(Ypred,YY)<<std::endl;
+    //   }
+    //   seq.sgd(X, Y, it, lrate);
+    // }
     
-    unsigned it=10000;
-    unsigned D= X.n_rows;
-    unsigned N= X.n_cols;
-    unsigned O= Y.n_rows;
 
-    scalar lrate = 0.005;
+    
     // Modifies the weights and biases
-    nn.sgd(X, Y, it, lrate);
-
-    // Draw it...
     
-    cout<<nn.predict(nn.forward(X))<<endl;
 
+    ////cmaes//
+    cmaes_t evo; /* an CMA-ES type struct or "object" */
+    double *arFunvals, *const*pop, *xfinal;
+    int i; 
+    arFunvals = cmaes_init(&evo, 5, NULL, NULL, 0, 0, "cpp_dnn/cmaes_initials.par");
+    printf("%s\n", cmaes_SayHello(&evo));
+     
+    cmaes_ReadSignals(&evo, "cmaes_signals.par");  /* write header and initial values */
+
+    /* Iterate until stop criterion holds */
+    while(!cmaes_TestForTermination(&evo))
+    { 
+      /* generate lambda new search points, sample population */
+      pop = cmaes_SamplePopulation(&evo); /* do not change content of pop */
+
+      /* Here we may resample each solution point pop[i] until it
+	 	 becomes feasible. function is_feasible(...) needs to be
+	 	 user-defined.
+	 	 Assumptions: the feasible domain is convex, the optimum is
+	 	 not on (or very close to) the domain boundary, initialX is
+	 	 feasible and initialStandardDeviations are sufficiently small
+	 	 to prevent quasi-infinite looping. */
+      /* for (i = 0; i < cmaes_Get(&evo, "popsize"); ++i)
+           while (!is_feasible(pop[i]))
+             cmaes_ReSampleSingle(&evo, i);
+      */
+
+      /* evaluate the new search points using fitfun */
+      for (i = 0; i < cmaes_Get(&evo, "lambda"); ++i) {
+    	  arFunvals[i] = fitfun(pop[i], (int) cmaes_Get(&evo, "dim"),X,Y,seq);
+      }
+
+      /* update the search distribution used for cmaes_SamplePopulation() */
+      cmaes_UpdateDistribution(&evo, arFunvals);  
+
+      /* read instructions for printing output or changing termination conditions */ 
+      cmaes_ReadSignals(&evo, "cmaes_signals.par");
+      fflush(stdout); /* useful in MinGW */
+    }
+    printf("Stop:\n%s\n",  cmaes_TestForTermination(&evo)); /* print termination reason */
+    cmaes_WriteToFile(&evo, "all", "allcmaes.dat");         /* write final results */
 
-    cout<<"hereeee "<<endl;
+    /* get best estimator for the optimum, xmean */
+    xfinal = cmaes_GetNew(&evo, "xmean"); /* "xbestever" might be used as well */
+    cmaes_exit(&evo); /* release memory */ 
 
+    /* do something with final solution and finally release memory */
+    std::cout<<*xfinal<<'\n';
     
-    // X = np.array([[2, 3, 9, 12],
-    //               [5, 1, 6, 5]])
-
-    // y = np.array([[1, 0, 1, 0]])
-    // return X, for_softmax(y)
+    free(xfinal); 
 
+    seq.setWeights( pointerToVector(pop[0], (int) cmaes_Get(&evo, "dim")));
+    Im.saveImage(seq.step(X,Y),"trialll");
     
 
 
+
+
+    
   
     return 0;
 }
 
-// void oldCode(){
-//   //Create Image
-//   Image Im;
-//   MatrixX X=Im.getLocMatrix();
-//   cpp_frep::Circle frep(1.5f,0.0f,0.0f);
-//   MatrixX Y=Im.getTarget( &frep ,"Circle");
-//   // Im.saveImage(seq.step(X,Y),"trial"); //test
-
-//   ///////////////////////////// //Optimize neldermead
-//   unsigned numWeights=seq.getWeightsNum();
-
-//   // std::vector<scalar> v=getRandomWeights(numWeights);
-//   // std::cout << seq.sumLoss()<< '\n';
-//   // seq.setWeights(v);
-//   // Im.saveImage(seq.step(X,Y),"trial1"); //test
-//   // std::cout << seq.sumLoss()<< '\n';
-
-
-//   // float precision = 0.001;
-//   // int dimension = (int)numWeights;
-//   // unsigned maxSteps=1000;
-//   // NelderMeadOptimizer o(dimension, precision);
-//   // std::cout << dimension<< '\n';
-
-//   // request a simplex to start with
-//   // Vector v(getRandomWeights(numWeights));
-//   // Vector v1(getRandomWeights(numWeights));
-//   // Vector v2(getRandomWeights(numWeights));
-//   // o.insert(v);
-//   // o.insert(v1);
-//   // o.insert(v2);
-//   // unsigned count=0;
-
-//   // while (!o.done() && count<maxSteps) {
-//   //     seq.setWeights(v.get());
-//   //     Im.saveImage(seq.step(X,Y),"trial"+std::to_string(count));
-//   //     v = o.step(v, -seq.sumLoss()); //later change f(v)
-//   //     count++;
-
-//   // }
-
-//   ///////////////////////////// //Optimize CMAES
-//   cmaes_t evo; /* an CMA-ES type struct or "object" */
-//   double *arFunvals, *const*pop, *xfinal;
-//   int i; 
-//   arFunvals = cmaes_init(&evo, 5, NULL, NULL, 0, 0, "cpp_dnn/cmaes_initials.par");
-//   printf("%s\n", cmaes_SayHello(&evo));
-
-//   cmaes_ReadSignals(&evo, "cmaes_signals.par");  /* write header and initial values */
-
-//   /* Iterate until stop criterion holds */
-//   while(!cmaes_TestForTermination(&evo))
-//   { 
-//     /* generate lambda new search points, sample population */
-//     pop = cmaes_SamplePopulation(&evo); /* do not change content of pop */
-
-//     /* Here we may resample each solution point pop[i] until it
-//   becomes feasible. function is_feasible(...) needs to be
-//   user-defined.
-//   Assumptions: the feasible domain is convex, the optimum is
-//   not on (or very close to) the domain boundary, initialX is
-//   feasible and initialStandardDeviations are sufficiently small
-//   to prevent quasi-infinite looping. */
-//     /* for (i = 0; i < cmaes_Get(&evo, "popsize"); ++i)
-//         while (!is_feasible(pop[i]))
-//           cmaes_ReSampleSingle(&evo, i);
-//     */
-
-//     /* evaluate the new search points using fitfun */
-//     for (i = 0; i < cmaes_Get(&evo, "lambda"); ++i) {
-//       arFunvals[i] = fitfun(pop[i], (int) cmaes_Get(&evo, "dim"),X,Y,seq);
-//     }
-
-//     /* update the search distribution used for cmaes_SamplePopulation() */
-//     cmaes_UpdateDistribution(&evo, arFunvals);  
-
-//     /* read instructions for printing output or changing termination conditions */ 
-//     cmaes_ReadSignals(&evo, "cmaes_signals.par");
-//     fflush(stdout); /* useful in MinGW */
-//   }
-//   printf("Stop:\n%s\n",  cmaes_TestForTermination(&evo)); /* print termination reason */
-//   cmaes_WriteToFile(&evo, "all", "allcmaes.dat");         /* write final results */
-
-//   /* get best estimator for the optimum, xmean */
-//   xfinal = cmaes_GetNew(&evo, "xmean"); /* "xbestever" might be used as well */
-//   cmaes_exit(&evo); /* release memory */ 
-
-//   /* do something with final solution and finally release memory */
-//   std::cout<<*xfinal<<'\n';
-
-//   free(xfinal); 
-//   seq.setWeights( pointerToVector(pop[0], (int) cmaes_Get(&evo, "dim")));
-//   Im.saveImage(seq.step(X,Y),"trialll");
-  
-// } 
+//dnn_sgd target 1
+  //   iter:0 score:7266
+  // iter:25 score:286
+  // iter:50 score:302
+  // iter:75 score:182
+  // iter:100 score:264
+  // iter:125 score:390
+  // iter:150 score:83
+  // iter:175 score:125
+  // iter:200 score:187
+  // iter:225 score:189
+  // iter:250 score:188
+  // iter:275 score:164
+  // iter:300 score:151
+  // iter:325 score:98
+  // iter:350 score:74
+  // iter:375 score:118
+  // iter:400 score:175
+  // iter:425 score:59
+  // iter:450 score:103
+  // iter:475 score:126
+  // iter:500 score:88
+  // iter:525 score:79
+  // iter:550 score:110
+  // iter:575 score:98
+  // iter:600 score:126
+  // iter:625 score:153
+  // iter:650 score:149
+  // iter:675 score:76
+  // iter:700 score:65
+  // iter:725 score:70
+  // iter:750 score:76
+  // iter:775 score:50
+  // iter:800 score:68
+  // iter:825 score:89
+  // iter:850 score:141
+  // iter:875 score:142
+  // iter:900 score:154
+  // iter:925 score:47
+  // iter:950 score:75
+  // iter:975 score:108
+  // iter:1000 score:53
+  // iter:1025 score:69
+  // iter:1050 score:120
+  // iter:1075 score:62
+  // iter:1100 score:70
+  // iter:1125 score:59
+  // iter:1150 score:122
+  // iter:1175 score:107
+  // iter:1200 score:84
+  // iter:1225 score:77
+  // iter:1250 score:67
+  // iter:1275 score:86
+  // iter:1300 score:76
+  // iter:1325 score:139
+  // iter:1350 score:43
+  // iter:1375 score:119
+  // iter:1400 score:113
+  // iter:1425 score:68
+  // iter:1450 score:63
+  // iter:1475 score:44
+  // iter:1500 score:163
+  // iter:1525 score:50
+  // iter:1550 score:118
+  // iter:1575 score:65
+  // iter:1600 score:72
+  // iter:1625 score:93
+  // iter:1650 score:33
+  // iter:1675 score:44
+  // iter:1700 score:52
+  // iter:1725 score:107
+  // iter:1750 score:67
+  // iter:1775 score:34
+  // iter:1800 score:66
+  // iter:1825 score:81
+  // iter:1850 score:47
+  // iter:1875 score:43
+  // iter:1900 score:63
+  // iter:1925 score:45
+  // iter:1950 score:43
+  // iter:1975 score:79
+  // iter:2000 score:53
+  // iter:2025 score:63
+  // iter:2050 score:52
+  // iter:2075 score:83
+  // iter:2100 score:62
+  // iter:2125 score:90
+  // iter:2150 score:61
+  // iter:2175 score:95
+  // iter:2200 score:77
+  // iter:2225 score:79
+  // iter:2250 score:85
+  // iter:2275 score:57
+  // iter:2300 score:89
+  // iter:2325 score:36
+  // iter:2350 score:56
+  // iter:2375 score:30
+  // iter:2400 score:54
+  // iter:2425 score:140
+  // iter:2450 score:52
+  // iter:2475 score:69
+//dnn_sgd target 2
+  //   Number of Weights:326
+  // iter:0 score:7760
+  // iter:25 score:459
+  // iter:50 score:270
+  // iter:75 score:344
+  // iter:100 score:142
+  // iter:125 score:138
+  // iter:150 score:203
+  // iter:175 score:264
+  // iter:200 score:137
+  // iter:225 score:98
+  // iter:250 score:84
+  // iter:275 score:202
+  // iter:300 score:134
+  // iter:325 score:106
+  // iter:350 score:62
+  // iter:375 score:88
+  // iter:400 score:133
+  // iter:425 score:106
+  // iter:450 score:91
+  // iter:475 score:227
+  // iter:500 score:201
+  // iter:525 score:141
+  // iter:550 score:90
+  // iter:575 score:36
+  // iter:600 score:105
+  // iter:625 score:106
+  // iter:650 score:80
+  // iter:675 score:67
+  // iter:700 score:26
+  // iter:725 score:59
+  // iter:750 score:69
+  // iter:775 score:45
+  // iter:800 score:85
+  // iter:825 score:97
+  // iter:850 score:32
+  // iter:875 score:42
+  // iter:900 score:109
+  // iter:925 score:43
+  // iter:950 score:77
+  // iter:975 score:59
+  // iter:1000 score:73
+  // iter:1025 score:68
+  // iter:1050 score:101
+  // iter:1075 score:105
+  // iter:1100 score:46
+  // iter:1125 score:19
+  // iter:1150 score:96
+  // iter:1175 score:36
+  // iter:1200 score:56
+  // iter:1225 score:35
+  // iter:1250 score:32
+  // iter:1275 score:64
+  // iter:1300 score:70
+  // iter:1325 score:33
+  // iter:1350 score:20
+  // iter:1375 score:43
+  // iter:1400 score:35
+  // iter:1425 score:19
+  // iter:1450 score:33
+  // iter:1475 score:27
+  // iter:1500 score:18
+  // iter:1525 score:47
+  // iter:1550 score:16
+  // iter:1575 score:19
+  // iter:1600 score:6
+  // iter:1625 score:32
+  // iter:1650 score:16
+  // iter:1675 score:61
+  // iter:1700 score:22
+  // iter:1725 score:8
+  // iter:1750 score:15
+  // iter:1775 score:23
+  // iter:1800 score:10
+  // iter:1825 score:6
+  // iter:1850 score:29
+  // iter:1875 score:21
+  // iter:1900 score:10
+  // iter:1925 score:9
+  // iter:1950 score:4
+  // iter:1975 score:5
+  // iter:2000 score:23
+  // iter:2025 score:67
+  // iter:2050 score:111
+  // iter:2075 score:34
+  // iter:2100 score:6
+  // iter:2125 score:29
+  // iter:2150 score:18
+  // iter:2175 score:48
+  // iter:2200 score:5
+  // iter:2225 score:12
+  // iter:2250 score:10
+  // iter:2275 score:24
+  // iter:2300 score:14
+  // iter:2325 score:1
+  // iter:2350 score:8
+  // iter:2375 score:2
+  // iter:2400 score:17
+  // iter:2425 score:20
+  // iter:2450 score:3
+  // iter:2475 score:5
+//dnn_sgd target 3
+  // Number of Weights:326
+  // iter:0 score:5168
+  // iter:25 score:1175
+  // iter:50 score:1110
+  // iter:75 score:1031
+  // iter:100 score:1106
+  // iter:125 score:872
+  // iter:150 score:989
+  // iter:175 score:745
+  // iter:200 score:905
+  // iter:225 score:825
+  // iter:250 score:665
+  // iter:275 score:694
+  // iter:300 score:903
+  // iter:325 score:692
+  // iter:350 score:792
+  // iter:375 score:767
+  // iter:400 score:695
+  // iter:425 score:633
+  // iter:450 score:699
+  // iter:475 score:719
+  // iter:500 score:642
+  // iter:525 score:704
+  // iter:550 score:634
+  // iter:575 score:547
+  // iter:600 score:581
+  // iter:625 score:541
+  // iter:650 score:723
+  // iter:675 score:610
+  // iter:700 score:658
+  // iter:725 score:595
+  // iter:750 score:595
+  // iter:775 score:669
+  // iter:800 score:672
+  // iter:825 score:723
+  // iter:850 score:834
+  // iter:875 score:593
+  // iter:900 score:609
+  // iter:925 score:582
+  // iter:950 score:592
+  // iter:975 score:511
+  // iter:1000 score:579
+  // iter:1025 score:537
+  // iter:1050 score:536
+  // iter:1075 score:512
+  // iter:1100 score:606
+  // iter:1125 score:571
+  // iter:1150 score:532
+  // iter:1175 score:607
+  // iter:1200 score:606
+  // iter:1225 score:496
+  // iter:1250 score:492
+  // iter:1275 score:583
+  // iter:1300 score:621
+  // iter:1325 score:521
+  // iter:1350 score:672
+  // iter:1375 score:643
+  // iter:1400 score:607
+  // iter:1425 score:551
+  // iter:1450 score:540
+  // iter:1475 score:573
+  // iter:1500 score:622
+  // iter:1525 score:499
+  // iter:1550 score:510
+  // iter:1575 score:584
+  // iter:1600 score:542
+  // iter:1625 score:541
+  // iter:1650 score:573
+  // iter:1675 score:607
+  // iter:1700 score:546
+  // iter:1725 score:661
+  // iter:1750 score:548
+  // iter:1775 score:533
+  // iter:1800 score:695
+  // iter:1825 score:592
+  // iter:1850 score:553
+  // iter:1875 score:557
+  // iter:1900 score:590
+  // iter:1925 score:515
+  // iter:1950 score:559
+  // iter:1975 score:514
+  // iter:2000 score:490
+  // iter:2025 score:539
+  // iter:2050 score:591
+  // iter:2075 score:517
+  // iter:2100 score:547
+  // iter:2125 score:560
+  // iter:2150 score:554
+  // iter:2175 score:468
+  // iter:2200 score:547
+  // iter:2225 score:559
+  // iter:2250 score:551
+  // iter:2275 score:651
+  // iter:2300 score:582
+  // iter:2325 score:617
+  // iter:2350 score:606
+  // iter:2375 score:550
+  // iter:2400 score:506
+  // iter:2425 score:837
+  // iter:2450 score:534
+  // iter:2475 score:566
+//dnn_sgd target 4
+  //   width: 99, height: 99
+  // Number of Weights:326
+  // iter:0 score:6479
+  // iter:25 score:484
+  // iter:50 score:220
+  // iter:75 score:244
+  // iter:100 score:350
+  // iter:125 score:325
+  // iter:150 score:374
+  // iter:175 score:303
+  // iter:200 score:425
+  // iter:225 score:184
+  // iter:250 score:248
+  // iter:275 score:229
+  // iter:300 score:197
+  // iter:325 score:252
+  // iter:350 score:316
+  // iter:375 score:222
+  // iter:400 score:194
+  // iter:425 score:134
+  // iter:450 score:201
+  // iter:475 score:146
+  // iter:500 score:166
+  // iter:525 score:187
+  // iter:550 score:198
+  // iter:575 score:237
+  // iter:600 score:185
+  // iter:625 score:154
+  // iter:650 score:173
+  // iter:675 score:364
+  // iter:700 score:155
+  // iter:725 score:381
+  // iter:750 score:165
+  // iter:775 score:224
+  // iter:800 score:169
+  // iter:825 score:157
+  // iter:850 score:182
+  // iter:875 score:163
+  // iter:900 score:154
+  // iter:925 score:143
+  // iter:950 score:201
+  // iter:975 score:291
+  // iter:1000 score:198
+  // iter:1025 score:161
+  // iter:1050 score:131
+  // iter:1075 score:188
+  // iter:1100 score:185
+  // iter:1125 score:132
+  // iter:1150 score:144
+  // iter:1175 score:217
+  // iter:1200 score:210
+  // iter:1225 score:160
+  // iter:1250 score:183
+  // iter:1275 score:202
+  // iter:1300 score:257
+  // iter:1325 score:210
+  // iter:1350 score:163
+  // iter:1375 score:118
+  // iter:1400 score:197
+  // iter:1425 score:160
+  // iter:1450 score:158
+  // iter:1475 score:166
+  // iter:1500 score:154
+  // iter:1525 score:162
+  // iter:1550 score:211
+  // iter:1575 score:150
+  // iter:1600 score:164
+  // iter:1625 score:193
+  // iter:1650 score:123
+  // iter:1675 score:146
+  // iter:1700 score:105
+  // iter:1725 score:185
+  // iter:1750 score:234
+  // iter:1775 score:101
+  // iter:1800 score:136
+  // iter:1825 score:122
+  // iter:1850 score:115
+  // iter:1875 score:199
+  // iter:1900 score:121
+  // iter:1925 score:130
+  // iter:1950 score:180
+  // iter:1975 score:85
+  // iter:2000 score:154
+  // iter:2025 score:154
+  // iter:2050 score:155
+  // iter:2075 score:161
+  // iter:2100 score:169
+  // iter:2125 score:132
+  // iter:2150 score:165
+  // iter:2175 score:126
+  // iter:2200 score:123
+  // iter:2225 score:115
+  // iter:2250 score:143
+  // iter:2275 score:145
+  // iter:2300 score:166
+  // iter:2325 score:119
+  // iter:2350 score:252
+  // iter:2375 score:85
+  // iter:2400 score:128
+  // iter:2425 score:151
+  // iter:2450 score:160
+  // iter:2475 score:119
+//dnn_sgd target 5
+  // Number of Weights:326
+  // iter:0 score:7535
+  // iter:25 score:516
+  // iter:50 score:376
+  // iter:75 score:350
+  // iter:100 score:295
+  // iter:125 score:301
+  // iter:150 score:218
+  // iter:175 score:255
+  // iter:200 score:196
+  // iter:225 score:249
+  // iter:250 score:195
+  // iter:275 score:164
+  // iter:300 score:176
+  // iter:325 score:209
+  // iter:350 score:225
+  // iter:375 score:157
+  // iter:400 score:183
+  // iter:425 score:188
+  // iter:450 score:182
+  // iter:475 score:244
+  // iter:500 score:81
+  // iter:525 score:84
+  // iter:550 score:122
+  // iter:575 score:121
+  // iter:600 score:150
+  // iter:625 score:162
+  // iter:650 score:209
+  // iter:675 score:244
+  // iter:700 score:135
+  // iter:725 score:93
+  // iter:750 score:117
+  // iter:775 score:78
+  // iter:800 score:114
+  // iter:825 score:112
+  // iter:850 score:131
+  // iter:875 score:183
+  // iter:900 score:145
+  // iter:925 score:113
+  // iter:950 score:96
+  // iter:975 score:87
+  // iter:1000 score:88
+  // iter:1025 score:112
+  // iter:1050 score:104
+  // iter:1075 score:110
+  // iter:1100 score:92
+  // iter:1125 score:131
+  // iter:1150 score:97
+  // iter:1175 score:176
+  // iter:1200 score:110
+  // iter:1225 score:93
+  // iter:1250 score:114
+  // iter:1275 score:73
+  // iter:1300 score:90
+  // iter:1325 score:117
+  // iter:1350 score:97
+  // iter:1375 score:163
+  // iter:1400 score:166
+  // iter:1425 score:111
+  // iter:1450 score:102
+  // iter:1475 score:117
+  // iter:1500 score:88
+  // iter:1525 score:78
+  // iter:1550 score:119
+  // iter:1575 score:92
+  // iter:1600 score:115
+  // iter:1625 score:169
+  // iter:1650 score:71
+  // iter:1675 score:77
+  // iter:1700 score:92
+  // iter:1725 score:100
+  // iter:1750 score:117
+  // iter:1775 score:81
+  // iter:1800 score:97
+  // iter:1825 score:93
+  // iter:1850 score:79
+  // iter:1875 score:84
+  // iter:1900 score:82
+  // iter:1925 score:86
+  // iter:1950 score:87
+  // iter:1975 score:119
+  // iter:2000 score:106
+  // iter:2025 score:124
+  // iter:2050 score:90
+  // iter:2075 score:111
+  // iter:2100 score:132
+  // iter:2125 score:78
+  // iter:2150 score:68
+  // iter:2175 score:98
+  // iter:2200 score:102
+  // iter:2225 score:86
+  // iter:2250 score:91
+  // iter:2275 score:84
+  // iter:2300 score:95
+  // iter:2325 score:78
+  // iter:2350 score:105
+  // iter:2375 score:68
+  // iter:2400 score:152
+  // iter:2425 score:82
+  // iter:2450 score:83
+  // iter:2475 score:103
+
+
+//dnn_cmaes target 1
+  // iter:0 score:7191
+  // iter:100 score:2809
+  // iter:200 score:2809
+  // iter:300 score:3091
+  // iter:400 score:3515
+  // iter:500 score:2859
+  // iter:600 score:2629
+  // iter:700 score:1527
+  // iter:800 score:1445
+  // iter:900 score:1498
+  // iter:1000 score:2193
+  // iter:1100 score:2199
+  // iter:1200 score:1046
+  // iter:1300 score:1008
+  // iter:1400 score:1141
+  // iter:1500 score:1034
+  // iter:1600 score:1113
+  // iter:1700 score:908
+  // iter:1800 score:1668
+  // iter:1900 score:1101
+  // iter:2000 score:870
+  // iter:2100 score:652
+  // iter:2200 score:1490
+  // iter:2300 score:1479
+  // iter:2400 score:725
+  // iter:2500 score:797
+  // iter:2600 score:744
+  // iter:2700 score:556
+  // iter:2800 score:849
+  // iter:2900 score:1052
+  // iter:3000 score:2033
+  // iter:3100 score:889
+  // iter:3200 score:949
+  // iter:3300 score:1250
+  // iter:3400 score:649
+  // iter:3500 score:862
+  // iter:3600 score:1601
+  // iter:3700 score:503
+  // iter:3800 score:453
+  // iter:3900 score:456
+  // iter:4000 score:555
+  // iter:4100 score:915
+  // iter:4200 score:616
+  // iter:4300 score:561
+  // iter:4400 score:1006
+  // iter:4500 score:480
+  // iter:4600 score:541
+  // iter:4700 score:442
+  // iter:4800 score:433
+  // iter:4900 score:535
+  // iter:5000 score:1155
+  // iter:5100 score:445
+  // iter:5200 score:505
+  // iter:5300 score:523
+  // iter:5400 score:560
+  // iter:5500 score:489
+  // iter:5600 score:569
+  // iter:5700 score:425
+  // iter:5800 score:958
+  // iter:5900 score:543
+  // iter:6000 score:422
+  // iter:6100 score:464
+  // iter:6200 score:551
+  // iter:6300 score:628
+  // iter:6400 score:543
+  // iter:6500 score:585
+  // iter:6600 score:436
+  // iter:6700 score:382
+  // iter:6800 score:385
+  // iter:6900 score:353
+  // iter:7000 score:512
+  // iter:7100 score:412
+  // iter:7200 score:519
+  // iter:7300 score:268
+  // iter:7400 score:2101
+  // iter:7500 score:426
+  // iter:7600 score:361
+  // iter:7700 score:301
+  // iter:7800 score:414
+  // iter:7900 score:335
+  // iter:8000 score:507
+  // iter:8100 score:317
+  // iter:8200 score:387
+  // iter:8300 score:325
+  // iter:8400 score:245
+  // iter:8500 score:394
+  // iter:8600 score:408
+  // iter:8700 score:285
+  // iter:8800 score:246
+  // iter:8900 score:769
+  // iter:9000 score:365
+  // iter:9100 score:281
+  // iter:9200 score:254
+  // iter:9300 score:325
+  // iter:9400 score:388
+  // iter:9500 score:380
+  // iter:9600 score:219
+  // iter:9700 score:291
+  // iter:9800 score:273
+  // iter:9900 score:333
+
+//dnn_cmaes target 2
+  // iter:0 score:7667
+  // iter:100 score:2333
+  // iter:200 score:3545
+  // iter:300 score:2288
+  // iter:400 score:2677
+  // iter:500 score:2320
+  // iter:600 score:2012
+  // iter:700 score:2441
+  // iter:800 score:1645
+  // iter:900 score:2071
+  // iter:1000 score:2333
+  // iter:1100 score:3033
+  // iter:1200 score:1211
+  // iter:1300 score:1150
+  // iter:1400 score:1299
+  // iter:1500 score:618
+  // iter:1600 score:7659
+  // iter:1700 score:1016
+  // iter:1800 score:1656
+  // iter:1900 score:1206
+  // iter:2000 score:1612
+  // iter:2100 score:1639
+  // iter:2200 score:1738
+  // iter:2300 score:957
+  // iter:2400 score:2271
+  // iter:2500 score:845
+  // iter:2600 score:1154
+  // iter:2700 score:2330
+  // iter:2800 score:1548
+  // iter:2900 score:842
+  // iter:3000 score:1151
+  // iter:3100 score:743
+  // iter:3200 score:2299
+  // iter:3300 score:567
+  // iter:3400 score:708
+  // iter:3500 score:540
+  // iter:3600 score:1110
+  // iter:3700 score:850
+  // iter:3800 score:488
+  // iter:3900 score:625
+  // iter:4000 score:644
+  // iter:4100 score:923
+  // iter:4200 score:1773
+  // iter:4300 score:389
+  // iter:4400 score:1115
+  // iter:4500 score:564
+  // iter:4600 score:487
+  // iter:4700 score:748
+  // iter:4800 score:755
+  // iter:4900 score:817
+  // iter:5000 score:718
+  // iter:5100 score:602
+  // iter:5200 score:590
+  // iter:5300 score:571
+  // iter:5400 score:863
+  // iter:5500 score:580
+  // iter:5600 score:410
+  // iter:5700 score:420
+  // iter:5800 score:1180
+  // iter:5900 score:683
+  // iter:6000 score:405
+  // iter:6100 score:294
+  // iter:6200 score:594
+  // iter:6300 score:265
+  // iter:6400 score:473
+  // iter:6500 score:561
+  // iter:6600 score:321
+  // iter:6700 score:506
+  // iter:6800 score:382
+  // iter:6900 score:253
+  // iter:7000 score:213
+  // iter:7100 score:571
+  // iter:7200 score:447
+  // iter:7300 score:403
+  // iter:7400 score:828
+  // iter:7500 score:183
+  // iter:7600 score:292
+  // iter:7700 score:385
+  // iter:7800 score:335
+  // iter:7900 score:863
+  // iter:8000 score:7475
+  // iter:8100 score:358
+  // iter:8200 score:339
+  // iter:8300 score:296
+  // iter:8400 score:193
+  // iter:8500 score:223
+  // iter:8600 score:150
+  // iter:8700 score:231
+  // iter:8800 score:347
+  // iter:8900 score:238
+  // iter:9000 score:564
+  // iter:9100 score:1489
+  // iter:9200 score:583
+  // iter:9300 score:287
+  // iter:9400 score:144
+  // iter:9500 score:214
+  // iter:9600 score:844
+  // iter:9700 score:244
+  // iter:9800 score:205
+  // iter:9900 score:293
+
+//dnn_cmaes target 3
+  //   iter:0 score:4978
+  // iter:100 score:4505
+  // iter:200 score:3940
+  // iter:300 score:4155
+  // iter:400 score:3182
+  // iter:500 score:4082
+  // iter:600 score:3220
+  // iter:700 score:3862
+  // iter:800 score:2531
+  // iter:900 score:2587
+  // iter:1000 score:2382
+  // iter:1100 score:2284
+  // iter:1200 score:3236
+  // iter:1300 score:2925
+  // iter:1400 score:3395
+  // iter:1500 score:2708
+  // iter:1600 score:2866
+  // iter:1700 score:2339
+  // iter:1800 score:3431
+  // iter:1900 score:2518
+  // iter:2000 score:2686
+  // iter:2100 score:2005
+  // iter:2200 score:2502
+  // iter:2300 score:2039
+  // iter:2400 score:2573
+  // iter:2500 score:2158
+  // iter:2600 score:2220
+  // iter:2700 score:3201
+  // iter:2800 score:2396
+  // iter:2900 score:2666
+  // iter:3000 score:2115
+  // iter:3100 score:2310
+  // iter:3200 score:2642
+  // iter:3300 score:2457
+  // iter:3400 score:2469
+  // iter:3500 score:2318
+  // iter:3600 score:2487
+  // iter:3700 score:2140
+  // iter:3800 score:2007
+  // iter:3900 score:2665
+  // iter:4000 score:2054
+  // iter:4100 score:1915
+  // iter:4200 score:2116
+  // iter:4300 score:2198
+  // iter:4400 score:2009
+  // iter:4500 score:2228
+  // iter:4600 score:2975
+  // iter:4700 score:2802
+  // iter:4800 score:1998
+  // iter:4900 score:2767
+  // iter:5000 score:1869
+  // iter:5100 score:2063
+  // iter:5200 score:1799
+  // iter:5300 score:2035
+  // iter:5400 score:1827
+  // iter:5500 score:1649
+  // iter:5600 score:1709
+  // iter:5700 score:2662
+  // iter:5800 score:1669
+  // iter:5900 score:1738
+  // iter:6000 score:1524
+  // iter:6100 score:1636
+  // iter:6200 score:1774
+  // iter:6300 score:1601
+  // iter:6400 score:1594
+  // iter:6500 score:1496
+  // iter:6600 score:1514
+  // iter:6700 score:1195
+  // iter:6800 score:1391
+  // iter:6900 score:1420
+  // iter:7000 score:1356
+  // iter:7100 score:1385
+  // iter:7200 score:1117
+  // iter:7300 score:1182
+  // iter:7400 score:1266
+  // iter:7500 score:1985
+  // iter:7600 score:1427
+  // iter:7700 score:1465
+  // iter:7800 score:1162
+  // iter:7900 score:1212
+  // iter:8000 score:1171
+  // iter:8100 score:1269
+  // iter:8200 score:1363
+  // iter:8300 score:1244
+  // iter:8400 score:1288
+  // iter:8500 score:1084
+  // iter:8600 score:1005
+  // iter:8700 score:1335
+  // iter:8800 score:1179
+  // iter:8900 score:967
+  // iter:9000 score:1049
+  // iter:9100 score:1043
+  // iter:9200 score:1015
+  // iter:9300 score:927
+  // iter:9400 score:1060
+  // iter:9500 score:973
+  // iter:9600 score:953
+  // iter:9700 score:915
+  // iter:9800 score:1064
+  // iter:9900 score:1032
+
+//dnn_cmaes target 4
+  // iter:0 score:3654
+  // iter:100 score:3662
+  // iter:200 score:3761
+  // iter:300 score:2381
+  // iter:400 score:3166
+  // iter:500 score:2930
+  // iter:600 score:3159
+  // iter:700 score:3242
+  // iter:800 score:1955
+  // iter:900 score:2193
+  // iter:1000 score:2459
+  // iter:1100 score:1792
+  // iter:1200 score:1677
+  // iter:1300 score:2123
+  // iter:1400 score:1566
+  // iter:1500 score:2084
+  // iter:1600 score:1739
+  // iter:1700 score:1559
+  // iter:1800 score:2688
+  // iter:1900 score:3921
+  // iter:2000 score:1308
+  // iter:2100 score:2527
+  // iter:2200 score:1826
+  // iter:2300 score:1617
+  // iter:2400 score:1653
+  // iter:2500 score:2763
+  // iter:2600 score:1414
+  // iter:2700 score:1603
+  // iter:2800 score:1159
+  // iter:2900 score:1680
+  // iter:3000 score:1256
+  // iter:3100 score:1563
+  // iter:3200 score:1615
+  // iter:3300 score:1537
+  // iter:3400 score:2101
+  // iter:3500 score:1629
+  // iter:3600 score:1231
+  // iter:3700 score:1288
+  // iter:3800 score:2119
+  // iter:3900 score:794
+  // iter:4000 score:888
+  // iter:4100 score:874
+  // iter:4200 score:1019
+  // iter:4300 score:1890
+  // iter:4400 score:1564
+  // iter:4500 score:1140
+  // iter:4600 score:1536
+  // iter:4700 score:1118
+  // iter:4800 score:1006
+  // iter:4900 score:1492
+  // iter:5000 score:1186
+  // iter:5100 score:980
+  // iter:5200 score:1271
+  // iter:5300 score:918
+  // iter:5400 score:769
+  // iter:5500 score:765
+  // iter:5600 score:886
+  // iter:5700 score:952
+  // iter:5800 score:1087
+  // iter:5900 score:1911
+  // iter:6000 score:954
+  // iter:6100 score:2255
+  // iter:6200 score:903
+  // iter:6300 score:674
+  // iter:6400 score:1305
+  // iter:6500 score:755
+  // iter:6600 score:696
+  // iter:6700 score:1306
+  // iter:6800 score:636
+  // iter:6900 score:660
+  // iter:7000 score:644
+  // iter:7100 score:786
+  // iter:7200 score:675
+  // iter:7300 score:708
+  // iter:7400 score:689
+  // iter:7500 score:1006
+  // iter:7600 score:563
+  // iter:7700 score:1100
+  // iter:7800 score:802
+  // iter:7900 score:753
+  // iter:8000 score:2403
+  // iter:8100 score:1479
+  // iter:8200 score:683
+  // iter:8300 score:736
+  // iter:8400 score:919
+  // iter:8500 score:1132
+  // iter:8600 score:1125
+  // iter:8700 score:763
+  // iter:8800 score:679
+  // iter:8900 score:2588
+  // iter:9000 score:637
+  // iter:9100 score:547
+  // iter:9200 score:660
+  // iter:9300 score:598
+  // iter:9400 score:499
+  // iter:9500 score:648
+  // iter:9600 score:805
+  // iter:9700 score:589
+  // iter:9800 score:577
+  // iter:9900 score:426
+
+
+//dnn_cmaes target 5
+  //   iter:0 score:2496
+  // iter:100 score:7168
+  // iter:200 score:3541
+  // iter:300 score:2496
+  // iter:400 score:2496
+  // iter:500 score:6930
+  // iter:600 score:2602
+  // iter:700 score:2182
+  // iter:800 score:2555
+  // iter:900 score:2200
+  // iter:1000 score:3032
+  // iter:1100 score:2509
+  // iter:1200 score:1907
+  // iter:1300 score:1459
+  // iter:1400 score:2356
+  // iter:1500 score:1897
+  // iter:1600 score:1724
+  // iter:1700 score:1491
+  // iter:1800 score:1731
+  // iter:1900 score:997
+  // iter:2000 score:1302
+  // iter:2100 score:1409
+  // iter:2200 score:1380
+  // iter:2300 score:1426
+  // iter:2400 score:1360
+  // iter:2500 score:978
+  // iter:2600 score:1006
+  // iter:2700 score:1147
+  // iter:2800 score:1110
+  // iter:2900 score:1251
+  // iter:3000 score:1530
+  // iter:3100 score:1143
+  // iter:3200 score:1082
+  // iter:3300 score:1072
+  // iter:3400 score:804
+  // iter:3500 score:877
+  // iter:3600 score:768
+  // iter:3700 score:1062
+  // iter:3800 score:771
+  // iter:3900 score:945
+  // iter:4000 score:1151
+  // iter:4100 score:957
+  // iter:4200 score:1349
+  // iter:4300 score:805
+  // iter:4400 score:965
+  // iter:4500 score:898
+  // iter:4600 score:817
+  // iter:4700 score:1461
+  // iter:4800 score:910
+  // iter:4900 score:1547
+  // iter:5000 score:7044
+  // iter:5100 score:850
+  // iter:5200 score:1996
+  // iter:5300 score:910
+  // iter:5400 score:1347
+  // iter:5500 score:803
+  // iter:5600 score:854
+  // iter:5700 score:725
+  // iter:5800 score:803
+  // iter:5900 score:805
+  // iter:6000 score:744
+  // iter:6100 score:922
+  // iter:6200 score:879
+  // iter:6300 score:701
+  // iter:6400 score:760
+  // iter:6500 score:1082
+  // iter:6600 score:1482
+  // iter:6700 score:821
+  // iter:6800 score:667
+  // iter:6900 score:843
+  // iter:7000 score:893
+  // iter:7100 score:1179
+  // iter:7200 score:852
+  // iter:7300 score:728
+  // iter:7400 score:777
+  // iter:7500 score:638
+  // iter:7600 score:716
+  // iter:7700 score:1334
+  // iter:7800 score:669
+  // iter:7900 score:633
+  // iter:8000 score:673
+  // iter:8100 score:545
+  // iter:8200 score:589
+  // iter:8300 score:602
+  // iter:8400 score:644
+  // iter:8500 score:787
+  // iter:8600 score:580
+  // iter:8700 score:751
+  // iter:8800 score:678
+  // iter:8900 score:551
+  // iter:9000 score:608
+  // iter:9100 score:699
+  // iter:9200 score:5326
+  // iter:9300 score:745
+  // iter:9400 score:682
+  // iter:9500 score:576
+  // iter:9600 score:975
+  // iter:9700 score:1511
+  // iter:9800 score:662
+  // iter:9900 score:683
+
+
diff --git a/cpp_voxel/main.cpp b/cpp_voxel/main.cpp
index 173f1a0c8abb9f94def6f34a09aed8987dd4414f..b2b933cedfccfedb5ec65b71e920d969607d1151 100644
--- a/cpp_voxel/main.cpp
+++ b/cpp_voxel/main.cpp
@@ -476,10 +476,10 @@ int main(int const, char const**) {
     std::vector<unsigned char> targ5 =drawFrep(&ss,minX, maxX, minY, maxY, dx, dy,"hole_target",false);
     
 
-    // EM( width, height,  targ5);
+    EM( width, height,  targ3);
 
 
-    EM_df( width, height,  targ5);
+    // EM_df( width, height,  targ5);
 
    
 
@@ -596,56 +596,56 @@ int main(int const, char const**) {
     // itr:50, distance:6
 
 //voxel target 3
-    // itr:2500, distance:4848
-    // itr:2450, distance:4619
-    // itr:2400, distance:4413
-    // itr:2350, distance:4181
-    // itr:2300, distance:3988
-    // itr:2250, distance:3774
-    // itr:2200, distance:3571
-    // itr:2150, distance:3360
-    // itr:2100, distance:3155
-    // itr:2050, distance:2976
-    // itr:2000, distance:2783
-    // itr:1950, distance:2550
-    // itr:1900, distance:2404
-    // itr:1850, distance:2217
-    // itr:1800, distance:2101
-    // itr:1750, distance:1909
-    // itr:1700, distance:1753
-    // itr:1650, distance:1609
-    // itr:1600, distance:1456
-    // itr:1550, distance:1308
-    // itr:1500, distance:1191
-    // itr:1450, distance:1050
-    // itr:1400, distance:941
-    // itr:1350, distance:804
-    // itr:1300, distance:720
-    // itr:1250, distance:622
-    // itr:1200, distance:515
-    // itr:1150, distance:451
-    // itr:1100, distance:372
-    // itr:1050, distance:287
-    // itr:1000, distance:219
-    // itr:950, distance:165
-    // itr:900, distance:124
-    // itr:850, distance:80
-    // itr:800, distance:47
-    // itr:750, distance:26
-    // itr:700, distance:12
-    // itr:650, distance:6
-    // itr:600, distance:6
-    // itr:550, distance:6
-    // itr:500, distance:6
-    // itr:450, distance:6
-    // itr:400, distance:6
-    // itr:350, distance:6
-    // itr:300, distance:6
-    // itr:250, distance:6
-    // itr:200, distance:6
-    // itr:150, distance:6
-    // itr:100, distance:6
-    // itr:50, distance:6
+    //     itr:2500, distance:4875
+    // itr:2450, distance:4634
+    // itr:2400, distance:4407
+    // itr:2350, distance:4196
+    // itr:2300, distance:3976
+    // itr:2250, distance:3803
+    // itr:2200, distance:3578
+    // itr:2150, distance:3374
+    // itr:2100, distance:3151
+    // itr:2050, distance:2964
+    // itr:2000, distance:2762
+    // itr:1950, distance:2554
+    // itr:1900, distance:2399
+    // itr:1850, distance:2205
+    // itr:1800, distance:2060
+    // itr:1750, distance:1885
+    // itr:1700, distance:1746
+    // itr:1650, distance:1563
+    // itr:1600, distance:1447
+    // itr:1550, distance:1288
+    // itr:1500, distance:1122
+    // itr:1450, distance:1020
+    // itr:1400, distance:938
+    // itr:1350, distance:813
+    // itr:1300, distance:683
+    // itr:1250, distance:593
+    // itr:1200, distance:514
+    // itr:1150, distance:427
+    // itr:1100, distance:343
+    // itr:1050, distance:272
+    // itr:1000, distance:206
+    // itr:950, distance:152
+    // itr:900, distance:105
+    // itr:850, distance:66
+    // itr:800, distance:39
+    // itr:750, distance:15
+    // itr:700, distance:2
+    // itr:650, distance:0
+    // itr:600, distance:0
+    // itr:550, distance:0
+    // itr:500, distance:0
+    // itr:450, distance:0
+    // itr:400, distance:0
+    // itr:350, distance:0
+    // itr:300, distance:0
+    // itr:250, distance:0
+    // itr:200, distance:0
+    // itr:150, distance:0
+    // itr:100, distance:0
+    // itr:50, distance:0
 
 //voxel target 4
     // itr:2500, distance:4875
diff --git a/img/df/1.png b/img/df/1.png
new file mode 100644
index 0000000000000000000000000000000000000000..9ba9fa10962308b0d3992623502322e2ee2bd3cf
Binary files /dev/null and b/img/df/1.png differ
diff --git a/img/df/2.png b/img/df/2.png
new file mode 100644
index 0000000000000000000000000000000000000000..b63acfa12b64f16c67d754430caee69b0b7d9c79
Binary files /dev/null and b/img/df/2.png differ
diff --git a/img/df/3.png b/img/df/3.png
new file mode 100644
index 0000000000000000000000000000000000000000..5e45ceb35884e06d8c0a4723d2903369da4c5efc
Binary files /dev/null and b/img/df/3.png differ
diff --git a/img/df/4.png b/img/df/4.png
new file mode 100644
index 0000000000000000000000000000000000000000..6ca8c9ae44ca980a5446651d7fb9b4198ba4f5f1
Binary files /dev/null and b/img/df/4.png differ
diff --git a/img/df/5.png b/img/df/5.png
new file mode 100644
index 0000000000000000000000000000000000000000..988bc3bad4ec3966bff643b65ff0151237e0b47d
Binary files /dev/null and b/img/df/5.png differ
diff --git a/img/dft/1.png b/img/dft/1.png
new file mode 100644
index 0000000000000000000000000000000000000000..473598ae345e38659e226f4f1d20bfa875c15fa4
Binary files /dev/null and b/img/dft/1.png differ
diff --git a/img/dft/2.png b/img/dft/2.png
new file mode 100644
index 0000000000000000000000000000000000000000..7a451daeaa658a71f6f1797d96bc5eeb36e196de
Binary files /dev/null and b/img/dft/2.png differ
diff --git a/img/dnn_cmaes/1.png b/img/dnn_cmaes/1.png
new file mode 100644
index 0000000000000000000000000000000000000000..c6908202e4246aadac0548894934b7f224c7e9a3
Binary files /dev/null and b/img/dnn_cmaes/1.png differ
diff --git a/img/dnn_cmaes/2.png b/img/dnn_cmaes/2.png
new file mode 100644
index 0000000000000000000000000000000000000000..c62de67ccd50ca68566bc9f2f3eeb6821eb60d8e
Binary files /dev/null and b/img/dnn_cmaes/2.png differ
diff --git a/img/dnn_cmaes/3.png b/img/dnn_cmaes/3.png
new file mode 100644
index 0000000000000000000000000000000000000000..7f205e82bbe26c8b5181d963f729f78dbc4affda
Binary files /dev/null and b/img/dnn_cmaes/3.png differ
diff --git a/img/dnn_cmaes/4.png b/img/dnn_cmaes/4.png
new file mode 100644
index 0000000000000000000000000000000000000000..a9a47a90caa78e776b95675e09c81df0cf6e0815
Binary files /dev/null and b/img/dnn_cmaes/4.png differ
diff --git a/img/dnn_cmaes/5.png b/img/dnn_cmaes/5.png
new file mode 100644
index 0000000000000000000000000000000000000000..33ca4e3c4b5398ae5d6728279ac8ede716e6efe1
Binary files /dev/null and b/img/dnn_cmaes/5.png differ
diff --git a/img/dnn_sgd/1.png b/img/dnn_sgd/1.png
new file mode 100644
index 0000000000000000000000000000000000000000..7ef016e17578484dc8106964e8bf4e2ece76522f
Binary files /dev/null and b/img/dnn_sgd/1.png differ
diff --git a/img/dnn_sgd/2.png b/img/dnn_sgd/2.png
new file mode 100644
index 0000000000000000000000000000000000000000..ae8d96fd29dab22a541223aba17928a1c17b09ab
Binary files /dev/null and b/img/dnn_sgd/2.png differ
diff --git a/img/dnn_sgd/3.png b/img/dnn_sgd/3.png
new file mode 100644
index 0000000000000000000000000000000000000000..1f0e82704372d82e516c85c943b2570d62da98e3
Binary files /dev/null and b/img/dnn_sgd/3.png differ
diff --git a/img/dnn_sgd/4.png b/img/dnn_sgd/4.png
new file mode 100644
index 0000000000000000000000000000000000000000..4c6eb410ac35c009d6a573bffa1676ac7d5daebd
Binary files /dev/null and b/img/dnn_sgd/4.png differ
diff --git a/img/dnn_sgd/5.png b/img/dnn_sgd/5.png
new file mode 100644
index 0000000000000000000000000000000000000000..8f325bbd4f7c6c1b76f998942b86e151bcbdbab1
Binary files /dev/null and b/img/dnn_sgd/5.png differ
diff --git a/img/voxel/1.png b/img/voxel/1.png
new file mode 100644
index 0000000000000000000000000000000000000000..1e69a7a5034d61dc58035fe1006533e2203e70c6
Binary files /dev/null and b/img/voxel/1.png differ
diff --git a/img/voxel/2.png b/img/voxel/2.png
new file mode 100644
index 0000000000000000000000000000000000000000..b2a87dab609a85c41e96c8585eb2c743727e85ff
Binary files /dev/null and b/img/voxel/2.png differ
diff --git a/img/voxel/3.png b/img/voxel/3.png
new file mode 100644
index 0000000000000000000000000000000000000000..6943013991b8ea6159b99308bd7a3ba910eeb7fb
Binary files /dev/null and b/img/voxel/3.png differ
diff --git a/img/voxel/4.png b/img/voxel/4.png
new file mode 100644
index 0000000000000000000000000000000000000000..81bc966f205904e8637abcbff33ba0d9276a9f40
Binary files /dev/null and b/img/voxel/4.png differ
diff --git a/img/voxel/5.png b/img/voxel/5.png
new file mode 100644
index 0000000000000000000000000000000000000000..ec347a49cf36b2e7cc5b82de0b42447884f3f051
Binary files /dev/null and b/img/voxel/5.png differ