Passed
Pull Request — master (#240)
by Grega
01:17
created

run_benchmark.logging_example()   A

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
# encoding=utf8
2
# This is temporary fix to import module from parent folder
3
# It will be removed when package is published on PyPI
4
import sys
5
sys.path.append('../')
6
# End of fix
7
8
import random
9
import logging
10
11
from NiaPy.algorithms.basic import BareBonesFireworksAlgorithm
12
from NiaPy.benchmarks import Benchmark, Katsuura, Elliptic
13
from NiaPy.task import StoppingTask
14
15
logging.basicConfig()
16
logger = logging.getLogger('examples')
17
logger.setLevel('INFO')
18
19 View Code Duplication
class MyBenchmark(Benchmark):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
20
	Name = ['MyBenchmark']
21
22
	def __init__(self):
23
		self.Lower = -11
24
		self.Upper = 11
25
26
	def function(self):
27
		def evaluate(D, sol):
28
			val = 0.0
29
			for i in range(D): val += sol[i] ** 2
30
			return val
31
		return evaluate
32
33
benc = MyBenchmark()
34
benc.plot3d()
35
36
benc = Katsuura(-1, 1)
37
benc.plot3d(0.06)
38
39
benc = Elliptic()
40
benc.plot3d(0.65)
41
42
# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
43