GalacticDynamics-Oxford / Agama

Action-based galaxy modeling framework
Other
76 stars 38 forks source link

RuntimeError: Error in solveOpt(): quadraticOptimizationSolve not implemented #10

Closed madmanofmadness closed 3 years ago

madmanofmadness commented 3 years ago

I get this error when trying to solve matrix equation for orbit weights. I installed agama using 'python setup.py install --user' and successfully installed optional packages including CVXOPT.

eugvas commented 3 years ago

did you install Agama using the setup.py script? it should have checked for CVXOPT and install it if needed, or complained otherwise (but the installation would have continued). What happens if you try to import cvxopt in python? do you have more than one python version in the system? - sometimes they could be mixed up

madmanofmadness commented 3 years ago

Yes, I installed Agama using the setup.py script. I tried to reapeat the installation process to see if I had missed installing CVXOPT, but there were no prompts. I even tried installing it separately using 'pip install cvxopt' but it says 'Requirement already met' (probably means CVXOPT is installed). If I try to import CVXOPT, Spyder tells me 'cvxopt is imported but unused', and the error still occurs. Also I have only 1 version of python installed (Python3.8).

madmanofmadness commented 3 years ago

image Actually you're right, the setup.py script does complain about a missing cvxopt.h header file

eugvas commented 3 years ago

right, so the CVXOPT Python module is found by the setup script, and now it downloads the C header files. Does the file Makefile.local contain "-DHAVE_CVXOPT" among COMPILE_FLAGS? And does the folder "extras/include" contain the files cvxopt.h, blas_redefines.h? if no, the setup script should have complained about some problems during downloading..

madmanofmadness commented 3 years ago

yes, '-DHAVE CVXOPT' is present under COMPILE_FLAGS, and both header files are also there

madmanofmadness commented 3 years ago

Great, so the runtime error is gone now. Thanks for the help.

eugvas commented 3 years ago

hmmm... so what has changed since the first failed attempt?..

madmanofmadness commented 3 years ago

I would say it was the missing header file, I just restarted anaconda after rerunning the setup.py script and the code was running. But oddly enough the error still persists in my laptop even though the header file is present under'extras/include' and '-DHAVE CVXOPT' is present under COMPILE_FLAGS. I should point out that when I reran the setup.py script, it asked me to use either reuse the present makefile or make a new one, and I instructed it to make a new one. I'll try doing the same thing in my laptop and see what happens.

madmanofmadness commented 3 years ago

Actually, that did not fix the error on my laptop. But the error has been fixed on my desktop pc... hmm...

eugvas commented 3 years ago

this is strange indeed. Just to double-check that when compiling the C++ library, the g++ command line for math_optimization.cpp contained arguments "-DHAVE_PYTHON" and "-DHAVE_CVXOPT" ? and that you are importing the new version of compiled library in your python script (in particular, agama.version contains today's date).

madmanofmadness commented 3 years ago

I do not see the argument '-DHAVE_PYTHON', but '-DHAVE_CVXOPT' is there. Also I'm not sure how to check the version, typing into the python console returns 'there is no attribute version'

eugvas commented 3 years ago

ok this is the problem (lack of HAVE_PYTHON) - because of this, CVXOPT is also disabled in the C++ library. But I'm puzzled as to how this could have happened, given that you used the python setup script and are able to load Agama as a python module! what if you manually add -DHAVE_PYTHON to COMPILE_FLAGS in Makefile.local? to check version, type print(agama.__version__) (sorry the underscores got eaten in the previous message)

madmanofmadness commented 3 years ago

ok so on the laptop print(agama.__version__) returns an old date, april 22 to be specific (april 25 for the desktop pc). And actually I was mistaken about '-DHAVE_PYTHON' missing in the g++ command line (my bad), I just totally missed it. So I think importing the old version of the module is to blame here maybe.

madmanofmadness commented 3 years ago

The solution that worked for me was uninstalling agama using pip then installing again from scratch using setup.py script. Hope this helps somebody else in the future