Beispiel #1
0
    def __init__(self, methodName, prop_file="models/fashion_for_test.props"):
        super().__init__(methodName=methodName)

        self.pa = props.read_props(MODEL_NM, prop_file)

        # Now we create a forest environment for our agents to act within:
        self.env = fm.Society("Society",
                              self.pa["grid_height"],
                              self.pa["grid_width"],
                              torus=False,
                              model_nm=MODEL_NM,
                              props=self.pa)

        for i in range(self.pa["num_followers"]):
            self.env.add_agent(
                fm.Follower("follower" + str(i), "Looking like hipsters",
                            self.pa["fmax_move"], self.pa["variability"]))

        for i in range(self.pa["num_hipsters"]):
            self.env.add_agent(
                fm.Hipster("hipster" + str(i), "Looking trendy",
                           self.pa["hmax_move"], self.pa["variability"]))
        self.env.add_agent(
            fm.Hipster("hipster for tracking", "Looking trendy",
                       self.pa["hmax_move"], self.pa["variability"]))
    def __init__(self,
                 methodName,
                 prop_file="models/forestfire_for_test.props"):
        super().__init__(methodName=methodName)

        pa = props.read_props(MODEL_NM, prop_file)

        grid_x = pa["grid_width"]
        grid_y = pa["grid_height"]
        density = pa["density"]

        # Now we create a forest environment for our agents to act within:
        self.env = fm.ForestEnv(grid_x,
                                grid_y,
                                density,
                                pa["strike_freq"],
                                pa["regen_period"],
                                model_nm=MODEL_NM,
                                torus=False,
                                props=pa)

        num_agents = int(grid_x * grid_y * density)

        for i in range(num_agents):
            self.env.add_agent(fm.Tree(name="tree" + str(i)))

        self.env.add_agent(fm.Tree(name="tree for tracking"))
Beispiel #3
0
    def __init__(self, methodName, prop_file="models/fashion_for_test.props"):
        super().__init__(methodName=methodName)

        self.pa = props.read_props(MODEL_NM, prop_file)

        # Now we create a forest environment for our agents to act within:
        self.env = fm.Society("Society",
                     self.pa["grid_height"],
                     self.pa["grid_width"],
                     torus=False,
                     model_nm=MODEL_NM,
                     props=self.pa)

        for i in range(self.pa["num_followers"]):
            self.env.add_agent(fm.Follower("follower" + str(i),
                                      "Looking like hipsters",
                                      self.pa["fmax_move"],
                                      self.pa["variability"]))

        for i in range(self.pa["num_hipsters"]):
            self.env.add_agent(fm.Hipster("hipster" + str(i), "Looking trendy",
                                     self.pa["hmax_move"],
                                     self.pa["variability"]))
        self.env.add_agent(fm.Hipster("hipster for tracking", "Looking trendy",
                                      self.pa["hmax_move"],
                                      self.pa["variability"]))
Beispiel #4
0
    def __init__(self, methodName, prop_file="models/forestfire_for_test.props"):
        super().__init__(methodName=methodName)

        pa = props.read_props(MODEL_NM, prop_file)

        grid_x = pa["grid_width"]
        grid_y = pa["grid_height"]
        density = pa["density"]

        # Now we create a forest environment for our agents to act within:
        self.env = fm.ForestEnv(grid_x,
                           grid_y,
                           density,
                           pa["strike_freq"],
                           pa["regen_period"],
                           model_nm=MODEL_NM,
                           torus=False,
                           props=pa)

        num_agents = int(grid_x * grid_y * density)

        for i in range(num_agents):
            self.env.add_agent(fm.Tree(name="tree" + str(i)))

        self.env.add_agent(fm.Tree(name="tree for tracking"))
Beispiel #5
0
    def __init__(self, methodName, prop_file="models/wolfsheep_for_test.props"):
        super().__init__(methodName=methodName)

        self.pa = props.read_props(MODEL_NM, prop_file)

        # Now we create a forest environment for our agents to act within:
        self.env = wsm.Meadow("Meadow",
                              self.pa["grid_width"],
                              self.pa["grid_height"],
                              model_nm=MODEL_NM,
                              preact=True,
                              postact=True,
                              props=self.pa)

        for i in range(self.pa["num_wolves"]):
            self.env.add_agent(wsm.Wolf("wolf" + str(i), "Eating sheep",
                                        self.pa["wolf_repro"],
                                        self.pa["wolf_lforce"],
                                        rand_age=True))

        for i in range(self.pa["num_sheep"]):
            self.env.add_agent(wsm.Sheep("sheep" + str(i), "Reproducing",
                                         self.pa["sheep_repro"],
                                         self.pa["sheep_lforce"],
                                         rand_age=True))
        self.env.add_agent(wsm.Sheep("sheep for tracking", "Reproducing",
                                     self.pa["sheep_repro"],
                                     self.pa["sheep_lforce"],
                                     rand_age=True))
Beispiel #6
0
    def __init__(self, methodName, prop_file="models/party_for_test.props"):
        super().__init__(methodName=methodName)

        self.pa = props.read_props(MODEL_NM, prop_file)

        # Now we create a forest environment for our agents to act within:
        if self.pa["user_type"] == props.WEB:
            self.pa["base_dir"] = os.environ['base_dir']

        # Now we create an environment for our agents to act within:
        self.env = pm.PartyEnv("A cocktail party",
                               self.pa["grid_width"],
                               self.pa["grid_height"],
                               model_nm=self.pa.model_nm,
                               props=self.pa)

        for i in range(self.pa["num_men"]):
            self.env.add_agent(
                pm.Man(name="Man" + str(i),
                       goal="A good party.",
                       tol=0.5,
                       max_detect=self.pa['max_detect']))

        for i in range(self.pa["num_women"]):
            self.env.add_agent(
                pm.Woman(name="Woman" + str(i),
                         goal="A good party.",
                         tol=0.5,
                         max_detect=self.pa['max_detect']))

        self.env.add_agent(
            pm.Woman(name="Woman for tracking",
                     goal="A good party.",
                     tol=0.5,
                     max_detect=self.pa['max_detect']))
Beispiel #7
0
    def __init__(self, methodName, prop_file="models/grid_for_test.props"):
        super().__init__(methodName=methodName)

        self.pa = props.read_props(MODEL_NM, prop_file)

        # Now we create a forest environment for our agents to act within:
        if self.pa["user_type"] == props.WEB:
            self.pa["base_dir"] = os.environ["base_dir"]

        # Now we create a minimal environment for our agents to act within:
        self.env = ge.GridEnv("Test grid env",
                         self.pa["grid_width"],
                         self.pa["grid_height"],
                         torus=False,
                         model_nm=MODEL_NM,
                         preact=True,
                         postact=True,
                         props=self.pa)

        for i in range(self.pa["num_agents"]):
            self.env.add_agent(gm.TestGridAgent(name="agent" + str(i),
                                           goal="taking up a grid space!"))

        self.env.add_agent(gm.TestGridAgent(name="agent for tracking",
                                       goal="taking up a grid space!"))
Beispiel #8
0
    def __init__(self, methodName, prop_file="models/party_for_test.props"):
        super().__init__(methodName=methodName)

        self.pa = props.read_props(MODEL_NM, prop_file)

        # Now we create a forest environment for our agents to act within:
        if self.pa["user_type"] == props.WEB:
            self.pa["base_dir"] = os.environ['base_dir']

        # Now we create an environment for our agents to act within:
        self.env = pm.PartyEnv("A cocktail party",
                          self.pa["grid_width"],
                          self.pa["grid_height"],
                          model_nm=self.pa.model_nm,
                          props=self.pa)

        for i in range(self.pa["num_men"]):
            self.env.add_agent(pm.Man(name="Man" + str(i),
                                 goal="A good party.",
                                 tol=0.5,
                                 max_detect=self.pa['max_detect']))

        for i in range(self.pa["num_women"]):
            self.env.add_agent(pm.Woman(name="Woman" + str(i),
                                   goal="A good party.",
                                   tol=0.5,
                                   max_detect=self.pa['max_detect']))

        self.env.add_agent(pm.Woman(name="Woman for tracking",
                                         goal="A good party.",
                                         tol=0.5,
                                         max_detect=self.pa['max_detect']))
Beispiel #9
0
    def __init__(self, methodName, prop_file="models/fmarket_for_test.props"):
        super().__init__(methodName=methodName)

        self.pa = props.read_props(MODEL_NM, prop_file)

        # Now we create a forest environment for our agents to act within:
        self.env = fm.FinMarket("Financial Market",
                       self.pa["grid_height"],
                       self.pa["grid_width"],
                       torus=False,
                       model_nm=MODEL_NM,
                       props=self.pa)

        for i in range(self.pa["num_followers"]):
            self.env.add_agent(fm.ChartFollower("follower" + str(i),
                                           "Following trend",
                                            self.pa["fmax_move"],
                                            self.pa["variability"]))
        for i in range(self.pa["num_vinvestors"]):
            self.env.add_agent(fm.ValueInvestor("value_inv" + str(i), "Buying value",
                                            self.pa["vmax_move"],
                                            self.pa["variability"]))
        self.env.add_agent(fm.ValueInvestor("value_inv for tracking", "Buying value",
                                            self.pa["vmax_move"],
                                            self.pa["variability"]))
Beispiel #10
0
def read_props(model_nm):
    """
    A prop file to read must be our first arg, if it exists.
    """
    if len(sys.argv) > 1:
        poss_props = sys.argv[1]
        if not poss_props.startswith('-'):  # not a property but a prop file
            return prop_args.read_props(model_nm, poss_props)

    return None
Beispiel #11
0
    def __init__(self, methodName, prop_file="models/coop_for_test.props"):
        super().__init__(methodName=methodName)

        self.pa = props.read_props(MODEL_NM, prop_file)

        # Now we create a forest environment for our agents to act within:
        self.env = cm.CoopEnv(model_nm=MODEL_NM, props=self.pa)

        for i in range(self.pa["num_agents"]):
            self.env.add_agent(cm.CoopAgent('agent' + str(i), 5, 0))

        self.env.add_agent(cm.CoopAgent('agent for tracking', 5, 0))
Beispiel #12
0
    def __init__(self, methodName, prop_file="models/basic_for_test.props"):

        super().__init__(methodName=methodName)

        pa = props.read_props(MODEL_NM, prop_file)
        # if result:
        #     pa.overwrite_props_from_dict(result.props)
        # else:
        #     print("Oh-oh, no props to read in!")
        #     exit(1)

        # Now we create a minimal environment for our agents to act within:
        self.env = bm.BasicEnv(model_nm=MODEL_NM, props=pa)

        # Now we loop creating multiple agents
        #  with numbered names based on the loop variable:
        for i in range(pa.props.get("num_agents").val):
            self.env.add_agent(
                bm.BasicAgent(name="agent" + str(i), goal="acting up!"))
        self.env.add_agent(
            bm.BasicAgent(name="agent for tracking", goal="acting up!"))
Beispiel #13
0
 def __init__(self, methodName, prop_file="models/basic_for_test.props"):
 
     super().__init__(methodName=methodName)
 
     pa = props.read_props(MODEL_NM, prop_file)
     # if result:
     #     pa.overwrite_props_from_dict(result.props)
     # else:
     #     print("Oh-oh, no props to read in!")
     #     exit(1)
 
     # Now we create a minimal environment for our agents to act within:
     self.env = bm.BasicEnv(model_nm=MODEL_NM, props=pa)
 
     # Now we loop creating multiple agents
     #  with numbered names based on the loop variable:
     for i in range(pa.props.get("num_agents").val):
         self.env.add_agent(bm.BasicAgent(name="agent" + str(i),
                                     goal="acting up!"))
     self.env.add_agent(bm.BasicAgent(name="agent for tracking",
                                      goal="acting up!"))
Beispiel #14
0
    def __init__(self, methodName, prop_file="models/fmarket_for_test.props"):
        super().__init__(methodName=methodName)

        self.pa = props.read_props(MODEL_NM, prop_file)

        # Now we create a forest environment for our agents to act within:
        self.env = fm.FinMarket("Financial Market",
                                self.pa["grid_height"],
                                self.pa["grid_width"],
                                torus=False,
                                model_nm=MODEL_NM,
                                props=self.pa)

        for i in range(self.pa["num_followers"]):
            self.env.add_agent(
                fm.ChartFollower("follower" + str(i), "Following trend",
                                 self.pa["fmax_move"], self.pa["variability"]))
        for i in range(self.pa["num_vinvestors"]):
            self.env.add_agent(
                fm.ValueInvestor("value_inv" + str(i), "Buying value",
                                 self.pa["vmax_move"], self.pa["variability"]))
        self.env.add_agent(
            fm.ValueInvestor("value_inv for tracking", "Buying value",
                             self.pa["vmax_move"], self.pa["variability"]))
Beispiel #15
0
    def __init__(self, methodName, prop_file="models/hiv_for_test.props"):
        super().__init__(methodName=methodName)

        self.pa = props.read_props(MODEL_NM, prop_file)

        # Now we create a forest environment for our agents to act within:
        self.env = hiv.People("People", self.pa["grid_width"],
                              self.pa["grid_height"], model_nm=MODEL_NM,
                              preact=True, postact=True, props=self.pa)

        self.max_ppl = self.pa["grid_width"] * self.pa["grid_height"]
        if self.pa["ini_ppl"] > self.max_ppl:
            self.ini_ppl = self.max_ppl
        else:
            self.ini_ppl = self.pa["ini_ppl"]
        self.ini_infected_ppl = round(INI_INFECTED_PCT * self.ini_ppl)
        self.ini_healthy_ppl = self.ini_ppl - self.ini_infected_ppl

        self.coup_tend = numpy.random.normal(self.pa["avg_coup_tend"],
                                             STD_COUP_TEND, self.ini_ppl)
        self.test_freq = numpy.random.normal(self.pa["avg_test_freq"],
                                             STD_TEST_FREQ, self.ini_ppl)
        self.commitment = numpy.random.normal(self.pa["avg_commitment"],
                                              STD_COMMITMENT, self.ini_ppl)
        self.condom_use = numpy.random.normal(self.pa["avg_condom_use"],
                                              STD_CONDOM_USE, self.ini_ppl)
        for i in range(self.ini_ppl):
            if self.coup_tend[i] < 0:
                self.coup_tend[i] = 0
            elif self.coup_tend[i] > 10:
                self.coup_tend[i] = 10
            if self.test_freq[i] < 0:
                self.test_freq[i] = 0
            elif self.test_freq[i] > 2:
                self.test_freq[i] = 2
            if self.commitment[i] < 1:
                self.commitment[i] = 1
            elif self.commitment[i] > 200:
                self.commitment[i] = 200
            if self.condom_use[i] < 0:
                self.condom_use[i] = 0
            elif self.condom_use[i] > 10:
                self.condom_use[i] = 10

        for i in range(self.ini_infected_ppl):
            rand_inf_len = random.randint(0, hiv.SYMPTOMS_SHOW-1)
            new_agent = hiv.Person(name="person" + str(i),
                                   infected=True,
                                   infection_length=rand_inf_len,
                                   initiative=i,
                                   coupling_tendency=self.coup_tend[i],
                                   test_frequency=self.test_freq[i],
                                   commitment=self.commitment[i],
                                   condom_use=self.condom_use[i])
            self.env.add_agent(new_agent)
        for i in range(self.ini_healthy_ppl):
            j = self.ini_infected_ppl+i
            new_agent = hiv.Person(name="person"+str(j),
                                   infected=False, infection_length=0,
                                   initiative=j,
                                   coupling_tendency=self.coup_tend[j],
                                   test_frequency=self.test_freq[j],
                                   commitment=self.commitment[j],
                                   condom_use=self.condom_use[j])
            self.env.add_agent(new_agent)