Commit 36f8834d authored by Tjerk Vreeken's avatar Tjerk Vreeken

CSVMixin: Expose all parameters read from file

Instead of only exposing the parameters in the Modelica model, we expose
all parameters read from the CSV file. This makes the behavior equal to
that of PIMixin, and as such can be moved to the common IOMixin.
parent 4e38744c
......@@ -192,23 +192,6 @@ class CSVMixin(IOMixin):
else:
return 1.0
@cached
def parameters(self, ensemble_member):
# Call parent class first for default values.
parameters = super().parameters(ensemble_member)
# Load parameters from parameter config
for parameter in self.dae_variables['parameters']:
parameter = parameter.name()
try:
parameters[parameter] = self.io.get_parameter(parameter, ensemble_member)
except KeyError:
pass
else:
if logger.getEffectiveLevel() == logging.DEBUG:
logger.debug("CSVMixin: Read parameter {} ".format(parameter))
return parameters
@cached
def initial_state(self, ensemble_member):
# Call parent class first for default values.
......
......@@ -240,6 +240,17 @@ class IOMixin(OptimizationProblem, metaclass=ABCMeta):
seed[variable] = s
return seed
@cached
def parameters(self, ensemble_member):
# Call parent class first for default values.
parameters = super().parameters(ensemble_member)
for parameter, value in self.io.parameters(ensemble_member).items():
parameters[parameter] = value
# Done
return parameters
@cached
def constant_inputs(self, ensemble_member):
# Call parent class first for default values.
......
......@@ -3,7 +3,6 @@ from datetime import timedelta
import rtctools.data.pi as pi
import rtctools.data.rtc as rtc
from rtctools._internal.caching import cached
from rtctools.optimization.io_mixin import IOMixin
logger = logging.getLogger("rtctools")
......@@ -147,17 +146,6 @@ class PIMixin(IOMixin):
# Done
return options
@cached
def parameters(self, ensemble_member):
# Call parent class first for default values.
parameters = super().parameters(ensemble_member)
for parameter, value in self.io.parameters(ensemble_member).items():
parameters[parameter] = value
# Done
return parameters
def write(self):
# Call parent class first for default behaviour.
super().write()
......
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