I’ve got a script in which I set the cvx_solver just before defining the CVX problem, using the following line:
cvx_solver sedumi
I’ve noticed that when I modify the statement of the CVX problem in a way that results in an error (either syntactical or DCP), correct the error, and then try to run the script again, I get the following error:
Error using cvx_solver (line 54)
The global CVX solver selection cannot be changed while a model is being constructed.
The only way I’ve figured out to get rid of the error is to restart MATLAB. This strategy works, but it’s time-consuming and annoying. Is there a way that I can get rid of the error without closing out of MATLAB?
It seems that I somehow need to clear the model that was being constructed when the original error occurred. I tried
cvx_clear
but that didn’t do the trick.
As an aside, I am aware that I could simply set SeDuMi as the default solver and then I would no longer need the cvx_solver line in my script. However, I would eventually like to distribute this code, and I want to make sure that the users are using SeDuMi.