Get the (partially) condensed OCP problem size

Hi,
I am using the ocp_qp c interface and was wondering if there is a way to read out the actual problem size of the condensed problem.
The ocp_qp_dims struct on both the solver_in and solver_out only yields the original size.

Thanks!
Franek

Hi Franek,

you can get a pointer to the structure xcond_qp_in which holds the QP data after (partial) condensing doing something like this:

    xcond->memory_get(xcond, mem->xcond_memory, "xcond_qp_in", &mem->xcond_qp_in);

E.g., here acados/acados/ocp_qp/ocp_qp_xcond_solver.c at 5b4bc5614620c01b2ef57d9d70dd178162600075 · acados/acados · GitHub
However, this should be added to the QP solver interface properly, i.e. in interfaces/acados_c/ocp_qp_interface.c.

Best,
Jonathan

Thanks Jonathan for the hint!
If the selected solver is a partial condensing solver, I made use of the print_ocp_qp_dims function, to print out the condensed problems dimension:

  std::cout << " ---> Original problem dimensions: " << std::endl;
  print_ocp_qp_dims(ocp_dims_);
  std::cout << " <--- " << std::endl;

  if (solver < FULL_CONDENSING_HPIPM
      && condensing_N < MPC_PREDICTION_HORIZON) {  // Only for partial condensed solvers, and if condensed size
                                                   // different from original size:
    std::cout << " ---> Partial condensed problem dimensions: " << std::endl;
    print_ocp_qp_dims(((ocp_qp_in *)((ocp_qp_xcond_solver_memory *)qp_solver_->mem)->xcond_qp_in)->dim);
    std::cout << " <--- " << std::endl;
  }

For fully condensed solvers this doesn’t work and i also makes no sense, as there would be only one stage, right?

EDIT:
For fully condensed solvers, I added this to print out some infos similarly:

else if (solver >= FULL_CONDENSING_HPIPM) {  // For fully condensed solvers
    auto dense_dim = ((ocp_qp_full_condensing_memory *)qp_solver_->mem)->fcond_qp_in->dim;
    std::cout << " ---> Full condensed problem dimensions: " << std::endl;
    printf("k\tnv\t\tnb\tne\t\tng\tns\n");
    printf("0\t%d\t\t%d\t%d\t\t%d\t%d\t\n", dense_dim->nv, dense_dim->nb, dense_dim->ne, dense_dim->ng, dense_dim->ns);
    std::cout << " <--- " << std::endl;
  }

That looks good! :+1:
Great that you solved it!
Happy the hint helped. I see that for your purposes it would be nice to have more functionality interfaced properly for ocp_qp. However the main focus of current developments is on ocp_nlp interfaces.
Of course, contributions for ocp_qp are very welcome :slight_smile:

1 Like