The basics of genetic algorithms

libyantawdryΤεχνίτη Νοημοσύνη και Ρομποτική

23 Οκτ 2013 (πριν από 4 χρόνια και 15 μέρες)

91 εμφανίσεις

© 2000 by Charles Richter, Jr. All rights reserved.

The basics of genetic algorithms

Charles W. Richter, Jr.

January 4, 2000

© 2000 by Charles Richter, Jr. All rights reserved.

Genetic algorithms

Initialize population; gen=0

Calculate fitness

Parent Selection

Crossover/Mutation

Put children into pop

gen += 1

done?

Stop

no

yes


A genetic algorithm is
a computer program
that evolves the
contents of data
structures through
survival of the fittest,
or by the natural
selection principle.

© 2000 by Charles Richter, Jr. All rights reserved.

Basics of genetic algorithms


First we need a data structure suitable for our problem


When evolving bidding strategies, each member of the
population could be represented by a string:


0 0 0 1 1 0 1 0 1 9 8 15 21 6 2 17 16 ... 2

% of price mark
-
up MWs/bid forecast method



UC schedules might be represented by a 0/1 matrix.


Once the appropriate data structure has been found, a
population of these solutions is initialized randomly with
valid data.

© 2000 by Charles Richter, Jr. All rights reserved.

Basics of genetic algorithms

Fitness


Fitness is a measure of how good the solution is


Each member of the population is assigned a fitness


Shows which members of the population are better than others


A good fitness function is crucial


For bidding strategies, fitness might equal the agent’s profit

Parent Selection


Members of the population to reproduce are chosen
randomly with a fitness bias to be parents


Parents are then paired
-
off for the reproduction

© 2000 by Charles Richter, Jr. All rights reserved.

Basics of genetic algorithms: Reproduction

Crossover


Both parents contribute to the genetic makeup of
child. The crossover point(s) are chosen randomly.


Example


Parent #1:


Parent #2:


Crossover point(s) chosen randomly



Child #1:


0 0 1 1 1 1 1 1 9 9 9 9 9 5 5 5 5 5 ... 5


Child #2:


1 1 0 0 0 0 0 0 5 5 5 5 5 9 9 9 9 9 ... 2

0 0 0 0 0 0 0 0 9 9 9 9 9 9 9 9 9 9 ... 2

1 1 1 1 1 1 1 1 5 5 5 5 5 5 5 5 5 5 ... 5

© 2000 by Charles Richter, Jr. All rights reserved.

Basics of genetic algorithms

Mutation


All children have the possibility of being mutated before
they are placed into the population.


With some probability, positions within the “gene” or
string, are changed from 1 to 0, or vice versa.


Example


Child:


0 0 0 0 1

1
1 1 9 9 9 9 9 5 5 5 5 5 ... 5


mutation occurs


Child:


0 0 0 0 1

0
1 1 9 9 9 9 9 5 5 5 5 5 ... 5

© 2000 by Charles Richter, Jr. All rights reserved.

Basics of genetic algorithms


The children are placed into the population. In order
to maintain a constant population size, the lesser fit
members are replaced.


Typically half of the population is replaced during
each generation.


Go to fitness calculation, and repeat until a good
solution is found, or as long as computer resources
are available.

© 2000 by Charles Richter, Jr. All rights reserved.

Genetic algorithms: An example


Suppose we want a GA to evolve a character string:


“I evolve, therefore, I am flawed.”


First, generate a population of solutions randomly:


lH"*N'M9xl$d]3J*,qU;=?pCj[,530q?

u
-
Lp3CqhGF:8J#vVy!w*Wrnb1T`o)
-
DS

fPaep
-
U3CrUm:Ffd&
\
"hYuvPlQd3?1a?

C
\
fSOu#c@!s
-
.AX<DH8$?[v*.!T/i0tR

PVQF%v9fUfxNw8dHU9)7
\
hM5=^.+> ]D

s%"^APJ?5]6JJtZW=Ah&9M)iJb[ie'pb

-
"n;#DWc8M(sA8=]+I[Is(.VNUmET@&T

AX6nldsY5sRPw9@aw6p
\
1%QM0L@]$M)h

xrugNUa!O)oAId./oIs_wSN.xw+?C:JE

$AxN/
\
HO*Q1*S%b6m
\
iYT<r!"flqk<ip

ck`f
-
Nj1cscL]%*K..G/L;m(q?2;^6@q

H=SKi!CD$$YY+ywtvjeQ'3F,35ct2&Nr

© 2000 by Charles Richter, Jr. All rights reserved.

Genetic algorithms: An example


To judge fitness we could count the number
of locations in which the candidate solution
matches the target solution. E.G.:


I evolve, therefore, I am flawed.

AX6nldsY5sRPw9@aw6p
\
1%QM0L@]$M)h



No matches, so fitness for this string is zero.

© 2000 by Charles Richter, Jr. All rights reserved.

Genetic algorithms: An example

Applying the Genetic Algorithm, we see evolution



gen[0], creat[0]: aiWFfmBNdB&:.!oiD^Hu Zu,;5NB2!d5


gen[10], creat[0]: $AxNo3ve>%,/:r:`oIs wSN."flqk<ip


gen[20], creat[0]: $AxNo3ve>%,/:r:`oIs wSN."flqk<ip


gen[30], creat[0]: $AxNolve>%,/:r:`oIs ISN. flqk<ip


gen[40], creat[0]: IAxNolve>%,/:r:`oIs ISN. flqw<ip


gen[50], creat[0]: IAxvolve>%,/:re`oIs ISN. flqw<ip


gen[100],creat[0]: IAevolve, ,here`ors ISa. flqw<ip


gen[200],creat[0]: IAevolve, there`ore ISam flaweip


gen[300],creat[0]: I evolve, there`ore I am flawed.


gen[590],creat[0]: I evolve, there`ore I am flawed.


gen[596],creat[0]: I evolve, therefore I am flawed.

© 2000 by Charles Richter, Jr. All rights reserved.

Basics of genetic algorithms


It’s easy when the optimal solution is known
a priori
.


Evolving optimal UC schedules & bidding strategies is
harder.


Fitness is a function of expected profit and risk


The solution is dynamic, it varies with


competitor’s strategies


underlying costs


customer choices


price and load forecasts


outages and maintenance schedules

© 2000 by Charles Richter, Jr. All rights reserved.

Hourly bidding strategies


Without losing money, we want to simulate
markets & agents and evolve bidding strategies
using GAs and GP
-
Automata for individual
simulated markets


Iterative bidding process for single time periods


ignores temporal inter
-
dependencies


Bidding strategies judged on the profit they produced.
Those with high expected profit said to be good
strategies.

© 2000 by Charles Richter, Jr. All rights reserved.

Using a GA to evolve
bidding strategies

evolving data structures

price history

cost curve

predicted

price

cost

MWs

price

fore
-

casting


bid

multiplier

bid

© 2000 by Charles Richter, Jr. All rights reserved.

Simulating markets and evolving
bidding strategies

Buyer 1

Buyer 2

Buyer 3

Buyer 4

...

Buyer N

auctioneer

Seller 1

Seller 2

Seller 3

Seller 4

...

Seller M

bids

offers

matched bids/offers

binding contracts

calculate exp. profit

Initialize populations of
with buyer and seller

Strategies, gen = 0

Calculate fitness

Parent Selection

Crossover/Mutation

Put children into pop

gen += 1

© 2000 by Charles Richter, Jr. All rights reserved.

GENCO bidding strategies


For GENCOs maximizing profit, bidding strategies
will be very important in winning electricity contracts.



Before bidding into the market, the GENCO should
begin with a UC, which considers


startup & shutdown costs


maximum and minimum ramp rates


minimum uptime & downtime constraints



Including these constraints and costs is important if
the company is to make long term profit.

© 2000 by Charles Richter, Jr. All rights reserved.

Unit Commitment


When should the generating units (G) controlled by the GENCO
be run for most economic operation?


Concern must be given to environmental effects


How does one define “economic operation”? Cost minimizing?


In a deregulated market, GENCO must maximize profit

G

G

G

G

G

G

G

G

G

© 2000 by Charles Richter, Jr. All rights reserved.

Price
-
based unit commitment for a GENCO


UC is the scheduling of generating plants
(on/off) for a given period of time (e.g., 1 week)


Regulated utilities were forced to meet the demand
constraint. (e.g., All demand must be met.)


The competitive marketplace allows the GENCO to
choose the most profitable segment of customer base.


In the past, the utility minimized its cost, but the GENCO
of the future must maximize its long run profits


expected profit = expected revenue
-

expected costs

© 2000 by Charles Richter, Jr. All rights reserved.

Solving the UC problem


UC is a nonlinear discrete problem which has been
solved using dynamic programming, Lagrangian
relaxation, etc.


Naturally suited for genetic algorithms


Genetic algorithms have been used for cost
-
based UC


We modified the program to maximize profit


The UC algorithm decides which units to turn on, but
how much power should be generated at each unit to
cover the load and losses?


For each hour of the schedule, we need to perform an
economic dispatch calculation (EDC)

© 2000 by Charles Richter, Jr. All rights reserved.

Strategies consider markets, units

Time

Q

expected demand curve

Time

P

expected price curve


unit commitment (7
-
day schedule)

Hour 1 2 3 4 5 6 7 8 9 .... T

unit 1: 0 1 1 1 1 1 1 1 1 .... 0

unit 2: 0 1 1 1 1 1 1 1 1 .... 1

unit 3: 1 1 1 1 0 0 0 0 1 .... 1

unit 4: 1 1 1 1 1 1 1 1 1 .... 1


unit N: 0 1 1 1 1 1 1 1 1 .... 0

Cost: $Y,000.00

Profit: $X,000.00

Call bid generator to make bid in the market

Unit info

Fuel costs

© 2000 by Charles Richter, Jr. All rights reserved.

UC
-
GA


Initialize population


Until done:


fitness calculation


parent selection


crossover


mutation


place children in pop.


Done is when fitness is
good enough or gen >=
max_gens

Initialize GA pop. Call EDC

Stop

no

yes

Intelligent Mutation I & II

Call EDC for mutated hours

Select parents, perform X
-
over

standard mutation, call EDC

Done


gen += 1

Load demand & price forecasts

Calculate profit of schedules

© 2000 by Charles Richter, Jr. All rights reserved.

UC Schedule Parent 1

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 0 0 0 1 1 … 1

Gen#3: 1 1 1 0 0 … 1

Gen#4: 1 1 1 1 1 … 0

Gen#5: 0 0 0 1 1 … 1

Gen#6: 1 1 1 0 0 … 1

UC Schedule Parent 2

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 1 1 1 1 1 … 0

Gen#3: 1 1 1 1 1 … 0

Gen#4: 1 1 1 1 1 … 0

Gen#5: 1 1 1 1 1 … 0

Gen#6: 1 1 1 1 1 … 0

UC Schedule Child 1

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 0 0 0 1 1 … 1

Gen#3: 1 1 1 0 0 … 1

Gen#4: 1 1 1 1 1 … 0

Gen#5: 0 0 0 1 1 … 1

Gen#6: 1 1 1 0 0 … 1


1 1 1


1 1 1


1 1 1


1 1 1


1 1 1


1 1 1

UC Schedule Child 2

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 1 1 1 1 1 … 0

Gen#3: 1 1 1 1 1 … 0

Gen#4: 1 1 1 1 1 … 0

Gen#5: 1 1 1 1 1 … 0

Gen#6: 1 1 1 1 1 … 0


1 1 1


0 1 1


1 0 0


1 1 1


0 1 1


1 0 0

Crossover with UC Schedules

UC Schedule

N

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 0 0 0 1 1 … 1

Gen#3: 1 1 1 0 0 … 1

Gen#4: 1 1 1 1 1 … 0

Gen#5: 0 0 0 1 1 … 1

Gen#6: 1 1 1 0 0 … 1

UC Schedule

7

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 0 0 0 1 1 … 1

Gen#3: 1 1 1 0 0 … 1

Gen#4: 1 1 1 1 1 … 0

Gen#5: 0 0 0 1 1 … 1

Gen#6: 1 1 1 0 0 … 1

UC Schedule

6

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 0 0 0 1 1 … 1

Gen#3: 1 1 1 0 0 … 1

Gen#4: 1 1 1 1 1 … 0

Gen#5: 0 0 0 1 1 … 1

Gen#6: 1 1 1 0 0 … 1

UC Schedule

5

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 0 0 0 1 1 … 1

Gen#3: 1 1 1 0 0 … 1

Gen#4: 1 1 1 1 1 … 0

Gen#5: 0 0 0 1 1 … 1

Gen#6: 1 1 1 0 0 … 1

UC Schedule

4

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 0 0 0 1 1 … 1

Gen#3: 1 1 1 0 0 … 1

Gen#4: 1 1 1 1 1 … 0

Gen#5: 0 0 0 1 1 … 1

Gen#6: 1 1 1 0 0 … 1

UC Schedule

3

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 0 0 0 1 1 … 1

Gen#3: 1 1 1 0 0 … 1

Gen#4: 1 1 1 1 1 … 0

Gen#5: 0 0 0 1 1 … 1

Gen#6: 1 1 1 0 0 … 1

UC Schedule

2

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 0 0 0 1 1 … 1

Gen#3: 1 1 1 0 0 … 1

Gen#4: 1 1 1 1 1 … 0

Gen#5: 0 0 0 1 1 … 1

Gen#6: 1 1 1 0 0 … 1

UC Schedule

1

Hour 1 2 3 4 5 … T

Gen#1: 1 1 1 1 1 … 0

Gen#2: 0 0 0 1 1 … 1

Gen#3: 1 1 1 0 0 … 1

Gen#4: 1 1 1 1 1 … 0

Gen#5: 0 0 0 1 1 … 1

Gen#6: 1 1 1 0 0 … 1

© 2000 by Charles Richter, Jr. All rights reserved.

UC
-
GA Summary


The profit
-
based UC
-
GA (written
in C++) finds the optimal solution
in several test cases.


cpu time for GA scales up linearly
with units & hours.


In competitive environments, good
UC & bidding strategies will be
important to winning contracts.


Some markets cost recovery strictly thru bids.


GENCOs must consider startup, shutdown and fixed costs when
submitting bids.


We allocated fixed and transition costs equally to all hours, but this
allocation can be adjusted.


E.g., no competition at night? Consider recovering some of the day
time costs during the night to make day prices lower.

© 2000 by Charles Richter, Jr. All rights reserved.

UC
-
GA Summary


An advantage of the GA is that it evolves entire
populations of solutions in parallel.


Although some of the schedules may be sub
-
optimal in
terms of profit, they may offer greater flexibility for the
system.


The user can specify a secondary GA fitness function
which considers additional information to determine
optimal schedules


fitness may include a reward for schedules that give
operators a greater flexibility, since ability to change the
amount purchased on the spot market could allow increased
profits.

© 2000 by Charles Richter, Jr. All rights reserved.

More information?


Contact information:



Charles W. Richter, Jr.


email alias: crichter@ieee.org