Skip to content

Commit

Permalink
Docs + error msgs: Fixed .setup_model
Browse files Browse the repository at this point in the history
Now it says .model always.
  • Loading branch information
Felix-Mac committed Jul 21, 2021
1 parent 6d42ea8 commit 5f0c6fe
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions do_mpc/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def set_objective(self, mterm=None, lterm=None):
"""
assert mterm.shape == (1,1), 'mterm must have shape=(1,1). You have {}'.format(mterm.shape)
assert lterm.shape == (1,1), 'lterm must have shape=(1,1). You have {}'.format(lterm.shape)
assert self.flags['setup'] == False, 'Cannot call .set_objective after .setup_model.'
assert self.flags['setup'] == False, 'Cannot call .set_objective after .setup().'

_x, _u, _z, _tvp, _p = self.model['x','u','z','tvp','p']

Expand Down Expand Up @@ -542,7 +542,7 @@ def set_rterm(self, **kwargs):
For :math:`k=0` we obtain :math:`u_{-1}` from the previous solution.
"""
assert self.flags['setup'] == False, 'Cannot call .set_rterm after .setup_model.'
assert self.flags['setup'] == False, 'Cannot call .set_rterm after .setup().'

self.flags['set_rterm'] = True
for key, val in kwargs.items():
Expand Down
2 changes: 1 addition & 1 deletion do_mpc/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Data:
"""
def __init__(self, model):
self.dtype = 'default'
assert model.flags['setup'] == True, 'Model was not setup. After the complete model creation call model.setup_model().'
assert model.flags['setup'] == True, 'Model was not setup. After the complete model creation call model.setup().'
# As discussed here: https://groups.google.com/forum/#!topic/casadi-users/dqAb4tnA2ik
# struct_SX cannot be unpickled (seems like a bug)
# TODO: Find better workaround.
Expand Down
2 changes: 1 addition & 1 deletion do_mpc/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, model):
self.model = model
do_mpc.model.IteratedVariables.__init__(self)

assert model.flags['setup'] == True, 'Model for estimator was not setup. After the complete model creation call model.setup_model().'
assert model.flags['setup'] == True, 'Model for estimator was not setup. After the complete model creation call model.setup().'

self.data = do_mpc.data.Data(model)
self.data.dtype = 'Estimator'
Expand Down
2 changes: 1 addition & 1 deletion do_mpc/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def set_nl_cons(self, expr_name, expr, ub=np.inf, soft_constraint=False, penalty
:return: Returns the newly created expression. Expression can be used e.g. for the RHS.
:rtype: casadi.SX or casadi.MX
"""
assert self.flags['setup'] == False, 'Cannot call .set_expression after .setup_model.'
assert self.flags['setup'] == False, 'Cannot call .set_expression after .setup().'
assert isinstance(expr_name, str), 'expr_name must be str, you have: {}'.format(type(expr_name))
assert isinstance(expr, (casadi.SX, casadi.MX)), 'expr must be a casadi SX or MX type, you have: {}'.format(type(expr))
assert isinstance(ub, (int, float, np.ndarray)), 'ub must be float, int or numpy.ndarray, you have: {}'.format(type(ub))
Expand Down
2 changes: 1 addition & 1 deletion do_mpc/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, model):
self.model = model
do_mpc.model.IteratedVariables.__init__(self)

assert model.flags['setup'] == True, 'Model for simulator was not setup. After the complete model creation call model.setup_model().'
assert model.flags['setup'] == True, 'Model for simulator was not setup. After the complete model creation call model.setup().'

self.data = Data(model)

Expand Down
4 changes: 2 additions & 2 deletions documentation/source/mhe_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The model setup is completed by calling `model.setup_model()`:"
"The model setup is completed by calling `model.setup()`:"
]
},
{
Expand All @@ -202,7 +202,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"After calling `model.setup_model()` we cannot define further variables etc."
"After calling `model.setup()` we cannot define further variables etc."
]
},
{
Expand Down

0 comments on commit 5f0c6fe

Please sign in to comment.