FINAL PROJECT
Franklin Pacheco
Spring 2015
Executive Summary
This project aims to explain alternative optimization methods that can be used in smart grids.
The specific application in this project was to determine the better option of energy
distribution minimizing the cost to provide energy from different sources to different loads
considering constraints in the demand, supply capabilities and capacity of each power link.
Table of Contents
Introduction .......................................................................................................................... 1
KarushKuhnTucker conditions................................................................................... 5
5.2
Conclusions ......................................................................................................................... 10
Bibliografa .......................................................................................................................... 10
Annexes ............................................................................................................................... 11
8.1
Genetic Algorithms.............................................................................................................. 14
Introduction
Smart grid generally refers to a class of technology people are using to bring utility electricity
delivery systems into the 21st century, using computer-based remote control and automation.
These systems are made possible by two-way communication technology and computer
processing that has been used for decades in other industries. They are beginning to be used
on electricity networks, from the power plants and wind farms all the way to the consumers of
electricity in homes and businesses. They offer many benefits to utilities and consumers mostly
seen in big improvements in energy efficiency on the electricity grid and in the energy users
homes and offices. (Office of Electricity Delivery & Energy Reliability, n.d.)
In a smart grid, the concept of optimization is involved in different aspects as is shown in
Figure 1.
One specific aspect to work in this work is the optimization in distribution, minimizing
the cost to connect different loads with available sources. The determination of the best
network topology can help in a network self-healing.
The self-healing grid isolates problems immediately as they occur, before they cascade
into major blackouts, and reorganizes the grid and reroutes energy transmissions so
services continue for all customers while the problem is physically repaired by line
crews. A self-healing smarter grid can provide a number of benefits that lead to a more
stable and efficient system. (Amin, 2013).
I pretended to determine the best alternative to deliver energy to different demand sites
from different supply sources when there are different constraints. Even though the
exercise seemed to be very simple, the idea was to identify how difficult it could be
when the design space is affected by a considerable number of constraints.
The design of the objective function was based in the paper Optimization Models for
Energy Reallocation in Smart Grid of Nygard et al.
Figure 2. A bipartite graph with supply and demand nodes. (Nygard, Ghosn, Minhaz, & Ranganathan, 2011)
Subject to :
I
x
i =1
ij
x
j =1
ij
dj
for all j
sj
for all i
0 xij uij
Solution Methods
In the document consulted the purpose is to define the optimization models, the authors
do not resolve a numerical value example. They use a smart grid simulator which runs
as a Multi-Agent System (MAS) using the Java Agent Development Framework
(JADE). Hence, in this project I decided to solve a basic problem considering 2 sources
and 3 loads utilizing different optimization methods.
1
30 KW
35 KW
2
25 KW
25 KW
3
25 KW
25 KW
The problem was solved utilizing Mathcad and defining some vectors for easier
manipulation of the values:
50
s :=
80
4
4
1
C :=
5
4
5
20
d := 30
40
x11
x12
x13
X( x11 , x12 , x13 , x21 , x22 , x23) :=
x21
x22
x23
30
25
25
u :=
35
25
25
z( x11 , x12 , x13 , x21 , x22 , x23) := C X( x11 , x12 , x13 , x21 , x22 , x23) 4 x11 + 4 x12 + 5 x21 + x13 + 4 x22 + 5 x23
Constraints:
g1( x11 , x12 , x13 , x21 , x22 , x23) := x11 x21 + d
g2( x11 , x12 , x13 , x21 , x22 , x23) := x12 x22 + d
g3( x11 , x12 , x13 , x21 , x22 , x23) := x13 x23 + d
0
1
2
g4( x11 , x12 , x13 , x21 , x22 , x23) := x11 + x12 + x13 s
g5( x11 , x12 , x13 , x21 , x22 , x23) := x11 + x12 + x13 s
g6( x11 , x12 , x13 , x21 , x22 , x23) := x11 u
g7( x11 , x12 , x13 , x21 , x22 , x23) := x12 u
g8( x11 , x12 , x13 , x21 , x22 , x23) := x13 u
g9( x11 , x12 , x13 , x21 , x22 , x23) := x21 u
4
5
1
1
0
0
A := 0
0
0
1
0
0
0
0
0
0 1 0
1 0
0
0
0
0
0
0
1
0
0
0
0
1
0
0 1 0
0 1 0
1 0
0 1 0
0 1 0
0 1
d0
d1
d2
s
0
s
1
u 0
u 1
u
b := 2
u3
u
4
u
5
0
0
0
0
0
0
Applying operations the objective is to obtain the identity matrix in the upper left side
and vector 0 below it:
Since the solution performed manually took very long, there is an easy way to perform
this calculation in Matlab. The code implemented was using the function linprog:
clear
clc
c=[4;4;1;5;4;5];
A=[-1,0,0,-1,0,0;...
0,-1,0,0,-1,0;...
0,0,-1,0,0,-1;...
1,1,1,0,0,0;...
1,1,1,0,0,0;...
1,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,1,0;...
0,0,0,0,0,1];
b=[-20;-30;-40;50;80;30;25;25;35;25;25];
lb = zeros(6,1);
x=linprog(c,A,b,[],[],lb);
x
Which are the same results obtained with the KKT conditions.
As we can see, even though the objective function was simple, the addition of many
constraints makes the problem very difficult to manage manually. In this cases it is
possible to see the importance of software tools that help to solve this kind of problems.
Trying to find other methods of optimization, I looked to population methods such as
Particle Swarm optimization, since I learned the application of those in an unconstraint
situation, I did not applied them to the current problem. However, I explain the work
performed with them in the Annexes section.
Conclusions
Bibliografa
Amin, M. (March de 2013). The Self-healing Grid: A Concept Two Decades in the Making .
Obtenido de IEEE Smart Grid: http://smartgrid.ieee.org/march-2013/813-the-selfhealing-grid-a-concept-two-decades-in-the-making
Capehart, B. L., C., T. W., & J., K. W. (2011). Guide to Energy Management. Lilburn: The
Fairmont Press, Inc.
Chong, E. K., & H., Z. S. (2014). Introduction to Optimization. Hoboken, New Jersey: John Wiley
& Sons, Inc.
Chrysler. (September de 2014). FCA Fiat Chrysler Automobiles. Obtenido de
http://media.chrysler.com/newsrelease.do;jsessionid=DC5AA8835CCCE16CA887FB5B5
94A6D7F?&id=328&mid=
Nygard, K. E., Ghosn, S. B., Minhaz, M., & Ranganathan, P. (2011). Optimization Models for
Energy Reallocation in a Smart Grid. IEEE INFOCOM 2011 Workshop on M2MCN-2011,
186-190.
Office of Electricity Delivery & Energy Reliability. (s.f.). Smart Grid. Recuperado el 12 de April
de
2015,
de
Energy.gov:
http://energy.gov/oe/services/technologydevelopment/smart-grid
Vedenyov, M. (15 de June de 2011). Travelling salesman problem with Genetic algorithm.
Recuperado
el
09
de
April
de
2015,
de
Mathworks:
http://www.mathworks.com/matlabcentral/fileexchange/31818-travelling-salesmanproblem-with-genetic-algorithm
Wikipedia. (s.f.). Wipedia. Obtenido de www.wikipedia.org
10
Annexes
In this section it is included additional work and research performed during the
realization of the present project.
8.1 Particle Swarm Optimization
It is a computational method that optimizes a problem by iteratively trying to improve a
candidate solution with regard to a given measure of quality. PSO optimizes a problem
by having a population of candidate solutions, here dubbed particles, and moving these
particles around in the search-space according to simple mathematical formulae over the
particle's position and velocity. Each particle's movement is influenced by its local best
known position but, is also guided toward the best known positions in the search-space,
which are updated as better positions are found by other particles. This is expected to
move the swarm toward the best solutions. (Wikipedia, n.d.).
PSO Algorithm
I implemented this algorithm in Matlab to obtain the global minimum of a function known as
the Griewank only in 2D with learning purposes.
The function for a 2D Griewank is:
f ( x1 , x2) := 1 +
1
4000
clear
clc
clf
syms x
f=@(x1,x2) 1+1/4000*(x1^2+x2^2)-cos(x1/sqrt(1))*cos(x2/sqrt(2));
xlabel('x_1');
ylabel('x_2');
title('part b');
X1 = [-5:.1:5]';
X2 = [-5:.1:5]';
[x1,x2]=meshgrid(X1',X2');
func= 1+1/4000*(x1.^2+x2.^2)-cos(x1/sqrt(1))*cos(x2/sqrt(2));
subplot(1,2,1);
mesh(x1,x2,func);
subplot(1,2,2);
contour(x1,x2,func,10);
while(norm(g)>0.1)
best(k)=min(fx);
worst(k)=max(fx);
average(k)=mean(fx);
for i=1:d
r(:,i)=rand(2,1);
s(:,i)=rand(2,1);
end
w=0.95;
c1=2;
c2=2;
for i=1:d
Vnext(:,i)=w*V(:,i)+c1*r(:,i).*(p(:,i)-X(:,i))+c2*s(:,i).*(gX(:,i));
Vnext(1,i)=min(vmax,max(-vmax,(Vnext(1,i))));
Vnext(2,i)=min(vmax,max(-vmax,(Vnext(2,i))));
end
Xnext=X+Vnext;
12
for i=1:d
fnext(i)= f(Xnext(1,i),Xnext(2,i));
fpbest(i)=f(p(1,i),p(2,i));
if fnext(i)<fpbest(i)
pnext(:,i)=Xnext(:,i);
else
pnext(:,i)=p(:,i);
end
end
[fmin,pos]=min(fnext);
if fmin<f(g(1),g(2))
gnext=Xnext(:,pos);
else
gnext=g;
end
drawnow;
hold on;
plot(g(1),g(2),'x');
%plot(X(1,:),X(2,:),'x');
k=k+1;
X=Xnext;
V=Vnext;
g=gnext;
p=pnext;
fx=fnext;
end
x1star=g(1);
x2star=g(2);
fprintf('The value of x that minimizes f is: [%.5f , %.5f]\n', x1star,
x2star)
fprintf('The number of iterations is: %d\n',k)
Knowing that the global minimum is x= [0,0]T. The exit criteria used was that the norm of the
global best less than 0.1
The results were:
13
Genetic Algorithms
It is a search heuristic that mimics the process of natural selection, it belongs to the larger class
of evolutionary algorithms (EA), which generate solutions to optimization problems using
techniques inspired by natural evolution, such as inheritance, mutation, selection, and
crossover. (Wikipedia, n.d.).
The algorithm for Genetic Algorithms is:
I applied genetic algorithms to solve the traveling sales problem for 10 cities. The code was a
modification of the tsp_ga.m code found in mathworks.com (Vedenyov, 2011).
14
There are
( N 1)!
2
possible paths because it does not matter in which city begin and if the
clear
clc
clf
nn=10; % number of cities
asz=10; % area size
asx x asz
ps=1000; % population size
ng=1000; % number of generation
pm=0.01; % probability of mutation of exchange 2 random cities in the
path (per gene, per generation)
pm2=0.00; % probability of mutation of exchange 2 pieces of path (per
gene, per generation)
pmf=0.00; % probability of mutation of flip random piece of path
%r=asz*rand(2,nn); % randomly distribute cities
% r(1,:) -x coordinates of cities
% r(2,:) -y coordinates of cities
r(1,:)=[0.4306 3.7094 6.9330 9.3582 4.7758 1.2910
3.6774 3.2849];
r(2,:)=[7.7288 2.9727 1.7785 6.9080 2.6394 4.5774
7.0002 7.5569];
4.83831 9.4560
8.43692 8.8150
15
16
Gch=zeros(ps,nn); % childrens
for prc=1:(ps/2) % pairs counting
i1=1+2*(prc-1);
g1=Gc(i1,:);
cp=ceil((nn-1)*rand); % crossover point
% child:
g1ch=insert_begining(g1,g2,cp);
Gch(i1,:)=g1ch;
end
G=Gch; % now children
% mutation of exchange 2 random cities:
for psc=1:ps
if rand<pm
rnp=ceil(nn*rand); % random number of sicies to permuation
rpnn=randperm(nn);
ctp=rpnn(1:rnp); %chose rnp random cities to permutation
Gt=G(psc,ctp); % get this cites from the list
Gt=Gt(randperm(rnp)); % permutate cities
G(psc,ctp)=Gt; % % return citeis back
end
end
G(1,:)=Gb; % elitism
end
roulette_wheel_indexes.m
cpr=cumsum(prn);
n=length(prn);
% make cpr - row-vector if neccessary:
sz=size(cpr);
if sz(1)>sz(2)
cpr1=cpr';
else
cpr1=cpr;
end
i1=interp1([0 cpr1],1:(n+1),rand(1,m),'linear');
ii=floor(i1); % random numbers from 1:n according probabilities
insert_begining.m
function gch=insert_begining_slow(g1,g2,cp)
% insert begining from g2 (g2(1:cp)) to geging of g1 (g1(1:cp))
% return modified g1 in such way
for cpc=1:cp
if g2(cpc)~=g1(cpc) % if not same
ind=find(g1==g2(cpc)); % then where where is it
% swap:
g1(ind)=g1(cpc); % send to that place
g1(cpc)=g2(cpc);
end
end
17
gch=g1;
[1 6 2 5 3 4 8 7 9 10 1]
18