예제 #1
0
def main(simulated_time):

    random.seed(RANDOM_SEED)
    """
    TOPOLOGY from a json
    """
    t = Topology()
    t_json = create_json_topology()
    t.load(t_json)
    t.write("network.gexf")
    """
    APPLICATION
    """
    app = create_application()
    """
    PLACEMENT algorithm
    """
    placement = CloudPlacement(
        "onCloud")  # it defines the deployed rules: module-device
    placement.scaleService({"ServiceA": 1})
    """
    POPULATION algorithm
    """
    #In ifogsim, during the creation of the application, the Sensors are assigned to the topology, in this case no. As mentioned, YAFS differentiates the adaptive sensors and their topological assignment.
    #In their case, the use a statical assignment.
    pop = Statical("Statical")
    #For each type of sink modules we set a deployment on some type of devices
    #A control sink consists on:
    #  args:
    #     model (str): identifies the device or devices where the sink is linked
    #     number (int): quantity of sinks linked in each device
    #     module (str): identifies the module from the app who receives the messages
    pop.set_sink_control({
        "model": "actuator-device",
        "number": 1,
        "module": app.get_sink_modules()
    })

    #In addition, a source includes a distribution function:
    dDistribution = deterministicDistribution(name="Deterministic", time=100)
    pop.set_src_control({
        "model": "sensor-device",
        "number": 1,
        "message": app.get_message("M.A"),
        "distribution": dDistribution
    })
    """--
    SELECTOR algorithm
    """
    #Their "selector" is actually the shortest way, there is not type of orchestration algorithm.
    #This implementation is already created in selector.class,called: First_ShortestPath
    selectorPath = MinimunPath()
    """
    SIMULATION ENGINE
    """

    stop_time = simulated_time
    s = Sim(t, default_results_path="Results")
    s.deploy_app(app, placement, pop, selectorPath)
    s.run(stop_time, show_progress_monitor=False)
예제 #2
0
def main(simulated_time):

    random.seed(RANDOM_SEED)
    np.random.seed(RANDOM_SEED)

    """
    TOPOLOGY from a json
    """
    t = Topology()
    t_json = create_json_topology()
    t.load(t_json)
    t.write("network.gexf")

    """
    APPLICATION
    """
    app = create_application()

    """
    PLACEMENT algorithm
    """
    # MINHA IMPLEMENTACAO DO ALGORITMO PARA PLACEMENT.
    # UTILIZA A PROPRIEDADE model:node
    placement = UCPlacement(name="UCPlacement")

    # Para criar replicas dos servicos
    placement.scaleService({"MLTTask": 1, "FLTTask":1, "DLTTask":1})

    """
    POPULATION algorithm
    """
    #In ifogsim, during the creation of the application, the Sensors are assigned to the topology, in this case no. As mentioned, YAFS differentiates the adaptive sensors and their topological assignment.
    #In their case, the use a statical assignment.
    pop = Statical("Statical")
    #For each type of sink modules we set a deployment on some type of devices
    #A control sink consists on:
    #  args:
    #     model (str): identifies the device or devices where the sink is linked
    #     number (int): quantity of sinks linked in each device
    #     module (str): identifies the module from the app who receives the messages
    pop.set_sink_control({"model": "sink","number":0,"module":app.get_sink_modules()})

    #In addition, a source includes a distribution function:
    dDistribution = deterministicDistribution(name="Deterministic",time=10)
    # delayDistribution = deterministicDistributionStartPoint(400, 100, name="DelayDeterministic")
    
    # number:quantidade de replicas
    pop.set_src_control({"model": "camera", "number":1,"message": app.get_message("M.Cam"), "distribution": dDistribution})
    # pop.set_src_control({"type": "mlt", "number":1,"message": app.get_message("M.MLT"), "distribution": dDistribution})
    

    """
    SELECTOR algorithm
    """
    #Their "selector" is actually the shortest way, there is not type of orchestration algorithm.
    #This implementation is already created in selector.class,called: First_ShortestPath
    selectorPath = MinimunPath()
    # selectorPath = MinPath_RoundRobin()
    

    """
    SIMULATION ENGINE
    """

    stop_time = simulated_time
    s = Sim(t, default_results_path="Results")
    s.deploy_app(app, placement, pop, selectorPath)
    s.run(stop_time,show_progress_monitor=False)

    s.draw_allocated_topology() # for debugging
예제 #3
0
def main():

    random.seed(RANDOM_SEED)
    np.random.seed(RANDOM_SEED)
    """
    Detalles
    """

    topologies = {
        "Grid": "data/grid200.graphml",
        "BarabasiAlbert": "data/BarabasiAlbert2.graphml",
        "RandomEuclidean": "data/RandomEuclidean.graphml",
        "Lobster": "data/Lobster.graphml",
    }
    community_size = [50, 100, 150, 200, 300]
    threshold_population_edge = 0.010

    ltopo = []
    lnodes = []
    ledges = []
    lavepath = []
    leddev = []

    try:
        for key_topo in topologies.keys():
            """
            TOPOLOGY from a json
            """
            t = Topology()
            # t_json = create_json_topology()
            # t.load(t_json)

            t.load_graphml(topologies[key_topo])
            print "TOPOLOGY: %s" % key_topo
            print "Total Nodes: %i" % len(t.G.nodes())
            print "Total Vertexs: %i" % len(t.G.edges())
            print "Average shortest path: %s" % nx.average_shortest_path_length(
                t.G)
            # t.write("network_ex2.gexf")

            ltopo.append(key_topo)
            lnodes.append(len(t.G.nodes()))
            ledges.append(len(t.G.edges()))
            lavepath.append(nx.average_shortest_path_length(t.G))

            ### COMPUTING Node degrees
            ### Stablish the Edge devices (acc. with Algoritm.nodedegree >... 1)
            ### Identify Cloud Device (max. degree)
            deg = {}
            edge = {}
            cloud_device = 0
            bestDeg = -1
            for n in t.G.nodes():
                d = t.G.degree(n)
                if d > bestDeg:
                    bestDeg = d
                    cloud_device = int(n)
                deg[n] = {"degree": d}
                #### MUST BE IMPROVED
                if key_topo in ["BarabasiAlbert", "Lobster"]:
                    if d == 1:
                        edge[n] = -1

                elif key_topo in ["Grid"]:
                    if d <= 3:
                        edge[n] = -1

                elif key_topo in ["RandomEuclidean"]:
                    if d > 14:
                        edge[n] = -1

            print "Total Edge-Devices: %i" % len(edge.keys())
            leddev.append(len(edge.keys()))
            """
            OJO
            """
            #TODO
            if key_topo in ["Grid"]:
                cloud_device = 320

            print "ID of Cloud-Device: %i" % cloud_device
            continue

            #print "Total edges devices: %i" % len(edge.keys())
            #nx.set_node_attributes(t.G, values=deg)

            ## COMPUTING MATRIX SHORTEST PATH among EDGE-devices
            minPath = {}
            minDis = {}
            for d in edge.keys():
                minDis[d] = []
                for d1 in edge.keys():
                    if d == d1: continue
                    path = list(nx.shortest_path(t.G, source=d, target=d1))
                    minPath[(d, d1)] = path
                    minDis[d].append(len(path))
            """
            WORKLOAD DEFINITION & REGION SENSORS (=Communities)
            """

            for size in community_size:

                print "SIZE Of Community: %i" % size

                communities, com = generate_communities(
                    size, edge, minPath, minDis, threshold_population_edge,
                    cloud_device)
                #print "Computed Communities"
                # print communities
                #for idx,c in enumerate(communities):
                #    print "\t %i - size: %i -: %s" %(idx,len(c),c)
                ### WRITING NETWORK
                nx.set_node_attributes(t.G, values=com)
                t.write("tmp/network-communities-%s-%i.gexf" %
                        (key_topo, size))

                # exit()

                #TODO suposicion cada comunidad es un tipo de carga
                sensor_workload_types = communities

                lambdas_wl = np.random.randint(low=5,
                                               high=10,
                                               size=len(sensor_workload_types))
                id_lambdas = zip(range(0, len(lambdas_wl)), lambdas_wl)
                id_lambdas.sort(key=lambda tup: tup[1],
                                reverse=True)  # sorts in place
                #print id_lambdas # [(1, 9), (0, 8)]
                """
                topology.Centricity
                """
                # Both next ids be extracted from topology.entities
                all_nodes_dev = t.G.nodes()
                edge_dev = edge.keys()

                weights = computingWeights(t, all_nodes_dev, edge_dev,
                                           sensor_workload_types)
                print "Computed weights"
                """
                APPLICATION
                """
                apps = []
                pops = []
                for idx in range(0, len(sensor_workload_types)):
                    apps.append(create_application(idx))
                    pops.append(Statical("Statical-%i" % idx))
                """
                PLACEMENT algorithm
                """
                #There is not modules thus placement.functions are empty
                placement = NoPlacementOfModules("empty")
                """--
                SELECTOR algorithm
                """
                # This implementation is already created in selector.class,called: First_ShortestPath
                selectorPath = First_ShortestPath()

                #In this point, the study analizes the behaviour of the deployment of (sink, src) modules (population) in different set of centroide algorithms
                #functions = {"Cluster":"Cluster","Eigenvector":nx.eigenvector_centrality,"Current_flow_betweenness_centrality":nx.current_flow_betweenness_centrality,
                #            "Betweenness_centrality":nx.betweenness_centrality,"load_centrality":nx.load_centrality} #"katz_centrality":nx.katz_centrality,
                #functions = {"Current_flow_betweenness_centrality":nx.current_flow_betweenness_centrality}

                functions = {
                    "Cluster": "Cluster",
                    "Eigenvector": nx.eigenvector_centrality,
                    "Current_flow_betweenness_centrality":
                    nx.current_flow_betweenness_centrality,
                    "Betweenness_centrality": nx.betweenness_centrality,
                    #"Load_centrality": nx.load_centrality
                }  # "katz_centrality":nx.katz_centrality,

                for f in functions:

                    print "Analysing network with algorithm: %s " % f
                    """
                    POPULATION algorithm
                    """
                    pops = []
                    for idx in range(0, len(sensor_workload_types)):
                        pops.append(Statical("Statical-%i" % idx))
                    # print "-"*20
                    # print "Function: %s" %f
                    # print "-"*20
                    if "Cluster" in f:
                        for idWL in id_lambdas:
                            idx = idWL[0]
                            # print idx
                            ## idWL[0] #index WL
                            ## idWL[1] #lambda

                            ### ALL SINKS  goes to Cluster ID: NODE 0
                            # print "\t", "SINK"
                            pops[idx].set_sink_control({
                                "id": [cloud_device],
                                "number":
                                1,
                                "module":
                                apps[idx].get_sink_modules()
                            })
                            # print "\t", "SOURCE"
                            # In addition, a source includes a distribution function:

                            dDistribution = deterministicDistribution(
                                name="Deterministic", time=idWL[1])
                            pops[idx].set_src_control({
                                "id":
                                sensor_workload_types[idx],
                                "number":
                                1,
                                "message":
                                apps[idx].get_message("m-st"),
                                "distribution":
                                dDistribution
                            })

                    else:
                        #Computing best device for each WL-type and each centrality function
                        print "\t Computando centralidad "
                        centralWL = range(0, len(weights))
                        for idx, v in enumerate(sensor_workload_types):
                            if idx % 20 == 0:
                                print "\t\t%i%%", idx
                            nx.set_edge_attributes(t.G,
                                                   values=weights[idx],
                                                   name="weight")
                            centrality = functions[f](t.G, weight="weight")
                            # print(['%s %0.2f' % (node, centrality[node]) for node in centrality])
                            centralWL[idx] = centrality

                        print "\t Generando SINK/SRCs centralidad "
                        previous_deploy = {}  ## DEV -> ID:load
                        for idWL in id_lambdas:
                            idx = idWL[0]
                            ## idWL[0] #index WL
                            ## idWL[1] #lambda

                            for dev, value in sorted(
                                    centralWL[idx].iteritems(),
                                    key=lambda (k, v): (v, k),
                                    reverse=True):
                                # print "%s: %s" % (dev, value)
                                #TODO CONTTOLAR LA CAPACIDAD DEL DISPOSITO HERE
                                if not dev in previous_deploy.values():
                                    previous_deploy[idx] = dev
                                    break
                            #TODO chequear que dEV es un device
                            # print "\t Previous deploy: ",previous_deploy
                            # print "\t NameApp: ",apps[idx].name
                            # print "\t Device:",dev
                            #Each application have a correspondence SRC/SINK among APPS

                            pops[idx].set_sink_control({
                                "id": [dev],
                                "number":
                                1,
                                "module":
                                apps[idx].get_sink_modules()
                            })
                            dDistribution = deterministicDistribution(
                                name="Deterministic", time=idWL[1])
                            #In addition, a source includes a distribution function:
                            pops[idx].set_src_control({
                                "id":
                                sensor_workload_types[idx],
                                "number":
                                1,
                                "message":
                                apps[idx].get_message("m-st"),
                                "distribution":
                                dDistribution
                            })
                    """
                    SIMULATION ENGINE
                    """
                    stop_time = 100  #CHECK
                    s = Sim(t)
                    for idx, app in enumerate(apps):
                        s.deploy_app(app, placement, pops[idx], selectorPath)

                    s.run(stop_time,
                          test_initial_deploy=False,
                          show_progress_monitor=False)

                #end for algorithms
            #end for communities size
        #end for topology change

        print ltopo
        print lnodes
        print ledges
        print lavepath
        print leddev

    #end try

    except:
        print "Some error??"
예제 #4
0
파일: main.py 프로젝트: SiNa88/YAFS
def main(simulated_time, depth, police):

    random.seed(RANDOM_SEED)
    """
    TOPOLOGY from a json
    """
    numOfDepts = depth
    numOfMobilesPerDept = 4  # Thus, this variable is used in the population algorithm
    # In YAFS simulator, entities representing mobiles devices (sensors or actuactors) are not necessary because they are simple "abstract" links to the  access points
    # in any case, they can be implemented with node entities with no capacity to execute services.
    #

    t = Topology()
    t_json = create_json_topology(numOfDepts, numOfMobilesPerDept)
    t.load(t_json)

    t.write("network_%s.gexf" % depth)
    """
    APPLICATION
    """
    app = create_application()
    """
    PLACEMENT algorithm
    """
    #In this case: it will deploy all app.modules in the cloud
    if police == "cloud":
        print "cloud"
        placement = CloudPlacement("onCloud")
        placement.scaleService({
            "Calculator": numOfDepts * numOfMobilesPerDept,
            "Coordinator": 1
        })
    else:
        print "EDGE"
        placement = FogPlacement("onProxies")
        placement.scaleService({
            "Calculator": numOfMobilesPerDept,
            "Coordinator": 1
        })

    # placement = ClusterPlacement("onCluster", activation_dist=next_time_periodic, time_shift=600)
    """
    POPULATION algorithm
    """
    #In ifogsim, during the creation of the application, the Sensors are assigned to the topology, in this case no. As mentioned, YAFS differentiates the adaptive sensors and their topological assignment.
    #In their case, the use a statical assignment.
    pop = Statical("Statical")
    #For each type of sink modules we set a deployment on some type of devices
    #A control sink consists on:
    #  args:
    #     model (str): identifies the device or devices where the sink is linked
    #     number (int): quantity of sinks linked in each device
    #     module (str): identifies the module from the app who receives the messages
    pop.set_sink_control({
        "model": "a",
        "number": 1,
        "module": app.get_sink_modules()
    })

    #In addition, a source includes a distribution function:
    dDistribution = deterministicDistribution(name="Deterministic", time=100)
    pop.set_src_control({
        "model": "s",
        "number": 1,
        "message": app.get_message("M.EGG"),
        "distribution": dDistribution
    })
    """--
    SELECTOR algorithm
    """
    #Their "selector" is actually the shortest way, there is not type of orchestration algorithm.
    #This implementation is already created in selector.class,called: First_ShortestPath
    if police == "cloud":
        selectorPath = CloudPath_RR()
    else:
        selectorPath = BroadPath(numOfMobilesPerDept)
    """
    SIMULATION ENGINE
    """

    stop_time = simulated_time
    s = Sim(t,
            default_results_path="Results_%s_%i_%i" %
            (police, stop_time, depth))
    s.deploy_app(app, placement, pop, selectorPath)

    s.run(stop_time, test_initial_deploy=False, show_progress_monitor=False)
예제 #5
0
파일: main.py 프로젝트: yangdz161/YAFS
                sim.stop_process(key)
        except IndexError:
            None

    else:
        sim.stop = True  ## We stop the simulation


def main(simulated_time, path, pathResults, case, it):
    """
    TOPOLOGY from a json
    """
    t = Topology()
    dataNetwork = json.load(open(path + 'networkDefinition.json'))
    t.load(dataNetwork)
    t.write(path + "network.gexf")
    # t = loadTopology(path + 'test_GLP.gml')
    """
    APPLICATION
    """
    dataApp = json.load(open(path + 'appDefinition.json'))
    apps = create_applications_from_json(dataApp)
    # for app in apps:
    #  print apps[app]
    """
    PLACEMENT algorithm
    """
    # In our model only initial cloud placements are enabled
    placementJson = json.load(open(path + 'allocDefinition.json'))
    placement = JSONPlacement(name="Placement", json=placementJson)
    """
예제 #6
0
파일: main.py 프로젝트: yangdz161/YAFS
def main(simulated_time):
    random.seed(RANDOM_SEED)

    """
    TOPOLOGY from a json
    """
    t = Topology()
    data = json.load(open('egg_infrastructure.json'))
    pprint(data["entity"])
    t.load(data)
    t.write("network.gexf")

    """
    APPLICATION
    """
    app = create_application()

    """
    PLACEMENT algorithm
    """
    #This adaptation can be done manually or automatically.
    # We make a simple manual allocation from the FogTorch output

    #8 - [client_0_0->sp_0_0][client_0_1->sp_0_1][client_0_2->sp_0_2][client_0_3->sp_0_3][client_1_0->sp_1_0][client_1_1->sp_1_1][client_1_2->sp_1_2]
    # [client_1_3->sp_1_3]
    # [concentrator->gw_0][coordinator->gw_1]; 0.105; 2.5; 6.01
    placementJson = {
        "initialAllocation": [
            {"app": "EGG_GAME",
             "module_name": "Calculator",
             "id_resource": 3},

            {"app": "EGG_GAME",
             "module_name": "Coordinator",
             "id_resource": 8},


            {"app": "EGG_GAME",
             "module_name": "Client",
             "id_resource": 4},
            {"app": "EGG_GAME",
             "module_name": "Client",
             "id_resource": 5},
            {"app": "EGG_GAME",
             "module_name": "Client",
             "id_resource": 6},
            {"app": "EGG_GAME",
             "module_name": "Client",
             "id_resource": 7},

            {"app": "EGG_GAME",
             "module_name": "Client",
             "id_resource": 9},
            {"app": "EGG_GAME",
             "module_name": "Client",
             "id_resource": 10},
            {"app": "EGG_GAME",
             "module_name": "Client",
             "id_resource": 11},
            {"app": "EGG_GAME",
             "module_name": "Client",
             "id_resource": 12},




        ]
    }


    placement = JSONPlacement(name="Places",json=placementJson)


    """
    POPULATION algorithm
    """

    populationJSON = {
          "sinks": [
            {"app": "EGG_GAME", "module_name": "Display", "id_resource": 4},
            {"app": "EGG_GAME", "module_name": "Display", "id_resource": 5},
            {"app": "EGG_GAME", "module_name": "Display", "id_resource": 6},
            {"app": "EGG_GAME", "module_name": "Display", "id_resource": 7},
            {"app": "EGG_GAME", "module_name": "Display", "id_resource": 9},
            {"app": "EGG_GAME", "module_name": "Display", "id_resource": 10},
            {"app": "EGG_GAME", "module_name": "Display", "id_resource": 11},
            {"app": "EGG_GAME", "module_name": "Display", "id_resource": 12}
        ],
        "sources":[
            {"app": "EGG_GAME", "message":"M.EGG", "lambda":100,"id_resource":4},
            {"app": "EGG_GAME", "message":"M.EGG", "lambda":100,"id_resource":5},
            {"app": "EGG_GAME", "message":"M.EGG", "lambda":100,"id_resource":6},
            {"app": "EGG_GAME", "message":"M.EGG", "lambda":100,"id_resource":7},
            {"app": "EGG_GAME", "message":"M.EGG", "lambda":100,"id_resource":9},
            {"app": "EGG_GAME", "message":"M.EGG", "lambda":100,"id_resource":10},
            {"app": "EGG_GAME", "message":"M.EGG", "lambda":100,"id_resource":11},
            {"app": "EGG_GAME", "message":"M.EGG", "lambda":100,"id_resource":12},
        ]

    }

    pop = JSONPopulation(name="Statical",json=populationJSON,iteration=0)

    """
    SELECTOR algorithm
    """
    selectorPath = MinShortPath()

    """
    SIMULATION ENGINE
    """

    stop_time = simulated_time
    s = Sim(t, default_results_path="Results_%i" % (stop_time))
    s.deploy_app(app, placement, pop, selectorPath)

    s.run(stop_time, test_initial_deploy=False, show_progress_monitor=False)
    s.print_debug_assignaments()
예제 #7
0
파일: main_nf.py 프로젝트: yangdz161/YAFS
def main(simulated_time, experimento, ilpPath, it):
    """
    TOPOLOGY from a json
    """
    t = Topology()
    dataNetwork = json.load(open(experimento + 'networkDefinition.json'))
    t.load(dataNetwork)
    t.write("network.gexf")
    """
    APPLICATION
    """
    dataApp = json.load(open(experimento + 'appDefinition.json'))
    apps = create_applications_from_json(dataApp)
    #for app in apps:
    #  print apps[app]
    """
    PLACEMENT algorithm
    """
    placementJson = json.load(
        open(experimento + 'allocDefinition%s.json' % ilpPath))
    placement = JSONPlacement(name="Placement", json=placementJson)

    ### Placement histogram

    # listDevices =[]
    # for item in placementJson["initialAllocation"]:
    #     listDevices.append(item["id_resource"])
    # import matplotlib.pyplot as plt
    # print listDevices
    # print np.histogram(listDevices,bins=range(101))
    # plt.hist(listDevices, bins=100)  # arguments are passed to np.histogram
    # plt.title("Placement Histogram")
    # plt.show()
    ## exit()
    """
    POPULATION algorithm
    """
    dataPopulation = json.load(open(experimento + 'usersDefinition.json'))
    pop = JSONPopulation(name="Statical", json=dataPopulation, iteration=it)
    """
    SELECTOR algorithm
    """
    selectorPath = DeviceSpeedAwareRouting()
    """
    SIMULATION ENGINE
    """

    stop_time = simulated_time
    s = Sim(t,
            default_results_path=experimento + "Results_%s_%i_%i" %
            (ilpPath, stop_time, it))
    """
    Failure process
    """
    # time_shift = 10000
    # distribution = deterministicDistributionStartPoint(name="Deterministic", time=time_shift,start=10000)
    # failurefilelog = open(experimento+"Failure_%s_%i.csv" % (ilpPath,stop_time),"w")
    # failurefilelog.write("node, module, time\n")
    # idCloud = t.find_IDs({"type": "CLOUD"})[0] #[0] -> In this study there is only one CLOUD DEVICE
    # centrality = np.load(pathExperimento+"centrality.npy")
    # randomValues = np.load(pathExperimento+"random.npy")
    # # s.deploy_monitor("Failure Generation", failureControl, distribution,sim=s,filelog=failurefilelog,ids=centrality)
    # s.deploy_monitor("Failure Generation", failureControl, distribution,sim=s,filelog=failurefilelog,ids=randomValues)

    #For each deployment the user - population have to contain only its specific sources
    for aName in apps.keys():
        print "Deploying app: ", aName
        pop_app = JSONPopulation(name="Statical_%s" % aName,
                                 json={},
                                 iteration=it)
        data = []
        for element in pop.data["sources"]:
            if element['app'] == aName:
                data.append(element)
        pop_app.data["sources"] = data

        s.deploy_app(apps[aName], placement, pop_app, selectorPath)

    s.run(stop_time, test_initial_deploy=False,
          show_progress_monitor=False)  #TEST to TRUE
예제 #8
0
파일: main.py 프로젝트: yangdz161/YAFS
def main(simulated_time,experimento,ilpPath):
    random.seed(RANDOM_SEED)
    np.random.seed(RANDOM_SEED)

    """
    TOPOLOGY from a json
    """
    t = Topology()
    dataNetwork = json.load(open(experimento+'networkDefinition.json'))
    t.load(dataNetwork)
    t.write("network.gexf")

    """
    APPLICATION
    """
    dataApp = json.load(open(experimento+'appDefinition.json'))
    apps = create_applications_from_json(dataApp)
    #for app in apps:
    #  print apps[app]

    """
    PLACEMENT algorithm
    """
    placementJson = json.load(open(experimento+'allocDefinition%s.json'%ilpPath))
    placement = JSONPlacement(name="Placement",json=placementJson)

    ### Placement histogram

    # listDevices =[]
    # for item in placementJson["initialAllocation"]:
    #     listDevices.append(item["id_resource"])
    # import matplotlib.pyplot as plt
    # print listDevices
    # print np.histogram(listDevices,bins=range(101))
    # plt.hist(listDevices, bins=100)  # arguments are passed to np.histogram
    # plt.title("Placement Histogram")
    # plt.show()
    ## exit()
    """
    POPULATION algorithm
    """
    dataPopulation = json.load(open(experimento+'usersDefinition.json'))
    pop = JSONPopulation(name="Statical",json=dataPopulation)


    """
    SELECTOR algorithm
    """
    selectorPath = DeviceSpeedAwareRouting()

    """
    SIMULATION ENGINE
    """

    stop_time = simulated_time
    s = Sim(t, default_results_path=experimento + "Results_%s_%i" % (ilpPath, stop_time))


    #For each deployment the user - population have to contain only its specific sources
    for aName in apps.keys():
        print "Deploying app: ",aName
        pop_app = JSONPopulation(name="Statical_%s"%aName,json={})
        data = []
        for element in pop.data["sources"]:
            if element['app'] == aName:
                data.append(element)
        pop_app.data["sources"]=data

        s.deploy_app(apps[aName], placement, pop_app, selectorPath)


    s.run(stop_time, test_initial_deploy=False, show_progress_monitor=False) #TEST to TRUE