I’m doing a simulation for MPC problem using osqp solver in two ways.

- using a class-based osqp solver
- using a mex solver generated from codegen of class-based osqp solver.

Firstly, the class-based osqp solver works really fine with good speed. Then, I generated a mex solver using codegen function of the osqp class and then applied it to the same problem. I used the exactly same setting for code generation. At this time, the solver speed was too slow. What I found so far is as follows:

Class-based solver returns solution within fairly small number of iteration. However, a mex solver, quite often but not always, returns the solution after the maximum iteration, 4000. I’m wondering why the mex solver has so slow convergence rate. Any big difference between the class-based osqp solver and a mex solver generated from codegen? How can I get the same solution from the two methods with same speeds?