Skip to content

Commit

Permalink
Merge pull request #3 from ucuapps/pippkg
Browse files Browse the repository at this point in the history
Simulation start added as an optional parameter for environment
  • Loading branch information
Oleh Lukianykhin authored Oct 27, 2019
2 parents 96dfcba + bb6e6f8 commit 90bcb7c
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions modelicagym/environment/modelica_cs_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@ class ModelicaCSEnv(ModelicaBaseEnv):
"""

def __init__(self, model_path, config, fmi_version, log_level):
def __init__(self, model_path, config, fmi_version, log_level,
simulation_start_time=0):
"""
:param model_path: path to the model FMU. Absolute path is advised.
:param config: dictionary with model specifications. For more details see ModelicaBaseEnv docs
:param fmi_version: version of FMI standard used in FMU compilation.
:param log_level: level of logging to be used in experiments on environment.
"""
self.simulation_start_time = simulation_start_time
self.fmi_version = fmi_version
logger.setLevel(log_level)
super().__init__(model_path, "CS", config, log_level)
Expand All @@ -47,10 +49,11 @@ def reset(self):

# get initial state of the model from the fmu
self.start = 0
self.stop = 0
self.stop = self.simulation_start_time
self.state = self.do_simulation()

self.stop = self.tau
self.start = self.simulation_start_time
self.stop = self.start + self.tau
self.done = self._is_done()
return self.state

Expand All @@ -65,8 +68,9 @@ class FMI1CSEnv(ModelicaCSEnv):
Refer to the ModelicaBaseEnv docs for detailed instructions on own environment implementation.
"""

def __init__(self, model_path, config, log_level):
super().__init__(model_path, config, FMIStandardVersion.first, log_level)
def __init__(self, model_path, config, log_level, simulation_start_time=0):
super().__init__(model_path, config, FMIStandardVersion.first, log_level,
simulation_start_time=simulation_start_time)


class FMI2CSEnv(ModelicaCSEnv):
Expand All @@ -78,5 +82,6 @@ class FMI2CSEnv(ModelicaCSEnv):
Refer to the ModelicaBaseEnv docs for detailed instructions on own environment implementation.
"""
def __init__(self, model_path, config, log_level):
super().__init__(model_path, config, FMIStandardVersion.second, log_level)
def __init__(self, model_path, config, log_level, simulation_start_time=0):
super().__init__(model_path, config, FMIStandardVersion.second, log_level,
simulation_start_time=simulation_start_time)

0 comments on commit 90bcb7c

Please sign in to comment.