This document provides an outline for a course on Optimization and Economics of Integrated Power Systems. The course will cover topics such as optimization basics, power systems basics, MATLAB review, and examples of optimization techniques applied to power systems, including linear, nonlinear, integer, and mixed integer programming. It also provides details on using MATLAB, including basics of variables, matrices, plotting, and loops. Equations and concepts from calculus relevant to optimization are defined, such as gradients, Hessians, and Taylor series.
2. 2
Course Outline
Review of Math
Basics of Optimization
Power systems basics
Review of Matlab
Examples of Optimization in Power systems
Graphical Optimization
Optimization Types Constraint and Unconstraint
Optimization Problem Types Linear NonLinear etc
Linear Optimization and Power Systems Applications
Non Linear Optimization and Power Systems Applications
Integer and Mixed integer programming and Power Systems Applications
Complexity Analysis
Quiz next week
3. 3
MATLAB
MATLAB is an interactive environment
Commands are interpreted one line at a time
Commands may be scripted to create your own functions or
procedures
Variables are created when they are used
Variables are typed, but variable names may be reused for different
types
Basic data structure is the matrix
Matrix dimensions are set dynamically
Operations on matrices are applied to all elements of a matrix at
once
Removes the need for looping over elements one by one!
Makes for fast & efficient programmes
5. 5
MATLAB
Variables
Names
Can be any string of upper and lower case
letters along with numbers and underscores but
it must begin with a letter
Reserved names are IF, WHILE, ELSE, END,
SUM, etc.
Names are case sensitive
Value
This is the data the is associated to the
variable; the data is accessed by using the
name.
Variables have the type of the last thing assigned
to them
Re-assignment is done silently – there are no
warnings if you overwrite a variable with
something of a different type.
To assign a value to a variable use the
equal symbol ‘=‘
>> A = 32
To find out the value of a variable simply
type the name in
7. 7
MATLAB
A MATLAB matrix is a rectangular array of numbers
Scalars and vectors are regarded as special cases of matrices
MATLAB allows you to work with a whole array at a time
You can also use built in functions to create a matrix
>> A = zeros(2, 4)
creates a matrix called A with 2 rows and 4 columns
containing the value 0
>> A = zeros(5) or >> A = zeros(5, 5)
creates a matrix called A with 5 rows and 5 columns
You can also use:
>> ones(rows, columns)
>> rand(rows, columns)
Note: MATLAB always refers to the first value as the
number of Rows then the second as the number of
Columns
8. 8
MATLAB
The colon : is actually an operator, that generates a row vector
This row vector may be treated as a set of indices when accessing a
elements of a matrix
The more general form is
[start:stepsize:end]
>> [11:2:21]
11 13 15 17 19 21
>>
Stepsize does not have to be integer (or positive)
>> [22:-2.07:11]
22.00 19.93 17.86 15.79 13.72 11.65
9. 9
MATLAB
Mathematical Operators:
Add: +
Subtract: -
Divide: ./
Multiply: .*
Power: .^ (e.g. .^2 means squared)
You can use round brackets to specify the order in
which operations will be performed
Note that preceding the symbol / or * or ^ by a ‘.’
means that the operator is applied between pairs of
corresponding elements of vectors of matrices
10. 10
MATLAB
Combining this with methods from Accessing Matrix Elements
gives way to more useful operations
>> results = zeros(3, 5)
>> results(:, 1:4) = rand(3, 4)
>> results(:, 5) = results(:, 1) + results(:, 2) + results(:, 3) + results(:, 4)
or
>> results(:, 5) = results(:, 1) .* results(:, 2) .* results(:, 3) .* results(:, 4)
11. 11
MATLAB
Logical Operators:
Greater Than: >
Less Than: <
Greater Than or Equal To: >=
Less Than or Equal To: <=
Is Equal: ==
Not Equal To: ~=
For example, you can find data that is above a certain limit:
>> r = results(:,1)
>> ind = r > 0.2
Boolean Operators:
AND: &
OR: |
NOT: ~
12. 12
MATLAB
There are a number of special functions that provide useful constants
pi = 3.14159265….
i or j = square root of -1
Inf = infinity
NaN = not a number
Passing a vector to a function like sum, mean, std will calculate the
property within the vector
>> sum([1,2,3,4,5])
= 15
>> mean([1,2,3,4,5])
= 3
>> max([1,2,3,4,5])
= 5
13. 13
MATLAB
The plot function can be used in different ways:
>> plot(data)
>> plot(x, y)
>> plot(data, ‘r.-’)
In the last example the line style is defined
Colour: r, b, g, c, k, y etc.
Point style: . + * x o > etc.
Line style: - -- : .-
A basic plot
>> x = [0:0.1:2*pi]
>> y = sin(x)
>> plot(x, y, ‘r.-’)
0 1 2 3 4 5 6 7
-1
-0.8
-0.6
-0.4
-0.2
0
0.2
0.4
0.6
0.8
1
14. 14
MATLAB
>> x = [0:0.1:2*pi];
>> y = sin(x);
>> plot(x, y, 'b*-')
>> hold on
>> plot(x, y*2, ‘r.-')
>> title('Sin Plots');
>> legend('sin(x)', '2*sin(x)');
>> axis([0 6.2 -2 2])
>> xlabel(‘x’);
>> ylabel(‘y’);
>> hold off
0 1 2 3 4 5 6
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
Sin Plots
x
y
sin(x)
2*sin(x)
15. 15
MATLAB
For command
Use a for loop to repeat one or more statements
The end keyword tells Matlab where the loop finishes
You control the number of times a loop is repeated by defining the
values taken by the index variable
This uses the colon operator again, so index values do not need
to be integer
For example
>> for i = 1:4
a(i) = i * 2
end
16. 16
MATLAB
The counter can be used to index different rows or columns
E.g.
>> results = rand(10,3)
>> for i = 1:3
m(i) = mean(results(:, i))
end
..although you could do this in one step
m = mean(results);
17. 17
MATLAB
The ‘if’ command is used with logical operators
Again, the end command is used to tell Matlab where the statement
ends.
For example, the following code loops through a matrix performing
calculations on each column
>> for i = 1:size(results, 2)
m = results(:, i)
if m > 1
do something
else
do something different
end
end
18. Calculus for Continuous Optimization
Calculus and Analytic Geometry By Thomas and Finney 9th
Edition
Introduction of Optimum Design By Jasbir S. Arora
Some figure from Web
http://www.ece.mcmaster.ca/~xwu/part4.pdf
18
19. Calculus for Continuous Optimization
Calculus and Analytic Geometry By Thomas and Finney 9th Edition
Shifting of Graph
19
25. Calculus for Continuous Optimization
Tangent and Normal
25
We make use of the fact that if two lines with
gradients m1 and m2 respectively are
perpendicular, then m1 m2 = −1.
The equation of the tangent line to y = f(x) at the point (x1,y1):
( 'm' is the gradient at (x1,y1) )
The equation of the normal line to y = f(x) at (x1,y1) is:
The derivative of y = f(x) at (x1,y1)
gives us the gradient 'm'.
41. Calculus for Continuous Optimization
41
Taylor’s expansion for f(x) about the point x* is
where R is the remainder term that is smaller in magnitude than the
previous terms if x is sufficiently close to x*.
Summation notation
For Two Variable
Matrix notation
42. Calculus for Continuous Optimization
42
Often a change in the function is desired when x* moves to a
neighboring point x. Defining the change as Δf=f(x)-f(x*)
A first-order change in f(x) at x* (denoted as δf ) is obtained by retaining
only the first term
where δx is a small change in x* (δx=x-x*). Note that the first-order
change in the function given in above equation is simply a dot product
of the vectors rf and δx. A first-order change is an acceptable
approximation for change in the original function when x is near x*.
43. Calculus for Continuous Optimization
Gradient
43
The gradient of a line is a specific term for the steepness of a straight line.
gradient =
vertical change
horizontal change
Gradient AB = vertical
horizontal
=
6
4
= 1.5
4
6
A
B
Note: A negative gradient means that the
line is travelling downhill or a decline.
44. Calculus for Continuous Optimization
44
Gradient from co-ordinates
This can be achieved in two ways:
1. Draw the co-ordinates on a grid and use the
previous method.
Gradient = Change in y
Change in x
Vertical
horizontal
=
Pairs (1,2) and (5,18)
Y2 - Y1
X2 - X1
=
m 18 - 2
5 - 1
= =
16
4
= 4
(X2,Y2)
Y2 - Y1
(X1,Y1) X2 - X1
45. Calculus for Continuous Optimization
45
Notations and definitions:
Let x = (x1,…,xn) be the vector of design variables.
The gradient vector, f, and Hessian, 2f, of f(x) are the
column vector and nn symmetric matrix defined by
.
,
2
2
2
2
1
2
2
2
2
2
2
1
2
2
1
2
2
1
2
2
1
2
2
1
n
n
n
n
n
n
x
f
x
x
f
x
x
f
x
x
f
x
f
x
x
f
x
x
f
x
x
f
x
f
f
x
f
x
f
f
46. Calculus for Continuous Optimization
46
Geometrically, the gradient vector is normal to the tangent plane at the
point x*
54. Assignment 1 Problem 1
54
Plot the functions of above examples
and their Taylor approximations in Matlab
For example 4.7 x* = 2
For example 4.8 x* = (1,2)
For example 4.8 x* = (2,2)
For example 4.8 x* = (3,2)
For example 4.9 x* = (1,1)
For example 4.9 x* = (2,2)
For example 4.9 x* = (3,2)
Due in two weeks
55. Some Objective Functions
55
Monotonic and unimodal functions
Monotonic:
Unimodal:
ƒ(x) is unimodal on the interval if and only if it is
monotonic on either side of the single optimal point x* in the
interval.
A monotonic increasing function Unimodal function
56. Some Objective Functions
56
0 0.5 1 1.5 2 2.5 3
0
1
2
3
4
5
6
(i) a discrete function (ii) a discontinuous function
Y
x
(iii) a continuous function
0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5
-40
-20
0
20
40
60
80
100
57. Some Objective Functions
57
Functions can be categorized as
Separable or nonseparable – for example, (x+y) vs. xy
Regular or irregular – for example, x vs. abs(x)
Unimodal or multimodal – for example, x2 vs. cos x
58. Some Objective Functions
58
nonseparable, regular, unimodal
Step function:
separable, irregular, unimodal
2
1
]
)
5
.
0
(
[floor
)
(
n
i
i
x
x
f
Rastrigin:
nonseparable, regular, multimodal
n
i
i
i x
x
n
x
f
1
2
)]
2
cos(
10
[
10
)
(
59. Some Objective Functions
59
Rosenbrock:
nonseparable, regular, unimodal
1
1
2
2
2
1 ]
)
1
(
)
(
100
[
)
(
n
i
i
i
i x
x
x
x
f
Schwefel 2.22:
nonseparable, irregular, unimodal
n
i
i
n
i
i x
x
x
f
1
1
|
|
|
|
)
(
Schwefel 2.26:
separable, irregular, multimodal
n
i
i
i x
x
x
f
1
|
|
sin
)
(
60. 60
Assignment 1 Problem 2
Plot the functions in matlab
Step function
Rastrigin
Rosenbrock
Schwefel 2.22
Schwefel 2.26
Due in two weeks
61. Calculus for Continuous Optimization
Contour Plot
61
A level curve: Each horizontal plane z=k intersects the surface in a curve.
The projection of this curve on the xy-plane is called a level curve
66. 66
Assignment 1 Problem 3
Plot the contour of Step function
Rastrigin
Rosenbrock
Schwefel 2.22
Schwefel 2.26
In Matlab
Due in two weeks
67. Necessary and Sufficient Conditions
67
Example: If a number is divisible by 4(call this H), then it is divisible by 2
(call this C). H implies C but C is not strong enough to imply H for example
6 is divisible by 2 but not by 4
Therefore C is necessary for H but not sufficient for H.
Example: In Euclidean geometry, a triangle has equal sides (call this H) if
and only if the triangle has equal angles (call this C). This means
H if C: H is necessary for C since C implies H
H only if C: C is necessary for H since H implies C
H if and only if C: H and C imply each other and are both necessary and
sufficient conditions for each other.