Passed
Pull Request — master (#233)
by
unknown
01:19
created

StrategyAdaptationDifferentialEvolutionV1.runIteration()   A

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 3
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 7
dl 3
loc 3
rs 10
c 0
b 0
f 0
1
# encoding=utf8
2
# pylint: disable=mixed-indentation, multiple-statements, logging-not-lazy, attribute-defined-outside-init, line-too-long, arguments-differ, singleton-comparison, bad-continuation, dangerous-default-value, consider-using-enumerate
3
import logging
4
5
# from numpy import random as rand, argmin, argmax, mean, asarray, cos
6
7
# from NiaPy.algorithms.algorithm import Individual
8
from NiaPy.algorithms.basic.de import DifferentialEvolution  # , CrossBest1, CrossRand1, CrossCurr2Best1, CrossBest2, CrossCurr2Rand1, proportional
9
10
logging.basicConfig()
11
logger = logging.getLogger('NiaPy.algorithms.modified')
12
logger.setLevel('INFO')
13
14
__all__ = [
15
	'StrategyAdaptationDifferentialEvolution',
16
	'StrategyAdaptationDifferentialEvolutionV1'
17
]
18
19 View Code Duplication
class StrategyAdaptationDifferentialEvolution(DifferentialEvolution):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
20
	r"""Implementation of Differential Evolution Algorithm With Strategy Adaptation algorihtm.
21
22
	Algorithm:
23
		Differential Evolution Algorithm With StrategyAdaptation
24
25
	Date:
26
		2019
27
28
	Author:
29
		Klemen Berkovič
30
31
	License:
32
		MIT
33
34
	Reference URL:
35
		https://ieeexplore.ieee.org/document/1554904
36
37
	Reference paper:
38
		Qin, A. Kai, and Ponnuthurai N. Suganthan. "Self-adaptive differential evolution algorithm for numerical optimization." 2005 IEEE congress on evolutionary computation. Vol. 2. IEEE, 2005.
39
40
	Attributes:
41
		Name (List[str]): List of strings representing algorithm name.
42
43
	See Also:
44
		:class:`NiaPy.algorithms.basic.DifferentialEvolution`
45
	"""
46
	Name = ['StrategyAdaptationDifferentialEvolution', 'SADE', 'SaDE']
47
48
	@staticmethod
49
	def algorithmInfo():
50
		r"""Geg basic algorithm information.
51
52
		Returns:
53
			str: Basic algorithm information.
54
55
		See Also:
56
			:func:`NiaPy.algorithms.algorithm.Algorithm.algorithmInfo`
57
		"""
58
		return r"""Qin, A. Kai, and Ponnuthurai N. Suganthan. "Self-adaptive differential evolution algorithm for numerical optimization." 2005 IEEE congress on evolutionary computation. Vol. 2. IEEE, 2005."""
59
60
	def setParameters(self, **kwargs):
61
		DifferentialEvolution.setParameters(self, **kwargs)
62
		# TODO add parameters of the algorithm
63
64
	def getParameters(self):
65
		d = DifferentialEvolution.getParameters(self)
66
		# TODO add paramters values
67
		return d
68
69
	def runIteration(self, task, pop, fpop, xb, fxb, **dparams):
70
		# TODO implemnt algorithm
71
		return pop, fpop, xb, fxb, dparams
72
73 View Code Duplication
class StrategyAdaptationDifferentialEvolutionV1(DifferentialEvolution):
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
74
	r"""Implementation of Differential Evolution Algorithm With Strategy Adaptation algorihtm.
75
76
	Algorithm:
77
		Differential Evolution Algorithm With StrategyAdaptation
78
79
	Date:
80
		2019
81
82
	Author:
83
		Klemen Berkovič
84
85
	License:
86
		MIT
87
88
	Reference URL:
89
		https://ieeexplore.ieee.org/document/4632146
90
91
	Reference paper:
92
		Qin, A. Kai, Vicky Ling Huang, and Ponnuthurai N. Suganthan. "Differential evolution algorithm with strategy adaptation for global numerical optimization." IEEE transactions on Evolutionary Computation 13.2 (2009): 398-417.
93
94
	Attributes:
95
		Name (List[str]): List of strings representing algorithm name.
96
97
	See Also:
98
		:class:`NiaPy.algorithms.basic.DifferentialEvolution`
99
	"""
100
	Name = ['StrategyAdaptationDifferentialEvolutionV1', 'SADEV1', 'SaDEV1']
101
102
	@staticmethod
103
	def algorithmInfo():
104
		r"""Get algorithm information.
105
106
		Returns:
107
			str: Get algorithm information.
108
109
		See Also:
110
			:func:`NiaPy.algorithms.algorithm.Algorithm.algorithmInfo`
111
		"""
112
		return r"""Qin, A. Kai, Vicky Ling Huang, and Ponnuthurai N. Suganthan. "Differential evolution algorithm with strategy adaptation for global numerical optimization." IEEE transactions on Evolutionary Computation 13.2 (2009): 398-417."""
113
114
	def setParameters(self, **kwargs):
115
		DifferentialEvolution.setParameters(self, **kwargs)
116
		# TODO add parameters of the algorithm
117
118
	def getParameters(self):
119
		d = DifferentialEvolution.getParameters(self)
120
		# TODO add paramters values
121
		return d
122
123
	def runIteration(self, task, pop, fpop, xb, fxb, **dparams):
124
		# TODO implement algorithm
125
		return pop, fpop, xb, fxb, dparams
126
127
# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
128