Case Study: ALADIN
Team 01
Whats waiting?
Slater's theorem provides a sufficient condition for strong duality to hold. Namely, if
1.)The primal problem is convex;
2.)It is strictly feasible, that is, there exists
where m is number of constraints, and n is dimention of x
What is infimum?🤔
What is infimum?🤔
Lowerbound!
What is infimum?🤔
Find the tightest lowerbound!
What is infimum?🤔
Gradient direction in the direction of increase in function.
What is infimum?🤔
Gradient direction in the direction of increase in function.
m is number of constraints
m is number of constraints
m is number of constraints
m is number of constraints
N subproblems can be solved in parallel
Can be carried out in parallel
Can be carried out in parallel
Can be carried out in parallel
Repeat till convergence
Agumented Lagrangian
Agumented Lagrangian
More Robust
Repeat till convergence
Repeat till convergence
Can be carried out in parallel
Can be carried out in parallel
Centralized
Can be carried out in parallel
Centralized
Solve NLP
Solve QP
Update
How QP?🤔
Augmented Lagrangian Based Alternating Direction Inexact Newton
Overview of ALADIN
Overview of ALADIN
Agumented Lagrangian
Overview of ALADIN
Solve NLPs of the form
In Parallel
For N subproblems, we should solve N different NLP's in parallel
Overview of ALADIN
Overview of ALADIN
Overview of ALADIN
Linear Approximation of Constraints,
Overview of ALADIN
Linear Approximation of Constraints,
Solve Coordinated QP.
(Centralized)
Overview of ALADIN
Linear Approximation of Constraints,
Solve Coordinated QP.
(Centralized)
Solve NLPs.
(Parallel)
Overview of ALADIN
Linear Approximation of Constraints,
Solve Coordinated QP.
(Centralized)
Solve NLPs.
(Parallel)
Update x and lambda
Unconstrained Newton Methods
Newton Methods
Newton Methods
Local Approximation
Around point x0
Newton Methods
Local Approximation
Around point x0
Newton Methods
Local Approximation
Around point x0
Newton Methods
Local Approximation
Around point x0
Newton Methods
1-D Updates
Newton Methods
1-D Updates
N-D Updates
Newton Methods
1-D Updates
N-D Updates
Newton Methods
1-D Updates
N-D Updates
If A is full Rank
Newton Methods
1-D Updates
N-D Updates
If A is full Rank
x update is simply solving a system of Linear Equation!
Newton Methods
1-D Updates
N-D Updates
If A is full Rank
x update is simply solving a system of Linear Equation!
Newton Methods
1-D Updates
N-D Updates
Remark!
Newton Iteration yields the roots, while Newton iteration on the first-order necessary conditions for optimality (of second-order approximation) of F yields a stationary point.
Sequential Quadratic Programming
First Order
Optimality Conditions
Root Finding Procedures can be invoked!
First Order
Optimality Conditions
Iteratively Solve till convergence
Sequential Quadratic Programming(SQP)
Sequential Quadratic Programming(SQP)
Equivalent Second-order Approximation of the Lagrangian
Equivalent First-order Approximation of the Constraints
ALADIN: A walkthrough
ALADIN: A walkthrough
Typicall Form of a distributed optimization problem
ALADIN: A walkthrough
Typicall Form of a distributed optimization problem
Other formulations can be casted into the above formulation by introducing auxiliary variables.
ALADIN: A walkthrough
Typicall Form of a distributed optimization problem
Other formulations can be casted into the above formulation by introducing auxiliary variables.
Box Constraint
Solvers, typically have spealized numerical routines to handle box constraints, which improves the efficiency of the solver
ALADIN: A walkthrough
Example Problem
ALADIN: A walkthrough
Example Problem
Non-Convex Constraints
ALADIN: A walkthrough
Example Problem
Non-Convex Constraints
ALADIN: A walkthrough
Example Problem
+
ALADIN: A walkthrough
Example Problem
+
ALADIN: A walkthrough
Example Problem
+
ALADIN: A walkthrough
Example Problem
ALADIN: A walkthrough
Example Problem
ALADIN: A walkthrough
Example Problem
ALADIN: A walkthrough
Example Problem
ALADIN: A walkthrough
Example Problem
Centralized Solution
ALADIN: A walkthrough
Example Problem
Centralized Solution
import casadi.*
x1 = SX.sym('x1');
x2 = SX.sym('x2');
nlp = struct('x', [x1;x2], 'f', 2*(x1 - 1)^2 + (x2 - 2)^2, 'g', x1 * x2);
S = nlpsol('S', 'ipopt', nlp);
sol = S('x0', [0, 0], 'lbg', -1, 'ubg', 1.5);ALADIN: A walkthrough
Example Problem
Distributed Optimization
To apply any distributed optimization, the objective function and constraints needs to be decoupled.
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Only in terms of x1
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Only in terms of x1
Only in terms of x2
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Only in terms of x1
Only in terms of x2
Complicating Constraint
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Only in terms of x1
Only in terms of x2
Complicating Constraint
A Complicating Constraint is a constraint that, if relaxed, the problem becomes decoupled
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Only in terms of x1
Only in terms of x2
Complicating Constraint
A Complicating Constraint is a constraint that, if relaxed, the problem becomes decoupled
Task: Decouple the Problem Formulation
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Use y21 as a "proxy" for y1 within subsystem 2
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Use y21 as a "proxy" for y1 within subsystem 2
To do this, set y1 to be equal to y21
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Without Loss of generality write,
Choose appropriate values of A1, A2,b
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Without Loss of generality write,
Take hint from dimentions
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Without Loss of generality write,
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Now we can write Constraints in terms of Proxy variable from subsystem 2
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Now we can write Constraints in terms of Proxy variable from subsystem 2
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Now we can write Constraints in terms of Proxy variable from subsystem 2
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Now we can write Constraints in terms of Proxy variable from subsystem 2
By setting a proxy variable, our constraints are now in terms of only y2. Hence the complicating constraint is removed with help of y1=y21
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Now we can write Constraints in terms of Proxy variable from subsystem 2
Only in terms of y2
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Now we can write Constraints in terms of Proxy variable from subsystem 2
Only in terms of y2
This kind of constraint is called affine coupling constraints/ Consensus constraints. They help us decompose the problem
Notice the extra set
of constraints
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
Now we can write Constraints in terms of Proxy variable from subsystem 2
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Task: Decouple the Problem Formulation
ALADIN: A walkthrough
Example Problem
Distributed Optimization
ALADIN: A walkthrough
Example Problem
Distributed Optimization
ALADIN: A walkthrough
Example Problem
Distributed Optimization
ALADIN: A walkthrough
Example Problem
Distributed Optimization
ALADIN: A walkthrough
Example Problem
Distributed Optimization
ALADIN: A walkthrough
Example Problem
Distributed Optimization
ALADIN: A walkthrough
Example Problem
Distributed Optimization
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Gradient of Objective
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Gradient of Objective
Hessian of Objective
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Solve
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Solve
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Solve
Constraints not active
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
gradient of objective
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
gradient of objective
hessian of objective
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
Casadi
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
ALADIN: A walkthrough
Example Problem
Distributed Optimization
Constraints not active
Updates
ALADIN: A walkthrough
Example Problem
Convergence
To find a suitable parameter w that can classify the input data into its label
N = number of input data
= dimension of input data
= number of subsystems
cap = capacity of each subsystem
gamma = hyperparameter
x, y = data ,label
= decison variable
L-2 Regularised Loss Function
N = number of sensors present in the network
is the unknown position of sensor 'i'
the estimated position of sensor 'i' by itself
the estimated position of sensor 'i+1' by sensor 'i'
estimated distance between sensor 'i' and it's neighbours.
DECOUPLED CASE
Each sensor takes a measurement of its position
COUPLED CASE
sensors additionally measure the distance to their neighbors
EQUIVALENCE FORMULATION
using Affine Coupling, the above constraint can be written as
COMPLETE FORMULATION OF
SENSOR LOCALIZATION PROBLEM
GENERALIZATION OF THE SENSOR MINIMIZATION PROBLEM
INITIAL ASSUMPTION
All the sensors present in the network are aligned along a circle
function [eta,eta_bar] = getEta(N, d, sigma)
% returns by sensor estimated initial position and distance to its neighbours
eta = zeros(d, N + 1);
eta_bar = zeros(1, N);
for i = 1 : N
eta( :, i ) = [N * cos(2 * i * pi / N) + normrnd(0, sigma) ; ...
N * sin(2 * i * pi / N) + normrnd(0, sigma)];
eta_bar(i) = 2 * N * sin( pi / N) + normrnd(0, sigma);
end
eta(:, N + 1) = eta(:, 1);
endIMPLEMENTATION OF THE OBJECTIVE FUNCTION AND INEQUALITY CONSTRAINTS IN MATLAB
function [F] = getObjective(N, y, eta, eta_bar, sigma)
% returns objective function for sensor network localization problem
F = zeros(N, 1);
F = sym(F);
F(:) = 1 / (4 * sigma^2) * ((y(1, :) - eta(1, 1 : N)).^2 + (y(2, :) - eta(2, 1 : N)).^2) ...
+ 1 / (4 * sigma^2) * ((y(3, :) - eta(1, 2 : end)).^2 + (y(4, :) - eta(2, 2 : end)).^2) ...
+ 1 / (2 * sigma^2) * (sqrt((y(1, :) - y(3, :)).^2 + (y(2, :) - y(4, :)).^2) - eta_bar(:)').^2;
end
function [H] = getInequalityConstr(N, y, eta_bar)
%GETINEQUALITYCONSTR retruns inequality constraint of sensor network
%localization probelm
H = zeros(N, 1);
H = sym(H);
H(:) = (sqrt((y(1, :) - y(3, :)).^2 + (y(2, :) - y(4, :)).^2) - eta_bar(:)').^2;
end
IMPLEMENTATION OF THE COUPLING CONSTRAINTS
IMPLEMENTATION OF THE COUPLING CONSTRAINTS
function [AA] = getCouplingMatrix(N, n)
% GETCOUPLINGMATRIX returns the coupling matrix of sensor network
% localization problem
I = [1, 0; 0, 1];
A0 = zeros(2*N, n);
A_1 = A0;
A_1(1:2, 3:4) = I;
A_1(2*N - 1: 2*N, 1:2) = -I;
AA(1) = mat2cell(A_1, 2 * N, n);
for i = 2 : 1 : N
A_i = A0;
A_i(2*(i-2) + 1 : 2*(i-2) + 2, 1:2) = -I;
A_i(2*i - 1: 2*i, 3:4 ) = I;
AA(i) = mat2cell(A_i, 2*N, n);
end
endTHE START VECTOR DEFINITION
function [zz0] = getStartValue(N, sigma)
%GETSTARTVALUE returns a start value for ALADIN opimization
initial_position = zeros(2, N);
for i = 1 : N
initial_position(1, i) = N * cos( 2 * i * pi / N ) + normrnd(0, sigma);
initial_position(2, i) = N * sin( 2 * i * pi / N ) + normrnd(0, sigma);
end
zz0 = cell(1, N);
for i = 1 : N-1
zz0(i) = {[initial_position(:, i); initial_position(:, i + 1)]};
end
zz0(N) = {[initial_position(:, N); initial_position(:, 1)]};
endSETTTING UP AN ALADIN SOLVER
function [sProb ] = setupSolver(N, sigma)
% general setup
n = 4; % dimension of design variables
d = 2; % dimension of coordinate system
% initialization of variables
y = sym('y%d%d', [N n], 'real');
y = y';
% get estimated initial positions
[eta, eta_bar] = getEta(N, d, sigma);
% definition of objective functions
F = getObjective(N, y, eta, eta_bar, sigma);
% definition of inequality constraint
H = getInequalityConstr(N, y, eta_bar);
% definition of counpling matrices
AA = getCouplingMatrix(N, n);
% start value for optimization
zz0 = getStartValue(N, sigma);
%% setting up solver
% set search area
sProb.llbx = cell(1, N);
sProb.uubx = cell(1, N);
for i = 1 : N
sProb.llbx(i) = mat2cell([-inf; -inf; -inf; -inf], 4, 1);
sProb.uubx(i) = mat2cell([ inf; inf; inf; inf], 4, 1);
end
% handover of functions
sProb.locFuns.ffi = cell(1, N);
sProb.locFuns.hhi = cell(1, N);
for i = 1 : N
sProb.locFuns.ffi(i) = {matlabFunction(F(i), 'Vars', {y(:, i)})} ;
sProb.locFuns.hhi(i) = {matlabFunction(H(i), 'Vars', {y(:, i)})} ;
end
sProb.AA = AA;
sProb.zz0 = zz0;
PERFORMING RUNTIME ANALYSIS FOR COMPARISON
clear all
N = [5, 10, 15 , 20, 25, 30, 35, 40, 50, 60, 70, 80, 90, 100];
sigma = [0.5, 1, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5];
opts.maxiter = 5;
time = zeros(2, length(N));
for i = 1 : length(N)
sProb = setupSolver(N(i), sigma(i));
opts.parfor = 'true';
time_parfor = tic;
sol = run_ALADIN(sProb, opts);
time(1, i) = toc(time_parfor);
time_for = tic;
opts.parfor = 'false';
sol = run_ALADIN(sProb, opts);
time(2, i) = toc(time_for);
end
figure
plot(N, time(1, :))
title('runtime analysis')
hold on
plot(N, time(2, :))
hold off
legend('time parfor', 'time for')
xlabel('number of sensors')
ylabel('time [s]')THE OUTPUT OBTAINED AS THE RESULT