L_opt = 0;
for(int i=0; i<4; i++)
{
//=========== 1-е здание ========================
L21 = abs(hub[2].x-mas_comp[i].x)+
abs(Form1->hub[2].y-Form1->mas_comp[i].y)+
(Form1->mas_comp[i].z)+
Form1->hub[2].z;
if(L21 < m21)
{
m21 = L21;
hub[0].x = mas_comp[i].x;
hub[0].y = mas_comp[i].y;
hub[0].z = mas_comp[i].z;
hub[0].nom = mas_comp[i].nom;
}
//=========== 2-е здание ========================
L23 = abs(hub[2].x-mas_comp[i+4].x)+
abs(Form1->hub[2].y-Form1->mas_comp[i+4].y)+
(Form1->mas_comp[i+4].z)+
Form1->hub[2].z;
if(L23 < m23)
{
m23 = L23;
hub[1].x = mas_comp[i+4].x;
hub[1].y = mas_comp[i+4].y;
hub[1].z = mas_comp[i+4].z;
hub[1].nom = mas_comp[i+4].nom;
}
//=========== 4-е здание ========================
L24 = abs(hub[2].x-mas_comp[i+12].x)+
abs(Form1->hub[2].y-Form1->mas_comp[i+12].y)+
(Form1->mas_comp[i+12].z)+
Form1->hub[2].z;
if(L24 < m24)
{
m24 = L24;
hub[3].x = mas_comp[i+12].x;
hub[3].y = mas_comp[i+12].y;
hub[3].z = mas_comp[i+12].z;
hub[3].nom = mas_comp[i+12].nom;
}
L_opt = m21 + m23 + m24;
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//конец оптимизации по оптоволокну
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
}
if(M_flag == 1)
{
//########################################################
//оптимизация по витой паре
//########################################################
int d[16],m=10000;
L_opt=0;
for(int i=0; i<16; i++)
d[i]=0;
//=========== 1-е здание ========================
for(int j=0; j<4; j++)
for(int i=0; i<4; i++)
{
d[j] = d[j]+ abs(mas_comp[j].x - mas_comp[i].x)+
abs(mas_comp[j].y - mas_comp[i].y)+
abs(mas_comp[j].z - mas_comp[i].z);
}
for(int i=0; i<4; i++)
if(d[i]<m)
{
m = d[i];
hub[0].x = mas_comp[i].x;
hub[0].y = mas_comp[i].y;
hub[0].z = mas_comp[i].z;
hub[0].nom = mas_comp[i].nom;
hub[0].Lsegm = m;
}
for(int i=0; i<16; i++)
d[i]=0;
//=========== 2-е здание ========================
m = 10000;
for(int j=4; j<8; j++)
for(int i=4; i<8; i++)
{
d[j] = d[j]+ abs(mas_comp[j].x - mas_comp[i].x)+
abs(mas_comp[j].y - mas_comp[i].y)+
abs(mas_comp[j].z - mas_comp[i].z);
}
for(int i=4; i<8; i++)
if(d[i]<m)
{
m = d[i];
hub[1].x = mas_comp[i].x;
hub[1].y = mas_comp[i].y;
hub[1].z = mas_comp[i].z;
hub[1].nom = mas_comp[i].nom;
hub[1].Lsegm = m;
}
for(int i=0; i<16; i++)
d[i]=0;
//=========== 3-е здание ========================
m = 10000;
hub[2].Lsegm = 0;
for(int i=8; i<12; i++)
hub[2].Lsegm = hub[2].Lsegm +
abs(hub[2].x - mas_comp[i].x)+
abs(hub[2].y - mas_comp[i].y)+
abs(hub[2].z - mas_comp[i].z);
for(int i=0; i<16; i++)
d[i]=0;
//=========== 4-е здание ========================
m = 10000;
for(int j=12; j<16; j++)
for(int i=12; i<16; i++)
{
d[j] = d[j]+ abs(mas_comp[j].x - mas_comp[i].x)+
abs(mas_comp[j].y - mas_comp[i].y)+
abs(mas_comp[j].z - mas_comp[i].z);
}
for(int i=12; i<16; i++)
if(d[i] < m)
{
m = d[i];
hub[3].x = mas_comp[i].x;
hub[3].y = mas_comp[i].y;
hub[3].z = mas_comp[i].z;
hub[3].nom = mas_comp[i].nom;
hub[3].Lsegm = m;
}
//########################################################
//конец оптимизации по витой паре
//########################################################
}
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// расчет параметров сети
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
if(M_flag != 1)
{
int k=0;
for(int j=0; j<4; j++)
{
hub[j].Lsegm = 0;
for(int i=0; i<4; i++)
hub[j].Lsegm = hub[j].Lsegm +
abs(hub[j].x - mas_comp[i+k].x)+
abs(hub[j].y - mas_comp[i+k].y)+
abs(hub[j].z - mas_comp[i+k].z);
k = k+4;
}
}
else
{
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.