@anonympins/fingerprint 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +66 -60
- package/package.json +1 -1
- package/src/js/fingerprint.js +4529 -4429
- package/src/js/pow.solver.js +531 -497
- package/src/js/problem-manager.js +614 -539
- package/src/js/tests/fingerprint.test.js +2351 -2319
- package/src/js/tests/pow.solver.test.js +233 -197
- package/src/js/tests/problem-manager.test.js +358 -322
- package/src/php/AutoTuner.php +197 -154
- package/src/php/FingerprintEngine.php +1018 -1006
- package/src/php/Optimization/FunctionRegistry.php +63 -62
- package/src/php/Optimization/OptimizationOperators.php +401 -304
- package/src/php/ProblemManager.php +287 -254
- package/src/php/Tests/FingerprintEngineTest.php +330 -299
- package/src/php/Tests/ProblemManagerTest.php +376 -296
- package/src/php/Tests/RequestUtilsTest.php +256 -253
- package/src/php/Tests/problems.config.json +8 -8
- package/src/php/Utils/RequestUtils.php +1189 -1169
|
@@ -1,63 +1,64 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
declare(strict_types=1);
|
|
4
|
-
|
|
5
|
-
namespace Anonympins\Fingerprint\Optimization;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Registre pour exposer de manière contrôlée les fonctions de la bibliothèque d'optimisation.
|
|
9
|
-
*/
|
|
10
|
-
class FunctionRegistry
|
|
11
|
-
{
|
|
12
|
-
/** @var array<string, callable> */
|
|
13
|
-
private static array $functions = [];
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Initialise le registre avec les fonctions disponibles.
|
|
17
|
-
*/
|
|
18
|
-
private static function initialize(): void
|
|
19
|
-
{
|
|
20
|
-
if (empty(self::$functions)) {
|
|
21
|
-
// Fonctions de "Scoring"
|
|
22
|
-
self::$functions['tsp.calculateEnergy'] = [OptimizationUtils::class, 'evaluatePathDistance'];
|
|
23
|
-
self::$functions['portfolio.calculateMetrics'] = [OptimizationOperators::class, 'createPortfolioAllocator'];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
self::$functions['
|
|
28
|
-
self::$functions['
|
|
29
|
-
self::$functions['
|
|
30
|
-
self::$functions['
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*
|
|
45
|
-
* @
|
|
46
|
-
* @param
|
|
47
|
-
* @
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
self
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
*
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
declare(strict_types=1);
|
|
4
|
+
|
|
5
|
+
namespace Anonympins\Fingerprint\Optimization;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Registre pour exposer de manière contrôlée les fonctions de la bibliothèque d'optimisation.
|
|
9
|
+
*/
|
|
10
|
+
class FunctionRegistry
|
|
11
|
+
{
|
|
12
|
+
/** @var array<string, callable> */
|
|
13
|
+
private static array $functions = [];
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Initialise le registre avec les fonctions disponibles.
|
|
17
|
+
*/
|
|
18
|
+
private static function initialize(): void
|
|
19
|
+
{
|
|
20
|
+
if (empty(self::$functions)) {
|
|
21
|
+
// Fonctions de "Scoring"
|
|
22
|
+
self::$functions['tsp.calculateEnergy'] = [OptimizationUtils::class, 'evaluatePathDistance'];
|
|
23
|
+
self::$functions['portfolio.calculateMetrics'] = [OptimizationOperators::class, 'createPortfolioAllocator'];
|
|
24
|
+
self::$functions['facility.calculateEnergy'] = [OptimizationOperators::class, 'evaluateFacilityLocation'];
|
|
25
|
+
|
|
26
|
+
// Fonctions de "Résolution"
|
|
27
|
+
self::$functions['tsp.solve'] = [OptimizationOperators::class, 'solveTSP'];
|
|
28
|
+
self::$functions['portfolio.solve'] = [OptimizationOperators::class, 'solvePortfolio'];
|
|
29
|
+
self::$functions['fraud.solve'] = [OptimizationOperators::class, 'solveFraudDetection'];
|
|
30
|
+
self::$functions['facility.solve'] = [OptimizationOperators::class, 'solveFacilityLocation'];
|
|
31
|
+
self::$functions['security.tune'] = [OptimizationOperators::class, 'solveFullSecurityTuning'];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Récupère une fonction depuis le registre.
|
|
37
|
+
*/
|
|
38
|
+
public static function get(string $name): ?callable
|
|
39
|
+
{
|
|
40
|
+
self::initialize();
|
|
41
|
+
return self::$functions[$name] ?? null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Enregistre une nouvelle fonction. Principalement pour les tests.
|
|
45
|
+
* @internal
|
|
46
|
+
* @param string $name
|
|
47
|
+
* @param callable $function
|
|
48
|
+
* @return void
|
|
49
|
+
*/
|
|
50
|
+
public static function register(string $name, callable $function): void
|
|
51
|
+
{
|
|
52
|
+
self::initialize();
|
|
53
|
+
self::$functions[$name] = $function;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Réinitialise le registre. Uniquement pour les tests.
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
public static function __internal_resetRegistry(): void
|
|
61
|
+
{
|
|
62
|
+
self::$functions = [];
|
|
63
|
+
}
|
|
63
64
|
}
|