public PhysicalNode GetMaxRCNode() { double max_rc = 0.0; PhysicalNode pn = null; foreach (var item in PhysicalNodeDict) { if (item.Value.RC > max_rc) { max_rc = item.Value.RC; pn = item.Value; } } return(pn); }
public string ServicePlacement(string virtual_json_str, string physical_json_str) { ParseInput(virtual_json_str, JsonStringType.Virtual); ParseInput(physical_json_str, JsonStringType.Physical); VNG.CalculateAllRC(); VNG.CalculateAllSAR(); VNG.SortNodeBySAR(); OutputMessage output = new OutputMessage(); while (VNG.SortedVirtualNodeDict.Any()) { PNG.CalculateAllRC(); VirtualNode vn = VNG.SortedVirtualNodeDict.Values.First(); PhysicalNode pn = PNG.GetMaxRCNode(); if (vn.RC <= pn.RC) { DeployVirtualNode(vn, pn); output.NodeMap.Add(vn, pn); VNG.SortedVirtualNodeDict.Remove(vn.ID); } else { output.State = "failed"; output.NodeMap = null; break; } } if (output.State != "failed") { output.State = "successful"; } return(EncapsulateOutput(output)); }
public void DeployVirtualNode(VirtualNode vn, PhysicalNode pn) { }