dindizz commited on
Commit
5366c37
·
verified ·
1 Parent(s): adb885b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -17
app.py CHANGED
@@ -1,35 +1,42 @@
1
  import gradio as gr
2
  import matplotlib.pyplot as plt
3
 
 
 
 
 
 
 
 
 
4
  def cmda_redevelopment_final_model(
5
  uds, num_owners, total_fsi, guideline_value, market_rate, construction_cost
6
  ):
7
- # Constants
8
  owner_fsi = 2.0
9
  premium_fsi = total_fsi - owner_fsi
10
 
11
- # Step 1: Area calculations
12
  owner_total_area = owner_fsi * uds
13
  builder_area = premium_fsi * uds
14
  total_built_up_area = total_fsi * uds
15
 
16
- # Step 2: Premium FSI Charges (new formula)
17
  premium_fsi_charge = 0.4 * guideline_value * uds * premium_fsi
18
 
19
- # Step 3: Construction cost for entire built-up area
20
  total_construction_cost = total_built_up_area * construction_cost
21
 
22
- # Step 4: Builder Revenue (saleable area = premium portion only)
23
  builder_sale_value = builder_area * market_rate
24
 
25
- # Step 5: Builder Profit
26
  builder_profit = builder_sale_value - total_construction_cost - premium_fsi_charge
27
 
28
- # Step 6: Owner Share Calculations
29
  uds_per_owner = uds / num_owners
30
  owner_area_per_owner = owner_total_area / num_owners
31
 
32
- # Step 7: Chart
33
  fig, ax = plt.subplots(figsize=(6, 4))
34
  labels = ['Owner Area (2.0x UDS)', f'Builder Area ({premium_fsi:.1f}x UDS)', 'Total Area']
35
  values = [owner_total_area, builder_area, total_built_up_area]
@@ -38,7 +45,7 @@ def cmda_redevelopment_final_model(
38
  ax.set_title("Redevelopment Share Breakdown")
39
  plt.tight_layout()
40
 
41
- # Step 8: Output
42
  result = {
43
  "Total UDS": f"{uds:.2f} sq.ft",
44
  "Total Built-up Area (FSI × UDS)": f"{total_built_up_area:.2f} sq.ft",
@@ -46,10 +53,10 @@ def cmda_redevelopment_final_model(
46
  f"Builder Saleable Area ({premium_fsi:.1f} × UDS)": f"{builder_area:.2f} sq.ft",
47
 
48
  "--- Builder Financials ---": "",
49
- "Premium FSI Charges (0.4 × guideline × UDS × extra FSI)": f"₹ {premium_fsi_charge:,.2f}",
50
- "Total Construction Cost (entire built-up area)": f"₹ {total_construction_cost:,.2f}",
51
- "Builder Revenue (@ market rate)": f"₹ {builder_sale_value:,.2f}",
52
- "Estimated Builder Profit": f"₹ {builder_profit:,.2f}",
53
 
54
  "--- Owner Breakdown ---": "",
55
  "Number of Owners": num_owners,
@@ -59,7 +66,7 @@ def cmda_redevelopment_final_model(
59
 
60
  return result, fig
61
 
62
- # Gradio Inputs and Outputs
63
  inputs = [
64
  gr.Number(label="Total UDS (in sq.ft)", value=450),
65
  gr.Number(label="Number of Owners", value=4),
@@ -74,15 +81,14 @@ outputs = [
74
  gr.Plot(label="Redevelopment Share Chart")
75
  ]
76
 
77
- # Interface setup
78
  app = gr.Interface(
79
  fn=cmda_redevelopment_final_model,
80
  inputs=inputs,
81
  outputs=outputs,
82
  title="CMDA Redevelopment Calculator (Fixed Owner FSI Model)",
83
  description=(
84
- "This calculator assumes flat owners receive 2.0× their UDS as new flats. Builder retains only the premium FSI portion "
85
- "and pays for full construction and premium FSI charges. Enter realistic values to assess feasibility."
86
  )
87
  )
88
 
 
1
  import gradio as gr
2
  import matplotlib.pyplot as plt
3
 
4
+ # Helper function to format INR values
5
+ def format_rupees(value):
6
+ inr = f"₹ {value:,.2f}"
7
+ if value >= 1e7:
8
+ cr = f" (₹ {value / 1e7:.2f} Cr)"
9
+ return inr + cr
10
+ return inr
11
+
12
  def cmda_redevelopment_final_model(
13
  uds, num_owners, total_fsi, guideline_value, market_rate, construction_cost
14
  ):
 
15
  owner_fsi = 2.0
16
  premium_fsi = total_fsi - owner_fsi
17
 
18
+ # Area calculations
19
  owner_total_area = owner_fsi * uds
20
  builder_area = premium_fsi * uds
21
  total_built_up_area = total_fsi * uds
22
 
23
+ # Premium FSI Charges
24
  premium_fsi_charge = 0.4 * guideline_value * uds * premium_fsi
25
 
26
+ # Construction cost for entire built-up area
27
  total_construction_cost = total_built_up_area * construction_cost
28
 
29
+ # Builder Revenue
30
  builder_sale_value = builder_area * market_rate
31
 
32
+ # Builder Profit
33
  builder_profit = builder_sale_value - total_construction_cost - premium_fsi_charge
34
 
35
+ # Owner share
36
  uds_per_owner = uds / num_owners
37
  owner_area_per_owner = owner_total_area / num_owners
38
 
39
+ # Chart
40
  fig, ax = plt.subplots(figsize=(6, 4))
41
  labels = ['Owner Area (2.0x UDS)', f'Builder Area ({premium_fsi:.1f}x UDS)', 'Total Area']
42
  values = [owner_total_area, builder_area, total_built_up_area]
 
45
  ax.set_title("Redevelopment Share Breakdown")
46
  plt.tight_layout()
47
 
48
+ # Output with formatted rupees
49
  result = {
50
  "Total UDS": f"{uds:.2f} sq.ft",
51
  "Total Built-up Area (FSI × UDS)": f"{total_built_up_area:.2f} sq.ft",
 
53
  f"Builder Saleable Area ({premium_fsi:.1f} × UDS)": f"{builder_area:.2f} sq.ft",
54
 
55
  "--- Builder Financials ---": "",
56
+ "Premium FSI Charges (0.4 × guideline × UDS × extra FSI)": format_rupees(premium_fsi_charge),
57
+ "Total Construction Cost (entire built-up area)": format_rupees(total_construction_cost),
58
+ "Builder Revenue (@ market rate)": format_rupees(builder_sale_value),
59
+ "Estimated Builder Profit": format_rupees(builder_profit),
60
 
61
  "--- Owner Breakdown ---": "",
62
  "Number of Owners": num_owners,
 
66
 
67
  return result, fig
68
 
69
+ # Gradio Interface
70
  inputs = [
71
  gr.Number(label="Total UDS (in sq.ft)", value=450),
72
  gr.Number(label="Number of Owners", value=4),
 
81
  gr.Plot(label="Redevelopment Share Chart")
82
  ]
83
 
 
84
  app = gr.Interface(
85
  fn=cmda_redevelopment_final_model,
86
  inputs=inputs,
87
  outputs=outputs,
88
  title="CMDA Redevelopment Calculator (Fixed Owner FSI Model)",
89
  description=(
90
+ "Owners receive flats at 2.0× their UDS. Builder gets only the premium FSI share, sells at market rate, "
91
+ "and bears full construction cost and premium FSI charges. Figures over ₹1 Cr are shown in crores."
92
  )
93
  )
94