leap_c.diff_mpc.utils.solve

Functions

solve_with_retry(→ tuple[numpy.ndarray, dict[str, float]])

Solve a batch of problem instances, and retry in case of failure.

Module Contents

leap_c.diff_mpc.utils.solve.solve_with_retry(batch_solver: acados_template.acados_ocp_batch_solver.AcadosOcpBatchSolver, initializer: leap_c.diff_mpc.initializer.AcadosDiffMpcInitializer, ocp_iterate: acados_template.acados_ocp_iterate.AcadosOcpFlattenedBatchIterate | None, solver_input: leap_c.diff_mpc.data.AcadosOcpSolverInput) tuple[numpy.ndarray, dict[str, float]][source]

Solve a batch of problem instances, and retry in case of failure.

This function prepares the batch solver by loading the iterate, setting the initial conditions, and configuring the global and stage-wise parameters. If p_global or p_stagewise is not provided, it will check if the model has default parameters and load them accordingly.

Parameters:
  • batch_solver – The batch solver to use.

  • initializer – The initializer used for retries.

  • ocp_iterate – The iterate to load into the batch solver.

  • solver_input – Input data for the solver, which includes initial conditions and parameters.

Returns:

The status of each solver (status != 0 means failure) and statistics of the solving process, i.e., “solving_time”, “success_rate”, and “retry_rate”.