Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is a good way to adjust both parameters of a convex optimization problem? #26

Closed
KarryMa opened this issue Jun 4, 2024 · 1 comment

Comments

@KarryMa
Copy link

KarryMa commented Jun 4, 2024

Here is my matlab code, cvx objective function has two regularization parameters tau1 and tau2. I need to set appropriate tau1 and tau2 values to make re1 and re2 small enough (minimum would be best). I have tried many, many values, including using the for loop, but still can't get the best re1 and re2 results. Is there another way (e.g. intelligent algorithms) to find the right parameters? Thank you very much!

clc;clear
n = 128;
m = 64;
i_s = floor(m*0.05);
i_c = i_s;
x0 = zeros(n,1);
x10_spt = randperm(n);
x0(x10_spt(1:i_c)) = randn(i_c,1);
v0 = zeros(m,1);
v0_spt = randperm(m);
v0(v0_spt(1:i_c)) = randn(i_c,1);
Phi = 1/sqrt(m) * randn(m,n);
data = real(Phi * x0);
N = 200;
p = (1+data)/2;
s0 = rand(numel(data),N);
P = repmat(p,1,N);
s = P > s0;
s1 = sum(s,2);
s2 = s1/N;
edata = 2*s2-1;
y = edata + v0 ;
% these two parameters I need to tune, I have tried for loop, but can't get
% good results of re1 and re2
tau1=0.01; 
tau2=0.01;
% Recovery via CVX
cvx_begin quiet

variable x(n) ;
variable v(m);
minimize 0.5*pow_pos(norm(y - Phi * x - v),2) + tau1 * norm(x,1) + tau2 * norm(v,1);

cvx_end
re1 = norm(x - x0, 2)/ norm(x0, 2)
re2 = norm(v - v0, 2)/ norm(v0, 2)
% how to find the optimal tau1 and tau2,then re1 and re2 are minimum respectively 
@aszekMosek
Copy link

This is not an issue/bug in CVX but a general modeling question for which a better venue would be https://or.stackexchange.com/search?tab=newest&q=mosek or https://math.stackexchange.com/search?tab=newest&q=mosek or some forum corresponding to the real-world domain your model is representing.

@KarryMa KarryMa closed this as completed Jun 13, 2024
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

No branches or pull requests

2 participants