Ejemplo n.º 1
0
DAY_INTERVAL = 5000
BUY_RATE = NumberGenerator(UNIFORM, a=4, b=12)
BUY_INTERVAL = NumberGenerator(UNIFORM, a=0, b=30)
SELL_PRICE = 50
BUY_PRICE = 35
RECYCLE_PRICE = 5


class Newspaper(Entity):
    def __init__(self, data):
        Entity.__init__(self, data)
        self.status = SOLD


d1 = Disposer()
d1.name = "Bought Newspapers"

d2 = Disposer()
d2.name = "Recycled Newspapers"

pr1 = ActorProbe(d1)
pr1.name = 'Bought Newspapers Probe'
d1.actorprobe = pr1

pr2 = ActorProbe(d2)
pr2.name = 'Recycled Newspapers Probe'
d2.actorprobe = pr2


def branchFunction(entity):
    global SOLD
Ejemplo n.º 2
0
DAY_INTERVAL = 5000
BUY_RATE = NumberGenerator(UNIFORM, a=4, b=12)
BUY_INTERVAL = NumberGenerator(UNIFORM, a=0, b=30)
SELL_PRICE = 50
BUY_PRICE = 35
RECYCLE_PRICE = 5


class Newspaper(Entity):
    def __init__(self, data):
        Entity.__init__(self, data)
        self.status = SOLD


d1 = Disposer()
d1.name = "Bought Newspapers"

d2 = Disposer()
d2.name = "Recycled Newspapers"

pr1 = ActorProbe(d1)
pr1.name = 'Bought Newspapers Probe'
d1.actorprobe = pr1

pr2 = ActorProbe(d2)
pr2.name = 'Recycled Newspapers Probe'
d2.actorprobe = pr2

def branchFunction(entity):
    global SOLD
    if entity.status == SOLD:
Ejemplo n.º 3
0
from convergance_entity import Entity
from randomNumber import RANDINT, NumberGenerator
import random

a = NumberGenerator(RANDINT, a=1, b=2)
def randomInterval():
    return random.randint(1,2)

def branchFunction(data):
    return random.randrange(0,2)

def delayFunction(data):
    return random.randrange(2,5)

d1 = Disposer()
d1.name = "Disposer1"
d1.logs = True
d2 = Disposer()
d2.name = "Disposer2"
d2.logs = True
dl1 = Delay(d2, delayFunction)
dl1.name = "Delay1"
dl1.logs = True
b1 = Branch([d1, dl1], branchFunction)
b1.name = "Branch1"
b1.logs = True
g1 = Generator(b1, Entity, None, randomInterval, 20)
g1.name = "MyGenerator"
g1.logs = True
sim = Simulation()
sim.logs = True
Ejemplo n.º 4
0

def randomInterval():
    return random.randint(1, 2)


def branchFunction(data):
    return random.randrange(0, 2)


def delayFunction(data):
    return random.randrange(2, 5)


d1 = Disposer()
d1.name = "Disposer1"
d1.logs = True
d2 = Disposer()
d2.name = "Disposer2"
d2.logs = True
dl1 = Delay(d2, delayFunction)
dl1.name = "Delay1"
dl1.logs = True
b1 = Branch([d1, dl1], branchFunction)
b1.name = "Branch1"
b1.logs = True
g1 = Generator(b1, Entity, None, randomInterval, 20)
g1.name = "MyGenerator"
g1.logs = True
sim = Simulation()
sim.logs = True