Commit 46f9a0a7 authored by EXT lLou's avatar EXT lLou

add add_operating_time_range function

parent 946f993c
......@@ -40,7 +40,7 @@ from pulp import LpBinary, LpInteger, LpContinuous
from ..io.poles import Epole
from ...general.optimisation.elements import Quantity, Constraint, \
DynamicConstraint, ExtDynConstraint, Objective
DynamicConstraint, HourlyDynamicConstraint, ExtDynConstraint, Objective
from ...general.optimisation.core import OptObject
__docformat__ = "restructuredtext en"
......@@ -478,6 +478,67 @@ class EnergyUnit(OptObject):
raise ValueError("The EnergyUnit {} already has hours of "
"availability defined.".format(self.name))
def add_operating_time_range(self, operating_time_range=[[int, int]]):
"""
Add a range of hours during which the energy unit can be operated
example: [[10, 12], [14, 17]]
:param operating_time_range: [[first hour of functioning : int,
hour to stop (not in functioning): int]]
"""
if operating_time_range[0][0] == 0:
pass
else:
set_start_time_range = HourlyDynamicConstraint(
exp_t='{name}_u[t] == 0'.format(name=self.name),
time=self.time,
init_h=0,
final_h=operating_time_range[0][0] - 1,
name='set_operating_init_time_range_{}'.format(
operating_time_range[0][0]),
parent=self)
setattr(self, 'set_start_time_range_{}'.format(
operating_time_range[0][0]),
set_start_time_range)
if len(operating_time_range) != 1:
set_time_range = []
for i in range(1, len(operating_time_range)):
print(operating_time_range[i - 1][1])
print(operating_time_range[i][0] - 1)
set_time_range.append(HourlyDynamicConstraint(
exp_t='{name}_u[t] == 0'.format(name=self.name),
time=self.time,
init_h=operating_time_range[i - 1][1],
final_h=operating_time_range[i][0] - 1,
name='set_time_range_{}_{}'.format(
operating_time_range[i - 1][1],
operating_time_range[i][0]),
parent=self))
setattr(self,
'set_time_range_{}_{}'.format(
operating_time_range[i - 1][1],
operating_time_range[i][0]),
set_time_range[i - 1])
if operating_time_range[-1][1] == 23:
pass
else:
set_end_time_range = HourlyDynamicConstraint(
exp_t='{name}_u[t] == 0'.format(name=self.name),
time=self.time,
init_h=operating_time_range[-1][1],
final_h=23,
name='set_operating_final_time_range_{}'.format(
operating_time_range[0][1]),
parent=self)
setattr(self,
'set_end_time_range_{}'.format(operating_time_range[0][1]),
set_end_time_range)
def set_energy_limits_on_time_period(self, e_min=0, e_max=None,
start='YYYY-MM-DD HH:MM:SS',
end='YYYY-MM-DD HH:MM:SS',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment