From 22c2ee7e5d2d18d1cc0832764fe736305104e525 Mon Sep 17 00:00:00 2001 From: Amira Abdel-Rahman <aabdelrahman@gsd.harvard.edu> Date: Tue, 25 Jun 2019 13:34:36 -0400 Subject: [PATCH] new frep_stree structure and multi node tree --- cpp_frep/frep.cpp | 137 ++++++++++++----- cpp_frep/frep_tree.cpp | 323 ++++++++++++++--------------------------- cpp_frep/main.cpp | 30 +++- cpp_frep/nelder_mead.h | 2 +- 4 files changed, 240 insertions(+), 252 deletions(-) diff --git a/cpp_frep/frep.cpp b/cpp_frep/frep.cpp index 72476d5..e2ff1e7 100755 --- a/cpp_frep/frep.cpp +++ b/cpp_frep/frep.cpp @@ -11,6 +11,9 @@ namespace cpp_frep { scalar Y; std::string name; std::vector<scalar> params; + Frep* shape1; + Frep* shape2; + Frep* shape; Frep():X(0.0f),Y(0.0f){}; Frep(std::string name_,scalar X_, scalar Y_) { @@ -23,6 +26,7 @@ namespace cpp_frep { return *this; } + void setXY(scalar X_,scalar Y_){ X=X_; Y=Y_; @@ -33,8 +37,24 @@ namespace cpp_frep { virtual void setParameters(std::vector<scalar> params_){ params=params_; } + virtual void printName(){ + std::cout<<"Frep"; + } - // private: + void setShape1(Frep* shape1_){ + shape1=shape1_; + } + void setShape2(Frep* shape2_){ + shape2=shape2_; + } + void setShape(Frep* shape_){ + shape=shape_; + } + virtual ~Frep() { + // std::cout<<"deleted_"<<name<<" \n"; + } + + private: }; //..........................SHAPES..................................// @@ -57,6 +77,10 @@ namespace cpp_frep { return 0.0f; } + virtual void printName(){ + std::cout<<name; + } + }; @@ -64,16 +88,18 @@ namespace cpp_frep { public: scalar radius; - Circle():radius(1.0f){}; + Circle():radius(1.0f){ + name="Circle"; + }; + Circle(scalar radius_,scalar center_x_, scalar center_y_) { radius=radius_; center_x=center_x_; center_y=center_y_; + name="Circle"; }; scalar eval(){ - // std::cout<<"circleee\n"; - return ((radius)*(radius)-((X-(center_x))*(X-(center_x))+(Y-(center_y))*(Y-(center_y)))); } @@ -93,12 +119,15 @@ namespace cpp_frep { scalar ymin; scalar ymax; - Rectangle():xmin (0.0f), xmax (0.0f), ymin (0.0f), ymax (0.0f) {}; + Rectangle():xmin (-1.0f), xmax (1.0f), ymin (-1.0f), ymax (1.0f) { + name="Rectangle"; + }; Rectangle(scalar xmin_, scalar xmax_,scalar ymin_,scalar ymax_) { xmin=xmin_; xmax=xmax_; ymin=ymin_; ymax=ymax_; + name="Rectangle"; }; scalar eval(){ @@ -119,26 +148,28 @@ namespace cpp_frep { //.......................OPERATORS..................................// class FrepOperators: public Frep { public: - Frep* shape1; - Frep* shape2; - FrepOperators(){}; - - void setShape1(Frep* shape1_){ - shape1=shape1_; - } - void setShape2(Frep* shape2_){ - shape2=shape2_; - } + FrepOperators(){}; + virtual void printName(){ + std::cout<<name<<"("; + shape1->printName(); + std::cout<<","; + shape2->printName(); + std::cout<<")"; + } + }; class Add: public FrepOperators { public: - Add(){}; + Add(){ + name="Add"; + }; Add(Frep* shape1_,Frep* shape2_) { shape1=shape1_; shape2=shape2_; + name="Add"; }; float eval(){ @@ -158,10 +189,13 @@ namespace cpp_frep { class Subtract: public FrepOperators { public: - Subtract(){}; + Subtract(){ + name="Subtract"; + }; Subtract(Frep* shape1_,Frep* shape2_) { shape1=shape1_; shape2=shape2_; + name="Subtract"; }; float eval(){ @@ -182,10 +216,13 @@ namespace cpp_frep { class Intersect: public FrepOperators { public: - Intersect(){}; + Intersect(){ + name="Intersect"; + }; Intersect(Frep* shape1_,Frep* shape2_) { shape1=shape1_; shape2=shape2_; + name="Intersect"; }; float eval(){ @@ -207,11 +244,14 @@ namespace cpp_frep { scalar offset; - Clearance():offset(0.5f){}; + Clearance():offset(0.5f){ + name="Clearance"; + }; Clearance(Frep* shape1_,Frep* shape2_,scalar offset_) { shape1=shape1_; shape2=shape2_; offset=offset_; + name="Clearance"; }; float eval(){ @@ -234,11 +274,14 @@ namespace cpp_frep { scalar offset; - Blend():offset(0.5f){}; + Blend():offset(0.5f){ + name="Blend"; + }; Blend(Frep* shape1_,Frep* shape2_,scalar offset_) { shape1=shape1_; shape2=shape2_; offset=offset_; + name="Blend"; }; Blend get(){ @@ -265,11 +308,14 @@ namespace cpp_frep { scalar weight; - Morph():weight(0.5f){}; + Morph():weight(0.5f){ + name="Morph"; + }; Morph(Frep* shape1_,Frep* shape2_,scalar weight_) { shape1=shape1_; shape2=shape2_; weight=weight_; + name="Morph"; }; void setParameters(std::vector<scalar> weight_){ @@ -295,13 +341,16 @@ namespace cpp_frep { //.......................TRANSFORMS.................................// class FrepTransforms: public Frep { public: - Frep* shape; + //Frep(std::string const& name): name_(std::move(name)) {} - FrepTransforms(){}; + FrepTransforms(){}; + virtual void printName(){ + std::cout<<name<<"("; + shape->printName(); + std::cout<<")"; + } - void setShape(Frep* shape_){ - shape=shape_; - } + }; @@ -310,11 +359,14 @@ namespace cpp_frep { scalar dx; scalar dy; - Translate():dx(1.0f),dy(1.0f){}; + Translate():dx(1.0f),dy(1.0f){ + name="Translate"; + }; Translate(Frep* shape_,scalar dx_,scalar dy_) { shape= shape_; dx=dx_; dy=dy_; + name="Translate"; }; float eval(){ @@ -340,13 +392,16 @@ namespace cpp_frep { scalar ox; scalar oy; - Scale():sx(0.5f),sy(0.5f),ox(0.0f),oy(0.0f){}; + Scale():sx(0.5f),sy(0.5f),ox(0.0f),oy(0.0f){ + name="Scale"; + }; Scale(Frep* shape_,scalar ox_, scalar oy_,scalar sx_,scalar sy_) { shape=shape_; sx=sx_; sy=sy_; ox=ox_; oy=oy_; + name="Scale"; }; float eval(){ @@ -374,12 +429,15 @@ namespace cpp_frep { scalar oy; const float PI_F=3.14159265358979f; - Rotate():angle(45.0f),ox(0.0f),oy(0.0f){}; + Rotate():angle(45.0f),ox(0.0f),oy(0.0f){ + name="Rotate"; + }; Rotate(Frep* shape_,scalar ox_, scalar oy_, scalar angle_) { shape=shape_; angle=angle_; ox=ox_; oy=oy_; + name="Rotate"; }; Rotate get(){ @@ -400,7 +458,11 @@ namespace cpp_frep { scalar newY=((oy)-(X-(ox))*sin(r)+(Y-(oy))*cos(r)); shape->setXY(newX,newY); // std::cout<<"rooottaattte\n"; - return shape->eval(); + + // std::cout<< shape->name<<"\n"; + float result=shape->eval(); + // std::cout<<"dvds\n"; + return result; } @@ -414,12 +476,15 @@ namespace cpp_frep { const float PI_F=3.14159265358979f; - LinearArrayX():spacing(0.5f),number(2.0f),size(1.0f){}; + LinearArrayX():spacing(0.5f),number(2.0f),size(1.0f){ + name="LinearArrayX"; + }; LinearArrayX(Frep* shape_,scalar spacing_,scalar number_,scalar size_) { shape=shape_; spacing=spacing_; number=number_; size=size_; + name="LinearArrayX"; }; LinearArrayX get(){ @@ -459,12 +524,15 @@ namespace cpp_frep { const float PI_F=3.14159265358979f; - LinearArrayY():spacing(0.5f),number(2.0f),size(1.0f){}; + LinearArrayY():spacing(0.5f),number(2.0f),size(1.0f){ + name="LinearArrayY"; + }; LinearArrayY(Frep* shape_,scalar spacing_,scalar number_,scalar size_) { shape=shape_; spacing=spacing_; number=number_; size=size_; + name="LinearArrayY"; }; LinearArrayY get(){ @@ -503,13 +571,16 @@ namespace cpp_frep { scalar oy; const float PI_F=3.14159265358979f; - PolarArray():angle(45.0f),radius(1.0f),ox(0.0f),oy(0.0f){}; + PolarArray():angle(45.0f),radius(1.0f),ox(0.0f),oy(0.0f){ + name="PolarArray"; + }; PolarArray(Frep* shape_,scalar ox_, scalar oy_, scalar angle_,scalar radius_) { shape=shape_; angle=angle_; radius=radius_; ox=ox_; oy=oy_; + name="PolarArray"; }; diff --git a/cpp_frep/frep_tree.cpp b/cpp_frep/frep_tree.cpp index 4889fa1..12db232 100644 --- a/cpp_frep/frep_tree.cpp +++ b/cpp_frep/frep_tree.cpp @@ -13,14 +13,47 @@ namespace cpp_frep { scalar X; scalar Y; Frep* parsedTree; - scalar nodeLength=12.0f; + scalar nodeLength; - Frep_tree():X(0.0f),Y(0.0f){}; + static const int storageSpace=5; + + Add ArrayAdd [storageSpace]; + Subtract ArraySubtract [storageSpace]; + Intersect ArrayIntersect [storageSpace]; + Scale ArrayScale [storageSpace]; + Morph ArrayMorph [storageSpace]; + Translate ArrayTranslate [storageSpace]; + Rotate ArrayRotate [storageSpace]; + LinearArrayX ArrayLinearArrayX [storageSpace]; + LinearArrayY ArrayLinearArrayY [storageSpace]; + PolarArray ArrayPolarArray [storageSpace]; + Circle ArrayCircle [storageSpace]; + Rectangle ArrayRectangle [storageSpace]; + + int counterAdd =0; + int counterSubtract =0; + int counterIntersect =0; + int counterScale =0; + int counterMorph =0; + int counterTranslate =0; + int counterRotate =0; + int counterLinearArrayX =0; + int counterLinearArrayY =0; + int counterPolarArray =0; + int counterCircle =0; + int counterRectangle =0; + + Frep_tree(){ + X=0.0f; + Y=0.0f; + }; + Frep_tree(std::vector<std::vector<scalar>> genome_) { // inputs=inputs_; genome=genome_; X=0.0f; Y=0.0f; + nodeLength=12.0f; std::vector<scalar> g,g1; g.push_back(10.0f/nodeLength); g1.push_back(11.0f/nodeLength); @@ -28,7 +61,9 @@ namespace cpp_frep { genome.push_back(g1); maxLength = genome.size(); parseTree(); + }; + void updateGenome(std::vector<std::vector<scalar>> genome_){ genome=genome_; std::vector<scalar> g,g1; @@ -48,143 +83,142 @@ namespace cpp_frep { parsedTree=getNode(0); // parsedTree=morphNodes(0); std::cout<<"\n"; + parsedTree->printName(); + std::cout<<"\n"; } Frep* getNode(int index){ int nodeIndex=(int)(genome[index][0]*nodeLength); int shape1Index,shape2Index,shapeIndex; - - // std::cout<<nodeIndex <<"\n"; + shape1Index=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); + shape2Index=index+(int)ceilf(genome[index][2]* (maxLength-1-index)); + shapeIndex =index+(int)ceilf(genome[index][1]* (maxLength-1-index)); //0 add, 1 subtract, 2 intersect, 3 morph, 4 translate, 5 scale, 6 rotate, 7 linearArrayX, 8 linearArrayX, 9 polar array //TODO: Add parameters switch (nodeIndex) { case 0: { - static Add f; + // Add f; + int n=counterAdd; std::cout<<"Add("; - shape1Index=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - f.setShape1(getNode(shape1Index)); + counterAdd++; + ArrayAdd[n].setShape1(getNode(shape1Index)); std::cout<<","; - shape2Index=index+(int)ceilf(genome[index][2]* (maxLength-1-index)); - f.setShape2(getNode(shape2Index)); + ArrayAdd[n].setShape2(getNode(shape2Index)); std::cout<<")"; - return &f; - break; + return &ArrayAdd[n]; } case 1: { - static Subtract f; + + // Subtract f; + int n=counterSubtract; std::cout<<"Subtract("; - shape1Index=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - f.setShape1(getNode(shape1Index)); + counterSubtract++; + ArraySubtract[n].setShape1(getNode(shape1Index)); std::cout<<","; - shape2Index=index+(int)ceilf(genome[index][2]* (maxLength-1-index)); - f.setShape2(getNode(shape2Index)); + ArraySubtract[n].setShape2(getNode(shape2Index)); std::cout<<")"; - return &f; - break; + return &ArraySubtract[n]; } case 2: { - static Intersect f; + // Intersect f; + int n=counterIntersect; std::cout<<"Intersect("; - shape1Index=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - f.setShape1(getNode(shape1Index)); + counterIntersect++; + ArrayIntersect[n].setShape1(getNode(shape1Index)); std::cout<<","; - shape2Index=index+(int)ceilf(genome[index][2]* (maxLength-1-index)); - f.setShape2(getNode(shape2Index)); + ArrayIntersect[n].setShape2(getNode(shape2Index)); std::cout<<")"; - return &f; - break; + return &ArrayIntersect[n]; } case 3: { - static Morph f; + // Morph f; + int n=counterMorph; std::cout<<"Morph("; - shape1Index=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - f.setShape1(getNode(shape1Index)); + counterMorph++; + ArrayMorph[n].setShape1(getNode(shape1Index)); std::cout<<","; - shape2Index=index+(int)ceilf(genome[index][2]* (maxLength-1-index)); - f.setShape2(getNode(shape2Index)); + ArrayMorph[n].setShape2(getNode(shape2Index)); std::cout<<")"; - return &f; - break; + return &ArrayMorph[n]; } case 4: { - static Translate f; + // Translate f; + int n=counterTranslate; std::cout<<"Translate("; - shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - f.setShape(getNode(shapeIndex)); + counterTranslate++; + ArrayTranslate[n].setShape(getNode(shapeIndex)); std::cout<<")"; - return &f; - break; + return &ArrayTranslate[n]; } case 5: { - static Scale f; + // Scale f; + int n=counterScale; std::cout<<"Scale("; - shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - f.setShape(getNode(shapeIndex)); + counterScale++; + ArrayScale[n].setShape(getNode(shapeIndex)); std::cout<<")"; - return &f; - break; + return &ArrayScale[n]; } case 6: { - static Rotate f; + //Rotate f; + int n=counterRotate; std::cout<<"Rotate("; - shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - f.setShape(getNode(shapeIndex)); + counterRotate++; + ArrayRotate[n].setShape(getNode(shapeIndex)); std::cout<<")"; - return &f; - break; + return &ArrayRotate[n]; } case 7: { - static LinearArrayX f; + // LinearArrayX f; + int n=counterLinearArrayX; std::cout<<"LinearArrayX("; - shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - f.setShape(getNode(shapeIndex)); + counterLinearArrayX++; + ArrayLinearArrayX[n].setShape(getNode(shapeIndex)); std::cout<<")"; - return &f; - break; + return &ArrayLinearArrayX[n]; } case 8: { - static LinearArrayY f; + // LinearArrayY f; + int n=counterLinearArrayY; std::cout<<"LinearArrayY("; - shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - f.setShape(getNode(shapeIndex)); + counterLinearArrayY++; + ArrayLinearArrayY[n].setShape(getNode(shapeIndex)); std::cout<<")"; - return &f; - break; + return &ArrayLinearArrayY[n]; } case 9: { - static PolarArray f; + // PolarArray f; + int n=counterPolarArray; std::cout<<"PolarArray("; - shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - f.setShape(getNode(shapeIndex)); + counterPolarArray++; + ArrayPolarArray[n].setShape(getNode(shapeIndex)); std::cout<<")"; - return &f; - break; + return &ArrayPolarArray[n]; } case 10: { - static Circle f(1.0f,0.0f,0.0f); + // Circle f(1.0f,0.0f,0.0f); + int n=counterCircle; + counterCircle++; std::cout<<"Circle"; - return &f; - break; + return &ArrayCircle[n]; } case 11: { - static Rectangle f(-1.0f,1.0f,-1.0f,1.0f); + // Rectangle f(-1.0f,1.0f,-1.0f,1.0f); + int n=counterRectangle; + counterRectangle++; std::cout<<"Rectangle"; - return &f; - break; + return &ArrayRectangle[n]; } default: { - static Rectangle f(-1.0f,1.0f,-1.0f,1.0f); - std::cout<<"rectangle1"; - return &f; - break; + int n=counterRectangle; + counterRectangle++; + std::cout<<"REECCC"; + return &ArrayRectangle[n]; } } - // static Rectangle f1(-1.0f,1.0f,-1.0f,1.0f); - // std::cout<<"rectangle2"; - // return &f1; } Frep* morphNodes(int index){ @@ -205,7 +239,6 @@ namespace cpp_frep { } - Frep* getNodeSharp(int index, int nodeIndex){ int shape1Index,shape2Index,shapeIndex; @@ -341,150 +374,18 @@ namespace cpp_frep { // return &f1; } - // Frep* getNodeSharp(int index, int nodeIndex){ - - // int shape1Index,shape2Index,shapeIndex; - - // //0 add, 1 subtract, 2 intersect, 3 morph, 4 translate, 5 scale, 6 rotate, 7 linearArrayX, 8 linearArrayX, 9 polar array - // //TODO: Add parameters - // switch (nodeIndex) - // { - // case 0: { - // static Add f; - // std::cout<<"Add("; - // shape1Index=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - // f.setShape1(getNode(shape1Index)); - // std::cout<<","; - // shape2Index=index+(int)ceilf(genome[index][2]* (maxLength-1-index)); - // f.setShape2(getNode(shape2Index)); - // std::cout<<")"; - // return &f; - // break; - // } - // case 1: { - // static Subtract f; - // std::cout<<"Subtract("; - // shape1Index=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - // f.setShape1(getNode(shape1Index)); - // std::cout<<","; - // shape2Index=index+(int)ceilf(genome[index][2]* (maxLength-1-index)); - // f.setShape2(getNode(shape2Index)); - // std::cout<<")"; - // return &f; - // break; - // } - // case 2: { - // static Intersect f; - // std::cout<<"Intersect("; - // shape1Index=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - // f.setShape1(getNode(shape1Index)); - // std::cout<<","; - // shape2Index=index+(int)ceilf(genome[index][2]* (maxLength-1-index)); - // f.setShape2(getNode(shape2Index)); - // std::cout<<")"; - // return &f; - // break; - // } - // case 3: { - // static Morph f; - // std::cout<<"Morph("; - // shape1Index=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - // f.setShape1(getNode(shape1Index)); - // std::cout<<","; - // shape2Index=index+(int)ceilf(genome[index][2]* (maxLength-1-index)); - // f.setShape2(getNode(shape2Index)); - // std::cout<<")"; - // return &f; - // break; - // } - // case 4: { - // static Translate f; - // std::cout<<"Translate("; - // shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - // f.setShape(getNode(shapeIndex)); - // std::cout<<")"; - // return &f; - // break; - // } - // case 5: { - // static Scale f; - // std::cout<<"Scale("; - // shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - // f.setShape(getNode(shapeIndex)); - // std::cout<<")"; - // return &f; - // break; - // } - // case 6: { - // static Rotate f; - // std::cout<<"Rotate("; - // shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - // f.setShape(getNode(shapeIndex)); - // std::cout<<")"; - // return &f; - // break; - // } - // case 7: { - // static LinearArrayX f; - // std::cout<<"LinearArrayX("; - // shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - // f.setShape(getNode(shapeIndex)); - // std::cout<<")"; - // return &f; - // break; - // } - // case 8: { - // static LinearArrayY f; - // std::cout<<"LinearArrayY("; - // shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - // f.setShape(getNode(shapeIndex)); - // std::cout<<")"; - // return &f; - // break; - // } - // case 9: { - // static PolarArray f; - // std::cout<<"PolarArray("; - // shapeIndex=index+(int)ceilf(genome[index][1]* (maxLength-1-index)); - // f.setShape(getNode(shapeIndex)); - // std::cout<<")"; - // return &f; - // break; - // } - // case 10: { - // static Circle f(1.0f,0.0f,0.0f); - // std::cout<<"Circle"; - // return &f; - // break; - // } - // case 11: { - // static Rectangle f(-1.0f,1.0f,-1.0f,1.0f); - // std::cout<<"Rectangle"; - // return &f; - // break; - // } - // default: { - // static Rectangle f(-1.0f,1.0f,-1.0f,1.0f); - // std::cout<<"rectangle1"; - // std::cout<<nodeIndex; - // return &f; - // break; - // } - // } - // // static Rectangle f1(-1.0f,1.0f,-1.0f,1.0f); - // // std::cout<<"rectangle2"; - // // return &f1; - // } - void setXY(scalar X_,scalar Y_){ X=X_; Y=Y_; } + scalar eval(){ parsedTree->setXY(X,Y); return parsedTree->eval(); } + virtual ~Frep_tree() {} + // private: }; diff --git a/cpp_frep/main.cpp b/cpp_frep/main.cpp index f8428bb..3973fe2 100755 --- a/cpp_frep/main.cpp +++ b/cpp_frep/main.cpp @@ -201,24 +201,32 @@ int main(int const, char const**) { std::vector<std::vector<scalar>> genome; + std::vector<scalar> node1; - node1.push_back(0.55); - node1.push_back(0.32); - node1.push_back(0.67); + node1.push_back(0.488889); + node1.push_back(0.433333); + node1.push_back(0.8407); genome.push_back(node1); // std::vector<scalar> node2; - // node2.push_back(0.55); - // node2.push_back(0.32); - // node2.push_back(0.67); + // node2.push_back(0.205); + // node2.push_back(0.4524); + // node2.push_back(0.94); // genome.push_back(node2); + // std::vector<scalar> node3; + // node3.push_back(0.2472); + // node3.push_back(0.452); + // node3.push_back(0.727); + // genome.push_back(node3); + Frep_tree tree(genome); // genome[0][0]=0.1; // tree.updateGenome(genome); // drawFrep(tree,minX, maxX, minY, maxY, dx, dy,"image"); + float precision = 0.01; int dimension = 3; NelderMeadOptimizer o(dimension, precision); @@ -240,7 +248,7 @@ int main(int const, char const**) { while (!o.done()&& !o.done(score)) { std::string name1 = "i"; std::string name=name1+std::to_string(count); - score=compareL1( v, &c, &tree, minX, maxX, minY, maxY, dx, dy, name); + score=compareL1( v, &s, &tree, minX, maxX, minY, maxY, dx, dy, name); v = o.step(v,score ); count++; } @@ -249,13 +257,21 @@ int main(int const, char const**) { // Circle c(1.0f,0.0f,0.0f); + // // drawFrep(&c,minX, maxX, minY, maxY, dx, dy); + // Circle *cc; + // cc=new Circle(); + // c=*cc; + // drawFrep(cc,minX, maxX, minY, maxY, dx, dy); // drawFrep(&c,minX, maxX, minY, maxY, dx, dy); + // Translate t(&c,0.0f,1.5f); // drawFrep(&t,minX, maxX, minY, maxY, dx, dy); // Scale sc(&t,0.0f,0.0f,2.0f,2.0f); // drawFrep(&sc,minX, maxX, minY, maxY, dx, dy); + // sc.printName(); + // std::cout<<"\n"; // Rectangle r(-1.0f,1.0f,-1.0f,1.0f); // drawFrep(&r,minX, maxX, minY, maxY, dx, dy); diff --git a/cpp_frep/nelder_mead.h b/cpp_frep/nelder_mead.h index 67f79b8..f8c0ebe 100644 --- a/cpp_frep/nelder_mead.h +++ b/cpp_frep/nelder_mead.h @@ -189,7 +189,7 @@ class NelderMeadOptimizer { // otherwise: optimize! if (vectors.size() == dimension+1) { - while(!done(score)) { + while(!done()) { sort(vectors.begin(), vectors.end(), *this); Vector cog; // center of gravity cog.prepare(dimension); -- GitLab