Esempio n. 1
0
    def load_car_models(self):
        """
        Loads all car models from car_models.csv.

        Returns
        -------
        None.
        """
        cast = Cast("Car Model")
        self.car_models = dict()

        csv_helper = CSVHelper("data", "car_models.csv")
        for row in csv_helper.data:
            uid = cast.to_positive_int(row[0], "Uid")
            cast.uid = uid

            car_model_name = str(row[1]).strip(" ").strip('"')
            car_consumption = cast.to_positive_float(row[2], "Car consumption")
            drag_coeff = cast.to_positive_float(row[3], "Drag coeff")
            frontal_area = cast.to_positive_float(row[4], "Frontal area")
            mass = cast.to_positive_float(row[5], "Mass")
            battery_capacity \
                = cast.to_positive_float(row[6], "Battery capacity")
            charger_capacity \
                = cast.to_positive_float(row[7], "Charger capacity")

            cm = CarModel(uid, car_model_name, car_consumption, drag_coeff,
                          frontal_area, mass, battery_capacity,
                          charger_capacity)
            self.car_models[uid] = cm
Esempio n. 2
0
    def load_charger_models(self):
        """
        Reads information on individual charger models from charger_models.csv.
        """
        cast = Cast("Charger Model")
        self.charger_models = dict()
        csv_helper = CSVHelper("data", "charger_models.csv")
        for row in csv_helper.data:
            uid = cast.to_positive_int(row[0], "Uid")
            cast.uid = uid
            classification = row[1]
            ac_power = cast.to_positive_int(row[2], "AC Power")
            dc_power = cast.to_positive_int(row[2], "DC Power")

            cm = ChargerModel(uid, classification, ac_power, dc_power)
            self.charger_models[uid] = cm
            if cm.classification == "com":
                self.commercial_model_uids.append(cm.uid)
            else:
                self.residential_model_uids.append(cm.uid)
    def load_electricity_plans(self, parameters, clock):
        """
        Loads all electricity plans from electricity_plans.csv.

        Parameters
        ----------
        clock : Clock
            required for time_step parameter

        Returns
        -------
        None.
        """
        cast = Cast("Electricity Plan")
        self.electricity_plans = dict()
        csv_helper = CSVHelper("data", "electricity_plans.csv")
        for row in csv_helper.data:
            uid = cast.to_positive_int(row[0], "Uid")
            cast.uid = uid
            classification = row[1]
            if not classification in ["res", "com"]:
                sys.exit("Classification of electricity plan " + str(uid) \
                         + " is ill-defined!")
            is_commercial_plan = classification == "com"
            base = cast.to_float(row[2], "Base")
            feed_in_tariff = parameters.get_parameter("feed_in_tariff",
                                                      "float")
            # create tariff structure
            tariff_str = row[3]
            tariff = self.extract_tariffs_from_string(tariff_str)

            ep = ElectricityPlan(uid, is_commercial_plan, base, feed_in_tariff,
                                 tariff, clock.time_step)
            self.electricity_plans[uid] = ep
            if ep.is_commercial_plan:
                self.commercial_plan_uids.append(ep.uid)
            else:
                self.residential_plan_uids.append(ep.uid)
    def load_connections(self):
        """
        Reads information on suburb connection from connections.csv.
        """
        cast = Cast("Connection")
        self.traffic_network = nx.Graph()
        # add locations
        for location in self.locations.values():
            self.traffic_network.add_node(location.uid)
        # add edges
        csv_helper = CSVHelper("data", "connections.csv")
        for row in csv_helper.data:
            try:
                start_location_uid = int(row[0])
                start_location = self.locations[start_location_uid]
                end_location_uid = int(row[1])
                end_location = self.locations[end_location_uid]
            except ValueError:
                sys.exit("Connection not well defined for " + row[0] + " - " \
                         + row[1] + ".")
            flt_dist = self.direct_distance_between_locations(
                start_location, end_location)
            speed_lmt = cast.to_positive_float(row[2], "Speed limit")
            # TODO incorperate conversion of Dom's road levels to speed_lmt
            speed_lmt = 50  # in km/h

            self.traffic_network.add_edge(start_location.uid,
                                          end_location.uid,
                                          distance=flt_dist,
                                          speed_limit=speed_lmt,
                                          current_velocity=speed_lmt)
            self.traffic_network.add_edge(end_location.uid,
                                          start_location.uid,
                                          distance=flt_dist,
                                          speed_limit=speed_lmt,
                                          current_velocity=speed_lmt)
Esempio n. 5
0
def Create_new_cast(check):
    movie_id = input("Id filmu: ")
    person_id = input("Id osoby: ")
    if_actor = input("aktor wpisz 1, rezyser wpisz 0: ")
    x = Cast(None, movie_id, person_id,
             if_actor)  #tworzenie obiektu klasy movie
    c.execute(
        "INSERT INTO cast VALUES(:cast_id,:movie_id,:person_id,:if_actor)", {
            'cast_id': x.cast_id,
            'movie_id': x.movie_id,
            'person_id': x.person_id,
            'if_actor': x.if_actor
        })
    conn.commit()
    menu(check)
Esempio n. 6
0
    def get_parameter(self, parameter_name, parameter_type):
        """
        Returns a parameter from self.parameter as a requested type.

        Parameters
        ----------
        parameter_name : string
            Name of the parameter requested.
        parameter_type : string
            Type the parameter is requested in. Currently    
            supported: float, positive_float, int, positive_int, string,
            boolean.

        Returns
        -------
        <Type as requested in parameter_type>
            Well the parameter request casted as the type requested

        """
        if parameter_name not in self.parameters:
            sys.exit("No parameter called " + parameter_name \
                     + " is defined in parameters.csv")
        value_str = self.parameters[parameter_name]
        
        cast = Cast("Get Parameter")
        if parameter_type == "float":
            return cast.to_float(value_str, parameter_name)
        elif parameter_type == "positive_float":
            return cast.to_positive_float(value_str, parameter_name)
        elif parameter_type == "int":
            return cast.to_int(value_str, parameter_name)
        elif parameter_type == "positive_int":
            return cast.to_positive_int(value_str, parameter_name)
        elif parameter_type == "string":
            return value_str
        elif parameter_type == "boolean":
            return cast.to_boolean(value_str, parameter_name)
        else:
            sys.exit("Type '" + parameter_type + "' for parameter " \
                     + parameter_name + " is not recognised")
Esempio n. 7
0
def generateMystery(num_players=None, num_male=None, num_female=None):
    # Create graph
    c = Cast()

    # Add characters
    if num_players is not None:
        chars = [Gender.getRandomGender() for x in range(num_players)]
    elif num_male is not None and num_female is not None:
        chars = [Gender.male for x in range(num_male)
                 ] + [Gender.female
                      for x in range(num_female)] + [Gender.getRandomGender()]
    else:
        chars = [
            Gender.getRandomGender() for x in range(random.randint(5, 15))
        ]

    [c.addCharacter(gender=gender) for gender in chars]
    totalCharacters = len(chars)

    # GENERATE FAMILIAL RELATIONSHIP NETWORK
    numFamilies = [int(totalCharacters / 6), int(totalCharacters / 3)]
    numFamilyMembers = [
        max(2, int(totalCharacters / 6)),
        int(totalCharacters / 3)
    ]
    if (numFamilies[1] * numFamilyMembers[1] > totalCharacters):
        print(
            "WARNING: May have too few characters for max possible families and members"
        )
    print("Family parameters: number {0}, size {1}".format(
        numFamilies, numFamilyMembers))

    # GENERATE ROMANTIC RELATIONSHIP NETWORK
    numRomances = int(0.5 * totalCharacters)

    # GENERATE PROFESSIONAL RELATIONSHIP NETWORK
    numEmployers = [int(totalCharacters / 6), int(totalCharacters / 3)]
    numEmployees = [max(2, int(totalCharacters / 6)), int(totalCharacters / 3)]
    if (numEmployers[1] * numEmployees[1] > totalCharacters):
        print(
            "WARNING: May have too few characters for max possible professional relationships"
        )
    print("Professional parameters: number {0}, size {1}".format(
        numEmployers, numEmployees))

    # GENERATE SOCIAL RELATIONSHIP NETWORK
    numSocialGroups = [int(totalCharacters / 6), int(totalCharacters / 3)]
    numSocialites = [
        max(2, int(totalCharacters / 6)),
        int(totalCharacters / 3)
    ]
    if (numSocialGroups[1] * numSocialites[1] > totalCharacters):
        print(
            "WARNING: May have too few characters for max possible social relationships"
        )
    print("Social parameters: number {0}, size {1}".format(
        numSocialGroups, numSocialites))

    # Create typed relationships between characters
    c.generateRelationshipGroupings(RelationshipType.familial, 1, numFamilies,
                                    numFamilyMembers,
                                    ConnectionStrategy.totallyConnect)
    c.generateRelationshipGroupings(RelationshipType.romantic, -1,
                                    (numRomances, numRomances), (2, 2),
                                    ConnectionStrategy.totallyConnect)
    c.generateRelationshipGroupings(RelationshipType.professional, 3,
                                    numEmployers, numEmployees,
                                    ConnectionStrategy.randomlyConnect)
    c.generateRelationshipGroupings(RelationshipType.social, 3,
                                    numSocialGroups, numSocialites,
                                    ConnectionStrategy.randomlyConnect)

    # Create entities and make characters members of them
    maxFamilyMembers = (max(2, int(totalCharacters / 6)),
                        int(totalCharacters / 3))
    # If familial relations can belong to different families (married off) then random.randint(min(*maxFamilyMembers), maxFamilyMembers[1]) could be used
    # If familial relations must all belong t same family, then -1 should be used, for infinite depth
    c.createTypedEntitiesForRelationships(RelationshipType.familial,
                                          -1,
                                          strategy="bfs")
    maxCompanyMembers = (max(2, int(totalCharacters / 6)),
                         int(totalCharacters / 3))
    c.createTypedEntitiesForRelationships(
        RelationshipType.professional,
        random.randint(*sorted(maxCompanyMembers)),
        strategy="bfs")
    maxSocialGroupMembers = (max(2, int(totalCharacters / 6)),
                             int(totalCharacters / 3))
    c.createTypedEntitiesForRelationships(
        RelationshipType.social,
        random.randint(*sorted(maxSocialGroupMembers)),
        strategy="bfs")

    # Fill in remaining details
    c.createIsolatedTypedEntities(RelationshipType.familial)

    title = c.generateTitle()
    location = c.generateLocation()
    scene = c.generateScene(location)

    return (c, title, location, scene)
Esempio n. 8
0
from cast import Cast
from utils import AllSubSetsOf, ClassSet, AttrDict
from node import (Node, IterableNode, MappingNode, IdentityNode, NodeInfo)

__all__ = [
    'serialize', 'deserialize', 'Cast', 'AllSubSetsOf', 'ClassSet', 'AttrDict',
    'Node', 'IterableNode', 'MappingNode', 'IdentityNode', 'NodeInfo'
]

serialize = Cast(
    {
        AllSubSetsOf(dict): MappingNode,
        AllSubSetsOf(list): IterableNode,
        AllSubSetsOf(int): IdentityNode,
        AllSubSetsOf(float): IdentityNode,
        AllSubSetsOf(bool): IdentityNode,
        AllSubSetsOf(basestring): IdentityNode,
        AllSubSetsOf(types.NoneType): IdentityNode,
    }, {
        AllSubSetsOf(dict): MappingNode,
        AllSubSetsOf(list): IterableNode,
        AllSubSetsOf(object): IdentityNode,
    })

deserialize = Cast({
    AllSubSetsOf(dict): MappingNode,
    AllSubSetsOf(list): IterableNode,
    AllSubSetsOf(int): IdentityNode,
    AllSubSetsOf(float): IdentityNode,
    AllSubSetsOf(bool): IdentityNode,
    AllSubSetsOf(basestring): IdentityNode,
    AllSubSetsOf(types.NoneType): IdentityNode,
    def load_locations(self):
        """
        Reads information on individual suburbs from locations.csv.
        """
        cast = Cast("Location")
        self.locations = {}
        csv_helper = CSVHelper("data", "locations.csv")
        for row in csv_helper.data:
            uid = cast.to_positive_int(row[0], "Uid")
            cast.uid = uid
            name = row[2]
            longitude = cast.to_float(row[3], "Longitude")
            latitude = cast.to_float(row[4], "Latitude")
            population = cast.to_positive_int(row[5], "Population")
            commute_mean = cast.to_positive_float(row[6], "Commute mean")
            commute_std_dev = cast.to_positive_float(row[7], "Commute std dev")
            occupant_distribution \
                = cast.to_positive_int_list(row[8], "Occupant distribution")
            occupant_values \
                = cast.to_positive_int_list(row[9], "Occupant values")
            pv_capacity_mean \
                = cast.to_positive_float(row[10], "PV capacity mean")
            pv_capacity_std_dev \
                = cast.to_positive_float(row[11], "PV capacity std dev")
            battery_capacity_mean \
                = cast.to_positive_float(row[12], "Battery capacity mean")
            battery_capacity_std_dev\
                = cast.to_positive_float(row[13], "Battery capacity std dev")

            loc = Location(uid, name, longitude, latitude, population,
                           commute_mean, commute_std_dev,
                           occupant_distribution, occupant_values,
                           pv_capacity_mean, pv_capacity_std_dev,
                           battery_capacity_mean, battery_capacity_std_dev)
            # add public charger
            self.cpm.add_company(loc)

            self.locations[loc.uid] = loc
Esempio n. 10
0
    def __init__(self, clock):
        self.clock = clock

        # load hourly consumption data
        cast = Cast("Hourly Consumption")
        self.hourly_consumption = dict()
        csv_helper = CSVHelper("data", "hourly_consumption.csv")
        for row in csv_helper.data:
            hour = cast.to_positive_int(row[0], "Hour")
            season_it = self.clock.season * 3
            hourly_cons = []
            hourly_cons.append(
                cast.to_positive_float(row[season_it + 1], "10%"))
            hourly_cons.append(
                cast.to_positive_float(row[season_it + 2], "50%"))
            hourly_cons.append(
                cast.to_positive_float(row[season_it + 3], "90%"))
            self.hourly_consumption[hour] = hourly_cons

        # load deviation data for consumption
        cast = Cast("Consumption Deviation")
        self.consumption_deviation = dict()
        csv_helper = CSVHelper("data", "consumption_deviation.csv")
        for row in csv_helper.data:
            location_uid = cast.to_positive_int(row[0], "LocationUid")
            season_it = self.clock.season * 5
            cons_deviation = dict()
            cons_deviation[1] = cast.to_positive_float(row[season_it + 1],
                                                       "1PHH")
            cons_deviation[2] = cast.to_positive_float(row[season_it + 2],
                                                       "2PHH")
            cons_deviation[3] = cast.to_positive_float(row[season_it + 3],
                                                       "3PHH")
            cons_deviation[4] = cast.to_positive_float(row[season_it + 4],
                                                       "4PHH")
            cons_deviation[5] = cast.to_positive_float(row[season_it + 5],
                                                       "5PHH")
            self.consumption_deviation[location_uid] = cons_deviation

        #
        cast = Cast("Consumption Forecast Parameters")
        self.forecast_parameters = dict()
        hourly_forecast_parameters = dict()
        csv_helper = CSVHelper("data", "hourly_consumption_fit.csv")
        season_it = self.clock.season * 2 + 1
        for row in csv_helper.data:
            hour = cast.to_positive_int(row[0], "Hour")
            mu = cast.to_positive_float(row[season_it], "mu")
            sig = cast.to_positive_float(row[season_it + 1], "sig")
            hourly_forecast_parameters[hour] = [mu, sig]

        for time_step in range(0, 24 * 60, self.clock.time_step):
            hour_begin = time_step // 60
            hour_end = (time_step + self.clock.time_step) // 60
            hour_end_remainder = (time_step + self.clock.time_step) % 60

            same_hour = hour_begin == hour_end \
                        or (hour_begin == hour_end - 1 \
                            and hour_end_remainder == 0)

            if same_hour:
                mu_hour, sig_hour = hourly_forecast_parameters[hour_begin]
                mu_time_step = mu_hour / (self.clock.time_step / 60)
                sig_sqr_time_step = sig_hour**2 / (self.clock.time_step / 60)

                self.forecast_parameters[time_step] = [
                    mu_time_step, sig_sqr_time_step
                ]
            else:
                raise RuntimeError("Demand forecast for 60 % time_step != 0" +
                                   " not implemented")

        cur_mu, cur_sig_sqr = 0, 0
        for time in range(0, self.clock.forecast_horizon,
                          self.clock.time_step):
            cur_mu += self.forecast_parameters[time][0]
            cur_sig_sqr += self.forecast_parameters[time][0]**2

        self.forecast_mu, self.forecast_sig = cur_mu, math.sqrt(cur_sig_sqr)
    def __init__(self, parameters, clock, electricity_plan_manager,
                 car_model_manager):
        self.parameters = parameters
        self.clock = clock
        self.epm = electricity_plan_manager

        cast = Cast("Solar Irradation")
        self.irradiances = []
        file_name = "solar_irradiance_" \
                    + self.clock.season_names[self.clock.season] + ".csv"
        csv_helper = CSVHelper("data", file_name)
        it = 0
        resolution_irradiance = 0
        for row in csv_helper.data:
            if it == 0:
                resolution_irradiance \
                    = - cast.to_positive_int(row[0], "Elapsed time")
            if it == 1:
                resolution_irradiance += \
                    + cast.to_positive_int(row[0], "Elapsed time")
            tmp_irradiances = []
            for col in row[1:]:
                value = cast.to_positive_float(col, "Solar irradiance")
                tmp_irradiances.append(value)
            self.irradiances.append(tmp_irradiances)
            it += 1

        cast = Cast("Temperatures")
        self.temperatures = []
        file_name = "temperatures_" \
                    + self.clock.season_names[self.clock.season] + ".csv"
        csv_helper = CSVHelper("data", file_name)
        it = 0
        resolution_temperatures = 0
        for row in csv_helper.data:
            if it == 0:
                resolution_temperatures \
                    = - cast.to_positive_int(row[0], "Elapsed time")
            if it == 1:
                resolution_temperatures += \
                    + cast.to_positive_int(row[0], "Elpased time")
            tmp_temperatures = []
            for col in row[1:]:
                value = cast.to_positive_float(col, "Temperatures")
                tmp_temperatures.append(value)
            self.temperatures.append(tmp_temperatures)
            it += 1

        self.cur_irradiances = self.irradiances[0]
        self.cur_temperatures = self.temperatures[0]

        self.forecast_horizon = parameters.get_parameter(
            "forecast_horizon", "int")

        cast = Cast("Normed rooftop PV output fit parameters")
        self.fit_data = []
        file_name = "normed_rooftop_pv_output_fit_parameters.csv"
        csv_helper = CSVHelper("data", file_name)
        it = 0
        resolution_fit = 0
        for row in csv_helper.data:
            if it == 0:
                resolution_fit = -cast.to_positive_int(row[0], "Elapsed time")
            if it == 1:
                resolution_fit += cast.to_positive_int(row[0], "Elpased time")
            self.fit_data.append(GenerationForecast(self.clock, row))
            it += 1

        self.resolution_irradiance = resolution_irradiance
        self.resolution_temperatures = resolution_temperatures
        self.resolution_fit = resolution_fit

        self.forecast_mu, self.forecast_sig = 0.0, 0.0
        self.forecast_mu_po, self.forecast_sig_po_sqr = 0.0, 0.0
        self.max_output_co_sum, self.max_output_co_count = 0.0, 0
        for it, fit_data_point in enumerate(self.fit_data):
            if it * self.resolution_fit >= self.clock.forecast_horizon:
                break
            if fit_data_point.peak_dominates_constant():
                self.forecast_mu_po += fit_data_point.mu_po
                self.forecast_sig_po_sqr += fit_data_point.sig_po**2
            else:
                self.max_output_co_sum += fit_data_point.max_output
                self.max_output_co_count += 1

        avg_max_output_co = 0
        if self.max_output_co_count != 0:
            avg_max_output_co \
                = self.max_output_co_sum / self.max_output_co_count
        # we use Irwin-Hall to derive normal distribution from co parts
        self.forecast_mu = self.forecast_mu_po + avg_max_output_co / 2
        forecast_sig_co_sqr = (avg_max_output_co / 12)**2
        self.forecast_sig \
            = math.sqrt(self.forecast_sig_po_sqr + forecast_sig_co_sqr)
Esempio n. 12
0
import tg_commands as commands

from cast import Cast
from plugins.animego import Site

from telegram.ext import CommandHandler, CallbackQueryHandler, ConversationHandler, MessageHandler, Filters

"""
All handler's functions must have '_handler' at the end for bot.py class add this handlers
"""
cast = Cast()
site = Site()  # скрапер видосов
cast_tg = commands.ControlCast(cast)


def help_handler(cmd='help'):
	return CommandHandler(cmd, commands.send_help_msg)


def get_animes_handler(cmd='get_animes'):
	return commands.GetAnimes(cast, site).get_conversation_handler(cmd)


def update_episode_handler(cmd='update_ep'):
	return commands.UpdateEpisode().get_conversation_handler(cmd)


def forward_handler(cmd=None):
	if cmd is None:
		cmd = ['forw', 'forward']
	return CommandHandler(cmd, cast_tg.forward)
Esempio n. 13
0
remove_char_from_Date = ["-", "T", ":", "Z"]

season_name = {0: "spring", 1: "summer", 2: "autumn", 3: "winter"}

store_raw_data = False
"""
SECTION 1: Read data from source file 

Data from source file "solcast.csv" is read, columns selected in
slcted_col_names extracted and store in data list.
"""

print("Read data!")

cast = Cast("Solar Irradiance Data")
data = []
read_header = False
with open("solcast.csv", newline='') as csvfile:
    reader = csv.reader(csvfile, delimiter=',', quotechar='|')
    for row in reader:
        if read_header == False:
            for header_col, header_name in enumerate(row):
                for slcted_col, slcted_col_name in enumerate(slcted_col_names):
                    if slcted_col_name == header_name:
                        slcted_cols[slcted_col] = header_col
            all_cols_identified = True
            for slcted_col_it, slcted_col in enumerate(slcted_cols):
                if slcted_col == -1:
                    print("Column with name " \
                          + slcted_col_names[slcted_col_it] \
Esempio n. 14
0
def importCast(path):
    cast = Cast()
    cast.load(path)

    for root in cast.Roots():
        importRootNode(root, path)
Esempio n. 15
0
def generateMystery(num_players = None, num_male = None, num_female = None):
    # Create graph
    c = Cast()

    # Add characters
    if num_players is not None:
        chars = [Gender.getRandomGender() for x in range(num_players)]
    elif num_male is not None and num_female is not None:
        chars = [Gender.male for x in range(num_male)] + [Gender.female for x in range(num_female)] + [Gender.getRandomGender()]
    else:
        chars = [Gender.getRandomGender() for x in range(random.randint(5, 15))]

    [c.addCharacter(gender=gender) for gender in chars]
    totalCharacters = len(chars)

    # GENERATE FAMILIAL RELATIONSHIP NETWORK
    numFamilies = [int(totalCharacters/6), int(totalCharacters/3)]
    numFamilyMembers = [max(2, int(totalCharacters/6)), int(totalCharacters/3)]
    if (numFamilies[1] * numFamilyMembers[1] > totalCharacters):
        print("WARNING: May have too few characters for max possible families and members")
    print("Family parameters: number {0}, size {1}".format(numFamilies, numFamilyMembers))

    # GENERATE ROMANTIC RELATIONSHIP NETWORK
    numRomances = int(0.5 * totalCharacters)

    # GENERATE PROFESSIONAL RELATIONSHIP NETWORK
    numEmployers = [int(totalCharacters/6), int(totalCharacters/3)]
    numEmployees = [max(2, int(totalCharacters/6)), int(totalCharacters/3)]
    if (numEmployers[1] * numEmployees[1] > totalCharacters):
        print("WARNING: May have too few characters for max possible professional relationships")
    print("Professional parameters: number {0}, size {1}".format(numEmployers, numEmployees))

    # GENERATE SOCIAL RELATIONSHIP NETWORK
    numSocialGroups = [int(totalCharacters/6), int(totalCharacters/3)]
    numSocialites = [max(2, int(totalCharacters/6)), int(totalCharacters/3)]
    if (numSocialGroups[1] * numSocialites[1] > totalCharacters):
        print("WARNING: May have too few characters for max possible social relationships")
    print("Social parameters: number {0}, size {1}".format(numSocialGroups, numSocialites))

    # Create typed relationships between characters
    c.generateRelationshipGroupings(RelationshipType.familial, 1, numFamilies, numFamilyMembers, ConnectionStrategy.totallyConnect)
    c.generateRelationshipGroupings(RelationshipType.romantic, -1, (numRomances, numRomances), (2,2), ConnectionStrategy.totallyConnect)
    c.generateRelationshipGroupings(RelationshipType.professional, 3, numEmployers, numEmployees, ConnectionStrategy.randomlyConnect)
    c.generateRelationshipGroupings(RelationshipType.social, 3, numSocialGroups, numSocialites, ConnectionStrategy.randomlyConnect)

    # Create entities and make characters members of them
    maxFamilyMembers = (max(2, int(totalCharacters/6)), int(totalCharacters/3))
    # If familial relations can belong to different families (married off) then random.randint(min(*maxFamilyMembers), maxFamilyMembers[1]) could be used
    # If familial relations must all belong t same family, then -1 should be used, for infinite depth
    c.createTypedEntitiesForRelationships(RelationshipType.familial, -1, strategy="bfs")
    maxCompanyMembers = (max(2, int(totalCharacters/6)), int(totalCharacters/3))
    c.createTypedEntitiesForRelationships(RelationshipType.professional, random.randint(*sorted(maxCompanyMembers)), strategy="bfs")
    maxSocialGroupMembers = (max(2, int(totalCharacters/6)), int(totalCharacters/3))
    c.createTypedEntitiesForRelationships(RelationshipType.social, random.randint(*sorted(maxSocialGroupMembers)), strategy="bfs")

    # Fill in remaining details
    c.createIsolatedTypedEntities(RelationshipType.familial)

    title = c.generateTitle()
    location = c.generateLocation()
    scene = c.generateScene(location)

    return (c, title, location, scene)
Esempio n. 16
0
 def __init__(self, clock, row):
     time_factor = 60 // clock.time_step
     time_factor_sqrt = numpy.sqrt(time_factor)
     if 60 % clock.time_step != 0:
         raise RuntimeError("time_step do not add up to full hour!")
     cast = Cast("Normed rooftop PV output fit parameters")
     self.max_output \
         = cast.to_positive_int(row[1], "Max output") / time_factor
     # x_border seperates the part fitted by a constant and the part
     # fitted by a gaussian
     self.x_border = cast.to_positive_int(row[2], "x_border") / time_factor
     self.A = cast.to_positive_float(row[3], "A")
     self.mu = cast.to_positive_int(row[4], "mu") / time_factor
     self.sig = cast.to_positive_float(row[5], "sig") / time_factor_sqrt
     self.y0 = cast.to_positive_float(row[6], "y0")
     self.A_po = cast.to_positive_float(row[7], "A_po")
     self.mu_po = cast.to_positive_int(row[8], "mu_po") / time_factor
     self.sig_po\
         = cast.to_positive_float(row[9], "sig_po") / time_factor_sqrt
     self.y_co = cast.to_positive_float(row[10], "y_co")
     self.surf_po = cast.to_positive_float(row[11], "surf_po")
     self.surf_co = cast.to_positive_float(row[12], "surf_co")