Figure 8.16: Quadratic placement problem
linewidth = 1;
markersize = 5;
fixed = [ 1 1 -1 -1 1 -1 -0.2 0.1;
1 -1 -1 1 -0.5 -0.2 -1 1]';
M = size(fixed,1);
N = 6;
A = [ 1 0 0 -1 0 0 0 0 0 0 0 0 0 0
1 0 -1 0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 -1 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 -1 0 0 0 0 0 0 0
1 0 0 0 0 0 0 -1 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 -1 0 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 -1
0 1 -1 0 0 0 0 0 0 0 0 0 0 0
0 1 0 -1 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 -1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 -1 0 0 0 0 0 0
0 1 0 0 0 0 0 0 -1 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0 0 0 -1 0
0 0 1 -1 0 0 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 -1 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0 -1 0 0 0
0 0 0 1 -1 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 -1 0 0 0 0 0
0 0 0 1 0 0 0 0 0 -1 0 0 0 0
0 0 0 1 0 0 0 0 0 0 0 -1 0 0
0 0 0 1 0 -1 0 0 0 0 0 -1 0 0
0 0 0 0 1 -1 0 0 0 0 0 0 0 0
0 0 0 0 1 0 -1 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0 0 -1 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 -1
0 0 0 0 0 1 0 0 -1 0 0 0 0 0
0 0 0 0 0 1 0 0 0 0 -1 0 0 0 ];
nolinks = size(A,1);
fprintf(1,'Computing the optimal locations of the 6 free points...');
cvx_begin
variable x(N+M,2)
minimize ( sum(square_pos(norms( A*x,2,2 ))))
x(N+[1:M],:) == fixed;
cvx_end
fprintf(1,'Done! \n');
free_sum = x(1:N,:);
figure(1);
dots = plot(free_sum(:,1), free_sum(:,2), 'or', fixed(:,1), fixed(:,2), 'bs');
set(dots(1),'MarkerFaceColor','red');
hold on
legend('Free points','Fixed points','Location','Best');
for i=1:nolinks
ind = find(A(i,:));
line2 = plot(x(ind,1), x(ind,2), ':k');
hold on
set(line2,'LineWidth',linewidth);
end
axis([-1.1 1.1 -1.1 1.1]) ;
axis equal;
title('Quadratic placement problem');
figure(2)
all = [free_sum; fixed];
bins = 0.05:0.1:1.95;
lengths = sqrt(sum((A*all).^2')');
[N2,hist2] = hist(lengths,bins);
bar(hist2,N2);
hold on;
xx = linspace(0,2,1000); yy = (4/1.5^2)*xx.^2;
plot(xx,yy,'--');
axis([0 1.5 0 4.5]);
hold on
plot([0 2], [0 0 ], 'k-');
title('Distribution of the 27 link lengths');
Computing the optimal locations of the 6 free points...
Calling SeDuMi: 174 variables (12 free), 108 equality constraints
------------------------------------------------------------------------
SeDuMi 1.1 by AdvOL, 2005 and Jos F. Sturm, 1998, 2001-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
Split 12 free variables
eqs m = 108, order n = 133, dim = 214, blocks = 55
nnz(A) = 335 + 0, nnz(ADA) = 1060, nnz(L) = 966
it : b*y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 7.62E+000 0.000
1 : 1.11E+001 2.07E+000 0.000 0.2722 0.9000 0.9000 1.83 1 1 1.6E+000
2 : 1.78E+001 5.03E-001 0.000 0.2426 0.9000 0.9000 0.88 1 1 4.4E-001
3 : 2.04E+001 2.17E-002 0.000 0.0432 0.9900 0.9900 0.96 1 1 2.0E-002
4 : 2.05E+001 5.56E-005 0.000 0.0026 0.9990 0.9990 1.00 1 1 5.1E-005
5 : 2.05E+001 2.16E-007 0.177 0.0039 0.9990 0.9990 1.00 1 1 2.0E-007
6 : 2.05E+001 4.32E-008 0.000 0.1999 0.9000 0.9000 1.00 2 2 4.0E-008
7 : 2.05E+001 8.88E-009 0.000 0.2055 0.9000 0.9000 1.00 2 2 8.1E-009
iter seconds digits c*x b*y
7 0.0 8.6 2.0547313604e+001 2.0547313551e+001
|Ax-b| = 1.6e-008, [Ay-c]_+ = 1.3E-009, |x|= 1.4e+001, |y|= 1.8e+001
Detailed timing (sec)
Pre IPM Post
2.003E-002 2.003E-002 1.001E-002
Max-norms: ||b||=1, ||c|| = 1,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 1.33546.
------------------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +20.5473
Done!