From 9847bbc25ea7d54048ea6e5f754f171b99b95d35 Mon Sep 17 00:00:00 2001 From: Marc Baranski Date: Fri, 17 May 2019 11:42:31 +0200 Subject: [PATCH] * Add individual prediction horizons for each subsystem, #33. --- pyDMPC/ControlFramework/Init.py | 5 ++++- pyDMPC/ControlFramework/Objective_Function.py | 4 ++-- pyDMPC/ControlFramework/Subsystem.py | 3 ++- pyDMPC/ControlFramework/System.py | 1 + 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pyDMPC/ControlFramework/Init.py b/pyDMPC/ControlFramework/Init.py index d07c28d..7e3cad2 100644 --- a/pyDMPC/ControlFramework/Init.py +++ b/pyDMPC/ControlFramework/Init.py @@ -123,6 +123,7 @@ T_set = [] Q_set = [] variation = [] +pred_hor = [] """ Subsystems """ #Ground_long @@ -142,6 +143,7 @@ T_set.append(285) Q_set.append(2200) variation.append(False) +pred_hor.append(3*365*24*86400.0) ## Ground_short #name.append('Field_short') @@ -177,4 +179,5 @@ cost_par.append("decisionVariables.y[1]") T_set.append(295) Q_set.append(0) -variation.append(True) \ No newline at end of file +variation.append(True) +pred_hor.append(5*3600) \ No newline at end of file diff --git a/pyDMPC/ControlFramework/Objective_Function.py b/pyDMPC/ControlFramework/Objective_Function.py index 42e7cce..7bb6f95 100644 --- a/pyDMPC/ControlFramework/Objective_Function.py +++ b/pyDMPC/ControlFramework/Objective_Function.py @@ -121,7 +121,7 @@ def Obj(values_DVs, BC, s): simStat = dymola.simulateExtendedModel( problem=s._model_path, startTime=Init.start_time, - stopTime=Init.stop_time, + stopTime=s.stop_time, outputInterval=Init.incr, method="Dassl", tolerance=Init.tol, @@ -132,7 +132,7 @@ def Obj(values_DVs, BC, s): simStat = dymola.simulateExtendedModel( problem=s._model_path, startTime=Init.start_time, - stopTime=Init.stop_time, + stopTime=s.stop_time, outputInterval=Init.incr, method="Dassl", tolerance=Init.tol, diff --git a/pyDMPC/ControlFramework/Subsystem.py b/pyDMPC/ControlFramework/Subsystem.py index 660126a..35f297b 100644 --- a/pyDMPC/ControlFramework/Subsystem.py +++ b/pyDMPC/ControlFramework/Subsystem.py @@ -19,7 +19,7 @@ def __init__(self, name, position, bounds_DVs,model_path, names_BCs, num_VarsOut, names_DVs, output_vars, initial_names, IDs_initial_values,IDs_inputs,cost_par, - T_set,Q_set,variation, type_subSyst=None): + T_set,Q_set,variation,pred_hor,type_subSyst=None): self._name = name self._type_subSyst = type_subSyst self._num_DVs = num_DVs @@ -42,6 +42,7 @@ def __init__(self, name, position, self.T_set = T_set self.Q_set = Q_set self.variation = variation + self.pred_hor = pred_hor def GetNeighbour(self, neighbour_name): diff --git a/pyDMPC/ControlFramework/System.py b/pyDMPC/ControlFramework/System.py index 83de130..bd1ec2c 100644 --- a/pyDMPC/ControlFramework/System.py +++ b/pyDMPC/ControlFramework/System.py @@ -54,6 +54,7 @@ def GenerateSubSys(self): Init.T_set[i], Init.Q_set[i], Init.variation[i], + Init.pred_hor[i], Init.type_subSyst[i]) ) subsystems.sort(key = lambda x: x.position)