Skip to content

Commit

Permalink
Correct iterative algorithm and add API support in Time, #78
Browse files Browse the repository at this point in the history
  • Loading branch information
MBaranskiEBC committed May 11, 2020
1 parent 95fb370 commit 5b24035
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
20 changes: 15 additions & 5 deletions pyDMPC/ControlFramework/System.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def prep_cont_sys(cls):
cls.contr_sys = ControlledSystem.PLCSys()
elif cls.contr_sys_typ == "Modelica":
cls.contr_sys = ControlledSystem.ModelicaSys()
elif cls.contr_sys_typ == "API":
cls.contr_sys = ControlledSystem.API()

@classmethod
def close_cont_sys(cls):
Expand Down Expand Up @@ -258,26 +260,34 @@ def iterate(self):
sub.get_inputs()
inputs = sub.model.states.inputs[0]

if i == 1:
if i == 0:
sub.inputs = [inputs[0] - 0.1, inputs[0] + 0.1]
else:
sub.inputs = [inputs[0], sub.model.states.set_points[0]]
if (self.subsystems[0].inputs[0] <
self.subsystems[1].model.states.set_points[0]):
sub.inputs = [min(self.subsystems[0].inputs[0],
sub.model.states.set_points[0] - 0.5),
sub.model.states.set_points[0]]
else:
sub.inputs = [max(self.subsystems[0].inputs[0],
sub.model.states.set_points[0] + 0.5),
sub.model.states.set_points[0]]

sub.inputs.sort()
sub.optimize(interp = True)
self.broadcast([i])


for ino in range(0,8,1):
for ino in range(0,3,1):
for i,sub in enumerate(self.subsystems):
if i == 1:
if i == 0:
sub.get_inputs()
inputs = sub.model.states.inputs[0]
sub.inputs = [inputs[0] - 0.1, inputs[0] + 0.1]

else:
if sub.coup_vars_rec != []:
if (self.subsystems[1].inputs[0] <
if (self.subsystems[0].inputs[0] <
self.subsystems[1].model.states.set_points[0]):
sub.inputs = [min(sub.coup_vars_rec[0],
sub.model.states.set_points[0] - 0.5),
Expand Down
2 changes: 1 addition & 1 deletion pyDMPC/ControlFramework/Time.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Time:

sys_time = 0
time_incr = Init.time_incr
contr_sys_typ = "Modelica"
contr_sys_typ = Init.contr_sys_typ

def __init__(self):
pass
Expand Down

0 comments on commit 5b24035

Please sign in to comment.