Closed xueminchi closed 1 month ago
Hi,
Infeasible_Problem_Detected
is the solver struggling. This can be due to your model being evaluated in areas where it produces unexpected results.
As an example, your training data might include input x=1
and x=1.1
and will produce the right result but, in theory, could produce the completely wrong result for x=1.05
, which your analytical model will not. This might not be exactly the case but it demonstrates how a trained model can diverge from an analytical model.
Best Tim
To check if your constraints are satisfied, you can add slack variables to each constraint and minimize them by including the slack variables as part of the cost function. Ideally, all slack variables should be zero.
Thanks. Indeed, both the accuracy of the learned model and the formulation of the problem will affect the final gradient-based solver to converge.
Hi, @Tim-Salzmann
I designed a predictive controller following your previous instructions in the example
simple_nlp.py
. The problem is very simple. A system tries to avoid a circle obstacle and reach the goal.The code runs without major issues, but after several iterations, it reports
Infeasible_Problem_Detected
. I tested the same scenario using an analytical model instead of the model defined by PyTorch andl4casadi
, and it works without triggering this infeasibility. I wonder if there might be a problem with my constraint formulation.To reproduce the issue, I have attached the script (only one
.py
file inside thezip
format). It requires the following packages:casadi
,numpy
,torch
,matplotlib
, andl4casadi
, so it should be easy to run.Best, Xuemin casadi_mpc_torch.zip