Information Technology Reference
In-Depth Information
ExpForm
nmbr
:
PaddedForm
nmbr,
6, 5
, ExponentFunction
1&
,
NumberFormat
1
"
E
"
3&
, NumberSigns
"
", "
"
;
BestInd
pop
:
Module
best, ind, str
,
best
Position
, Min
1
1
&
Transpose
pop
1
;
ind
pop
best
;
str
"Best individual is on position "
ToString
best
" with cost value "
ToString
ExpForm
ind
1
" and
parameters "
ToString
ind
2
;
Print
str
;
Return
Flatten
best, ind
,1
BestInd
np
Best individual is on position 7 with cost
value
3.41433
E
2 and parameters
297.175,
150.458
7,
341.433,
297.175,
150.458
Fig. 7.25.
Best individual from population
NewPop
Pop
:
MapThread
If
1
1
2
1
,
1,
2
&,
Pop,
CostFunction
1
,
1
&
Flatten
MapIndexed
CheckInterval
1,
2
&,
1
,1
&
Flatten
Table
If
Cr
Random
, Pop
i, 2, j
,
1
i, j
,
i, NP
,
j, Dim
&
F
1
1, 2
1
2, 2
1
3, 2
&
Pop
1
&
MapIndexed
SelectOther
2
1
&, Pop
,1
Fig. 7.26.
Compressed DE form
Repair
Sol
:
Module
Temp, MissingValue, Solution, Pos, Size
,
Solution
Sol; Size
Length
Solution
;
MissingValue
RandomRelist
Complement
Range
Size
, Solution
;
Pos
&
Position
Solution,
Range
Size
;
Drop
Solution,
&
Pos
Solution
Sort
Flatten
MapIndexed
Drop
1, 1
&,
1
&
MapIndexed
RandomRelist
1
&,
&
Join
Temp
&
1
&
Range
Length
1
&
Flatten
Position
Flatten
Dimensions
Temp
Flatten
Pos
&
Range
Size
,
?
1
&
, Greater
;
Pos
Sort
Pos, Less
;
MapThread
Solution
Insert
Solution,
1,
2
&,
MissingValue, Pos
Return
Solution
Fig. 7.27.
Repair routine
The
Repair
function is broken down and explained in-depth. The initial process is
to find all the
missing values
in the solution. Since this is a
permutative
solution, each
value is exist only
once
in the solution. Therefore it stands to reason that if there are
more than one single value in the solution, then some values will be missing.
The function:
MissingValue = RandomRelist[Complement[Range[Size]
,
Solution]]; finds the missing
values in the solution.
Search WWH ::
Custom Search