| @@ 116-138 (lines=23) @@ | ||
| 113 | }) |
|
| 114 | return d |
|
| 115 | ||
| 116 | def initPopulation(self, task): |
|
| 117 | r"""Initialize the starting population. |
|
| 118 | ||
| 119 | Parameters: |
|
| 120 | task (Task): Optimization task |
|
| 121 | ||
| 122 | Returns: |
|
| 123 | Tuple[numpy.ndarray, numpy.ndarray[float], Dict[str, Any]]: |
|
| 124 | 1. New population. |
|
| 125 | 2. New population fitness/function values. |
|
| 126 | 3. Additional arguments: |
|
| 127 | * A (float): Loudness. |
|
| 128 | * S (numpy.ndarray): TODO |
|
| 129 | * Q (numpy.ndarray[float]): TODO |
|
| 130 | * v (numpy.ndarray[float]): TODO |
|
| 131 | ||
| 132 | See Also: |
|
| 133 | * :func:`NiaPy.algorithms.Algorithm.initPopulation` |
|
| 134 | """ |
|
| 135 | Sol, Fitness, d = Algorithm.initPopulation(self, task) |
|
| 136 | A, S, Q, v = np.full(self.NP, self.A), np.full([self.NP, task.D], 0.0), np.full(self.NP, 0.0), np.full([self.NP, task.D], 0.0) |
|
| 137 | d.update({'A': A, 'S': S, 'Q': Q, 'v': v}) |
|
| 138 | return Sol, Fitness, d |
|
| 139 | ||
| 140 | def localSearch(self, best, A, task, **kwargs): |
|
| 141 | r"""Improve the best solution according to the Yang (2010). |
|
| @@ 109-130 (lines=22) @@ | ||
| 106 | }) |
|
| 107 | return d |
|
| 108 | ||
| 109 | def initPopulation(self, task): |
|
| 110 | r"""Initialize the starting population. |
|
| 111 | ||
| 112 | Parameters: |
|
| 113 | task (Task): Optimization task |
|
| 114 | ||
| 115 | Returns: |
|
| 116 | Tuple[numpy.ndarray, numpy.ndarray[float], Dict[str, Any]]: |
|
| 117 | 1. New population. |
|
| 118 | 2. New population fitness/function values. |
|
| 119 | 3. Additional arguments: |
|
| 120 | * S (numpy.ndarray): TODO |
|
| 121 | * Q (numpy.ndarray[float]): TODO |
|
| 122 | * v (numpy.ndarray[float]): TODO |
|
| 123 | ||
| 124 | See Also: |
|
| 125 | * :func:`NiaPy.algorithms.Algorithm.initPopulation` |
|
| 126 | """ |
|
| 127 | Sol, Fitness, d = Algorithm.initPopulation(self, task) |
|
| 128 | S, Q, v = full([self.NP, task.D], 0.0), full(self.NP, 0.0), full([self.NP, task.D], 0.0) |
|
| 129 | d.update({'S': S, 'Q': Q, 'v': v}) |
|
| 130 | return Sol, Fitness, d |
|
| 131 | ||
| 132 | def localSearch(self, best, task, **kwargs): |
|
| 133 | r"""Improve the best solution according to the Yang (2010). |
|