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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -26
app.py CHANGED
@@ -2,60 +2,59 @@ import gradio as gr
2
  import matplotlib.pyplot as plt
3
 
4
  def cmda_redevelopment_final_model(
5
- uds, num_owners, guideline_value, market_rate, construction_cost
6
  ):
7
- # Step 1: Fixed FSI logic
8
- normal_fsi = 2.0
9
- premium_fsi = 0.8
10
- total_fsi = normal_fsi + premium_fsi
11
 
12
- # Step 2: Area calculations
13
- owner_total_area = normal_fsi * uds
14
  builder_area = premium_fsi * uds
15
  total_built_up_area = total_fsi * uds
16
 
17
- # Step 3: Premium FSI Charges
18
- premium_fsi_charge = 0.4 * guideline_value * builder_area
19
 
20
- # Step 4: Construction cost for entire built-up area (owner + builder)
21
  total_construction_cost = total_built_up_area * construction_cost
22
 
23
- # Step 5: Builder Revenue (sale of builder share at market rate)
24
  builder_sale_value = builder_area * market_rate
25
 
26
- # Step 6: Builder Profit
27
  builder_profit = builder_sale_value - total_construction_cost - premium_fsi_charge
28
 
29
- # Step 7: Owner Share Calculations
30
  uds_per_owner = uds / num_owners
31
  owner_area_per_owner = owner_total_area / num_owners
32
 
33
- # Step 8: Chart
34
  fig, ax = plt.subplots(figsize=(6, 4))
35
- labels = ['Owner Area (2.0x UDS)', 'Builder Area (0.8x UDS)', 'Total Area']
36
  values = [owner_total_area, builder_area, total_built_up_area]
37
  ax.bar(labels, values, edgecolor='black')
38
  ax.set_ylabel("Area (sq.ft)")
39
  ax.set_title("Redevelopment Share Breakdown")
40
  plt.tight_layout()
41
 
42
- # Step 9: Output
43
  result = {
44
  "Total UDS": f"{uds:.2f} sq.ft",
45
- "Total Built-up Area (2.8 FSI)": f"{total_built_up_area:.2f} sq.ft",
46
- "Owner Entitlement Area (2.0 x UDS)": f"{owner_total_area:.2f} sq.ft",
47
- "Builder Saleable Area (0.8 x UDS)": f"{builder_area:.2f} sq.ft",
48
 
49
  "--- Builder Financials ---": "",
50
- "Premium FSI Charges (0.4 × guideline × area)": f"₹ {premium_fsi_charge:,.2f}",
51
- "Total Construction Cost (entire 2.8x)": f"₹ {total_construction_cost:,.2f}",
52
  "Builder Revenue (@ market rate)": f"₹ {builder_sale_value:,.2f}",
53
  "Estimated Builder Profit": f"₹ {builder_profit:,.2f}",
54
 
55
  "--- Owner Breakdown ---": "",
56
  "Number of Owners": num_owners,
57
  "UDS per Owner": f"{uds_per_owner:.2f} sq.ft",
58
- "New Flat per Owner (2x UDS)": f"{owner_area_per_owner:.2f} sq.ft"
59
  }
60
 
61
  return result, fig
@@ -64,8 +63,9 @@ def cmda_redevelopment_final_model(
64
  inputs = [
65
  gr.Number(label="Total UDS (in sq.ft)", value=450),
66
  gr.Number(label="Number of Owners", value=4),
 
67
  gr.Number(label="Guideline Value (₹/sq.ft)", value=5000),
68
- gr.Number(label="Market Rate (₹/sq.ft)", value=9500),
69
  gr.Number(label="Construction Cost (₹/sq.ft)", value=3500),
70
  ]
71
 
@@ -79,10 +79,10 @@ app = gr.Interface(
79
  fn=cmda_redevelopment_final_model,
80
  inputs=inputs,
81
  outputs=outputs,
82
- title="CMDA Redevelopment Calculator - Owner-Builder Model (Fixed FSI)",
83
  description=(
84
- "This calculator assumes owners are returned flats at 2x their UDS (normal FSI), and builder gets the premium FSI portion (0.8x UDS) "
85
- "to sell. Builder pays full construction cost for entire 2.8x area and premium FSI charges."
86
  )
87
  )
88
 
 
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]
36
  ax.bar(labels, values, edgecolor='black')
37
  ax.set_ylabel("Area (sq.ft)")
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",
45
+ "Owner Entitlement Area (2.0 × UDS)": f"{owner_total_area:.2f} sq.ft",
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,
56
  "UDS per Owner": f"{uds_per_owner:.2f} sq.ft",
57
+ "New Flat per Owner (2.0 × UDS)": f"{owner_area_per_owner:.2f} sq.ft"
58
  }
59
 
60
  return result, fig
 
63
  inputs = [
64
  gr.Number(label="Total UDS (in sq.ft)", value=450),
65
  gr.Number(label="Number of Owners", value=4),
66
+ gr.Number(label="Total FSI (e.g., 2.8)", value=2.8, minimum=2.0, maximum=3.5, step=0.1),
67
  gr.Number(label="Guideline Value (₹/sq.ft)", value=5000),
68
+ gr.Number(label="Market Rate (₹/sq.ft for builder sale)", value=9500),
69
  gr.Number(label="Construction Cost (₹/sq.ft)", value=3500),
70
  ]
71
 
 
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