Exemple #1
0
def test_demand():
    from demand import Demand
    
    dm = Demand()
    # in-home activities and out-of-home activities
    #   madantory activities: work/business, school/college
    #   maintenance activities: escort passengers, shopping
    #   discretionary activities: eating out, visiting friends
    activity_data = [
        ['home',             1.0,  600, -0.010, 1.0,   720, (  0, 1440), 360],
        ['work',             0.0, 1600,  0.010, 1.0,   720, (240, 1440), 240],
        ['school',           0.0, 1600,  0.010, 1.0,   720, (240, 1440), 240],
        ['eating',           0.0,  420,  0.010, 1.0,  1170, (720, 1440),  10],
        ['shopping',         0.0,  500,  0.010, 1.0,  1110, (720, 1440),  10],
        ['visiting',         0.0,  500,  0.010, 1.0,  1110, (720, 1440),  10],
        ['escorting',         0.0,  500,  0.010, 1.0,  1110, (720, 1440),  10]
    ]
    create_objects(dm.add_activity, activity_data)
    print 'activities:'
    pprint(dm.activities.items())
    
    print "building activity utility..."
    dm.build_activity_util()
    logger.info('activity utility: home')
    logger.debug(pformat(dm.get_activity_util(dm.activities["home"])))
    logger.info('activity utility: work')
    logger.debug(pformat(dm.get_activity_util(dm.activities["work"])))
    logger.info('activity utility: shopping')
    logger.debug(pformat(dm.get_activity_util(dm.activities["shopping"])))
    
    # intra-household interactions
    #   entire day level: 
    #     staying at home, absent together
    #     non-madantory DAP together (day-off for major shopping)
    #   episode level:
    #     shared activity
    #     escorting (children to school)
    #     allocation of maintenance task (shopping)
    #     car allocation
    # types of joint travel
    #   fully-joint tour, joint outbound, joint inbound
    #   drop-off/get-off, pick-up/get-in
    program_data = [
        [0, []],
        [1, ['shopping']],
        [3, ['eating']],
        [2, ['visiting']],
        [4, ['shopping', 'visiting']],
        [5, ['shopping', 'eating']]
    ]
    create_objects(dm.add_program, program_data)
    print 'programs:'
    pprint(dm.programs.items())
    return dm
Exemple #2
0
def test_network():
    from network import Network

    net = Network()
    street_data = [[1, 3, 40, 3000, 40.0], [1, 5, 20, 2000, 15.0],
                   [2, 5, 20, 2000, 15.0], [2, 4, 60, 4000, 50.0],
                   [5, 6, 20, 3000, 20.0], [6, 3, 20, 2000, 20.0],
                   [6, 4, 20, 2000, 20.0]]
    create_objects(net.add_street, street_data)
    print 'nodes:'
    pprint(net.nodes)
    return net
Exemple #3
0
def test_demand():
    from demand import Demand

    dm = Demand()
    # in-home activities and out-of-home activities
    #   madantory activities: work/business, school/college
    #   maintenance activities: escort passengers, shopping
    #   discretionary activities: eating out, visiting friends
    activity_data = [['home', 1.0, 600, -0.010, 1.0, 720, (0, 1440), 360],
                     ['work', 0.0, 1600, 0.010, 1.0, 720, (240, 1440), 240],
                     ['school', 0.0, 1600, 0.010, 1.0, 720, (240, 1440), 240],
                     ['eating', 0.0, 420, 0.010, 1.0, 1170, (720, 1440), 10],
                     ['shopping', 0.0, 500, 0.010, 1.0, 1110, (720, 1440), 10],
                     ['visiting', 0.0, 500, 0.010, 1.0, 1110, (720, 1440), 10],
                     [
                         'escorting', 0.0, 500, 0.010, 1.0, 1110, (720, 1440),
                         10
                     ]]
    create_objects(dm.add_activity, activity_data)
    print 'activities:'
    pprint(dm.activities.items())

    print "building activity utility..."
    dm.build_activity_util()
    logger.info('activity utility: home')
    logger.debug(pformat(dm.get_activity_util(dm.activities["home"])))
    logger.info('activity utility: work')
    logger.debug(pformat(dm.get_activity_util(dm.activities["work"])))
    logger.info('activity utility: shopping')
    logger.debug(pformat(dm.get_activity_util(dm.activities["shopping"])))

    # intra-household interactions
    #   entire day level:
    #     staying at home, absent together
    #     non-madantory DAP together (day-off for major shopping)
    #   episode level:
    #     shared activity
    #     escorting (children to school)
    #     allocation of maintenance task (shopping)
    #     car allocation
    # types of joint travel
    #   fully-joint tour, joint outbound, joint inbound
    #   drop-off/get-off, pick-up/get-in
    program_data = [[0, []], [1, ['shopping']], [3, ['eating']],
                    [2, ['visiting']], [4, ['shopping', 'visiting']],
                    [5, ['shopping', 'eating']]]
    create_objects(dm.add_program, program_data)
    print 'programs:'
    pprint(dm.programs.items())
    return dm
Exemple #4
0
def test_network():
    from network import Network
    
    net = Network()
    street_data = [
        [1,      3,      40,     3000,      40.0],
        [1,      5,      20,     2000,      15.0],
        [2,      5,      20,     2000,      15.0],
        [2,      4,      60,     4000,      50.0],
        [5,      6,      20,     3000,      20.0],
        [6,      3,      20,     2000,      20.0],
        [6,      4,      20,     2000,      20.0]
    ]
    create_objects(net.add_street, street_data)
    print 'nodes:'
    pprint(net.nodes)
    return net
Exemple #5
0
def test_landuse(dm, net):
    from landuse import LandUse
    
    land = LandUse(dm, net)
    location_data = [
        # centriod, access, activities
        [100, 1,   {'work': 4000, 'home': 1000, 'school': 5000, 'shopping': 10000, 'eating': 10000}],
        [200, 2,   {'work': 4000, 'home': 1000, 'school': 5000, 'shopping': 10000, 'visiting': 10000}],
        [300, 3,   {'work': 4000, 'home': 2000, 'school': 5000, 'eating':   10000, 'visiting': 10000}],
        [400, 4,   {'work': 4000, 'home': 2000, 'school': 5000, 'shopping': 10000}],
        [500, 5,   {'work': 4000, 'home': 2000, 'school': 5000, 'eating':   10000}],
        [600, 6,   {'work': 4000, 'home': 2000, 'school': 5000, 'visiting': 10000}]
    ]
    create_objects(land.add_location, location_data)
    print "location capacities"
    pprint(land.locations.items())
    print "activity capacities"
    pprint(land.activities.items())
    return land
def run():
    fields = ('id', 'slug') + i18n_fieldnames('name')
    data = get_data(get_data_path('sex.csv'))
    create_objects(Sex, fields, data)
def run():
    fields = ('id', 'slug') + i18n_fieldnames('name')
    data = get_data(get_data_path('direction.csv'))
    create_objects(Direction, fields, data)
def run():
    fields = ('id', 'slug') + i18n_fieldnames('name')
    data = get_data(get_data_path('plumage.csv'))
    create_objects(Plumage, fields, data)
Exemple #9
0
    if (len(blobs) > 0):

        frame_time = cnt / FPS

        blobs_id_output = utils.blobs_coloring(blobs, frame_orig_res,
                                               frame_time, RATIO)

        if DISP_RESULT:
            cv2.imshow("Blobs IDs", blobs_id_output)
            # cv2.imwrite("Blobs_IDs.jpg", blobs_id_output)
            # cv2.imwrite("Frame_curr.jpg", frame_orig)

        # blobs_output = cv2.resize(blobs_output, None, fx=1/RATIO, fy=1/RATIO)
        # cv2.imshow("blobs", blobs_output)

        objects = utils.create_objects(frame_orig_res, blobs,
                                       objects)  # create objects from blobs

    blobs_old = blobs.copy()

    # save a list of blobs_old in memory
    if len(blobs_old) > 0:
        if len(blobs_old_list) < MEMORY:
            blobs_old_list.append(blobs_old)
        else:
            del blobs_old_list[0]
            blobs_old_list.append(blobs_old)

    t_it = time.time() - t_start  # time per frame
    label = 'TPF: ' + str(round(t_it, 3))
    cv2.putText(frame_orig, label, (20, 30), FONT, 1.0, (0, 255, 255), 2,
                cv2.LINE_AA)
Exemple #10
0
def test_landuse(dm, net):
    from landuse import LandUse

    land = LandUse(dm, net)
    location_data = [
        # centriod, access, activities
        [
            100, 1, {
                'work': 4000,
                'home': 1000,
                'school': 5000,
                'shopping': 10000,
                'eating': 10000
            }
        ],
        [
            200, 2, {
                'work': 4000,
                'home': 1000,
                'school': 5000,
                'shopping': 10000,
                'visiting': 10000
            }
        ],
        [
            300, 3, {
                'work': 4000,
                'home': 2000,
                'school': 5000,
                'eating': 10000,
                'visiting': 10000
            }
        ],
        [
            400, 4, {
                'work': 4000,
                'home': 2000,
                'school': 5000,
                'shopping': 10000
            }
        ],
        [
            500, 5, {
                'work': 4000,
                'home': 2000,
                'school': 5000,
                'eating': 10000
            }
        ],
        [
            600, 6, {
                'work': 4000,
                'home': 2000,
                'school': 5000,
                'visiting': 10000
            }
        ]
    ]
    create_objects(land.add_location, location_data)
    print "location capacities"
    pprint(land.locations.items())
    print "activity capacities"
    pprint(land.activities.items())
    return land
def run():
    fields = ('id', 'slug') + i18n_fieldnames('name')
    data = get_data(get_data_path('activity.csv'))
    create_objects(Activity, fields, data)
 def update_GUI(self, OL, fileArray):
     fileArray.filearray = u.write_filearray(fileArray)
     OL.objectList = u.create_objects(fileArray, OL.cooldownLength)
     self.make_screen(OL, fileArray)
def run():
    fields = ('id', 'slug') + i18n_fieldnames('name')
    data = get_data(get_data_path('protocol.csv'))
    create_objects(Protocol, fields, data)