clc
clear all
close all

l=[100.000;100.000;100.080;200.040;200.000]

W_l=eye(5)

% l1+v1=x1
% l2+v2=x2
% l3+v3=x3
% l4+v4=x1+x2
% l5+v5=x2+x3

% v1-x1=-l1
% v2-x2=-l2
% v3-x3=-l3
% v4-x1-x2=-l4
% v5-x2-x3=-l5

B=[-1 0 0;0 -1 0;0 0 -1;-1 -1 0;0 -1 -1]
f=[-l(1);-l(2);-l(3);-l(4);-l(5)]

N=B'*W_l*B
t=B'*W_l*f
delta=inv(N)*t
v=f-B*delta

l_ajust=l+v

AD=delta(1)+delta(2)+delta(3)

