Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import matplotlib.pyplot as plt | |
| # Helper function to format INR values | |
| def format_rupees(value): | |
| inr = f"₹ {value:,.2f}" | |
| if value >= 1e7: | |
| cr = f" (₹ {value / 1e7:.2f} Cr)" | |
| return inr + cr | |
| return inr | |
| def cmda_redevelopment_final_model( | |
| uds, num_owners, total_fsi, guideline_value, market_rate, construction_cost | |
| ): | |
| owner_fsi = 2.0 | |
| premium_fsi = total_fsi - owner_fsi | |
| # Area calculations | |
| owner_total_area = owner_fsi * uds | |
| builder_area = premium_fsi * uds | |
| total_built_up_area = total_fsi * uds | |
| # Premium FSI Charges | |
| premium_fsi_charge = 0.4 * guideline_value * uds * premium_fsi | |
| # Construction cost for entire built-up area | |
| total_construction_cost = total_built_up_area * construction_cost | |
| # Builder Revenue | |
| builder_sale_value = builder_area * market_rate | |
| # Builder Profit | |
| builder_profit = builder_sale_value - total_construction_cost - premium_fsi_charge | |
| # Owner share | |
| uds_per_owner = uds / num_owners | |
| owner_area_per_owner = owner_total_area / num_owners | |
| # Chart | |
| fig, ax = plt.subplots(figsize=(6, 4)) | |
| labels = ['Owner Area (2.0x UDS)', f'Builder Area ({premium_fsi:.1f}x UDS)', 'Total Area'] | |
| values = [owner_total_area, builder_area, total_built_up_area] | |
| ax.bar(labels, values, edgecolor='black') | |
| ax.set_ylabel("Area (sq.ft)") | |
| ax.set_title("Redevelopment Share Breakdown") | |
| plt.tight_layout() | |
| # Output with formatted rupees | |
| result = { | |
| "Total UDS": f"{uds:.2f} sq.ft", | |
| "Total Built-up Area (FSI × UDS)": f"{total_built_up_area:.2f} sq.ft", | |
| "Owner Entitlement Area (2.0 × UDS)": f"{owner_total_area:.2f} sq.ft", | |
| f"Builder Saleable Area ({premium_fsi:.1f} × UDS)": f"{builder_area:.2f} sq.ft", | |
| "--- Builder Financials ---": "", | |
| "Premium FSI Charges (0.4 × guideline × UDS × extra FSI)": format_rupees(premium_fsi_charge), | |
| "Total Construction Cost (entire built-up area)": format_rupees(total_construction_cost), | |
| "Builder Revenue (@ market rate)": format_rupees(builder_sale_value), | |
| "Estimated Builder Profit": format_rupees(builder_profit), | |
| "--- Owner Breakdown ---": "", | |
| "Number of Owners": num_owners, | |
| "UDS per Owner": f"{uds_per_owner:.2f} sq.ft", | |
| "New Flat per Owner (2.0 × UDS)": f"{owner_area_per_owner:.2f} sq.ft" | |
| } | |
| return result, fig | |
| # Gradio Interface | |
| inputs = [ | |
| gr.Number(label="Total UDS (in sq.ft)", value=450), | |
| gr.Number(label="Number of Owners", value=4), | |
| gr.Number(label="Total FSI (e.g., 2.8)", value=2.8, minimum=2.0, maximum=3.5, step=0.1), | |
| gr.Number(label="Guideline Value (₹/sq.ft)", value=5000), | |
| gr.Number(label="Market Rate (₹/sq.ft for builder sale)", value=9500), | |
| gr.Number(label="Construction Cost (₹/sq.ft)", value=3500), | |
| ] | |
| outputs = [ | |
| gr.JSON(label="CMDA Redevelopment Report"), | |
| gr.Plot(label="Redevelopment Share Chart") | |
| ] | |
| app = gr.Interface( | |
| fn=cmda_redevelopment_final_model, | |
| inputs=inputs, | |
| outputs=outputs, | |
| title="CMDA Redevelopment Calculator (Fixed Owner FSI Model)", | |
| description=( | |
| "Owners receive flats at 2.0× their UDS. Builder gets only the premium FSI share, sells at market rate, " | |
| "and bears full construction cost and premium FSI charges. Figures over ₹1 Cr are shown in crores." | |
| ) | |
| ) | |
| if __name__ == "__main__": | |
| app.launch() | |