当前位置: 首页>>代码示例>>C++>>正文


C++ Cost::calculateCost方法代码示例

本文整理汇总了C++中Cost::calculateCost方法的典型用法代码示例。如果您正苦于以下问题:C++ Cost::calculateCost方法的具体用法?C++ Cost::calculateCost怎么用?C++ Cost::calculateCost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cost的用法示例。


在下文中一共展示了Cost::calculateCost方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
   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);
   assert(swapCore == 2);
   Coordinate oldPos = core[changedCore].getPosition();

   //remove old cost (compaction, slack, proximity)
   cost.updateCost(bandwidth, latency, 1, core, REMOVE, changedCore,
         swapCore);
   //remove all connections from the changed core
   network.changeAllConnections(bandwidth, core, changedCore, REMOVE);
   //remove all connections from the old position of the swap core
   network.changeAllConnections(bandwidth, core, swapCore, REMOVE);
   //add the overlap
   if (bandwidth[changedCore][swapCore] != 0) {
      network.changeConnection(core[changedCore].getPosition(),
            core[swapCore].getPosition(), ADD);
   }
   if (bandwidth[swapCore][changedCore] != 0) {
      network.changeConnection(core[swapCore].getPosition(),
            core[changedCore].getPosition(), ADD);
   }

   //place core on new pos
   core[swapCore].setPosition(oldPos);
   network.addCore(oldPos, swapCore);
   core[changedCore].setPosition(newPos);
   network.addCore(newPos, changedCore);

   //add all connections of changedCore
   network.changeAllConnections(bandwidth, core, changedCore, ADD);
   //add all connections of swap core
   network.changeAllConnections(bandwidth, core, swapCore, ADD);
   //remove overlap
   if (bandwidth[changedCore][swapCore] != 0) {
      network.changeConnection(core[changedCore].getPosition(),
            core[swapCore].getPosition(), REMOVE);
   }
   if (bandwidth[swapCore][changedCore] != 0) {
      network.changeConnection(core[swapCore].getPosition(),
            core[changedCore].getPosition(), REMOVE);
   }
   //calculate new cost (compaction, slack, proximity)
   cost.updateCost(bandwidth, latency, 1, core, ADD, changedCore,
         swapCore);
   //calculate new cost
   //cost.initCost(bandwidth, latency, core, LINK_LATENCY, network);
   cost.calculateCost(bandwidth, core, network);

   network.updateUtilization(bandwidth, core);

   //network.printNetwork();

   network.showDiagram();

   cost.printCost();
   cout << endl;

   return 0;
}
开发者ID:guitarnana,项目名称:Core-placement-simulation,代码行数:101,代码来源:testNetwork.cpp


注:本文中的Cost::calculateCost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。