-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not having an accurate result / error not match the cost #615
Comments
Hi @alwaysbyx, sorry for the long delay, I've been incredibly busy. The code you shared above doesn't run, I had to make some modifications: set |
Regarding the error output, I'm assuming you are referring to the optimizer logs. If so, this corresponds to the sum of weighted squared costs, divided by two; here is the code. |
Hi, sorry for some mistakes in the above code. I am sending the code file link to your email and compare a simple problem (MPC with disturbance) of theseus and gurobi solver. Do you receive that email? I believe you can directly run that code and compare the performance. |
Hi @alwaysbyx , I saw your email, thanks for your interest in Theseus and your kind words! I was looking at your colab, and one thing I noticed is that you are squaring the terms in your cost function. However, note that Theseus automatically squares the weighted costs passed to the optimizer. So, for example, if you create this import theseus as th
x = th.Vector(1, name="x")
t = th.Vector(1, name="t")
w = th.ScaleCostWeight(2.0, name="w")
obj = th.Objective()
obj.add(th.Difference(x, t, w) what you are minimizing is I also didn't see the terms The other thing I noticed is that you are creating a single cost function for all terms, which are a mix of equality constraints and optimization terms. Might be clearer to create separate cost functions for each, although this is not a hard requirement. Finally, note that we don't yet have explicit support for equality constraints, so it might not be possible to exactly reproduce the results with gurobi, even after adding these fixes (see #519, for example). Let me know if this helps and feel free to share updated versions; this small example could be useful for us in debugging problems with equality constraints. |
Hi Thank you for your comments. I do not implement xu[t] == x[t] * u[t] in Theseus but this holds when evaluating the dynamics in Theseus (B_.tensor * us_[t].tensor * xs_true[-1]). |
❓ Questions and Help
I am following the simple example to solve a simple Model predictive control (1dimension) problem:
but got the incorrect result.
Using LQR controller law u[0] should around -23, and the solver gives -11.4.
And also I was wondering why the error output is not the same as the cost I defined. Thanks!
The text was updated successfully, but these errors were encountered: