Skip to content

Add Realtime Optimization Algorithms (for now just MPC) - #87

Merged
apozharski merged 16 commits into
ap/shift-warmstartfrom
ap/rtopt
Aug 18, 2026
Merged

apozharski merged 16 commits into
ap/shift-warmstartfrom
ap/rtopt

Conversation

@apozharski

Copy link
Copy Markdown
Member

This PR adds FullMPC and RTIMPC which includes its AS-RTI variants.

I also moved the old examples in this pr to address #70 for my own sanity.

It is not yet feature complete.

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown
TestsPassed ✅SkippedFailed
JUnit Test Report3028 ran3028 passed0 skipped0 failed

@apozharski
apozharski marked this pull request as ready for review August 15, 2026 11:09

@nurkanovic nurkanovic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work overall, MPC runs on my machine.

Some small typos to be fixed, some clarifications for warm start, cvx, and MPEC Lagrangians needed.

Comment thread src/nosnoc/rtopt/rtopt.py Outdated
Comment thread src/nosnoc/qpcc.py Outdated
Comment thread src/nosnoc/rtopt/rti.py
self.__warmstart_ocp()
self._prediction(**kwargs)
self.ocp_solver.solve()
elif self.rt_opts.prepare_step == PreparationStep.SQPCC:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a shift warm start possible/happening here since self.__warmstart_ocp() is not called ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the SQPCC step we aren't warmstarting because I haven't implemented yet a QPCC warmstart. We may want this but from the testing I did before (for the HyRTI paper) the benefit of this is dubious (since the zero warmstart is already pretty good assuming the measurement doesn't differ much)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the SQPCC local convergence theory suggests that this warm start ensures a locally unique sequence of iterates that does not jump to other seqeunces. so there might be some benefits when there are nearby multiple minimizers (dont ask me how much this gets wrapped by the homotopy and its restarts)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are calculating $\Delta x$ shouldn't this already be ideally tracking the locally unique solution? I think with interior point this is anyway a fools errand to enforce 😅 .

Comment thread src/nosnoc/qpcc.py
self.solver_opts = None
self.solver = None

def convexify(self, cvx_opts):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function is independent of the Hessian, but in our current implementation, we pass and convexify the Scholtes NLP Lagrangian Hessian and not the MPEC Langragian Hessian?

I never thought about it, but, the value of their gradients of these two Lagrangians match because of stationary (at least at S-stationary points - both are zero and we use this fact to backcompute mpec multipliers from NLP multipliers), but I am not sure do their Hesians match?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we? I am not sure what you mean by this. We pass here the MPCC objective and generic constraints and form the Lagrangian ourselves or also include the contribution form the MPCC multiplier. I suspect the Hessians do not match because the MPCC Lagrangian Hessian has no cross term contribution (though maybe in the limit they do?).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For SQPCC, and hence RTI we must use the Hessian of the MPEC Langragian (https://arxiv.org/pdf/2604.18432v1, Definition 4) -- or an approximation lof it, like GN, which is multiplier free.
Our solvers return MPCC solvers return NLP multipliers, hence the Lagrnagian and its derivative might be wrong.
The values of gradients of NLP Lagrangians of MPCC relaxations and MPEC Lagrangians may match at stationary points, but otherwise they dont.

In conclusion, when we already convexify a Hessian, it should be the MPEC Lagrangain Hessian but which requires MPEC multipliers which must be backcomputed from the homotopy solution.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the functions G and H are affine the Lagrangian Hessians match everywhere though right (as the hessian of an affine function is the null matrix).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But generally yes. We should use the MPCC Lagrangian.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. but all the other multipliers still do not match. Even if he contribution of G and H are zero, the two set of remaining multipliers do not match? The difference may be infused through the lifting constraints for nonlinear G or H, or something else.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... I must think about it. It is not clear to me that these are not also correct.

Comment thread src/nosnoc/qpcc.py
Comment thread src/nosnoc/qpcc.py
Comment thread src/nosnoc/rtopt/rti.py Outdated
Comment thread src/nosnoc/rtopt/rti.py
Comment thread src/nosnoc/rtopt/full_mpc.py Outdated
Comment thread src/nosnoc/qpcc.py Outdated
@apozharski
apozharski merged commit 83c5f72 into v1.0.0-rc Aug 18, 2026
2 checks passed
@apozharski
apozharski deleted the ap/rtopt branch August 18, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants