我实现了一个简单的皮质微电路模型的缩放版本代码如下
void crete_cm(double n_scale, double k_scale)
{
float conn_threshold = 0.0f;
int n_full[8] = { 20683, 5834, 21915, 5479, 4850, 1065, 14395, 2948 };
std::vector pops;
//创建种群
int group1 = kernel().conn_manger.create(n_full[0] * n_scale);
pops.push_back(group1);
int group2 = kernel().conn_manger.create(n_full[1] * n_scale);
pops.push_back(group2);
int group3 = kernel().conn_manger.create(n_full[2] * n_scale);
pops.push_back(group3);
int group4 = kernel().conn_manger.create(n_full[3] * n_scale);
pops.push_back(group4);
int group5 = kernel().conn_manger.create(n_full[4] * n_scale);
pops.push_back(group5);
int group6 = kernel().conn_manger.create(n_full[5] * n_scale);
pops.push_back(group6);
int group7 = kernel().conn_manger.create(n_full[6] * n_scale);
pops.push_back(group7);
int group8 = kernel().conn_manger.create(n_full[7] * n_scale);
pops.push_back(group8);
// 不同种群的连接概率
float conn_probs[8][8] = { {0.1009f, 0.1689f, 0.0437f, 0.0818f, 0.0323f, 0.f, 0.0076f, 0.f},
{0.1346f, 0.1371f, 0.0316f, 0.0515f, 0.0755f, 0.f, 0.0042f, 0.f},
{0.0077f, 0.0059f, 0.0497f, 0.135f, 0.0067f, 0.0003f, 0.0453f, 0.f},
{0.0691f, 0.0029f, 0.0794f, 0.1597f, 0.0033f, 0.f, 0.1057f, 0.f},
{0.1004f, 0.0622f, 0.0505f, 0.0057f, 0.0831f, 0.3726f, 0.0204f, 0.f},
{0.0548f, 0.0269f, 0.0257f, 0.0022f, 0.06f, 0.3158f, 0.0086f, 0.f},
{0.0156f, 0.0066f, 0.0211f, 0.0166f, 0.0572f, 0.0197f, 0.0396f, 0.2252f},
{0.0364f, 0.001f, 0.0034f, 0.0005f, 0.0277f, 0.008f, 0.0658f, 0.1443f} };
// cap connection probabilities
for (int ii = 0; ii < 8; ii++)
{
for (int jj = 0; jj < 8; jj++)
{
if (conn_probs[ii][jj] < conn_threshold)
conn_probs[ii][jj] = 0;
}
}
// 定义出度概率
float k_full[8][8] = { 0 };
for (int ii = 0; ii < pops.size(); ii++)
{
for (int jj = 0; jj < pops.size(); jj++)
{
k_full[ii][jj] = roundf(log(1.f - conn_probs[ii][jj]) / (log((double)((n_full[ii] * n_full[jj] - 1)) / (double)((n_full[ii] * n_full[jj]))))) / n_full[ii];
}
}
// 建立连接
for (int ii = 0; ii < pops.size(); ii++)
{
for (int jj = 0; jj < pops.size(); jj++)
{
kernel().conn_manger.connect(pops[ii], pops[jj], k_scale * k_full[jj][ii] * kernel().conn_manger.get_population_nums(pops[jj]) / (float)(kernel().conn_manger.get_population_nums(pops[jj]) * kernel().conn_manger.get_population_nums(pops[ii])));
}
}
}