private static double netCost( int gene_index, IChromosome chromos, IMSApplication app, IMSProvider prov) { Double costPerNet = (Double) prov.getNetwork().getCharacteristic().get(Constant.COST_BW); Gene[] genes = chromos.getGenes(); int current_prov = (int) genes[gene_index].getAllele(); MSApplicationNode curr_node = app.getNodes().get(gene_index); // this is safe int geneVmId = curr_node.getID(); MSApplication am = (MSApplication) app; double cost = 0; Set<ApplicationEdge> set = am.getEdges(); for (ApplicationEdge e : set) { if (e.getSourceVmId() == geneVmId) { int target_index = MSPolicy.getGeneIndexFromNodeId(e.getTargetVmId(), genes, app); int tProvId = (int) genes[target_index].getAllele(); cost += CostComputer.computeLinkCost(e, geneVmId, current_prov, tProvId, costPerNet); } } return cost; }