Remi
October 13, 2025, 1:45pm
1
Hi
I’m using acados python and try to implement lexicographic optimization MPC.
For this, I would need the cost result of the solution for each horizon step. But as far as I know, it’s only possible to get it for the whole solution (using get_cost). Or it is?
kaethe
October 14, 2025, 8:56am
2
Hi
You can try to use AcadosCostConstraintEvaluator. It’s a bit of a prototype implementation though.
Easiest is just to build the stage cost function again yourself.
Best, Katrin
Remi
October 14, 2025, 12:25pm
3
Hi,
Thank you for your answer.
Would you have an implementation example? I couldn’t find any documentation.
Or otherwise a way to access the function from the AcadosOcpSolver?
Best, Rémi
kaethe
October 14, 2025, 1:59pm
4
Here is an example using the evaluator
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.;
#
import sys
sys.path.insert(0, '../getting_started')
from matplotlib import pyplot as plt
from acados_template import AcadosOcp, AcadosOcpSolver, AcadosSimSolver, AcadosSim, ACADOS_INFTY
from acados_template.mpc_utils import AcadosCostConstraintEvaluator
from pendulum_model import export_pendulum_ode_model
from utils_eval import plot_pendulum_eval
import numpy as np
import scipy.linalg
import math
from casadi import vertcat, SX
# Define constraints to make evaluation more challenging
constraint_par = {'omega_dot_min_1': -4,
'omega_dot_min_2': -6,
1 Like