def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument("number_of_requests", type=int, required=True)
        parser.add_argument("region_id", type=str, required=True)
        args = parser.parse_args()

        regions = self.__fetch_region(args["region_id"])

        if (len(regions) > 0):
            result = Simulator(regions[0]).simulate(args["number_of_requests"])
            self.__insert_booking_distance(args["region_id"],
                                           result["booking_distance_bins"])
            return result, 200
        else:
            return {"message": "Region not found"}, 404
Exemple #2
0
import pandas as pd
import numpy as np
from sklearn.cluster import KMeans
from datetime import timedelta
import os
import zipfile
import io
import shutil

from services.simulator import Simulator
from constants import *

app = Flask(__name__)
CORS(app)

simulator = Simulator()

def get_stations():
    stations = []

    for station_snapshot in simulator.station_snapshots.values():
        station_response = {}
        station = station_snapshot.station
        station_response['name'] = station.name
        station_response['id'] = station.id
        station_response['coordinates'] = station.coordinates
        station_response['capacity'] = station.capacity
        station_response['count'] = station_snapshot.current_bike_count
        stations.append(station_response)

    return stations
Exemple #3
0
def on_open(ws):
    print("### OPEN ###")
    if simulation is True:
        simulator = Simulator(ws)
        simulator.start_simulation()
print("-----------------------------------------------")
print("now enter the angel of projectile:(rad)")
angel = float(input())
print("-----------------------------------------------")
print("it's time for air to play its role, enter radius of ball:(m)")
radius = float(input())
print("-----------------------------------------------")
print("ohh we forget about mass :), enter the mass of projectile:(kg)")
mass = float(input())
print("-----------------------------------------------")
print(
    "at the end enter time duration:(s)  *[the less time duration is the accurate your graphs will be]*"
)
delta_t = float(input())

simulator = Simulator(mass, initial_velocity, angel, radius, delta_t)
simulator.simulate()
Plotter.plot(simulator.y_components, simulator.x_components, r'$y\/(m)$',
             r'$x\/(m)$', "[y-x]graph")
Plotter.plot(simulator.x_components, simulator.time, r'$x\/(m)$', r'$t\/(s)$',
             "[x-t]graph")
Plotter.plot(simulator.y_components, simulator.time, r'$y\/(m)$', r'$t\/(s)$',
             "[y-t]graph")
Plotter.plot(simulator.v_x_components, simulator.time, r'$\.x\/(m/s)$',
             r'$t\/(s)$', "[xdot-t]graph")
Plotter.plot(simulator.v_y_components, simulator.time, r'$\.y\/(m/s)$',
             r'$t\/(s)$', "[ydot-t]graph")
Plotter.plot(simulator.v_x_components, simulator.x_components, r'$\.x\/(m/s)$',
             r'$x\/(m)$', "[xdot-x]graph")
Plotter.plot(simulator.v_y_components, simulator.y_components, r'$\.y\/(m/s)$',
             r'$y\/(m)$', "[ydot-y]graph")