# nlp_obj¶

Class attribute.

MPC.nlp_obj

Query and modify (symbolically) the NLP objective function. Use the variables in opt_x and opt_p.

mpc.prepare_nlp()
# Modify the objective
mpc.nlp_obj += sum1(vertcat(*mpc.opt_x['_x', -1, 0])**2)
# Finish creating the NLP
mpc.create_nlp()


See the documentation of opt_x and opt_p on how to query these attributes.

Warning

This is a VERY low level feature and should be used with extreme caution. It is easy to break the code.

Be especially careful NOT to accidentially overwrite the default objective.

Note

Modifications must be done after calling prepare_nlp() and before calling create_nlp()