Distributed Optimization
Case Study: ALADIN
- Aadharsh Aadhithya A
- Abhinesh S
- Akshaya J
- Jayanth Mohan
- Vishnu Radhakrishnan
Team 01
- Duality
- Dual Ascent
- Dual Decomposition
- Method of Multipliers (MM)
- ADMM
- Parallel ADMM
- ALADIN: Overview
- ALADIN: A Walkthrough
- Case Study: ALADIN for Sensor Network Localization
- Case Study: ALADIN for learning problems
Whats waiting?

Duality
principle of duality states that any optimization problems can be viewed from either of the two perspectives, the primal form or the dual form. If the primal is a minimization problem then the dual is a maximization problem and vice-versa.
Duality Principle

Duality gap represents the difference between the values obtained on solving the primal form and the solution obtained on solving the dual for of the same optimization problem.
DUAL GAP
Solving an optimization problem in it’s dual form is more preferable that solving it in it’s dual form because, The dual problem is always a convex optimization problem, even if the problem is not convex in it’s primal form.
Why Dual form?
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
Slater's sufficient condition for strong duality
Dual Ascent
Dual Ascent
- Based on the fact that dual problem is always convex/concave
Dual Ascent
- Based on the fact that dual problem is always convex/concave
- Solving the dual problem, helps us iteratively drive the primal towards optimality.
Dual Ascent
- Based on the fact that dual problem is always convex/concave
- Solving the dual problem, helps us iteratively drive the primal towards optimality.
Dual Ascent
- Solving the dual problem, helps us iteratively drive the primal towards optimality.
Dual Ascent
where m is number of constraints, and n is dimention of x
Dual Ascent
What is infimum?🤔
Dual Ascent
What is infimum?🤔
Lowerbound!
Dual Ascent
What is infimum?🤔
Find the tightest lowerbound!
Dual Ascent
What is infimum?🤔
Gradient direction in the direction of increase in function.
Dual Ascent
What is infimum?🤔
Gradient direction in the direction of increase in function.
Dual Ascent

Dual Ascent

Dual Ascent

Dual Ascent

Dual Ascent

Dual Ascent

Repeat till Convergence

Dual Decomposition
Dual Decomposition
Dual Decomposition
Dual Decomposition
m is number of constraints
Dual Decomposition
m is number of constraints
Dual Decomposition
m is number of constraints
Dual Decomposition
m is number of constraints
Dual Decomposition
Dual Decomposition
N subproblems can be solved in parallel
Dual Decomposition
Dual Decomposition
Dual Decomposition
Can be carried out in parallel
Dual Decomposition
Can be carried out in parallel
Dual Decomposition
Can be carried out in parallel
Repeat till convergence
Method Of Multipliers
Method Of Multipliers
Method Of Multipliers
Method Of Multipliers
Agumented Lagrangian
Method Of Multipliers
Agumented Lagrangian
More Robust
Method Of Multipliers
Method Of Multipliers
Method Of Multipliers
Repeat till convergence
ADMM
ADMM
ADMM
ADMM
ADMM
ADMM
ADMM
ADMM
ADMM
ADMM
ADMM
Repeat till convergence
Parallel ADMM
Parallel ADMM
Parallel ADMM
Parallel ADMM
Parallel ADMM
Parallel ADMM
Parallel ADMM
Parallel ADMM
Can be carried out in parallel
Parallel ADMM
Can be carried out in parallel
Centralized
Parallel ADMM
Can be carried out in parallel
Centralized
Solve NLP
Solve QP
Update
How QP?🤔
ALADIN
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

Application of ALADIN in "Classification Problems in Machine Learning"
Problem Goal
To find a suitable parameter w that can classify the input data into its label
Problem Setup
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
Loss Function
L-2 Regularised Loss Function
Input Data
- ML_data.mat
- In this example we have have taken 10 subsystems

Implementation Using Aladin-



Algorithm Convergence

Inference
- ALADIN converges after 5 iterations
- As observed in the graph the y residue log|Ax-b| converges to a value
- As we proceed in the iterations the value of x does not chnage
Application of ALADIN in "Sensor Network Localization"
Problem SETUP
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

ALADIN
By aie'24 amrita
ALADIN
- 495