Exemplo n.º 1
0
        plt.ion()
        plt.show()
    
    def run(self):
        while(simx.get_now() < end_time):
            plt.clf()
            nx.draw_networkx_edges(G,Gpos,nodelist=[ncenter],alpha=0.4,edge_color='grey')
            nx.draw_networkx_nodes(G,Gpos,node_size=80,nodelist=p.keys(),node_color=p.values(),cmap=plt.cm.Reds_r)
            plt.xlim(-0.05,1.05)
            plt.ylim(-0.05,1.05)
            plt.axis('off')
            plt.draw()
            self.sleep(update_interval)


simx.init("consensus")
simx.set_end_time(end_time)
simx.set_min_delay(min_delay)
#simx.set_log_level("debug3")
simx.init_env()

for i in xrange(num_nodes):
    simx.create_entity(('n',i),Node,ent_data=({'gnode_id':i}))
    node_list.append(simx.get_entity(('n',i)))

#quit()
    
simx.get_controller().install_service(Receiver,eAddr_RECVR)
simx.schedule_process(Updater())

#only rank 0 does the plotting
Exemplo n.º 2
0
# Additionally, this library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License v 2.1 as published by the
# Free Software Foundation. Accordingly, this library is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt for more details.

import simx

from Person import *
from HelloHandler import *

random.seed(0)

####### Initialize MPI and configuration framework#######
simx.init("HelloWorld")

end_time = 500000

##### set simulation configuration values ########
simx.set_min_delay(1)
simx.set_end_time(end_time)

# These are optional
simx.set_output_file("helloworld.out")
#simx.set_log_level("debug3")
simx.set_log_file("helloworld.log")

####### Initialize environment (logging, output etc) ###########
simx.init_env()
Exemplo n.º 3
0
Arquivo: hello.py Projeto: thulas/simx
# Free Software Foundation. Accordingly, this library is distributed in the hope that 
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt for more details.



import simx



from Person import *
from HelloHandler import *


####### Initialize MPI and configuration framework#######
simx.init("HelloWorld")

end_time = 2**10

##### set simulation configuration values ########
simx.set_min_delay(10)
simx.set_end_time(end_time)

# These are optional
simx.set_output_file("helloworld.out")
simx.set_log_level("info")
simx.set_log_file("helloworld.log")

####### Initialize environment (logging, output etc) ###########
simx.init_env()
Exemplo n.º 4
0
Arquivo: ossim.py Projeto: gaber/simx
            "finished computing on resource ",self.resource, \
            " at time ", simx.get_now()
        
        
        bp = self.os.create_process(BarProcess)
        # waits for Bar process to finish before resuming
        self.waitfor(bp)

        print "Foo process ",id(self)," on node",self.os.get_entity_id(), \
            "returned from waitfor. Acquired resource ",self.resource, \
            " at time ", simx.get_now()



#initialize
simx.init("ossim")
simx.set_end_time(1000)
simx.set_min_delay(1)
simx.set_log_level("debug3")
simx.init_env()

num_nodes = 1

#create nodes
for i in xrange(num_nodes):
    simx.create_entity(('n',i), os.Node,ent_data=({'num_cores':1}))

num_processes = 1
#on each node create foo processes
for i in xrange(num_nodes):
    node = simx.get_entity(('n',i))
Exemplo n.º 5
0
Arquivo: cd.py Projeto: nmtrmail/simx
    """
    Just another process
    """
    def __init__(self, id_):
        self.id_ = id_

    def run(self):
        print "foo process: ", self.id_, " Time: ", simx.get_now()
        #if id == 0:
        #    self.spawn(fooprocess(id+1))
        self.sleep(2)
        print "foo process: ", self.id_, " wake up at time:", simx.get_now()

    def end(self):
        print "foo process: ", self.id_, " ends here"


simx.init("cd")

simx.set_min_delay(1)
simx.set_end_time(100)
simx.set_log_level("debug3")

simx.init_env()

for i in range(1):
    cd = CountDown(i, 10)
    simx.schedule_process(cd)

simx.run()
Exemplo n.º 6
0
                                   alpha=0.4,
                                   edge_color='grey')
            nx.draw_networkx_nodes(G,
                                   Gpos,
                                   node_size=80,
                                   nodelist=p.keys(),
                                   node_color=p.values(),
                                   cmap=plt.cm.Reds_r)
            plt.xlim(-0.05, 1.05)
            plt.ylim(-0.05, 1.05)
            plt.axis('off')
            plt.draw()
            self.sleep(update_interval)


simx.init("consensus")
simx.set_end_time(end_time)
simx.set_min_delay(min_delay)
#simx.set_log_level("debug3")
simx.init_env()

for i in xrange(num_nodes):
    simx.create_entity(('n', i), Node, ent_data=({'gnode_id': i}))
    node_list.append(simx.get_entity(('n', i)))

#quit()

simx.get_controller().install_service(Receiver, eAddr_RECVR)
simx.schedule_process(Updater())

#only rank 0 does the plotting
Exemplo n.º 7
0
import simx
import random

endTime = 500
count = 100000
maxSleep = 100

#Initialize
simx.init("GREEN")
simx.set_end_time(endTime)
simx.set_min_delay(1)
simx.set_log_level("warn")
simx.init_env()


#Create a message generation process
class processApp(simx.Process):
    """
    Schedule the compute nodes to run their applications (Booting Up)
    """
    def run(self):
        while True:
            x = int(maxSleep * random.random())
            #print "Sleeping for", x
            self.sleep(x)
            #print "Woke"


for i in xrange(count):
    #print "Adding process", i
    mg = processApp()
Exemplo n.º 8
0
import simx
import random

endTime = 500
count = 100000
maxSleep = 100

#Initialize
simx.init("GREEN")
simx.set_end_time(endTime)
simx.set_min_delay(1)
simx.set_log_level("warn")
simx.init_env()

#Create a message generation process
class processApp(simx.Process):
    """
    Schedule the compute nodes to run their applications (Booting Up)
    """
    def run(self):
        while True:
            x = int(maxSleep*random.random())
            #print "Sleeping for", x
            self.sleep(x)
            #print "Woke"

for i in xrange(count):
    #print "Adding process", i
    mg = processApp()
    simx.schedule_process(mg)
Exemplo n.º 9
0
    def recv(self, msg):
        targetId = random.randrange(count)
        offset = int(exponential(1) + min_delay)
        #print "node ",self.get_entity_id()," sending message with offset ",\
        #    offset," at time ",simx.get_now(), "to target ", targetId
        self.send_info(None,offset,('n',targetId),
                       addr_RECEIVER)
                       
simx.register_service(Receiver)
simx.register_address("addr_RECEIVER",addr_RECEIVER)
        
class Node(simx.PyEntity):
    def __init__(self,ID,lp,entity_input,py_obj=None):
        super(Node,self).__init__(ID,lp,entity_input,self)
        self.install_service(Receiver, addr_RECEIVER)
        #print "node ",ID," being created"


simx.init("phold")
simx.set_end_time(500000)
simx.set_min_delay(1)
simx.init_env()
        
for i in xrange(count):
    simx.create_entity(('n',i),Node)

for i in xrange(count):
    simx.schedule_event(0,('n',i),addr_RECEIVER,None)

simx.run()
Exemplo n.º 10
0
import simx
from Person import *
from HelloHandler import *

# initialize
simx.init("helloworld")
simx.set_end_time(1024)
simx.set_min_delay(1)
simx.init_env()

# create Persons
person_list = []
num_persons = 1024
for i in xrange(num_persons):
    simx.create_entity(('p', i), Person)
    person_list.append(('p', i))

#schedule events
for evt_time in range(1, end_time):
    hello_rcvr = random.choice(person_list)
    reply_rcvr = random.choice(person_list)
    simx.schedule_event(evt_time, hello_rcvr, eAddr_HelloHandlerPerson,
                        HelloMessage(source_id=reply_rcvr))

#Run the simulation
simx.run()
Exemplo n.º 11
0
class fooprocess(simx.Process):
    """
    Just another process
    """
    def __init__(self,id_):
        self.id_ = id_

    def run(self):
        print "foo process: ",self.id_," Time: ",simx.get_now()
        self.sleep(2)
        print "foo process: ",self.id_," wake up at time:",simx.get_now()
        self.spawn(fooprocess(self.id_))

    def end(self):
        print "foo process: ",self.id_," ends here"

simx.init("cdkill")

simx.set_min_delay(1)
simx.set_end_time(100)
simx.set_log_level("debug3")

simx.init_env()

for i in range(1):
    cd = CountDown(i,10)
    simx.schedule_process( cd )

simx.run()
Exemplo n.º 12
0
class fooprocess(simx.Process):
    """
    Just another process
    """
    def __init__(self, id_):
        self.id_ = id_

    def run(self):
        print "foo process: ", self.id_, " Time: ", simx.get_now()
        self.sleep(2)
        print "foo process: ", self.id_, " wake up at time:", simx.get_now()
        self.spawn(fooprocess(self.id_))

    def end(self):
        print "foo process: ", self.id_, " ends here"


simx.init("cdkill")

simx.set_min_delay(1)
simx.set_end_time(100)
simx.set_log_level("debug3")

simx.init_env()

for i in range(1):
    cd = CountDown(i, 10)
    simx.schedule_process(cd)

simx.run()
Exemplo n.º 13
0
Arquivo: cd.py Projeto: dailypips/simx
class fooprocess(simx.Process):
    """
    Just another process
    """
    def __init__(self,id_):
        self.id_ = id_

    def run(self):
        print "foo process: ",self.id_," Time: ",simx.get_now()
        #if id == 0:
        #    self.spawn(fooprocess(id+1))
        self.sleep(2)
        print "foo process: ",self.id_," wake up at time:",simx.get_now()

    def end(self):
        print "foo process: ",self.id_," ends here"

simx.init("cd")

simx.set_min_delay(1)
simx.set_end_time(100)
simx.set_log_level("debug3")

simx.init_env()

for i in range(1):
    cd = CountDown(i,10)
    simx.schedule_process( cd )

simx.run()
Exemplo n.º 14
0
        targetId = random.randrange(count)
        offset = int(exponential(1) + min_delay)
        #print "node ",self.get_entity_id()," sending message with offset ",\
        #    offset," at time ",simx.get_now(), "to target ", targetId
        self.send_info(None, offset, ('n', targetId), addr_RECEIVER)


simx.register_service(Receiver)
simx.register_address("addr_RECEIVER", addr_RECEIVER)


class Node(simx.PyEntity):
    def __init__(self, ID, lp, entity_input, py_obj=None):
        super(Node, self).__init__(ID, lp, entity_input, self)
        self.install_service(Receiver, addr_RECEIVER)
        #print "node ",ID," being created"


simx.init("phold")
simx.set_end_time(500000)
simx.set_min_delay(1)
simx.init_env()

for i in xrange(count):
    simx.create_entity(('n', i), Node)

for i in xrange(count):
    simx.schedule_event(0, ('n', i), addr_RECEIVER, None)

simx.run()
Exemplo n.º 15
0
# Additionally, this library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License v 2.1 as published by the 
# Free Software Foundation. Accordingly, this library is distributed in the hope that 
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt for more details.

import simx
from Person import *
from HelloHandler import *

num_entities = 32
end_time = 1024

# initialize
simx.init("helloworldv2")
simx.set_end_time(end_time)
simx.set_min_delay(1)
simx.init_env()



# create Persons
for i in xrange(num_entities):
    simx.create_entity(('p',i), Person)
    
# create a message generation process
class MessageGen (simx.Process):
    """
    Schedule simple message sending and receiving
    """
Exemplo n.º 16
0
# it under the terms of the GNU Lesser General Public License v 2.1 as published by the
# Free Software Foundation. Accordingly, this library is distributed in the hope that
# it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt for more details.

import simx
from Person import *
from HelloHandler import *

random.seed(0)

num_entities = 32
end_time = 1000000

# initialize
simx.init("helloworldv2")
simx.set_end_time(end_time)
simx.set_min_delay(1)
simx.init_env()

# create Persons
for i in xrange(num_entities):
    simx.create_entity(('p', i), Person)


# create a message generation process
class MessageGen(simx.Process):
    """
    Schedule simple message sending and receiving
    """
    def run(self):
Exemplo n.º 17
0
            "finished computing on resource ",self.resource, \
            " at time ", simx.get_now()
        
        
        bp = self.os.create_process(BarProcess)
        # waits for Bar process to finish before resuming
        self.waitfor(bp)

        print "Foo process ",id(self)," on node",self.os.get_entity_id(), \
            "returned from waitfor. Acquired resource ",self.resource, \
            " at time ", simx.get_now()



#initialize
simx.init("ossim")
simx.set_end_time(1000)
simx.set_min_delay(1)
simx.set_log_level("debug3")
simx.init_env()

num_nodes = 2

#create nodes
for i in xrange(num_nodes):
    simx.create_entity(('n',i), os.Node,ent_data=({'num_cores':1}))

num_processes = 1
#on each node create foo processes
for i in xrange(num_nodes):
    node = simx.get_entity(('n',i))