MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

searches/hill_climbing.py:11–23  ·  view source on GitHub ↗

The constructor of the search problem. x: the x coordinate of the current search state. y: the y coordinate of the current search state. step_size: size of the step to take when looking for neighbors. function_to_optimize: a function to optimize having the s

(self, x: int, y: int, step_size: int, function_to_optimize)

Source from the content-addressed store, hash-verified

9 """
10
11 def __init__(self, x: int, y: int, step_size: int, function_to_optimize):
12 """
13 The constructor of the search problem.
14
15 x: the x coordinate of the current search state.
16 y: the y coordinate of the current search state.
17 step_size: size of the step to take when looking for neighbors.
18 function_to_optimize: a function to optimize having the signature f(x, y).
19 """
20 self.x = x
21 self.y = y
22 self.step_size = step_size
23 self.function = function_to_optimize
24
25 def score(self) -> int:
26 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected