-
Notifications
You must be signed in to change notification settings - Fork 0
/
frange.py
39 lines (26 loc) · 830 Bytes
/
frange.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
File: frange.py
By Peter Caven, peter@sparseinference.com
Description:
A test function for the Stepping Stone Search Algorithm.
"""
import numpy
from numpy import *
from sss import Optimize
def Frange(x):
"""
Optimal value is 0.0 at arange(1,len(x)+1)
"""
return sum((arange(1,len(x)+1) - x)**2)
optimum = Optimize( Frange,
dimensions = 100,
lowerDomain = -110.0,
upperDomain = 110.0,
maxMutations = 2,
maxIndexes = 2,
gamma = 0.99,
minImprovements = 3,
popSize = 20,
maxIterations = 1000000,
targetLoss = 1.0e-10)
print(f"Solution:\n{optimum.rep}")