本文整理汇总了C++中Network::addCore方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::addCore方法的具体用法?C++ Network::addCore怎么用?C++ Network::addCore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::addCore方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[]) {
vector<Core> core;
core.push_back(Core(0, 1));
core.push_back(Core(1, 4));
core.push_back(Core(4, 6));
core.push_back(Core(3, 0));
core.push_back(Core(4, 3));
double** bandwidth;
double** latency;
bandwidth = new double*[5];
latency = new double*[5];
for (int i = 0; i < 5; i++) {
bandwidth[i] = new double[5];
memset(bandwidth[i], 0, sizeof(double) * 5);
latency[i] = new double[5];
memset(latency[i], 0, sizeof(double) * 5);
}
bandwidth[0][3] = 10;
bandwidth[0][4] = 20;
bandwidth[1][0] = 30;
bandwidth[1][4] = 40;
bandwidth[2][3] = 25;
bandwidth[3][1] = 40;
bandwidth[3][2] = 50;
bandwidth[4][0] = 10;
bandwidth[4][1] = 30;
latency[0][3] = 10;
latency[0][4] = 10;
latency[1][0] = 10;
latency[1][4] = 10;
latency[2][3] = 10;
latency[3][1] = 10;
latency[3][2] = 10;
latency[4][0] = 10;
latency[4][1] = 10;
Network network;
network.init(7, 5);
Coordinate from = { 0, 1 };
Coordinate to = { 3, 0 };
network.addCore(from, 0); //core1
network.addCore(to, 3); //core4
network.changeConnection(from, to, ADD); //1-4
to.x = 4;
to.y = 3;
network.addCore(to, 4); //core5
network.changeConnection(from, to, ADD); //1-5
from.x = 1;
from.y = 4;
network.addCore(from, 1); //core2
to.x = 0;
to.y = 1;
network.changeConnection(from, to, ADD); //2-1
to.x = 4;
to.y = 3;
network.changeConnection(from, to, ADD); //2-5
from.x = 4;
from.y = 6;
network.addCore(from, 2); //core3
to.x = 3;
to.y = 0;
network.changeConnection(from, to, ADD); //3-4
from.x = 3;
from.y = 0;
to.x = 1;
to.y = 4;
network.changeConnection(from, to, ADD); //4-2
to.x = 4;
to.y = 6;
network.changeConnection(from, to, ADD); //4-3
from.x = 4;
from.y = 3;
to.x = 0;
to.y = 1;
network.changeConnection(from, to, ADD); //5-1
to.x = 1;
to.y = 4;
network.changeConnection(from, to, ADD); //5-2
Cost cost;
cost.init(1, 1, 0.2, 0.04);
cost.initCost(bandwidth, latency, core, 1, network);
network.updateUtilization(bandwidth, core);
network.showDiagram();
cost.printCost();
cout << endl;
int changedCore = 3;
Coordinate newPos = { 4, 6 };
int swapCore = network.getCoreIndex(newPos);
//.........这里部分代码省略.........