Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """This module is main module for contestant's solution."""
- from hackathon.utils.control import Control
- from hackathon.utils.utils import ResultsMessage, DataMessage, PVMode, \
- TYPHOON_DIR, config_outs
- from hackathon.framework.http_server import prepare_dot_dir
- def worker(msg: DataMessage) -> ResultsMessage:
- """TODO: This function should be implemented by contestants."""
- # Details about DataMessage and ResultsMessage objects can be found in /utils/utils.py
- if msg.current_load > 2.5:
- if msg.solar_production - msg.current_load > 0:
- load3 = True
- else:
- load3 = False
- else:
- load3 = True
- if msg.current_load > 6:
- if msg.solar_production - msg.current_load > 0:
- load2 = True
- else:
- load2 = False
- else:
- load2 = True
- pr = calculatePowerReference(msg)
- pv = calculatePV(msg)
- return ResultsMessage(data_msg=msg,
- load_one=True,
- load_two=load2,
- load_three=load3,
- power_reference = pr,
- pv_mode = pv)
- # Dummy result is returned in every cycle here
- def calculatePowerReference(msg : DataMessage):
- if msg.bessSOC != 1:
- if msg.solar_production > msg.current_load:
- return (-1)*(msg.solar_production - msg.current_load)
- if msg.bessSOC < 0.2:
- if not msg.grid_status:
- return (0.0)
- else:
- if msg.buying_price < 5:
- if msg.solar_production == 0:
- return (-0.143)
- else:
- if msg.solar_production < 6:
- return ((-1) * msg.solar_production)
- else:
- return (-6.0)
- else:
- return (0.0)
- else:
- if not msg.grid_status:
- return (0.0)
- else:
- if msg.buying_price < 5:
- if msg.solar_production == 0:
- return (-0.143)
- else:
- if msg.solar_production < 6:
- return ((-1) * msg.solar_production)
- else:
- return (-6.0)
- else:
- if msg.selling_price == 0:
- return (0.0)
- else:
- return (6.0)
- def calculatePV(msg : DataMessage):
- if not msg.grid_status and msg.bessSOC == 1.0:
- return (PVMode.OFF)
- else:
- return (PVMode.ON)
- def run(args) -> None:
- prepare_dot_dir()
- config_outs(args, 'solution')
- cntrl = Control()
- for data in cntrl.get_data():
- cntrl.push_results(worker(data))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement