{"action":"created","comment":{"url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/comments/50369836","id":50369836,"diff_hunk":"@@ -0,0 +1,619 @@\n+import emission.simulation.markov_model_counter as emmc\n+import emission.net.ext_service.otp.otp as otp\n+import emission.core.our_geocoder as geo\n+import emission.core.wrapper.trip_old as to\n+import emission.net.ext_service.gmaps.googlemaps as gmaps\n+import emission.net.ext_service.gmaps.common as gmcommon\n+import emission.core.get_database as edb\n+\n+import datetime\n+import random\n+import math\n+import urllib2\n+import json\n+import heapq\n+import time\n+import googlemaps\n+import requests\n+\n+CENTER_OF_CAMPUS = to.Coordinate(37.871790, -122.260005)\n+RANDOM_RADIUS = .3  # 300 meters around center of campus; for randomization\n+N_TOP_TRIPS = 3 # Number of top trips we return for the user to look at\n+\n+\n+class UserBase:\n+\n+    \"\"\" \n+    Stores all the users and stores the population of areas  \n+    Also keeps state on other useful things that we need to know, like caches\n+    \"\"\"\n+\n+    def __init__(self):\n+        self.users = {}\n+        self.crowd_areas = {}\n+        self.last_info = {}  ## so we only call google maps if we change things\n+        self.old_trips = None\n+        self.geocode_cache = {} # fewer calls to google maps\n+\n+    def add_user(self, user):\n+        self.users[user.name] = user\n+\n+    def get_user(self, user_name):\n+        return self.users[user_name]\n+\n+    def add_crowd(self, area):\n+        self.crowd_areas[area.name] = area\n+\n+    def get_crowd_info(self, area_name):\n+        return self.crowd_areas[area_name]\n+\n+    def geocode_with_cache(self, place):\n+        coder = geo.Geocoder()\n+        if place in self.geocode_cache:\n+            return self.geocode_cache[place]\n+        else:\n+            coded = coder.geocode(place)\n+            self.geocode_cache[place] = coded\n+            return coded\n+\n+\n+the_base = UserBase()\n+\n+\n+class CampusTrip:\n+\n+    def __init__(self, score_list, time_duration, points, source):\n+        self.time = score_list[0] \n+        self.sweat = score_list[1]\n+        self.beauty = score_list[2]\n+        self.social = score_list[3]\n+        self.tot_score = sum(score_list)\n+        self.time_duration = time_duration / float(60)\n+        self.points = points\n+        self.source = source\n+\n+    def make_points(self):\n+        to_return = \"\"\n+        for p in self.points:\n+            to_return += str(p[0])\n+            to_return += \",\"\n+            to_return += str(p[1])\n+            to_return += \",\"\n+        return to_return\n+\n+\n+    def make_for_browser(self):\n+        return '%s;%s;%s;%s;%s;%s' % (self.beauty, self.time, self.social, self.sweat, self.time_duration, self.make_points())\n+\n+    def make_jsn(self):\n+        return json.dumps({\"time\" : self.time, \"beauty\" : self.beauty, \"social\" : self.social, \"sweat\" : self.sweat, \"duration\" : self.time_duration, \"points\" : self.points})\n+        \n+    def make_json(self):\n+        return json.dumps(self.make_for_browser())\n+\n+    def __repr__(self):\n+        return \"total score : %f || source : %s || beauty : %f || sweat : %f || time : %f || social : %f\" % (self.tot_score, self.source, self.beauty, self.sweat, self.time, self.social)\n+\n+    def __eq__(self, other):\n+        return self.make_points() == other.make_points()\n+\n+\n+class UserModel:\n+\n+    \"\"\" \n+    User Model class  \n+    Can do lots of cool things\n+    \"\"\" \n+\n+    def __init__(self, name, has_bike=False):\n+        self.name = name\n+        self.utilities = emmc.Counter()\n+        self.has_bike = has_bike\n+        self.user_base = the_base\n+\n+        self.user_base.add_user(self)","path":"emission/user_model_josh/utility_model.py","position":116,"original_position":114,"commit_id":"985fcf4617cf67cb6863d42ae70a5d0848e94e65","original_commit_id":"4c1590edffd134f3f7cf49cdb3c0c91f751a3c39","user":{"login":"joshzarrabi","id":3689026,"avatar_url":"https://avatars.githubusercontent.com/u/3689026?v=3","gravatar_id":"","url":"https://api.github.com/users/joshzarrabi","html_url":"https://github.com/joshzarrabi","followers_url":"https://api.github.com/users/joshzarrabi/followers","following_url":"https://api.github.com/users/joshzarrabi/following{/other_user}","gists_url":"https://api.github.com/users/joshzarrabi/gists{/gist_id}","starred_url":"https://api.github.com/users/joshzarrabi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshzarrabi/subscriptions","organizations_url":"https://api.github.com/users/joshzarrabi/orgs","repos_url":"https://api.github.com/users/joshzarrabi/repos","events_url":"https://api.github.com/users/joshzarrabi/events{/privacy}","received_events_url":"https://api.github.com/users/joshzarrabi/received_events","type":"User","site_admin":false},"body":"Hi, sorry for the late reply.\r\nThe program isn't sophisticated enough to take advantage of user names.\r\nWhat happens is we see what time the trip ends, and add a point to each section for that time,","created_at":"2016-01-21T08:02:08Z","updated_at":"2016-01-21T08:02:08Z","html_url":"https://github.com/e-mission/e-mission-server/pull/226#discussion_r50369836","pull_request_url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/226","_links":{"self":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/comments/50369836"},"html":{"href":"https://github.com/e-mission/e-mission-server/pull/226#discussion_r50369836"},"pull_request":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/226"}}},"pull_request":{"url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/226","id":55391845,"html_url":"https://github.com/e-mission/e-mission-server/pull/226","diff_url":"https://github.com/e-mission/e-mission-server/pull/226.diff","patch_url":"https://github.com/e-mission/e-mission-server/pull/226.patch","issue_url":"https://api.github.com/repos/e-mission/e-mission-server/issues/226","number":226,"state":"open","locked":false,"title":"Josh utility model","user":{"login":"joshzarrabi","id":3689026,"avatar_url":"https://avatars.githubusercontent.com/u/3689026?v=3","gravatar_id":"","url":"https://api.github.com/users/joshzarrabi","html_url":"https://github.com/joshzarrabi","followers_url":"https://api.github.com/users/joshzarrabi/followers","following_url":"https://api.github.com/users/joshzarrabi/following{/other_user}","gists_url":"https://api.github.com/users/joshzarrabi/gists{/gist_id}","starred_url":"https://api.github.com/users/joshzarrabi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshzarrabi/subscriptions","organizations_url":"https://api.github.com/users/joshzarrabi/orgs","repos_url":"https://api.github.com/users/joshzarrabi/repos","events_url":"https://api.github.com/users/joshzarrabi/events{/privacy}","received_events_url":"https://api.github.com/users/joshzarrabi/received_events","type":"User","site_admin":false},"body":"The utility model for emission I made for class\r\nTakes in a utility model from the api and then finds an optimal route based on csv files and other info. \r\n","created_at":"2016-01-07T21:20:45Z","updated_at":"2016-01-21T08:02:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9f8f0e94083e2a83acfdd910c7297098669e3e30","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/226/commits","review_comments_url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/226/comments","review_comment_url":"https://api.github.com/repos/e-mission/e-mission-server/pulls/comments{/number}","comments_url":"https://api.github.com/repos/e-mission/e-mission-server/issues/226/comments","statuses_url":"https://api.github.com/repos/e-mission/e-mission-server/statuses/985fcf4617cf67cb6863d42ae70a5d0848e94e65","head":{"label":"joshzarrabi:josh_utility_model","ref":"josh_utility_model","sha":"985fcf4617cf67cb6863d42ae70a5d0848e94e65","user":{"login":"joshzarrabi","id":3689026,"avatar_url":"https://avatars.githubusercontent.com/u/3689026?v=3","gravatar_id":"","url":"https://api.github.com/users/joshzarrabi","html_url":"https://github.com/joshzarrabi","followers_url":"https://api.github.com/users/joshzarrabi/followers","following_url":"https://api.github.com/users/joshzarrabi/following{/other_user}","gists_url":"https://api.github.com/users/joshzarrabi/gists{/gist_id}","starred_url":"https://api.github.com/users/joshzarrabi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshzarrabi/subscriptions","organizations_url":"https://api.github.com/users/joshzarrabi/orgs","repos_url":"https://api.github.com/users/joshzarrabi/repos","events_url":"https://api.github.com/users/joshzarrabi/events{/privacy}","received_events_url":"https://api.github.com/users/joshzarrabi/received_events","type":"User","site_admin":false},"repo":{"id":41275946,"name":"e-mission-server","full_name":"joshzarrabi/e-mission-server","owner":{"login":"joshzarrabi","id":3689026,"avatar_url":"https://avatars.githubusercontent.com/u/3689026?v=3","gravatar_id":"","url":"https://api.github.com/users/joshzarrabi","html_url":"https://github.com/joshzarrabi","followers_url":"https://api.github.com/users/joshzarrabi/followers","following_url":"https://api.github.com/users/joshzarrabi/following{/other_user}","gists_url":"https://api.github.com/users/joshzarrabi/gists{/gist_id}","starred_url":"https://api.github.com/users/joshzarrabi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshzarrabi/subscriptions","organizations_url":"https://api.github.com/users/joshzarrabi/orgs","repos_url":"https://api.github.com/users/joshzarrabi/repos","events_url":"https://api.github.com/users/joshzarrabi/events{/privacy}","received_events_url":"https://api.github.com/users/joshzarrabi/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joshzarrabi/e-mission-server","description":"The backend (server) code for the e-mission server","fork":true,"url":"https://api.github.com/repos/joshzarrabi/e-mission-server","forks_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/forks","keys_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/teams","hooks_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/hooks","issue_events_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/issues/events{/number}","events_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/events","assignees_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/assignees{/user}","branches_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/branches{/branch}","tags_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/tags","blobs_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/statuses/{sha}","languages_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/languages","stargazers_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/stargazers","contributors_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/contributors","subscribers_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/subscribers","subscription_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/subscription","commits_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/contents/{+path}","compare_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/merges","archive_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/downloads","issues_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/issues{/number}","pulls_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/pulls{/number}","milestones_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/milestones{/number}","notifications_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/labels{/name}","releases_url":"https://api.github.com/repos/joshzarrabi/e-mission-server/releases{/id}","created_at":"2015-08-24T01:53:03Z","updated_at":"2015-08-24T01:53:04Z","pushed_at":"2016-01-20T06:02:06Z","git_url":"git://github.com/joshzarrabi/e-mission-server.git","ssh_url":"git@github.com:joshzarrabi/e-mission-server.git","clone_url":"https://github.com/joshzarrabi/e-mission-server.git","svn_url":"https://github.com/joshzarrabi/e-mission-server","homepage":"https://e-mission.eecs.berkeley.edu","size":64714,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"e-mission:master","ref":"master","sha":"03a84d5f8f425201b670f51a502882d88acd78b4","user":{"login":"e-mission","id":10713694,"avatar_url":"https://avatars.githubusercontent.com/u/10713694?v=3","gravatar_id":"","url":"https://api.github.com/users/e-mission","html_url":"https://github.com/e-mission","followers_url":"https://api.github.com/users/e-mission/followers","following_url":"https://api.github.com/users/e-mission/following{/other_user}","gists_url":"https://api.github.com/users/e-mission/gists{/gist_id}","starred_url":"https://api.github.com/users/e-mission/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e-mission/subscriptions","organizations_url":"https://api.github.com/users/e-mission/orgs","repos_url":"https://api.github.com/users/e-mission/repos","events_url":"https://api.github.com/users/e-mission/events{/privacy}","received_events_url":"https://api.github.com/users/e-mission/received_events","type":"Organization","site_admin":false},"repo":{"id":26307245,"name":"e-mission-server","full_name":"e-mission/e-mission-server","owner":{"login":"e-mission","id":10713694,"avatar_url":"https://avatars.githubusercontent.com/u/10713694?v=3","gravatar_id":"","url":"https://api.github.com/users/e-mission","html_url":"https://github.com/e-mission","followers_url":"https://api.github.com/users/e-mission/followers","following_url":"https://api.github.com/users/e-mission/following{/other_user}","gists_url":"https://api.github.com/users/e-mission/gists{/gist_id}","starred_url":"https://api.github.com/users/e-mission/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/e-mission/subscriptions","organizations_url":"https://api.github.com/users/e-mission/orgs","repos_url":"https://api.github.com/users/e-mission/repos","events_url":"https://api.github.com/users/e-mission/events{/privacy}","received_events_url":"https://api.github.com/users/e-mission/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/e-mission/e-mission-server","description":"The backend (server) code for the e-mission server","fork":false,"url":"https://api.github.com/repos/e-mission/e-mission-server","forks_url":"https://api.github.com/repos/e-mission/e-mission-server/forks","keys_url":"https://api.github.com/repos/e-mission/e-mission-server/keys{/key_id}","collaborators_url":"https://api.github.com/repos/e-mission/e-mission-server/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/e-mission/e-mission-server/teams","hooks_url":"https://api.github.com/repos/e-mission/e-mission-server/hooks","issue_events_url":"https://api.github.com/repos/e-mission/e-mission-server/issues/events{/number}","events_url":"https://api.github.com/repos/e-mission/e-mission-server/events","assignees_url":"https://api.github.com/repos/e-mission/e-mission-server/assignees{/user}","branches_url":"https://api.github.com/repos/e-mission/e-mission-server/branches{/branch}","tags_url":"https://api.github.com/repos/e-mission/e-mission-server/tags","blobs_url":"https://api.github.com/repos/e-mission/e-mission-server/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/e-mission/e-mission-server/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/e-mission/e-mission-server/git/refs{/sha}","trees_url":"https://api.github.com/repos/e-mission/e-mission-server/git/trees{/sha}","statuses_url":"https://api.github.com/repos/e-mission/e-mission-server/statuses/{sha}","languages_url":"https://api.github.com/repos/e-mission/e-mission-server/languages","stargazers_url":"https://api.github.com/repos/e-mission/e-mission-server/stargazers","contributors_url":"https://api.github.com/repos/e-mission/e-mission-server/contributors","subscribers_url":"https://api.github.com/repos/e-mission/e-mission-server/subscribers","subscription_url":"https://api.github.com/repos/e-mission/e-mission-server/subscription","commits_url":"https://api.github.com/repos/e-mission/e-mission-server/commits{/sha}","git_commits_url":"https://api.github.com/repos/e-mission/e-mission-server/git/commits{/sha}","comments_url":"https://api.github.com/repos/e-mission/e-mission-server/comments{/number}","issue_comment_url":"https://api.github.com/repos/e-mission/e-mission-server/issues/comments{/number}","contents_url":"https://api.github.com/repos/e-mission/e-mission-server/contents/{+path}","compare_url":"https://api.github.com/repos/e-mission/e-mission-server/compare/{base}...{head}","merges_url":"https://api.github.com/repos/e-mission/e-mission-server/merges","archive_url":"https://api.github.com/repos/e-mission/e-mission-server/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/e-mission/e-mission-server/downloads","issues_url":"https://api.github.com/repos/e-mission/e-mission-server/issues{/number}","pulls_url":"https://api.github.com/repos/e-mission/e-mission-server/pulls{/number}","milestones_url":"https://api.github.com/repos/e-mission/e-mission-server/milestones{/number}","notifications_url":"https://api.github.com/repos/e-mission/e-mission-server/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/e-mission/e-mission-server/labels{/name}","releases_url":"https://api.github.com/repos/e-mission/e-mission-server/releases{/id}","created_at":"2014-11-07T06:39:02Z","updated_at":"2015-12-15T17:56:35Z","pushed_at":"2016-01-20T06:02:07Z","git_url":"git://github.com/e-mission/e-mission-server.git","ssh_url":"git@github.com:e-mission/e-mission-server.git","clone_url":"https://github.com/e-mission/e-mission-server.git","svn_url":"https://github.com/e-mission/e-mission-server","homepage":"https://e-mission.eecs.berkeley.edu","size":75278,"stargazers_count":2,"watchers_count":2,"language":"Jupyter Notebook","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":21,"mirror_url":null,"open_issues_count":36,"forks":21,"open_issues":36,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/226"},"html":{"href":"https://github.com/e-mission/e-mission-server/pull/226"},"issue":{"href":"https://api.github.com/repos/e-mission/e-mission-server/issues/226"},"comments":{"href":"https://api.github.com/repos/e-mission/e-mission-server/issues/226/comments"},"review_comments":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/226/comments"},"review_comment":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/e-mission/e-mission-server/pulls/226/commits"},"statuses":{"href":"https://api.github.com/repos/e-mission/e-mission-server/statuses/985fcf4617cf67cb6863d42ae70a5d0848e94e65"}}}}