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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -56
app.py CHANGED
@@ -1,97 +1,88 @@
1
  import gradio as gr
2
  import matplotlib.pyplot as plt
3
 
4
- def cmda_redevelopment_fsi_calculator(
5
- uds, num_owners, old_fsi, new_fsi,
6
- guideline_value, market_rate, construction_cost, current_area,
7
- builder_share_percent
8
  ):
9
- # Step 1: Calculate buildable areas
10
- old_area = old_fsi * uds
11
- new_area = new_fsi * uds
12
- area_gain = new_area - old_area
13
 
14
- # Step 2: Premium FSI Charges (only beyond FSI 2.0)
15
- premium_fsi_factor = max(0, new_fsi - 2.0)
16
- premium_area = premium_fsi_factor * uds
17
- premium_fsi_charge = 0.4 * guideline_value * premium_area
18
 
19
- # Step 3: Construction Cost
20
- total_construction_cost = new_area * construction_cost
21
 
22
- # Step 4: Builder Share
23
- builder_share_area = (builder_share_percent / 100) * new_area
24
- owner_share_area = new_area - builder_share_area
25
 
26
- # Resale value based on current market rate
27
- resale_value_builder = builder_share_area * market_rate
28
- construction_cost_builder = builder_share_area * construction_cost
29
- builder_profit = resale_value_builder - construction_cost_builder - premium_fsi_charge
30
 
31
- # Step 5: Owner-wise area (based on UDS)
 
 
 
32
  uds_per_owner = uds / num_owners
33
- new_area_per_owner = owner_share_area / num_owners
34
- net_gain_per_owner = new_area_per_owner - uds_per_owner
35
 
36
- # Step 6: Visualization
37
  fig, ax = plt.subplots(figsize=(6, 4))
38
- labels = ['Old FSI Area', 'New FSI Area', 'Premium FSI Area']
39
- values = [old_area, new_area, premium_area]
40
  ax.bar(labels, values, edgecolor='black')
41
  ax.set_ylabel("Area (sq.ft)")
42
- ax.set_title("FSI Area Comparison")
43
  plt.tight_layout()
44
 
45
- # Step 7: Output
46
  result = {
47
- "Old FSI Buildable Area": f"{old_area:.2f} sq.ft",
48
- "New FSI Buildable Area": f"{new_area:.2f} sq.ft",
49
- "Total Area Gain": f"{area_gain:.2f} sq.ft",
50
- "Premium FSI Portion": f"{premium_area:.2f} sq.ft",
51
- "Premium FSI Charges": f"₹ {premium_fsi_charge:,.2f}",
52
- "Total Construction Cost (New FSI)": f"₹ {total_construction_cost:,.2f}",
53
-
54
- "--- Builder Deal Analysis ---": "",
55
- "Builder Share Area": f"{builder_share_area:.2f} sq.ft",
56
- "Owner Share Area": f"{owner_share_area:.2f} sq.ft",
57
- "Resale Value (Builder Area @ Market Rate)": f"₹ {resale_value_builder:,.2f}",
58
- "Construction Cost for Builder": f"₹ {construction_cost_builder:,.2f}",
59
  "Estimated Builder Profit": f"₹ {builder_profit:,.2f}",
60
 
61
- "--- Owner Breakdown (based on UDS) ---": "",
 
62
  "UDS per Owner": f"{uds_per_owner:.2f} sq.ft",
63
- "New Area per Owner": f"{new_area_per_owner:.2f} sq.ft",
64
- "Net Gain per Owner": f"{net_gain_per_owner:.2f} sq.ft"
65
  }
66
 
67
  return result, fig
68
 
69
- # Gradio Interface Setup
70
  inputs = [
71
- gr.Number(label="Current UDS (in sq.ft)", value=450),
72
  gr.Number(label="Number of Owners", value=4),
73
- gr.Number(label="Old FSI", value=1.5),
74
- gr.Number(label="New FSI (max 2.8)", value=2.8),
75
  gr.Number(label="Guideline Value (₹/sq.ft)", value=5000),
76
- gr.Number(label="Market Rate (₹/sq.ft for sale)", value=9500),
77
  gr.Number(label="Construction Cost (₹/sq.ft)", value=3500),
78
- gr.Number(label="Current Total Area (in sq.ft)", value=1800),
79
- gr.Slider(label="Builder Share (%) of Redeveloped Area", minimum=0, maximum=80, step=1, value=40)
80
  ]
81
 
82
  outputs = [
83
  gr.JSON(label="CMDA Redevelopment Report"),
84
- gr.Plot(label="FSI Area Comparison Chart")
85
  ]
86
 
 
87
  app = gr.Interface(
88
- fn=cmda_redevelopment_fsi_calculator,
89
  inputs=inputs,
90
  outputs=outputs,
91
- title="CMDA Redevelopment Calculator with Builder Profit Estimator",
92
  description=(
93
- "Compare old and new FSI, calculate premium FSI charges, construction costs, and simulate builder profit "
94
- "based on market resale rate. Assumes equal UDS share among owners."
95
  )
96
  )
97
 
 
1
  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
62
 
63
+ # Gradio Inputs and Outputs
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
 
72
  outputs = [
73
  gr.JSON(label="CMDA Redevelopment Report"),
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 - 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