@anonympins/fingerprint 0.4.2 → 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 +17 -0
- package/README.md +66 -60
- package/package.json +1 -1
- package/src/js/fingerprint.js +10 -2
- package/src/js/pow.solver.js +531 -497
- package/src/js/problem-manager.js +24 -0
- 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/FingerprintEngine.php +10 -2
- package/src/php/Optimization/FunctionRegistry.php +63 -62
- package/src/php/Optimization/OptimizationOperators.php +401 -304
- package/src/php/ProblemManager.php +29 -0
- 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 +3 -3
- package/src/php/Utils/RequestUtils.php +1 -1
|
@@ -19,6 +19,30 @@ const FunctionRegistry = {};
|
|
|
19
19
|
// avec la structure attendue par le ProblemManager.
|
|
20
20
|
FunctionRegistry['cpc.solve'] = Optimization.Operators.solveOptimalCPC; // NOUVEAU: Enregistrement du solveur CPC
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Évalue le coût total pour le problème de placement d'infrastructures.
|
|
24
|
+
* @param {Array<{x: number, y: number}>} facilities - Les installations.
|
|
25
|
+
* @param {object} payload - Le payload contenant les clients et les options.
|
|
26
|
+
* @returns {number} Le coût total.
|
|
27
|
+
*/
|
|
28
|
+
FunctionRegistry['facility.calculateEnergy'] = (facilities, payload) => {
|
|
29
|
+
const customers = payload.customers || [];
|
|
30
|
+
const fixedCostPerFacility = payload.options?.fixedCostPerFacility || 0;
|
|
31
|
+
const distanceSq = (p1, p2) => Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2);
|
|
32
|
+
let totalConnectionCost = 0;
|
|
33
|
+
for (const customer of customers) {
|
|
34
|
+
let minDistanceToCustomer = Infinity;
|
|
35
|
+
for (const facility of facilities) {
|
|
36
|
+
const d = distanceSq(customer, facility);
|
|
37
|
+
if (d < minDistanceToCustomer) {
|
|
38
|
+
minDistanceToCustomer = d;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
totalConnectionCost += Math.sqrt(minDistanceToCustomer);
|
|
42
|
+
}
|
|
43
|
+
return totalConnectionCost + facilities.length * fixedCostPerFacility;
|
|
44
|
+
};
|
|
45
|
+
|
|
22
46
|
/**
|
|
23
47
|
* Évalue la distance totale d'un chemin pour le problème du voyageur de commerce (TSP).
|
|
24
48
|
* @param {Array<{x: number, y: number}>} path - Un tableau de points représentant le chemin.
|