hareshchander commited on
Commit
a5c97a6
·
verified ·
1 Parent(s): 064c10b

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -51
app.py DELETED
@@ -1,51 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """Untitled2.ipynb
3
-
4
- Automatically generated by Colab.
5
-
6
- Original file is located at
7
- https://colab.research.google.com/drive/1uawKsZ38jh7bbAoDfTj-rW3phe-4Lfto
8
- """
9
-
10
- !pip install gradio pyomo pandas
11
-
12
- import gradio as gr
13
- from pyomo.environ import *
14
-
15
- def optimize_dispatch(solar, wind, grid, load):
16
- sources = {
17
- "solar": {"max": solar, "cost": 0},
18
- "wind": {"max": wind, "cost": 0},
19
- "grid": {"max": grid, "cost": 5}
20
- }
21
-
22
- model = ConcreteModel()
23
- model.sources = Set(initialize=sources.keys())
24
- model.P = Var(model.sources, bounds=(0, None))
25
- model.cost = Objective(expr=sum(sources[s]['cost'] * model.P[s] for s in model.sources), sense=minimize)
26
- model.balance = Constraint(expr=sum(model.P[s] for s in model.sources) == load)
27
- model.capacity = ConstraintList()
28
- for s in sources:
29
- model.capacity.add(model.P[s] <= sources[s]['max'])
30
-
31
- SolverFactory('glpk').solve(model)
32
- return {s: round(model.P[s].value, 2) for s in sources}
33
-
34
- def ui(solar, wind, grid, load):
35
- result = optimize_dispatch(solar, wind, grid, load)
36
- explanation = f"Optimized dispatch: {result}. Priority was given to renewables (zero cost), with remaining load met by grid."
37
- return str(result), explanation
38
-
39
- demo = gr.Interface(
40
- fn=ui,
41
- inputs=[
42
- gr.Slider(0, 100, label="Solar Capacity (MW)"),
43
- gr.Slider(0, 100, label="Wind Capacity (MW)"),
44
- gr.Slider(0, 200, label="Grid Capacity (MW)"),
45
- gr.Slider(0, 300, label="Total Load (MW)")
46
- ],
47
- outputs=["text", "text"],
48
- title="Renewable Integration Optimization Assistant"
49
- )
50
-
51
- demo.launch(share=True)