Error Using Optimization with Integer Variables and Non-linear Constraints
Hi guys! I would be very grateful if you could help me!
I’m trying to minimize the norm of a vector using optimization algorithms in MATLAB, but I’m getting an error that says "Problems with integer variables and nonlinear equality constraints are not supported."
Could someone help me understand how I can solve this and minimize the norm of the vector?
Here’s the implemented code:
wpass = 0.0318*pi;
wstop = 0.15*pi;
pb_ripple = 0.03;
sb_ripple = 0.03;
n = 25;
l = 7;
k = 2^l;
N = 15*n;
w = linspace(0,pi,N);
A = [ones(N,1) 2*cos(kron(w’,1:n))];
Ap = A((0 <= w) & (w <= wpass),:);
As = A((wstop <= w) & (w <= pi),:);
H_dac=sinc(w);
H_dac_p=H_dac(1,(0 <= w) & (w <= wpass));
H_dac_s=H_dac(1,(wstop <= w) & (w <= pi));
h = optimvar(‘h’,(n+1), ‘Type’,’integer’,’LowerBound’,-inf,’UpperBound’,inf);
norm_h=optimvar(‘norm_h’,’Type’,’integer’);
prob = optimproblem(‘ObjectiveSense’,’minimize’);
prob.Constraints.cons1 = norm_h==norm(cat(1,h(end:-1:2),h),1);
prob.Objective = norm_h;
prob.Constraints.cons2 = Ap*h <= k*(1 + pb_ripple);
prob.Constraints.cons3 = Ap*h >= k*(1 – pb_ripple);
prob.Constraints.cons4 = As*h <= k*(sb_ripple);
prob.Constraints.cons5 = As*h >= -k*(sb_ripple);
sol = solve(prob);Hi guys! I would be very grateful if you could help me!
I’m trying to minimize the norm of a vector using optimization algorithms in MATLAB, but I’m getting an error that says "Problems with integer variables and nonlinear equality constraints are not supported."
Could someone help me understand how I can solve this and minimize the norm of the vector?
Here’s the implemented code:
wpass = 0.0318*pi;
wstop = 0.15*pi;
pb_ripple = 0.03;
sb_ripple = 0.03;
n = 25;
l = 7;
k = 2^l;
N = 15*n;
w = linspace(0,pi,N);
A = [ones(N,1) 2*cos(kron(w’,1:n))];
Ap = A((0 <= w) & (w <= wpass),:);
As = A((wstop <= w) & (w <= pi),:);
H_dac=sinc(w);
H_dac_p=H_dac(1,(0 <= w) & (w <= wpass));
H_dac_s=H_dac(1,(wstop <= w) & (w <= pi));
h = optimvar(‘h’,(n+1), ‘Type’,’integer’,’LowerBound’,-inf,’UpperBound’,inf);
norm_h=optimvar(‘norm_h’,’Type’,’integer’);
prob = optimproblem(‘ObjectiveSense’,’minimize’);
prob.Constraints.cons1 = norm_h==norm(cat(1,h(end:-1:2),h),1);
prob.Objective = norm_h;
prob.Constraints.cons2 = Ap*h <= k*(1 + pb_ripple);
prob.Constraints.cons3 = Ap*h >= k*(1 – pb_ripple);
prob.Constraints.cons4 = As*h <= k*(sb_ripple);
prob.Constraints.cons5 = As*h >= -k*(sb_ripple);
sol = solve(prob); Hi guys! I would be very grateful if you could help me!
I’m trying to minimize the norm of a vector using optimization algorithms in MATLAB, but I’m getting an error that says "Problems with integer variables and nonlinear equality constraints are not supported."
Could someone help me understand how I can solve this and minimize the norm of the vector?
Here’s the implemented code:
wpass = 0.0318*pi;
wstop = 0.15*pi;
pb_ripple = 0.03;
sb_ripple = 0.03;
n = 25;
l = 7;
k = 2^l;
N = 15*n;
w = linspace(0,pi,N);
A = [ones(N,1) 2*cos(kron(w’,1:n))];
Ap = A((0 <= w) & (w <= wpass),:);
As = A((wstop <= w) & (w <= pi),:);
H_dac=sinc(w);
H_dac_p=H_dac(1,(0 <= w) & (w <= wpass));
H_dac_s=H_dac(1,(wstop <= w) & (w <= pi));
h = optimvar(‘h’,(n+1), ‘Type’,’integer’,’LowerBound’,-inf,’UpperBound’,inf);
norm_h=optimvar(‘norm_h’,’Type’,’integer’);
prob = optimproblem(‘ObjectiveSense’,’minimize’);
prob.Constraints.cons1 = norm_h==norm(cat(1,h(end:-1:2),h),1);
prob.Objective = norm_h;
prob.Constraints.cons2 = Ap*h <= k*(1 + pb_ripple);
prob.Constraints.cons3 = Ap*h >= k*(1 – pb_ripple);
prob.Constraints.cons4 = As*h <= k*(sb_ripple);
prob.Constraints.cons5 = As*h >= -k*(sb_ripple);
sol = solve(prob); optimization, minimize MATLAB Answers — New Questions