# Optimizing constants applied to multiple vectors with multiple constraints

2 views (last 30 days)
Craig on 8 Jun 2020
Commented: Craig on 10 Jun 2020
Hello, I have 6 vectors given below. I would like to find two constants, a and b, such that:
1) the elements of sqrt( (a*U).^2 + (b*V).^2 ) are as small as possible (hopefully all with values < 0.8)
2) the elements of sqrt( (a*W).^2 + (b*X).^2 ) are as close to 1 as possible
3) the elements of sqrt( (a*Y).^2 + (b*Z).^2 ) are as large as possible (hopefully all with values > 1.2)
How would one go about setting up this problem to find the best a and b using the optimization toolbox?
Thanks for any assistance you can provide.
U = [0.255533929
0.225391099
0.309547494
0.654021159
0.620657919
0.702112095
1.191504738
1.209453366
1.211036147
1.045063574
1.047682214 ];
V = [0.711221344
0.480397832
0.855346308
0.641913032
0
0
0
0.450686486
0.886286133
0.377284731
0.715048781 ];
W = [0.703234145
0.661481123
0.680938355
1.348926117
1.213094284
1.227020665
1.373111841
1.764042991 ];
X = [1.232745135
1.357287095
1.28138892
0
1.209100227
1.266457293
0.505682363
0 ];
Y = [0.822623864
0.751947223
0.717610808
0.733428167
0.667499868
1.328856667
1.242252969
1.387983711
1.070372916
1.045063574
1.414452191
1.373461829
2.000592955 ];
Z = [2.07106942
1.593285407
1.602925001
1.970190532
1.732521225
2.181746415
1.062587656
3.489796952
0.886469414
0.377284731
1.234992392
1.826285175
0 ];
a = 1 / 1.556484554;
b = 1 / 1.560365817;
figure,
plot(sqrt( (a*U).^2 + (b*V).^2 ), 'go', 'MarkerFace', 'g')
hold on
plot(sqrt( (a*W).^2 + (b*X).^2 ), 'yo', 'MarkerFace', 'y')
plot(sqrt( (a*Y).^2 + (b*Z).^2 ), 'ro', 'MarkerFace', 'r')
grid on; grid minor

#### 1 Comment

Craig on 10 Jun 2020
Hi Alan, Thanks for taking a look. I am only allowed to change "a" and "b". I'm not sure how to write the optimization parameters to make:
sqrt((a*U).^2 + (b*V).^2 ) as small as possible
sqrt((a*Y).^2 + (b*Z).^2 ) as large as possible
and sqrt( (a*W).^2 + (b*X).^2 ) are as close to 1 as possible
all happening at the same time.
Hope that clarifies the issue. I do know how to minimize or maximize a function, or make it equal to a value, just not sure how to do all three at once.

Alan Weiss on 10 Jun 2020
I do not understand your question. What are you allowed to vary? Are there any constraints? I mean, why not just set all elements of U and V to zero?
Alan Weiss
MATLAB mathematical toolbox documentation