Skip to content

Commit

Permalink
Add an error if a non-convex cost is used with a slew rate for #12.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon Amos committed Nov 1, 2018
1 parent bc315fe commit 1df3c4b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mpc/mpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,12 @@ def approximate_cost(self, x, u, Cf, diff=True):
tau = torch.cat((x, u), dim=2).data
tau = Variable(tau, requires_grad=True)
if self.slew_rate_penalty is not None:
print("""
MPC Error: Using a non-convex cost with a slew rate penalty is not yet implemented.
The current implementation does not correctly do a line search.
More details: https://github.com/locuslab/mpc.pytorch/issues/12
""")
sys.exit(-1)
differences = tau[1:, :, -self.n_ctrl:] - tau[:-1, :, -self.n_ctrl:]
slew_penalty = (self.slew_rate_penalty * differences.pow(2)).sum(-1)
costs = list()
Expand Down

0 comments on commit 1df3c4b

Please sign in to comment.