MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / score

Method score

searches/hill_climbing.py:25–35  ·  view source on GitHub ↗

Returns the output of the function called with current x and y coordinates. >>> def test_function(x, y): ... return x + y >>> SearchProblem(0, 0, 1, test_function).score() # 0 + 0 = 0 0 >>> SearchProblem(5, 7, 1, test_function).score() # 5 + 7 =

(self)

Source from the content-addressed store, hash-verified

23 self.function = function_to_optimize
24
25 def score(self) -> int:
26 """
27 Returns the output of the function called with current x and y coordinates.
28 >>> def test_function(x, y):
29 ... return x + y
30 >>> SearchProblem(0, 0, 1, test_function).score() # 0 + 0 = 0
31 0
32 >>> SearchProblem(5, 7, 1, test_function).score() # 5 + 7 = 12
33 12
34 """
35 return self.function(self.x, self.y)
36
37 def get_neighbors(self):
38 """

Callers 4

simulated_annealingFunction · 0.80
hill_climbingFunction · 0.80
hill_climbing.pyFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected