Completed
Push — master ( ff5cab...a135cc )
by
unknown
17s queued 13s
created

TabuSearch.algorithmInfo()   A

Complexity

Conditions 1

Size

Total Lines 11
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
# encoding=utf8
2
import logging
3
from numpy import random as rand
4
from NiaPy.algorithms.algorithm import Algorithm
5
6
logging.basicConfig()
7
logger = logging.getLogger('NiaPy.algorithms.other')
8
logger.setLevel('INFO')
9
10
__all__ = ['TabuSearch']
11
12
# TODO implement algorithm
13
14
def TabuSearchF(task, SR=None, TL_size=25, rnd=rand):
15
	if SR == None: SR = task.bRange
16
	x = rnd.uniform(task.Lower, task.Upper)
17
	x_f = task.eval(x)
18
	# while not task.stopCondI():
19
	# Generate neigours
20
	# evaluate x not in ts
21
	# get best of of evaluated
22
	# compare new best with best
23
	return x, x_f
24
25
class TabuSearch(Algorithm):
26
	r"""Implementation of Tabu Search Algorithm.
27
28
	Algorithm:
29
		Tabu Search Algorithm
30
31
	Date:
32
		2018
33
34
	Authors:
35
		Klemen Berkovič
36
37
	License:
38
		MIT
39
40
	Reference URL:
41
		http://www.cleveralgorithms.com/nature-inspired/stochastic/tabu_search.html
42
43
	Reference paper:
44
45
	Attributes:
46
		Name (List[str]): List of strings representing algorithm name.
47
	"""
48
	Name = ['TabuSearch', 'TS']
49
50
	@staticmethod
51
	def algorithmInfo():
52
		r"""Get basic information of algorithm.
53
54
		Returns:
55
			str: Basic information of algorithm.
56
57
		See Also:
58
			* :func:`NiaPy.algorithms.Algorithm.algorithmInfo`
59
		"""
60
		return r"""None"""
61
62
	@staticmethod
63
	def typeParameters(): return {
64
			'NP': lambda x: isinstance(x, int) and x > 0
65
	}
66
67
	def setParameters(self, **ukwargs):
68
		r"""Set the algorithm parameters/arguments."""
69
		Algorithm.setParameters(self, **ukwargs)
70
71
	def move(self): return list()
72
73
	def runIteration(self, task, pop, fpop, xb, fxb, **dparams):
74
		r"""Core function of the algorithm.
75
76
		Args:
77
			task (Task): Optimization task.
78
			pop (numpy.ndarray): Current population.
79
			fpop (numpy.ndarray): Individuals fitness/objective values.
80
			xb (numpy.ndarray): Global best solution.
81
			fxb (float): Global best solutions fitness/objective value.
82
			**dparams (dict):
83
84
		Returns:
85
			Tuple[numpy.ndarray, numpy.ndarray, numpy.ndarray, float, dict]:
86
		"""
87
		return pop, fpop, xb, fxb, dparams
88
89
# vim: tabstop=3 noexpandtab shiftwidth=3 softtabstop=3
90