Genetic Algorithm Implementation in ns2

Genetic Algorithm Implementation in ns2

Genetic Algorithm Implementation in ns2 designed to simulate processes in natural systems.Over consecutive generation GA simulate the survival of the fittest among individuals.GA is  also a part of evolutionary computing.

Basic Operators in GA:

After initial population the algorithms defines following functions:

  • Selection.
  • Crossover.
  • and also Mutation.

Applications of GA:

  • Airlines Revenue Management.
  • Artificial creativity.
  • Biology and also computational chemistry.
  • Chemical kinetics.
  • Computer architecture.
  • Clustering.
  • Electronic circuit design.
  • Economics.
  • Image processing.
  • Mechanical engineering.

Benefits of GA:

  • GA solve optimization problem.
  • Solves problems with multiple solutions.
  • Its execution technique not dependent on the error surface.
  • Structural genetic algorithm gives the possibility to solve the solution structure.
  • GA method is very easy to understand.
  • Easily transferred to existing simulations and also models.

Genetic Algorithm Implementation in ns2 , helps to solve out

  • Multi-dimensional.
  • Non-differential.
  • Non-continuous.
  • And also in Non-parametrical problems.

GA ARCHITECURE:

Genetic Algorithm system Architecture

Sample code for genetic algorithm implementation in ns2:

#Creating a new Simulator object
set ns [new Simulator]
#Opening file to be used as nam trace file
set nf [open shot.nam w]
$ns namtrace-all $nf
#Finish procedure
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam shot.nam &
exit 0}
#Defining two nodes
set n0 [$ns node]
set n1 [$ns node]
#Connecting two nodes
$ns duplex-link $n0 $n1 1Mb 10ms DropTail
#CreateUDP agent and connect to node0
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
#Create CBR traffic source and attach to UDP agent
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 500
$cbr0 set interval_ 1
$cbr0 attach-agent $udp0
set null0 [new Agent/Null]
$ns attach-agent $n1 $null0
$ns connect $udp0 $null0
#CreateUDP agent and connect to node1
set udp1 [new Agent/UDP]
$ns attach-agent $n1 $udp1
#Create CBR traffic source and attach to UDP agent
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500
$cbr1 set interval_ 1
$cbr1 attach-agent $udp1
set null1 [new Agent/Null]
$ns attach-agent $n0 $null1
$ns connect $udp1 $null1
for {set i 0} {$i < 10} {incr i} {
set q [expr $i%2]
if {$q==0} {
set a i
set b [expr $i+1]
$ns at a “$cbr0 start”
$ns at b “$cbr0 stop”}
if {$q!=0} {
set a i
set b [expr $i+1]
$ns at a “$cbr1 start”
$ns at b “$cbr1 stop”}}
#Stop after 10 seconds
$ns at 10.0 “finish”
#Running simulation
$ns run

Live Tasks
Technology Ph.D MS M.Tech
NS2 23 13 14
NS3 20 12 13
OMNET++ 13 10 9
OPNET 11 12 10
QULANET 9 10 11
PEERSIM 11 12 9
RTOOL 12 9 11
VEINS 10 7 11
SWANS 11 9 7
MININET 10 8 10
PSIM 9 10 7
OPENPANA 7 11 9
GATETOOL 6 9 11
TRANS 9 10 8
SUMO 6 5 5
ITETRIS 7 7 9
CONTIKI OS 5 9 10
KOMPICS 7 8 6
PETRI NET 7 15 11
TINY OS 10 9 7
TOSSIM 8 5 4
DIVERT 6 9 5
GLOMOSIM 6 4 7
GROOVE NET 10 6 9
JIST 9 7 5
ONE SIM 6 4 5
OPTISYSTEM 5 5 4
RAPID MINER 3 4 5

Related Pages

Workflow

Subscribe to our YouTube Channel