Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6854265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:36:43+00:00 2026-05-27T01:36:43+00:00

I finally determined that this function is responsible for the majority of my bottleneck

  • 0

I finally determined that this function is responsible for the majority of my bottleneck issues. I think its because of the massively excessive random access that happens when most of the synapses are already active. Basically, as the title says, I need to somehow optimize the algorithm so that I’m not randomly checking a ton of active elements before landing on one of the few that are left.

Also, I included the whole function in case of other flaws that can be spotted.

void NetClass::Explore(vector <synapse> & synapses, int & n_syns)   //add new synapses
{
    int size = synapses.size();
    assert(n_syns <= size );

    //Increase the age of each active synapse by 1
    Age_Increment(synapses);

    //make sure there is at least one inactive vector left
    if(n_syns == size)
        return;

        //stochastically decide whether a new connection is added
        if((rand_r(seedp) %1000) < ( x / (1 +(n_syns * ( y / 100)))))  
        {
            n_syns++; //a new synapse has been created

            //main inefficiency here
            while(1)
            {
                int syn = rand_r(seedp) % (size);
                if (!synapses[syn].active)
                {
                    synapses[syn].active = true;
                    synapses[syn].weight = .04 + (float (rand_r(seedp) % 17) / 100);     
                    break;
                }
            }
        }  
}

void NetClass::Age_Increment(vector <synapse> & synapses)  
{
    for(int q=0, int size = synapses.size(); q < size; q++)
        if(synapses[q].active)
            synapses[q].age++;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:36:43+00:00Added an answer on May 27, 2026 at 1:36 am

    Pass a random number, k, in the range [0, size-n_syns) to Age_Increment. Have Age_Increment return the kth empty slot.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I finally have a hardware guy that is insterested in controlling the firmware. This
I have a thread that, when its function exits its loop (the exit is
I understand that this question is similar to others asking about Java Properties, and
This article states that Despite the fact that the Mersenne Twister is an extremely
As the description states, I have a function that takes in an array and
Here's what I got so far (that doesn't work). At this point I thought
I am trying to write a simple function for windows that answers the following
Finally i tried to draw a line using OpenGL ES framework in XCode 4.2
Finally deployed my ruby on rails 3.2 app but when trying to open it
Finally figured it out thanks to One Mad Monkey, but forgot quotes on my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.