/* See {nmsim_group_neuron_sim.h} */ /* Last edited on 2019-07-04 19:57:48 by jstolfi */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include void nmsim_group_neuron_sim_do_firings ( nmsim_group_neuron_state_t *st, nmsim_class_neuron_t *nclass, double *rhoP, double *rhoHP ) { int32_t nco = st->nc; // Number of cohorts in current state. int32_t ncn = nco+1; // Number of cohorts in new state. /* Make room for one more cohort: */ nmsim_cohort_neuron_state_vec_expand(&(st->cs), ncn); /* The state of the new cohort of age zero: */ nmsim_cohort_neuron_state_t cs_new_fire; nmsim_cohort_neuron_state_clear(&cs_new_fire); double rho = 0.0; /* Group firing rate. */ double rhoH = 0.0; /* Group firing rate weighted by output modulators {H[k]}. */ int32_t k; for (k = nco; k > 0; k--) { /* Update state of cohort {S[k,t]} and evolve it to time {t+1}: */ nmsim_cohort_neuron_state_t *cs_k = &(st->cs.e[k]); /* Original cohort age {k}. */ nmsim_cohort_neuron_state_t *cs_k1 = &(st->cs.e[k+1]); /* New cohort of duds, age {k+1}. */ nmsim_cohort_neuron_state_t cs_k_fire; /* Cohort data of firers from age {k}. */ double rho_k = nmsim_cohort_neuron_sim_do_firings(cs_k, nclass, &cs_k_fire, cs_k1); /* Accumulate group firing rate: */ double H_k = cs_k->H; rho += cs_k->eta*rho_k; rhoH += cs_k->eta*rho_k*H_k; /* Merge the part of the cohort {k} that fired into {cs_new_fire}: */ bool_t ok = nmsim_cohort_neuron_state_merge(&cs_k_fire, &cs_new_fire); assert(ok); } /* Save new age 0 cohort with everybody who fired: */ st->cs.e[0] = cs_new_fire; /* We have one additional cohort: */ st->nc = ncn; /* Return the group's overall firing rate: */ (*rhoP) = rho; (*rhoHP) = rhoH; } void nmsim_group_neuron_sim_update_potentials ( nmsim_group_neuron_state_t *st, double J_avg, double J_dev, nmsim_class_neuron_t *nclass ) { int32_t nc = st->nc; // Number of cohorts in current state. int32_t k; for (k = 0; k <= nc; k++) { /* Update state of cohort {S[k,t]} with total inputs: */ nmsim_cohort_neuron_state_t *cs_k = &(st->cs.e[k]); /* Original cohort age {k}. */ nmsim_cohort_neuron_sim_update_potentials(cs_k, k, nclass, J_avg, J_dev); } /* Collapse any insignificant cohorts at the end: */ while (nc > 0) { nmsim_cohort_neuron_state_t *cs_k = &(st->cs.e[nc-1]); nmsim_cohort_neuron_state_t *cs_k1 = &(st->cs.e[nc]); bool_t ok = nmsim_cohort_neuron_state_merge(cs_k1, cs_k); if (! ok) { break; } nc--; } st->nc = nc; }