Skip to content

Commit

Permalink
feat: Pass kwargs to model load via optimisation wrappers (#1096)
Browse files Browse the repository at this point in the history
Allow passing keyword arguments to models via the optimisation wrapper.

---------

Co-authored-by: Stefano Simoncelli <Stefano.Simoncelli@dwrcymru.com>
  • Loading branch information
s-simoncelli and Stefano Simoncelli committed Jun 30, 2023
1 parent 4dac394 commit 3557e4b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pywr/optimisation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class BaseOptimisationWrapper(object):
def __init__(self, pywr_model_json, *args, **kwargs):
uid = kwargs.pop("uid", None)
self.pywr_model_klass = kwargs.pop("model_klass", Model)
self.pywr_model_kwargs = kwargs.pop("model_kwargs", {})
super(BaseOptimisationWrapper, self).__init__(*args, **kwargs)
self.pywr_model_json = pywr_model_json

Expand Down Expand Up @@ -107,7 +108,7 @@ def model_constraints(self):
return self._cached.constraints

def make_model(self):
m = self.pywr_model_klass.load(self.pywr_model_json)
m = self.pywr_model_klass.load(self.pywr_model_json, **self.pywr_model_kwargs)
# Apply any user defined changes to the model
self.customise_model(m)
return m
Expand Down

0 comments on commit 3557e4b

Please sign in to comment.