pympcc.solve

pympcc.solve(problem, strategy='scholtes', backend='ipopt', ipopt_options=None, solver_options=None, callback=None, inner_callback=None, time_limit=None, verbose=False, presolve=False, diagnostics=False, autoscale=False, b_stat_max_biactive=10, tnlp_refine=False, tnlp_max_iter=500, n_starts=1, perturb_scale=0.1, multistart_seed=0, n_jobs=1, **strategy_options)[source]

Solve an MPCC problem — convenience wrapper around MPCCSolver.

Parameters:
  • problem (MPCCProblem) – The MPCC problem instance.

  • strategy ({'direct', 'scholtes', 'smoothing', 'lin_fukushima', 'augmented_lagrangian', 'slack'}) – Reformulation strategy (default 'scholtes'). See MPCCSolver for a description of each option.

  • backend ({'ipopt', 'filterSQP', 'scipy'}, optional) – NLP backend solver (default 'ipopt'). 'filterSQP' requires the pyfiltersqp package and is incompatible with strategy='slack'. 'scipy' uses scipy.optimize.minimize with method='trust-constr' and requires no IPOPT installation.

  • ipopt_options (dict, optional) – IPOPT solver options (merged with package defaults). When backend='filterSQP' the common keys "tol" and "max_iter" are translated; IPOPT-specific keys are silently ignored.

  • solver_options (dict, optional) – Options forwarded directly to SQPSolver. Ignored when backend='ipopt'.

  • callback (callable, optional) – f(k: int, info: IterationInfo) -> None called after each outer iteration. Not called by the 'direct' strategy.

  • inner_callback (callable, optional) – f(iter_count: int, info: dict) -> bool invoked once per IPOPT inner iteration (every NLP solve, including each outer-loop NLP). info carries IPOPT’s intermediate arguments (alg_mod, obj_value, inf_pr, inf_du, mu, d_norm, regularization_size, alpha_du, alpha_pr, ls_trials). Return False to stop the current inner solve early; True (or None) to continue.

  • verbose (bool, optional) – If True and no callback is provided, prints a formatted progress table to stdout after each outer iteration (default False).

  • **strategy_options – Additional options for the strategy (e.g. epsilon_0, reduction, max_iter).

  • time_limit (float | None)

  • presolve (bool)

  • diagnostics (bool)

  • autoscale (bool)

  • b_stat_max_biactive (int)

  • tnlp_refine (bool)

  • tnlp_max_iter (int)

  • n_starts (int)

  • perturb_scale (float)

  • multistart_seed (int)

  • n_jobs (int)

Return type:

MPCCResult

Examples

Minimal call:

result = pympcc.solve(problem)

Use the filterSQP backend:

result = pympcc.solve(problem, backend='filterSQP')

Print progress after each outer iteration:

result = pympcc.solve(problem, strategy='scholtes', verbose=True)

Custom callback:

def my_cb(k, info):
    print(f"[{k}] obj={info.obj:.6f}  comp={info.comp_residual:.2e}")

result = pympcc.solve(problem, strategy='smoothing', callback=my_cb)

Enable verbose IPOPT output:

result = pympcc.solve(problem, ipopt_options={'print_level': 5})