Skip to content

Conversation

@apozharski
Copy link
Member

Part 1 of the work to make LCQPow easier to use as a sub-solver. This PR (mostly) doesn't touch the core algorithm and just provides an interface for matlab which allows creating LCQProblem objects, e.g.:

Q = diag([2,2]); g = [-2;-2]; L = [1 0]; R = [0 1];
prob = LCQProblem(2,0,1);
opts = LCQPow_options;
prob.loadLCQP(Q, g, L, R, [], [], [], [], [], [], [], [], [], opts);
[x,y,stats] =  prob.runProblem(); 

This uses the modern (since R2017b) C++ library for creating .mex interfaces (though it has only been tested on >=R2023b), and a casADi style pointer to "self" in each object to store the underlying pointer to the LCQProblem C++ object.

There are a few things that still should be (and will be in part 2,3,4,...) cleaned up, namely a more maintainable CMakeLists.txt for the interface targets, unifying indentation (there is a bunch of tabs vs spaces conflicts), and some memory handling improvements to reduce the number of copies that need to happen to load problem data and pass it to the QP solvers.

I don't know what detail you want to look at this in @hallfjonas, but I figured I shouldn't just start pushing directly to main 😄

(updated this to a PR from a branch in this repo so the fork can be deleted).

@hallfjonas hallfjonas self-requested a review April 15, 2025 16:38
@hallfjonas
Copy link
Collaborator

Nice work in general! Would love to merge this PR.

However, I have some issues running this. I ran your example from above to test the matlab interface. Here is my error message:

Error using LCQProblem/loadLCQP
Invalid MEX-file '/home/jonas/LCQPow/build/lib/@LCQProblem/loadLCQP.mexa64': /usr/local/MATLAB/R2021b/bin/glnxa64/../../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.26' not found (required by
/home/jonas/LCQPow/build/lib/@LCQProblem/loadLCQP.mexa64)

Anything I need to do in the build process?
FYI, using R2021b.

@apozharski
Copy link
Member Author

Ah this actually has little to do with the matlab version and more to do with the fact that Mathworks in their infinite wisdom ships their own (old) version of libstdc++ instead of using the system one. One way would be to change the build system to link against the libstdc++ shipped with matlab (though in my opinion this is a bad idea). The way that I work around this (and have for a while because the casadi matlab interface has the same issue if built from source) is by setting the following environment variable before launching matlab:

LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libstdc++.so.6"

This is a known issue with many matlab interfaces including e.g. IPOPT: https://list.coin-or.org/pipermail/ipopt/2013-July/003429.html

@hallfjonas
Copy link
Collaborator

Okay, great! That resolved it. I think we should update the README file with those changes before merging. Would you be willing to update that section?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants