29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
"""
|
|
API for running Energy Optimization with Pyomo.
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
Copyright © 2023 Project Author Alireza Adli alireza.adli@concordia.ca
|
|
"""
|
|
|
|
from flask_apispec import use_kwargs
|
|
from flask import request
|
|
from flask_restful import Resource
|
|
from energy_optimization_pyomo_post_data import EnergyOptimizationPyomoPostData
|
|
from energy_optimization_po import pyomo_energy_optimization
|
|
|
|
|
|
class EnergyOptimizationPyomo(Resource):
|
|
@use_kwargs(EnergyOptimizationPyomoPostData)
|
|
def post(self, **kwargs):
|
|
json_data = request.get_json()
|
|
schema = EnergyOptimizationPyomoPostData()
|
|
errors = schema.validate(json_data)
|
|
if errors:
|
|
return errors, 400
|
|
result = pyomo_energy_optimization(kwargs)
|
|
return {'Object FU': result[0], 'Cost of Energy (COE)': result[1],
|
|
'Number of PV': result[2], 'Number of Wind Turbines': result[3],
|
|
'Battery Storage Capacity': result[4],
|
|
'Total Capital Cost ($)': result[5],
|
|
'Renewable Penetration': result[6],
|
|
'Payback Period': result[7]}, 200
|