-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_single_fun_all.py
53 lines (44 loc) · 1.57 KB
/
example_single_fun_all.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
Author: Andrijan Ostrun
Year: 2017.
"""
from models import *
from nonlinear_optimizations import *
from nonlinear_optimizations.function import Function
#########################################################
# Example 1:
# Performing all of the implemented algorithms on the
# minimization of function 1 and printing all the
# steps that algorithm performed
#
# function: f1 (Rosenbrock's "Banana" function)
# -> Golden cut minimization
# -> Simplex Nelder-Mead minimization
# -> Hooke-Jeeves minimization
# -> Coordinate Axis search minimization
#
#########################################################
fun = Function(fun_1zad)
x0 = [10]
results = {}
print("Golden cut:")
print("\nResulting point (interval): " +
golden_section_search(x0, fun).__str__())
results['golden'] = fun.iterations
print("################################################\n")
print("Simplex:")
print("\nResulting point: " + simplex_nelder_mead(x0, fun).__str__())
results['simplex'] = fun.iterations
print("################################################\n")
print("Hooke-Jeeves:")
print("\nResulting point: " + hooke_jeeves(x0, fun).__str__())
results['H-J'] = fun.iterations
print("################################################\n")
print("Coordinate axis:")
print("\nResulting point: " + coordinate_axis_search(x0, fun).__str__())
results['Co-Ax'] = fun.iterations
print("################################################\n")
print("Cost Function calls:")
for k, v in results.items():
print("\t {} : {}".format(k, v))
############################################################