Skip to content

Commit

Permalink
fixed small bug in SCMPC where single slacks were not substituted in …
Browse files Browse the repository at this point in the history
…constraints
  • Loading branch information
FilippoAiraldi committed Nov 4, 2024
1 parent a81ca0e commit 0e8b72f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/csnlp/multistart/multistart_nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ def _chained_subevalf(
) -> Union[SymType, cs.DM, np.ndarray]:
"""Internal utility to perform :func:`subevalf` on variables, dual variables and
parameters in chain."""
expr = subsevalf(expr, old_vars, new_vars, eval=False)
if old_dual_vars is None:
return subsevalf(expr, old_pars, new_pars, eval=eval)
expr = subsevalf(expr, old_pars, new_pars, eval=False)
return subsevalf(expr, old_dual_vars, new_dual_vars, eval=eval)
if old_dual_vars is not None and old_dual_vars:
expr = subsevalf(expr, old_dual_vars, new_dual_vars, False)
if old_vars:
expr = subsevalf(expr, old_vars, new_vars, False)
if old_pars:
return subsevalf(expr, old_pars, new_pars, eval)
return cs.evalf(expr) if eval else expr


def _cmp_key(sol: dict[str, Any]) -> tuple[bool, bool, float]:
Expand Down
2 changes: 2 additions & 0 deletions src/csnlp/wrappers/mpc/scenario_based_mpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ def constraint_from_single(
self.states_i(i),
self.single_disturbances,
self.disturbances_i(i),
self.single_slacks,
self.slacks_i(i),
eval=False,
)

Expand Down

0 comments on commit 0e8b72f

Please sign in to comment.