| Conditions | 1 |
| Total Lines | 56 |
| Code Lines | 52 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | """Implementation of benchmarks utility function.""" |
||
| 64 | def __init__(self): |
||
| 65 | r"""Initialize benchmarks.""" |
||
| 66 | |||
| 67 | self.benchmark_classes = { |
||
| 68 | "ackley": Ackley, |
||
| 69 | "alpine1": Alpine1, |
||
| 70 | "alpine2": Alpine2, |
||
| 71 | "bentcigar": BentCigar, |
||
| 72 | "chungReynolds": ChungReynolds, |
||
| 73 | "cosinemixture": CosineMixture, |
||
| 74 | "csendes": Csendes, |
||
| 75 | "discus": Discus, |
||
| 76 | "dixonprice": DixonPrice, |
||
| 77 | "conditionedellptic": Elliptic, |
||
| 78 | "elliptic": Elliptic, |
||
| 79 | "expandedgriewankplusrosenbrock": ExpandedGriewankPlusRosenbrock, |
||
| 80 | "expandedschaffer": ExpandedSchaffer, |
||
| 81 | "griewank": Griewank, |
||
| 82 | "happyCat": HappyCat, |
||
| 83 | "hgbat": HGBat, |
||
| 84 | "infinity": Infinity, |
||
| 85 | "katsuura": Katsuura, |
||
| 86 | "levy": Levy, |
||
| 87 | "michalewicz": Michalewichz, |
||
| 88 | "modifiedscwefel": ModifiedSchwefel, |
||
| 89 | "perm": Perm, |
||
| 90 | "pinter": Pinter, |
||
| 91 | "powell": Powell, |
||
| 92 | "qing": Qing, |
||
| 93 | "quintic": Quintic, |
||
| 94 | "rastrigin": Rastrigin, |
||
| 95 | "ridge": Ridge, |
||
| 96 | "rosenbrock": Rosenbrock, |
||
| 97 | "salomon": Salomon, |
||
| 98 | "schaffer2": SchafferN2, |
||
| 99 | "schaffer4": SchafferN4, |
||
| 100 | "schumerSteiglitz": SchumerSteiglitz, |
||
| 101 | "schwefel": Schwefel, |
||
| 102 | "schwefel221": Schwefel221, |
||
| 103 | "schwefel222": Schwefel222, |
||
| 104 | "sphere": Sphere, |
||
| 105 | "sphere2": Sphere2, |
||
| 106 | "sphere3": Sphere3, |
||
| 107 | "step": Step, |
||
| 108 | "step2": Step2, |
||
| 109 | "step3": Step3, |
||
| 110 | "stepint": Stepint, |
||
| 111 | "styblinskiTang": StyblinskiTang, |
||
| 112 | "sumSquares": SumSquares, |
||
| 113 | "trid": Trid, |
||
| 114 | "weierstrass": Weierstrass, |
||
| 115 | "whitley": Whitley, |
||
| 116 | "zakharov": Zakharov |
||
| 117 | } |
||
| 118 | |||
| 119 | self.algorithm_classes = {} |
||
| 120 | |||
| 149 |