peter-ch / MultiNEAT

Portable NeuroEvolution Library
http://MultiNEAT.com
GNU Lesser General Public License v3.0
328 stars 104 forks source link

ndtree class added #51

Closed ai-nick closed 5 years ago

ai-nick commented 5 years ago

getting weird line spacing changes, start with clean branch of master branch so idk what to do but the lion's share of changes are in genome.h lines: 664 - 705 (nd cppn division tree)

ai-nick commented 5 years ago
   // this is like a quadpoint but supports coordinates > 2 dimensions
    class nTree {
        std::vector<double> coord;
        double weight;
        double varience;
        int lvl;
        double width;
        unsigned int num_childrens;
        std::vector<string> signs;
        std::vector<nTree> children;
        nTree(std::vector<double> coord_in, int level, double wdth){
            this->width = wdth;
            this->lvl = level;
            this->coord = coord_in;
            this->num_childrens = pow(2,coord_in.size());
            this->set_signs();
            cout<<this->num_childrens<<endl;
        }
        void set_signs(){
            for(unsigned int ix = 0; ix < this->num_childrens; ix++){
                this->signs.push_back(this->toBinary(ix, this->coord.size()));
                cout << this->signs[ix] << endl;
            }
        }
        string toBinary(unsigned int n, int min_len)
        {
            std::string r;
            while(n!=0) {r=(n%2==0 ?"0":"1")+r; n/=2;}
            if(r.length() < min_len){
                int diff = min_len - r.length();
                for(unsigned int x = 0; x < diff; x++){
                    r = '0' +r;
                }
            }
            return r;
        }
        string get_sign(int n){
            return this->signs[n];
        }
    };

sorry for all the line junk in the changes idk where its coming from so i figured i would pull out the change, im currently using an implementation of this tree to achieve 3d es hyperneat nets in python3 with the (albiet tweeked) pureples library ill get back to doing the rest of the nd code once i confirm my pureples algo is running correctly

maybe the line endings for win

anton-matosov commented 5 years ago

Junk is coming from the trimmed whitespaces on empty lines when you save a file (it is a feature of IDE you use). Good news is that whitespaces changes can be ignored in diff settings and it becomes easy to review your changes.

Regarding your code.

  1. It looks like that nTree is not really used anywhere and all of its members are private, which makes it really impossible to use it. Can you please provide examples on how to use your code?
  2. code formatting doesn't match rest of the file. please put braces on new lines, don't have more then 1 statement in one line and put spaces on both sides of operators.
ai-nick commented 5 years ago

Hey Anton, I'm extremely happy to hear it's easy for you to ignore those line endings (running on Windows sorry about that) I will reformat and the trees it is all private and not referenced anywhere just cause I wanted to test the waters code commit wise with this repo before putting in the time to implement all the es-hyperneat code for n dimensions but I will do that, i will allow access as need to the tree and other methods and I'll refactor to comply with current conventions, do you see any issues as far as permutation switching in the subdivision method of the tree or logic within it in general, one caveat I just realized would be crucial is the variance and output activation, since I'm only using a few classes but with >2d input should I use softmax? sorry was at a christmas party, not my best correspondance

Get Outlook for iOShttps://aka.ms/o0ukef


From: Anton Matosov notifications@github.com Sent: Saturday, December 8, 2018 10:30:52 PM To: peter-ch/MultiNEAT Cc: Nick Williams; Author Subject: Re: [peter-ch/MultiNEAT] ndtree class added (#51)

Junk is coming from the trimmed whitespaces on empty lines when you save a file (it is a feature of IDE you use). Good news is that whitespaces changes can be ignored in diff settings and it becomes easy to review your changes.

Regarding your code.

  1. It looks like that nTree is not really used anywhere and all of its members are private, which makes it really impossible to use it. Can you please provide examples on how to use your code?
  2. code formatting doesn't match rest of the file. please put braces on new lines, don't have more then 1 statement in one line and put spaces on both sides of operators.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/peter-ch/MultiNEAT/pull/51#issuecomment-445512498, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AQzrBnJqFgdUhOuhtVKMWnu9X7-WOKz1ks5u3KAMgaJpZM4YamXr.

ai-nick commented 5 years ago

Sorry for all the errors I'm at Christmas party. If i bring the code into public scope and follow code conventions, is this a viable option for extension to n dimensions? I ask because I already implemented and am using this tree and supporting code in the same fashion as pureples extension I wrote.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Nick Williams nick5664@outlook.com Sent: Saturday, December 8, 2018 10:42:52 PM To: peter-ch/MultiNEAT; peter-ch/MultiNEAT Cc: Author Subject: Re: [peter-ch/MultiNEAT] ndtree class added (#51)

Hey Anton, I'm extremely happy to eat it's easy for you to ignore those line endings (running on Windows sorry about that) I will reformat and the trees is all private and not reference anywhere just cause I wanted to test the waters code commit wise with this repo before putting in the time to implement all the es-hyperneat code for n dimensions but I will do that, allow access as need to the classes and I'll refactor to comply with current conventions, do you see any issues as far as permutations witching the subdivision method of the tree or logic within it in general, one caveat I just realized would be crucial is the variance and tang activation, since I'm only using a few classes but with >2d input should I use softmax for it's built in normalization tendency?

Get Outlook for iOShttps://aka.ms/o0ukef


From: Anton Matosov notifications@github.com Sent: Saturday, December 8, 2018 10:30:52 PM To: peter-ch/MultiNEAT Cc: Nick Williams; Author Subject: Re: [peter-ch/MultiNEAT] ndtree class added (#51)

Junk is coming from the trimmed whitespaces on empty lines when you save a file (it is a feature of IDE you use). Good news is that whitespaces changes can be ignored in diff settings and it becomes easy to review your changes.

Regarding your code.

  1. It looks like that nTree is not really used anywhere and all of its members are private, which makes it really impossible to use it. Can you please provide examples on how to use your code?
  2. code formatting doesn't match rest of the file. please put braces on new lines, don't have more then 1 statement in one line and put spaces on both sides of operators.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/peter-ch/MultiNEAT/pull/51#issuecomment-445512498, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AQzrBnJqFgdUhOuhtVKMWnu9X7-WOKz1ks5u3KAMgaJpZM4YamXr.

ai-nick commented 5 years ago

hey im going to close this since i made a new pr, i dont have boost on my dev machine and i tried using cython as the global build var but it still needs boost for some stuff it seems, ill get boost on a ubuntu machine and try the build/install/use here in the next couple weeks