| import gradio as gr |
| import numpy as np |
| import pandas as pd |
| import plotly.express as px |
|
|
| |
| |
| |
|
|
| def simulate_city(initial_population, growth_rate, years): |
| years_list = list(range(years + 1)) |
| population_growth = [] |
|
|
| for year in years_list: |
| population = initial_population * ((1 + growth_rate) ** year) |
| population_growth.append(population) |
|
|
| df = pd.DataFrame({ |
| "Year": years_list, |
| "Population": population_growth |
| }) |
|
|
| fig = px.line(df, x="Year", y="Population", |
| title="Aurora City Growth Simulation", |
| markers=True) |
|
|
| return fig |
|
|
|
|
| with gr.Blocks() as demo: |
| gr.Markdown("# 🌆 Aurora Urban Simulation Engine") |
| gr.Markdown("Simulação de crescimento urbano baseada em taxa anual.") |
|
|
| initial_population = gr.Number(label="População Inicial", value=100000) |
| growth_rate = gr.Slider(0.0, 0.2, value=0.03, step=0.01, label="Taxa de Crescimento") |
| years = gr.Slider(1, 50, value=20, step=1, label="Anos") |
|
|
| simulate_button = gr.Button("Simular") |
|
|
| output_graph = gr.Plot() |
|
|
| simulate_button.click( |
| simulate_city, |
| inputs=[initial_population, growth_rate, years], |
| outputs=output_graph |
| ) |
|
|
| demo.launch() |