Matlab taking too much time to give output
19 views (last 30 days)
I'm solving a convex optimization problem which has to minimize a variable matrix of 498x498 size. As I run it, it is taking forever to give final value of x. When I terminate the process in between it shows like this
my code is
function f= coheren(x)
Z = (D)*(D');
a = mtimes(U,V');
b = mtimes(V,U);
f = (norm(U-(a*(x')*(x)*b)))^2;
function [c,ceq] = cohcon(x)
k = D*(D');
T = (x)*k*(x');
ceq = rank(U1)-m;
Walter Roberson on 30 May 2018
Never load() inside a cost function. Load the data outside the function and pass the data in.
In your case, for coheren(), you could pre-calculate U, a, and b, and pass those all in. For cohcon, you could pre-calculate k = D*(D') and pass that in.
Aakash Deep on 31 May 2018
Solving a convex optimization problem is a big task. Yes, it can take a long time to converge. You can not minimize the time of the algorithm but what you can do is, you can change your converging threshold.
As you know, the convergence plot of convex optimization problem decrease exponentially and hence the major components are already gets covered in the starting. So, you can give a threshold (try to keep the threshold at or below 0.1) such that whenever your error value gets below the threshold then stop the algorithm.
Rishabh Rathore on 4 Jun 2018
Edited: Rishabh Rathore on 4 Jun 2018
For the convergence problem, the upper bound could be used on the number of iterations, as suggested by Aakash. As for the problem with size of array being too large, Tall arrays could be used to overcome the issue as Tall arrays are not loaded in the memory at once.
You could refer:- Tall Arrays
Note:- the computation would take time since the size of the data to be manipulated and the number of calculations to be performed is very high.