forked from justinormont/pareto-frontier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpackage.json
46 lines (46 loc) · 2.58 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{
"name": "pareto-frontier",
"version": "1.1.1",
"description": "The Pareto frontier, or Pareto set, is the set of choices which optimizes a system. This package calculates the optimal set of points in a 2D system.",
"main": "index.js",
"scripts": {
"test": "mocha",
"test-cov": "./node_modules/istanbul/lib/cli.js cover ./node_modules/.bin/_mocha --dir ./reports/coverage -- -R spec",
"codecov": "./node_modules/istanbul/lib/cli.js cover ./node_modules/.bin/_mocha --dir ./reports/codecov/coverage --report lcovonly -- -R spec && cat ./reports/codecov/coverage/lcov.info | ./node_modules/codecov/bin/codecov && rm -rf ./reports/codecov"
},
"repository": {
"type": "git",
"url": "git+https://github.com/justinormont/pareto-frontier.git"
},
"keywords": [
"pareto optimal",
"Pareto optimality",
"Pareto set",
"Pareto front",
"skyline",
"skyline query",
"Nash equilibrium",
"maximum vector problem",
"economics",
"statistics"
],
"author": "Justin Ormont (https://linkedin.com/in/justinormont)",
"contributors": [
{
"name": "Justin Ormont"
}
],
"license": "MIT",
"bugs": {
"url": "https://github.com/justinormont/pareto-frontier/issues"
},
"homepage": "https://github.com/justinormont/pareto-frontier#readme",
"devDependencies": {
"chai": "^3.5.0",
"istanbul": "^0.4.4",
"jshint": "^2.9.2",
"jshint-stylish": "^2.2.0",
"mocha": "^2.5.3"
},
"tonicExample": "const pf = require('pareto-frontier');\n\nconst graph = [\n [55, 42],\n [60, 22],\n [83, 20],\n [20, 81],\n [41, 35],\n [12, 32],\n [29, 17],\n [64, 55],\n [47, 31],\n [89, 10],\n [68, 66],\n [33, 35],\n [72, 47],\n [33, 90],\n [49, 25],\n];\n\nconst paretoPoints = pf.getParetoFrontier(graph, {optimize: 'topRight'});\n\n/* -- graph -- */\nconst Canvas = require('canvas');\nconst canvas = new Canvas(400, 400);\nconst ctx = canvas.getContext('2d');\nctx.transform(1, 0, 0, -1, 0, canvas.height); // set +Y-axis upwards\n\nfunction drawCircles(points) { ctx.lineWidth = 5; ctx.fillStyle = 'rgba(0, 0, 255, 0.5)'; points.forEach(p => { ctx.beginPath(); ctx.arc(4*p[0], 4*p[1], 25, 0, 2 * Math.PI); ctx.fill(); ctx.closePath(); ctx.stroke(); }); }\n\nfunction drawLine(points) { ctx.lineCap = 'round'; ctx.lineWidth = 15; ctx.strokeStyle = 'rgba(255, 0, 0, 0.5)'; ctx.beginPath(); points.forEach((p, i, arr) => { if (arr[i+1]) { ctx.moveTo(4*p[0], 4*p[1]); ctx.lineTo(4*arr[i+1][0], 4*arr[i+1][1]); } }); ctx.stroke(); ctx.closePath(); }\n\ndrawCircles(graph);\ndrawLine(paretoPoints);\n\ncanvas.toBuffer();"
}