Skip to content

datriever/smart-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Smart App

Authors

Rozhina Ahmadi, Esther Lozano, Álvaro Terrón, Marcel Claramunt

Overview

  • app: SvelteKit static web app
  • api: Python FastAPI backend
  • sdk: Python SDK for the backend with all logic

Frontend

Development

  1. Install Node.js and npm
  2. cd app
  3. npm install
  4. npm run dev --host

Backend

Development

  1. Create virtual env (first time)
python3.11 -m venv .venv
  1. Activate virtual env
source .venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt
  1. Run server
python api/main.py

Deployment

  1. Build Docker image
docker build -t smart-app -f api/Dockerfile .
  1. Run Docker container
docker run -p 80:80 smart-app

SDK

Portfolio Optimization

from datriever.smart_app import portfolio

solar = portfolio.Source(cost=50, emissions=30, risk=0.05, p_min=0.1, p_max=0.7)
wind = portfolio.Source(cost=40, emissions=40, risk=0.1, p_min=0.05, p_max=0.7)
nuclear = portfolio.Source(cost=70, emissions=10, risk=0.2, p_min=0.05, p_max=0.6)

portfolio.optimize([solar, wind, nuclear], goals={'green': 0.5, 'cheap': 1})
# [0.25, 0.7, 0.05]

portfolio.cost([(0.5, solar), (0.3, wind), (0.2, nuclear)])
# 51.0	

portfolio.emissions([(0.5, solar), (0.3, wind), (0.2, nuclear)])
# 29.0

portfolio.risk([(0.5, solar), (0.3, wind), (0.2, nuclear)])
# 0.095

About

Smart Energy App

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors